resolveFunction
Using
Function that retrieves or resolves only function values. This function should handle various input types, resolving functions if encountered, and ultimately return an function if possible.
If the final resolved value is not an function or if a function remains unresolved within the specified depth, the function return undefined
.
Arguments
Argument | Type | Description | Example |
---|---|---|---|
value | function | Value for resolve. | () => 13 () => () => undefined |
depth | number | Depth of maximum resolve. | 2 |
Returns
function
| undefined
— Returns the resolved function otherwise undefined
.
Examples
resolveFunction(() => 55);
// () => 55
resolveFunction(() => () => () => 'some');
// () => "some"
resolveFunction('text');
// undefined
resolveFunction(() => () => () => () => () => [0, false], 2);
// () => () => () => [0, false]
resolveFunction(() => ['text'], 2);
// undefined