Skip to main content
Version: 1.2.0

resolveValue

Using​

Function that retrieves or resolves only values. This function should handle various input types, resolving functions if encountered, and ultimately return an value if possible.

If the final resolved value is a function remains unresolved within the specified depth, the function return undefined.

Demo - use JSON
resolveValue(
,
)
["name"]

Arguments​

ArgumentTypeDescriptionExample
valueanyValue for resolve.[13, false]
() => () => "text"
() => { name: "Alina" }
12
() => () => () => false
depthnumberDepth of maximum resolve.2

Returns​

any — Returns the resolved value otherwise undefined.

Examples​

resolveValue([12, null]);
// [12, null]

resolveValue(() => () => ({ name: 'Alina' }));
// { name: 'Alina' }

resolveValue('text');
// 'text'

resolveValue(() => false, 0);
// () => false

resolveValue(() => false, 1);
// false

resolveValue(() => false, 2);
// undefined

Resources​

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