toArray
Converts a value to an array.
- Arrays are returned as-is.
- Iterables (strings, Sets, Maps) are spread into an array.
null/undefinedreturn[].- All other values are wrapped in a single-element array.
Usage
toArray<T>(value: Iterable<T> | T | null | undefined)
Converts a value to an array.
- Arrays are returned as-is.
- Iterables (strings, Sets, Maps) are spread into an array.
null/undefinedreturn[].- All other values are wrapped in a single-element array.
Parameters
valueIterable<T> | T | null | undefinedrequired
the value to convert.
Returns
an array containing the input values, or an empty array for null and undefined.