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