Skip to main content
Version: 1.2.0

resolveString

Using

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

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

Arguments

ArgumentTypeDescriptionExample
valuestring
function
Value for resolve."text"
() => () => "Shegit"
depthnumberDepth of maximum resolve.2

Returns

string | undefined — Returns the resolved string otherwise undefined.

Examples

resolveString('text');
// "text"

resolveString(() => () => 'name');
// "name"

resolveString(12);
// undefined

resolveString(() => 'Shegit', 1);
// "Shegit"

resolveString(() => 'Shegit', 2);
// "Shegit"

resolveString(() => 'Shegit', 0);
// undefined

Resources

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