Root namespace for GPF exports
- Since:
-
- 0.1.5
Classes
Namespaces
Members
-
<static, readonly> hosts :enum
-
Host type enumeration
Type:
- enum
- Since:
-
- 0.1.5
Properties:
Name Type Description browserenum Any browser (phantomjs is recognized separately)
nashornenum nodejsenum phantomjsenum rhinoenum unknownenum Unknown (detection failed or the host is unknown)
wscriptenum
Methods
-
<static> assert(condition, message)
-
Assertion helper
Parameters:
Name Type Description conditionBoolean Truthy / Falsy value
messageString Assertion message explaining the violation when the condition is false
- Since:
-
- 0.1.5
Throws:
-
<static> asserts(assertions)
-
Batch assertion helper
Parameters:
Name Type Description assertionsObject Dictionary of messages associated to condition values
- Since:
-
- 0.1.5
Throws:
-
<static> context(path)
-
Resolve the provided contextual path and returns the result.
Parameters:
Name Type Description pathString Dot separated list of identifiers
- Since:
-
- 0.1.5
Returns:
Resolved path
-
<static> createFilterFunction(specification)
-
Create a filtering function based on the given specification.
Parameters:
Name Type Description specificationgpf.typedef.filterItem Filter specification
- Since:
-
- 0.1.9
Returns:
Function that takes an object and return a truthy / falsy value indicating if the object matches the filter
-
<static> createSortFunction(specifications)
-
Create a sorting function based on the given specification
Parameters:
Name Type Description specificationsgpf.typedef.sortItem | Array.<gpf.typedef.sortItem> Sort specification
- Since:
-
- 0.1.9
Returns:
Function that can compare two objects
- Type
- function
-
<static> define(definition)
-
Define an entity, see Entity definition
Parameters:
Name Type Description definitionObject Entity definition
- Since:
-
- 0.1.6
Returns:
Entity constructor
- Type
- function
-
<static> forEach(container, callback [, thisArg])
-
Executes a provided function once per structure element. NOTE:
- For arrays: unlike [].forEach, non own properties are also enumerated.
For instance:
gpf.forEach(new Array(3), callback)will trigger the callback three times but(new Array(3)).forEach(callback)won't trigger any call - For objects: only the own properties are enumerated.
Parameters:
Name Type Argument Description containerArray | Object Container to enumerate
callbackgpf.typedef.forEachCallback Callback function executed on each item or own property
thisArg* <optional>
thisArg Value to use as this when executing callback
- Since:
-
- 0.1.5
- For arrays: unlike [].forEach, non own properties are also enumerated.
For instance:
-
<static> forEachAsync(container, callback [, thisArg])
-
Executes a provided function once per structure element. NOTE: unlike [].forEach, non own properties are also enumerated
Parameters:
Name Type Argument Description containerArray Container to enumerate
callbackgpf.typedef.forEachCallback Callback function executed on each item or own property, may return a Promise. If so, waits for the promise to be resolved before iterating over the next item.
thisArg* <optional>
thisArg Value to use as this when executing callback
- Since:
-
- 0.2.8
Throws:
Returns:
Resolved when the iteration is done
- Type
- Promise
-
<static> handleTimeout()
-
For WSCRIPT, RHINO and NASHORN environments, this function must be used to process the timeout queue when using setTimeout. For the other environments, this function has no effect.
- Since:
-
- 0.1.5
-
<static> host()
-
Returns the detected host type
- Since:
-
- 0.1.5
Returns:
Host type
- Type
- gpf.hosts
-
<static> isArrayLike(obj)
-
Return true if the parameter looks like an array, meaning a property length is available and members can be accessed through the [] operator. The length property does not have to be writable.
Parameters:
Name Type Description objObject Object to test
- Since:
-
- 0.1.5
Returns:
True if array-like
- Type
- Boolean
-
<static> isClass(value)
-
Check if the parameter is an ES6 class
Parameters:
Name Type Description value* Value to test
- Since:
-
- 0.2.9
Returns:
true if the parameter is an ES6 class
- Type
- Boolean
-
<static> isLiteralObject(value)
-
Check if the parameter is a literal object
Parameters:
Name Type Description value* Value to check
- Since:
-
- 0.2.1
Returns:
True if the value is a literal object
- Type
- Boolean
-
<static> preventAssertWarnings(silent)
-
By default, a failing assert will generate a console warning. Use this method to prevent console warnings to be generated.
Parameters:
Name Type Description silentBoolean True to prevent console warnings on failing assertions
- Since:
-
- 0.1.8
-
<static> promisify(value)
-
Converts any value into a promise. If the value implements gpf.interfaces.IThenable, it is considered as a promise.
Parameters:
Name Type Description value* Value to convert
- Since:
-
- 0.2.2
- Deprecated:
-
- since version 0.2.6, use [Promise.resolve](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve) instead
Returns:
Promisified version of the value
- Type
- Promise.<*>
-
<static> promisifyDefined(value)
-
Converts value into a promise if not undefined. If the value implements gpf.interfaces.IThenable, it is considered as a promise.
Parameters:
Name Type Description value* Value to convert
- Since:
-
- 0.2.2
- Deprecated:
-
- since version 0.2.6, use [Promise.resolve](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve) combined with a condition instead
Returns:
Promisified version of the value or undefined
- Type
- Promise.<*> | undefined
-
<static> read(path)
-
Generic read method
Parameters:
Name Type Description pathString File path
- Since:
-
- 0.2.6
Returns:
Resolved with the file content
- Type
- Promise.<String>
-
<static> version()
-
Returns the current version
- Since:
-
- 0.1.5
Returns:
Version
- Type
- String