Skip to main content
Version: 1.2.0

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

ArgumentTypeDescriptionExample
valuearray
function
Value for resolve.[13, false]
() => () => [undefined]
depthnumberDepth 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

Resources

📦 Since:1.1.0
📦 Last updated:1.1.0
📦 Available in:1.3.0