Methods
(static) createFilter(jsonQueryopt) → {function}
Turns the given JSON object into a filter function.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
jsonQuery |
object |
<optional> |
An object specifying properties and values that an object has to match in order to pass the filter. If omitted, or if the object has no keys, any object will pass the generated filter. |
- Source:
Returns:
the generated filter function, accepts an object as argument and returns true if it passes the filter and false otherwise.
- Type
- function
(static) defaultHandler(callbackopt) → {function}
Creates a default error handler function and returns it.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
function |
<optional> |
possibly existing callback |
- Source:
Returns:
the callback
parameter if it is a function, and
otherwise a function that treats its first argument as an error
object and throws it if it is defined.
- Type
- function
(static) defineLinkedPropertiesFromMap(obj, propMapDict, dictKey, srcPropopt)
Defines properties on the given object according to property specifications found in a map. If a property specification defines setter behavior, the object is an event emitter, and a property set changes the value, the object will emit an 'update' event, with 4 parameters: the object, the name of the property, the new value, and the previous value.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
object | the object on which to define the properties |
|
propMapDict |
object | a dictionary of property specification maps.
A property specification map is keyed by the names of the properties
to define. The value (the property specification) is an array. Its
first element is the name of the property in another object (see
|
|
dictKey |
string | the key to the dictionary under which the property specification map is found. If the specification map is a string, it will be used recursively to look up the specification map. |
|
srcProp |
string |
<optional> |
the name of the property storing the object from which property values will be linked. Default is 'data'. |
- Since:
- 0.7.0
- Source:
(static) defineLinkedProperty(obj, prop, srcPropopt, readOnlyopt)
Defines a property on the given object whose value will be linked to that of the property of another object. If the object is an event emitter, a property set that changes the value will emit an 'update' event for the object with 3 parameters, the object, the name of the property, and the new value.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
object | the object for which to define the property |
|
prop |
string | Array.<string> | the name of the property to define, or an array of two elements, namely the name of the property to define, and the name of the property to link to |
|
srcProp |
string |
<optional> |
the name of the property that stores the source object (from which values will be linked). Default is 'data'. |
readOnly |
boolean |
<optional> |
whether the property is to be read-only,
defaults to |
- Since:
- 0.7.0
- Source:
(static) defineOnChangeProperty(obj, propNameopt, eventopt)
Defines a property with the given name for the given object using a getter/setter combination. If the objset is an event emitter, the object will emit an event of the given name if a property set changes the value of the property.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
object | the object for which to define the property |
|
propName |
string |
<optional> |
the name of the property, defaults to 'data' |
event |
event |
<optional> |
the name of the event to emit, defaults to 'data' |
- Since:
- 0.7.0
- Source:
(static) FILETIMEtoDate(filetime) → {number}
Converts from Windows FILETIME (100 nanosecond intervals since January 1, 1601 (UTC)) to JavaScript Date (milliseconds since January 1, 1970 (UTC)).
Parameters:
Name | Type | Description |
---|---|---|
filetime |
number | the Windows FILETIME value to convert |
- Source:
Returns:
the corresponding milliseconds since the epoch
- Type
- number
(static) retryUntil(action, success, optionsopt)
Retries the given (assumed to be asynchronous) action until it succeeds, or throws a general error.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
action |
function | the action to retry, expected to return a promise |
|
success |
function | A function that is passed the value to which
|
|
options |
object |
<optional> |
options to be passed on to |
- Source:
Returns:
the value to which the action resolves
(static) round(number, precision)
Similar to Math.round()
but rounds to given precision of decimal places.
Parameters:
Name | Type | Description |
---|---|---|
number |
number | the number to round |
precision |
number | the precision to round to in decimal places |
- Source: