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