Skip to main content
Version: 1.1.0

resolveBoolean

Using

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

If the final resolved value is not an boolean or if a function remains unresolved within the specified depth, the function return undefined.

Demo - use JSON
resolveBoolean(
,
)
false

Arguments

ArgumentTypeDescriptionExample
valueboolean
function
Value for resolve.false
() => () => true
depthnumberDepth of maximum resolve.2

Returns

boolean | undefined — Returns the resolved boolean otherwise undefined.

Examples

resolveBoolean(false);
// false

resolveBoolean(() => () => true);
// true

resolveBoolean(14);
// undefined

resolveBoolean(() => true, 1);
// true

resolveBoolean(() => true, 2);
// true

resolveBoolean(() => true, 0);
// undefined

Resources

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