FCF 2.0 development in progress...
> >
[News] [Packages API] [Downloads] [Donate to the project] [Contacts]

Package fcf-framework-core

A package of basic functions and classes required for the framework to work. This package provides functions for modular loading of JS files, basic processing of strings and data, a class for working with asynchronous operations, a logging mechanism, state and context saving methods, etc.
Pages
Configuration parameters
warnEmptyContext - If set to true, then on the server side, when using an empty context, a warning message is displayed in the log.
defaultLanguage - Default language
aliases - An object that stores path aliases
translations - An array with information about translations. Can be specified either as an object containing translations, or as a string containing the path to the translation file.
tokenize - An object describing the list of available objects and functions in the server-side tokenizer used in the fcf.tokenize, fcf.pattern and fcf.inlineExecution functions.
moduleDirectories - Directories where NODEJS packages are searched
webModuleDirectory - URL prefix for packages that do not have an explicit package download URL in the sources configuration parameter (Browser side).
sources - An object that describes source files for loading JS modules on the client and server side
merge - An object that describes the rules for merging configuration properties from different configuration sources.
Constants
fcf.UNDEFINED = 0 - Indicates the data type is undefined. Used in functions fcf.isNature, etc.
fcf.NULL = 1 - Indicates the data type is null. Used in functions fcf.isNature, etc.
fcf.NAN = 2 - Indicates the data type is NaN. Used in functions fcf.isNature, etc.
fcf.BOOLEAN = 3 - Indicates the data type is boolean. Used in functions fcf.isNature, etc.
fcf.NUMBER = 4 - Specifies the number data type (not including the NaN value). Used in functions fcf.isNature and others.
fcf.STRING = 5 - Indicates the data type is string. Used in functions fcf.isNature, etc.
fcf.DATE = 6 - Indicates the data type is Date. Used in functions fcf.isNature, etc.
fcf.OBJECT = 7 - Indicates the data type is object (excluding null and Date). Used in functions fcf.isNature, etc.
fcf.ARRAY = 8 - Indicates the data type is array. Used in functions fcf.isNature, etc.
fcf.ITERABLE = 9 - Points to an iterable object (the string type is not included in this category). Used in functions fcf.isNature, etc.
fcf.NUMBERED = 10 - Points to an numerable object (the string type is not included in this category). Used in functions fcf.isNature, etc.
Variables
fcf.log - Global logger
Events
[BROWSER ONLY] page_ready
- The event is called when the page is completely loaded.
Classes
- Error class. Stores a string alias for the error, a tokenized string to be translated, and may also contain a pointer to the underlying error that caused the current error to be generated.
- An execution context object that contains information about the enforcement proceedings in the case of the meeting. For more progress information, see Context.
- The class of asynchronous operations is similar to Promise and can be used with the await operator, but has slightly different functionality.
- Abstract class for completing the asynchronous operation. Copies of this class are transmitted to the functions of the fcf.Actions
- The class that describes information about a URL's route
- The event channel class that implements the communication of different program blocks of the framework. The framework can use multiple event channels, but by default it always uses the main event channel, which is available via the fcf.getEventChannel() function
- Base class that adds functionality for handling internal events of an object
- A class that provides functionality for storing and expanding configuration parameters.
- Logger class with file recording
Functions
fcf.Actions fcf.actions()
fcf.Actions fcf.actions({deferred, noexcept, errorResult} a_options)
- Creates an fcf.Actions object
fcf.addException(string a_messageName, string a_messageText)
- Registers an exception name for fcf.Exception objects.
mixed fcf.append(object|array|Map|Set a_dest, object|array|Map|Set a_source1, ..., object|array|Map|Set a_sourceN)
mixed fcf.append(boolean a_copyMode, object|array|Map|Set a_dest, object|array|Map|Set a_source1, ..., object|array|Map|Set a_sourceN)
- Copies data from sources a_source1 ... a_sourceN to destination a_dest. If the argument a_copyMode is equal to true, a full (recursion) copy of the data is performed with the re-creation of objects
fcf.appendTranslate(object|string|[object|string]|undefined a_dataOrFileName, boolean a_reload = false)
- Adds translations. If necessary, it can cause a complete reloading of all translation files.
string fcf.buildUrl(string|fcf.RouteInfo a_url, object a_args = undefined, string a_anchor = undefined)
- Gathers a new URL from the original one by adding arguments and an anchor
mixed fcf.clone(mixed a_object)
- Creates a copy of an object with recursive copying of fields
integer fcf.compare(mixed a_left, mixed a_right, boolean a_strict = false)
- Compares two values.
integer fcf.count(string|{}|[]|Map|Set a_object)
integer fcf.count(string|{}|[]|Map|Set a_object, function a_cb)
- Determines the number of elements in an object or a string. The function works both with simple objects and with arrays, Map and Set
string fcf.decodeBase64(string a_base64String)
- Decodes a string from base64 format
string fcf.decodeHtml(string a_str)
- Performs decoding of descriptions of special characters in an HTML string
fcf.Actions->mixed fcf.each(mixed a_object, function a_cb)
- Iterates over the elements in the a_object argument. Iteration ends if the callback function returns a value other than undefined.
boolean fcf.empty(mixed a_value)
- Checks if the object is empty. The following are considered empty: all empty iterables, fieldless objects (except Error and Date), empty strings, and the following values: new Date(NaN), NaN , null, undefined.
string fcf.encodeBase64(string a_str)
- Encodes a string in base64 format
string fcf.encodeHtml(string a_str)
- Encodes only structural special characters ( " ' > < &) in an HTML code construct
boolean fcf.equal(mixed a_left, mixed a_right, boolean a_strict = false)
- Compares two values for equality.
string fcf.errorToString(Error a_error, boolean a_fullMode = false)
- Converts the error object to a string representation
string fcf.escapeQuotes(string a_str, string|[string] a_quote = undefined)
- Escapes single and double quotes with \
string fcf.formatDate(Date a_date, string a_format = "Y-m-d H:i:s.v", integer a_timezoneOffset = 0)
- Converts a Date object to a string representation
mixed fcf.get(object a_object, mixed a_key)
- Get an element stored in an object by key. Also performed for Map and Set objects
fcf.Configuration fcf.getConfiguration()
- Returns the default configuration object. You can read more about the configuration object on the configuration description page: Configuration
fcf.Context fcf.getContext()
- Returns the current execution context. More information about execution context can be found at Context
string fcf.getDirectory(string a_path)
- Returns the path of a directory
fcf.EventChannel fcf.getEventChannel()
- Returns the message channel used by the default framework.
string fcf.getExtension(string a_path)
- Returns an extension for a file path
string fcf.getFileName(string a_path)
- Returns a filename
string fcf.getPath(string a_uri, string a_aliases, boolean a_innerServerPath = fcf.isServer())
string fcf.getPath(string a_uri, boolean a_innerServerPath = fcf.isServer())
- Translates a relative URI in FCF notation into a real resource path
{module, subpath} fcf.getPathInfo(string a_path, a_isServerPath = fcf.isServer(), boolean a_quiet = false)
- Returns the module and the subpath by the path
string fcf.getShortFileName(string a_path)
- Returns a filename without a path extension
object fcf.getState()
- Gets the current state object. More information about execution context and status can be found at Context
boolean fcf.has(object a_object, mixed a_key)
- Checks if an object contains an element with a given key. Also performed for Map and Set objects
string fcf.id(integer a_size = 32, boolean a_safeFirstChar = false)
- Creates a string from random characters in hex format
mixed fcf.inlineExecution(string a_code)
mixed fcf.inlineExecution(string a_code, object a_environment)
- Evaluates a single line Javascript expression
boolean fcf.isIterable(mixed a_value)
- Checks if an argument is iterable, but is not a string.
boolean fcf.isNature(mixed a_value, string | fcf.UNDEFINED..fcf.NUMBERED | [string|fcf.UNDEFINED..fcf.NUMBERED] a_nature, boolean a_softMode = false)
- Checks if an argument matches the given data classification
boolean fcf.isNumbered(mixed a_value)
- Checks if the passed argument is an enumerable object. But string data is not treated as enumerated objects.
boolean fcf.isObject(mixed a_value)
- Checks if the argument is an object and not null
boolean fcf.isServer()
- Determines where code is executed on the server or on the client
fcf.Actions->mixed fcf.load(string a_uri)
fcf.Actions->mixed fcf.load(string a_uri, object a_options)
- Loads a resource (file or HTTP/HTTPS) at the given URI.
string fcf.ltrim(string a_str, string|false|[string|false] a_delimiter = [false])
- Removes the given characters from the beginning of a string
mixed fcf.module({name, dependencies, lazy, module} a_options)
- Declares an FCF module.
string fcf.normalizeObjectAddress(string|[string|object] a_path)
- Normalizes the path address to a subfield of an object
string fcf.normalizePath(string a_path, boolean a_isServerPath = fcf.isServer())
- Normalizes the resource path (File path/HTTP/HTTPS).
string fcf.normalizeSubpath(string a_path)
- Normalizes the relative subpath. Removes paths ./ and performs an offset ../ inside the relative path. Changes the multiple use of the character / (/////) to the single use (/).
string fcf.pad(string a_str, number a_len, string a_fill = " ", "l"|"left"|"r"|"right"|"c"|"center" a_align = "left")
- Pads a string to a given length
Date fcf.parseDate(string a_string, string a_format = "Y*m*d*H*i*s*v", boolean a_strict = false, Date a_default = new Date(1970, 0, 1, 0, 0, 0, 0), integer a_timezoneOffset = 0)
- Converts the string representation of a date and time to a Date
[{message, fullMessage, stack, stackArr}] fcf.parseError(Error|fcf.Exception a_error)
- Parses error information from the Error object.
[string|object] fcf.parseObjectAddress(string|[string|object] a_path, boolean a_exMode = false)
- Converts a string with the path to the object into an array with information about the elements
[{file,function,line,column}] fcf.parseStack(string|Error a_stack)
- Parses a string containing information about the stack obtained from Error.stack
mixed fcf.pattern(strign|object a_code, object a_environment = {}, object a_options = {quiet: false, result: "string"})
- Performs tokenization of the given string. The control constructs of the tokenizer are @{...}@ and !{...}!.
object|array fcf.prepare(object a_object, string|[string|object] a_objectPath)
- Creates an object or an array at the path specified in the argument if the object does not exist. And returns the specified object.
string fcf.replaceAll(string a_str, string a_search, string a_replacement)
- Performs replacement of all searched substrings in a string
fcf.Actions->array fcf.require(string a_module1, ..., string a_moduleN)
fcf.Actions->array fcf.require(string a_module1, ..., string a_moduleN, {quiet, async} a_options)
fcf.Actions->array fcf.require([string] a_modules)
fcf.Actions->array fcf.require([string] a_modules, {quiet, async} a_options)
- Performs module loading
mixed fcf.resolve(object a_obj, string|[string] a_path, boolean a_quiet = true)
- Returns a subfield of the object at the specified path
{object, key} fcf.resolveEx(object a_obj, string|[string|object] a_path, boolean a_createObj = false)
- Returns information about the subobject at the given path, and optionally creates subobjects at the specified path if it is not present in the source object.
string fcf.resolvePath(string a_uri, object a_aliases = undefined)
- Converts a string containing an alias to a real path in FCF notation.
string fcf.rtrim(string a_str, string|false|[string|false] a_delimiter = [false])
- Removes the specified characters from the end of a string
fcf.saveContext(ExpressResponse a_request)
- Stores the current context in Cookies. The context is stored in base64 encoded JSON format in the cookies parameter "fcf-context"

If the code is executed on the browser side, then the function must be called without arguments.

If the code is executed on the server side, then the function takes as an argument an Express server response object.

More information about execution context can be found at Context

fcf.setContext(fcf.Context a_context)
- Sets the execution context. More information about execution context can be found at Context
fcf.setState(object a_state)
- Sets the state object as current. More information about execution context and status can be found at Context
- Converts stack information to string representation
string fcf.str(mixed a_data)
- Converts data to a string.
string fcf.stripTags(string a_str)
- Removes HTML tags from a source string
string fcf.styleToString(string a_name, a_mixed a_value)
string fcf.styleToString({name: value} a_descriptions)
- Converts the a_name and a_value parameters to a string of the format `a_name : a_value`. For dimension values, automatically adds the ending "px";
string fcf.t(string a_str, string a_lang = fcf.getContext().language || fcf.getConfiguration().defaultLanguage)
- Performs a line feed. If no translation is found, the original string is returned.
fcf.test(string a_part, string a_group, string a_name, function a_cbtest)
fcf.test(string a_group, string a_name, function a_cbtest)
fcf.test(string a_name, function a_cbtest)
- Declares a unit test.
mixed fcf.tokenize(strign|object a_code, object a_environment = {}, object a_options = {quiet: false, result: "string"})
- Performs tokenization of the given string. The control constructs of the tokenizer are @{{...}}@ and !{{...}}!.
string|object fcf.translate(string|object a_str, string a_lang = fcf.getContext().language || fcf.getConfiguration().defaultLanguage)
- Performs tokenization only for translation constructs !{{...}}! and !{...}!.
string fcf.trim(string a_str, string|false|[string|false] a_delimiter = [false])
- Removes the specified characters from the beginning and end of a string
string|object fcf.unescape(string|object a_data)
- Performs unescaping of a string or strings in the passed object
string fcf.uuid()
- Creates a UUID string (v4)