Helpers.Functions

These are a collection of helper functions, some borrowed from Lodash, Underscore, etc, to provide common functionality without the need for using a dependency. All of this is an attempt to reduce the file size of the library.

Source:

Methods

(static) callback(string, …args) → {void}

Check if fn is a function, and call it with this context and pass the arguments.

Parameters:
Name Type Attributes Description
string string

The callback fn.

args * <repeatable>

The arguments to pass.

Source:
Returns:
Type
void

(static) chain(before, after) → {function}

Returns a function that executes the before attribute and passes that value to after and the subsequent value is returned.

Parameters:
Name Type Description
before function

The first function to execute.

after function

The subsequent function to execute.

Source:
Returns:
  • A function that executes the chain.
Type
function

(static) concatMap(fn) → {function}

Returns a function that returns maps the values before concatenating them.

Parameters:
Name Type Description
fn function

The map callback function.

Source:
Returns:
  • A function that executes the map and concatenation.
Type
function

(static) deepFlatten(value) → {array}

Deep flatten an array.

Parameters:
Name Type Description
value array

The array to flatten.

Source:
Returns:
  • The flattened array.
Type
array

(static) error(string) → {void}

Throw a string as an Error exception.

Parameters:
Name Type Description
string string

The error message.

Source:
Returns:
Type
void

(static) flatten(value) → {array}

Flatten an array.

Parameters:
Name Type Description
value array

The array to flatten.

Source:
Returns:
  • The flattened array.
Type
array

(static) isConstructor(value) → {boolean}

Determines if a value is a constructor.

Parameters:
Name Type Description
value *

The value to check.

Source:
Returns:
  • Returns true if the value is a constructor.
Type
boolean

(static) isNegative(value) → {boolean}

Determines if a value is a negative.

Parameters:
Name Type Description
value number

The value to check.

Source:
Returns:
  • Returns true if the value is a negative.
Type
boolean

(static) isNegativeZero(value) → {boolean}

Determines if a value is a negative zero.

Parameters:
Name Type Description
value number

The value to check.

Source:
Returns:
  • Returns true if the value is a negative zero (-0).
Type
boolean

(static) isNull(value) → {boolean}

Determines if a value is null.

Parameters:
Name Type Description
value *

The value to check.

Source:
Returns:
  • Returns true if the value is a null.
Type
boolean

(static) isNull(value) → {boolean}

Determines if a value is undefined.

Parameters:
Name Type Description
value *

The value to check.

Source:
Returns:
  • Returns true if the value is a undefined.
Type
boolean

(static) isObject(value) → {boolean}

Determines if a value is an object.

Parameters:
Name Type Description
value *

The value to check.

Source:
Returns:
  • Returns true if the value is an object.
Type
boolean

(static) isObject(value) → {boolean}

Determines if a value is a function.

Parameters:
Name Type Description
value *

The value to check.

Source:
Returns:
  • Returns true if the value is a function.
Type
boolean

(static) isObject(value) → {boolean}

Determines if a value is a number.

Parameters:
Name Type Description
value *

The value to check.

Source:
Returns:
  • Returns true if the value is a number.
Type
boolean

(static) isString(value) → {boolean}

Determines if a value is a string.

Parameters:
Name Type Description
value *

The value to check.

Source:
Returns:
  • Returns true if the value is a string.
Type
boolean

(static) isString(value) → {boolean}

Determines if a value is a array.

Parameters:
Name Type Description
value *

The value to check.

Source:
Returns:
  • Returns true if the value is a string.
Type
boolean

(static) kebabCase(string) → {string}

Converts a string into kebab case.

Parameters:
Name Type Description
string string

The string to convert.

Source:
Returns:
  • The converted string.
Type
string

(static) length(value) → {number}

Returns the length of a deep flatten array.

Parameters:
Name Type Description
value array

The array to count.

Source:
Returns:
  • The length of the deep flattened array.
Type
number

(static) noop(string) → {boolean}

Returns true if undefined ornull`.

Parameters:
Name Type Description
string value

The value to check.

Source:
Returns:
  • true if undefined ornull`.
Type
boolean

(static) round(string) → {string}

Round the value to the correct value. Takes into account negative numbers.

Parameters:
Name Type Description
string value

The value to round.

Source:
Returns:
  • The rounded value.
Type
string

(static) ucfirst(string) → {string}

Capitalize the first letter in a string.

Parameters:
Name Type Description
string string

The string to capitalize.

Source:
Returns:
  • The capitalized string.
Type
string