Namespace: gpf

gpf

Root namespace for GPF exports

Since:
  • 0.1.5

Classes

Error

Namespaces

attributes
fs
http
interfaces
java
node
path
require
rhino
serial
stream
typedef
web
wscript

Members


<static, readonly> hosts :enum

Host type enumeration

Type:
  • enum
Properties:
Name Type Description
browser enum

Any browser (phantomjs is recognized separately)

nashorn enum

Nashorn

nodejs enum

NodeJs

phantomjs enum

PhantomJS

rhino enum

Rhino

unknown enum

Unknown (detection failed or the host is unknown)

wscript enum

cscript/wscript

Since:
  • 0.1.5

Methods


<static> assert(condition, message)

Assertion helper

Parameters:
Name Type Description
condition Boolean

Truthy / Falsy value

message String

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
assertions Object

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
path String

Dot separated list of identifiers

Since:
  • 0.1.5
Returns:

Resolved path

Type
gpf.typedef.contextResult

<static> createFilterFunction(specification)

Create a filtering function based on the given specification.

Parameters:
Name Type Description
specification gpf.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

Type
gpf.typedef.filterFunc

<static> createSortFunction(specifications)

Create a sorting function based on the given specification

Parameters:
Name Type Description
specifications gpf.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
definition Object

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
container Array | Object

Container to enumerate

callback gpf.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

<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
container Array

Container to enumerate

callback gpf.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
obj Object

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
silent Boolean

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
path String

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