new Resolve()
- 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 |
any | T | producerHandler.<T> | Promise.<T> | a literal value or an (async) function or Promise that may produce a value of the expected type or exemplary 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