unwrapOptionRecursively
Call Signature
unwrapOptionRecursively<
T
>(input
):UnwrappedOption
<T
>
Recursively unwraps all nested Option types within a value.
This function traverses a given value and removes all instances of Option, replacing them with their contained values.
- If an Option is encountered, its value is extracted.
- If an array or object is encountered, its elements are traversed recursively.
- If
None
is encountered, it is replaced with the fallback value (default:null
).
Type Parameters
Type Parameter | Description |
---|---|
T | The type of the input value. |
Parameters
Parameter | Type | Description |
---|---|---|
input | T | The value to unwrap. |
Returns
The recursively unwrapped value.
Examples
Recursively unwrapping nested options.
Recursively unwrapping options inside objects and arrays.
Using a fallback value for None
options.
Remarks
This function does not mutate objects or arrays.
See
Call Signature
unwrapOptionRecursively<
T
,U
>(input
,fallback
):UnwrappedOption
<T
,U
>
Recursively unwraps all nested Option types within a value.
This function traverses a given value and removes all instances of Option, replacing them with their contained values.
- If an Option is encountered, its value is extracted.
- If an array or object is encountered, its elements are traversed recursively.
- If
None
is encountered, it is replaced with the fallback value (default:null
).
Type Parameters
Type Parameter | Description |
---|---|
T | The type of the input value. |
U | The fallback type for None values (defaults to null ). |
Parameters
Parameter | Type | Description |
---|---|---|
input | T | The value to unwrap. |
fallback | () => U | A function that provides a fallback value for None options. |
Returns
UnwrappedOption
<T
, U
>
The recursively unwrapped value.
Examples
Recursively unwrapping nested options.
Recursively unwrapping options inside objects and arrays.
Using a fallback value for None
options.
Remarks
This function does not mutate objects or arrays.