Module: utils

Module: utils

Utils
Source:

Members

<static, constant> array :module:array

Access to the array module
Type:
Source:

<static, constant> object :module:object

Access to the object module
Type:
Source:

<static, constant> promises :module:promises

Access to the promises module
Type:
Source:

<static, constant> string :module:string

Access to the string module
Type:
Source:

Methods

<static> entries(arg, callback, thisArg) → {Iterator}

The entries() method returns a new Iterator that contains the key/value pairs for each index in the Object|Array.
Parameters:
Name Type Argument Description
arg Object | Array | Map
callback function
thisArg * <optional>
Source:
Returns:
Type
Iterator

<static> filter(arg, callback, thisArg) → {Object|Array}

The filter() method creates a new Object|Array with all elements that pass the test implemented by the provided function.
Parameters:
Name Type Argument Description
arg Object | Array
callback function
thisArg * <optional>
Source:
Returns:
Type
Object | Array

<static> find(arg, callback, thisArg) → {*}

The find() method returns a value in the Object|Array if an element in the Object|Array satisfies the provided testing function.
Parameters:
Name Type Argument Description
arg Object | Array
callback function
thisArg * <optional>
Source:
Returns:
Type
*

<static> findIndex(arg, callback, thisArg) → {number|string|undefined}

The findIndex() method returns a value in the Object|Array if an element in the Object|Array satisfies the provided testing function.
Parameters:
Name Type Argument Description
arg Object | Array
callback function
thisArg * <optional>
Source:
Returns:
Type
number | string | undefined

<static> forEach(arg, callback, thisArg) → {number|string|undefined}

The forEach() method executes a provided function once per Object|Array element.
Parameters:
Name Type Argument Description
arg Object | Array | Map
callback function
thisArg * <optional>
Source:
Returns:
Type
number | string | undefined

<static> join(arg, separator) → {String}

The join() method joins all elements of an Object|Array into a string.
Parameters:
Name Type Description
arg Object | Array
separator String
Source:
Returns:
Type
String

<static> map(arg, callback, thisArg) → {Object|Array}

The map() method creates a new Object|Array with the results of calling a provided function on every element in this Object|Array.
Parameters:
Name Type Argument Description
arg Object | Array
callback function
thisArg * <optional>
Source:
Returns:
Type
Object | Array

<static> mapToArray(arg, callback, thisArg) → {Array}

The mapToArray() method creates a new array with the results of calling a provided function on every element in this Object|Array.
Parameters:
Name Type Argument Description
arg Object | Array | Map
callback function
thisArg * <optional>
Source:
Returns:
Type
Array

<static> promiseCallback(callback) → {Promise}

Returns a promise The first argument is a callback with a done function
Parameters:
Name Type Description
callback function callback((done) => {})
Source:
Returns:
Type
Promise
Example
S.promiseCallback((done) => {
    fs.readFile('./myFile.txt', done);
}).then((txtContentBuffer) => {
    console.log(txtContentBuffer.toString());
});

<static> reduce(arg, callback, initialValue) → {*}

The reduce() method applies a function against an accumulator and each value of the Object|Array (from left-to-right) has to reduce it to a single value.
Parameters:
Name Type Argument Description
arg Object | Array
callback function callback(previousValue, currentKey, currentValue, objectOrArray)
initialValue * <optional>
Source:
Returns:
Type
*

<static> reduceRight(arg, callback, initialValue) → {*}

The reduceRight() method applies a function against an accumulator and each value of the Object|Array (from right-to-left) has to reduce it to a single value.
Parameters:
Name Type Argument Description
arg Object | Array
callback function callback(previousValue, currentKey, currentValue, objectOrArray)
initialValue * <optional>
Source:
Returns:
Type
*

<static> some(arg, callback, thisArg) → {*}

The some() method tests whether some element in the Object|Array passes the test implemented by the provided function.
Parameters:
Name Type Argument Description
arg Object | Array
callback function
thisArg * <optional>
Source:
Returns:
Type
*

<inner> defineConstant(target, property, value, options:) → {Object}

Shortcut for Object.defineProperty
Parameters:
Name Type Argument Description
target Object
property String name of the property
value * value
options: Object <optional>
enumerable default false
Source:
Returns:
target
Type
Object

<inner> defineGetter(target, property, getter, options:) → {Object}

Shortcut for Object.defineProperty
Parameters:
Name Type Argument Description
target Object
property String name of the property
getter function getter function
options: Object <optional>
configurable default true, enumerable default false
Source:
Returns:
target
Type
Object

<inner> defineProperties(target, properties, options:) → {Object}

Shortcut for Object.defineProperties
Parameters:
Name Type Argument Description
target Object
properties Object
options: Object <optional>
writable default true, configurable default true, enumerable default false
Source:
Returns:
target
Type
Object

<inner> defineProperty(target, property, value, options:) → {Object}

Shortcut for Object.defineProperty
Parameters:
Name Type Argument Description
target Object
property String name of the property
value * value
options: Object <optional>
writable default true, configurable default true, enumerable default false
Source:
Returns:
target
Type
Object

<inner> defineSetter(target, property, setter, options:) → {Object}

Shortcut for Object.defineProperty
Parameters:
Name Type Argument Description
target Object
property String name of the property
setter function setter function
options: Object <optional>
configurable default true, enumerable default false
Source:
Returns:
target
Type
Object

<inner> escape(html) → {String}

Escape an html string
Parameters:
Name Type Description
html String string to be escaped
Source:
Returns:
escaped string
Type
String

<inner> escapeUrl(url) → {String}

Escape an url for html
Parameters:
Name Type Description
url String
Source:
Returns:
escaped url
Type
String

<inner> isArray(arg) → {Boolean}

Test is a variable is an array
Parameters:
Name Type Description
arg *
Source:
Returns:
Type
Boolean

<inner> isFunction(value) → {Boolean}

Test is a variable is a function
Parameters:
Name Type Description
value *
Source:
Returns:
Type
Boolean

<inner> isInteger(value) → {Boolean}

Test is a variable is a integer number
Parameters:
Name Type Description
value *
Source:
Returns:
Type
Boolean

<inner> isNumber(value) → {Boolean}

Test is a variable is a number
Parameters:
Name Type Description
value *
Source:
Returns:
Type
Boolean

<inner> isObject(value) → {Boolean}

Test is a variable is an object
Parameters:
Name Type Description
value *
Source:
Returns:
Type
Boolean

<inner> isString(value) → {Boolean}

Test is a variable is a string
Parameters:
Name Type Description
value *
Source:
Returns:
Type
Boolean

<inner> regexpEscape(string) → {String}

Escape a string for regexp
Parameters:
Name Type Description
string String
Source:
Returns:
escaped string
Type
String

<inner> toInt(value) → {Number}

shortcut for parseInt(value, 10)
Parameters:
Name Type Description
value String
Source:
Returns:
parsed int
Type
Number