Class: Resolve

Resolve()

new Resolve()

Author:
Source:

Methods

(async, static) asyncFuncOrPromise(asyncFuncOrPromise) → {T}

Parameters:
Name Type Description
asyncFuncOrPromise producerHandler.<(T|Promise.<T>)> | Promise.<T> An (async) function or a Promise.
Source:
See:
Returns:
The result of deeply resolving the given function or Promise.
Type
T

(static) isFunction(value) → {boolean}

Parameters:
Name Type Description
value any | function | AsyncFunction
Source:
Returns:
true, iff the given value is an (async) function
Type
boolean

(static) isNumber(value) → {boolean}

Parameters:
Name Type Description
value any | Number
Source:
Returns:
true, iff the given number or NaN is of type Number
Type
boolean

(static) isPrimitive(value) → {boolean}

Parameters:
Name Type Description
value any
Source:
Returns:
true, iff the value is primitive
Type
boolean

(static) isPromise(value) → {boolean}

Parameters:
Name Type Description
value any | Promise
Source:
Returns:
true, iff the value is an instance of Promise
Type
boolean

(static) isSymbol(value) → {boolean}

Parameters:
Name Type Description
value Symbol
Source:
Returns:
Type
boolean

(static) isTypeOf(value, exampleOrTypeOrClassName) → {boolean}

Check whether or not a value is of a specific type, that can be given as an example, an actual Type/Class or the name of a class.
Parameters:
Name Type Description
value any the value to check
exampleOrTypeOrClassName any | string an examplary other value you'd expect, a type (e.g. RegExp) or class or the name of a class or c'tor-function.
Source:
Returns:
Type
boolean

(async, static) optionalToValue() → {T}

Similar to @see {toValue}, this method returns the default value for the given value, should it be undefined. Other than that, this method returns the same as
Source:
See:
  • {toValue}.
  • {toValue}
Returns:
the resolved-to value or its default, should it be undefined.
Type
T

(async, static) toValue(value, exampleOrTypeOrClassNameopt, resolveFuncsopt, resolvePromisesopt) → {T}

Resolve a literal value, a function or Promise to a value. If enabled, deeply resolves functions or Promises. Attempts to resolve (to a) value until it matches the expected example, type/class or class name.
Parameters:
Name Type Attributes Default Description
value
exampleOrTypeOrClassName any | string | T <optional>
Optional. If not given, will only resolve functions and promises to a value that is not a function and not a Promise. Otherwise, pass in an examplary other value you'd expect, a type (e.g. RegExp) or class or the name of a class or c'tor-function.
resolveFuncs boolean <optional>
true Optional. Defaults to true. If true, then functions will be called and their return value will be checked against the expected type or exemplary value. Note that this parameter applies recursively, until a function's returned value no longer is a function.
resolvePromises boolean <optional>
true Optional. Defaults to true. If true, then Promises will be awaited and their resolved value will be checked against the expected type or exemplary value. Note that this parameter applies recursively, until a Promise's resolved value no longer is a Promise.
Source:
See:
Throws:
if the value cannot be resolved to the expected type or exemplary value.
Type
Error
Returns:
the resolved-to value
Type
T