fn
toArray
v0.0.10testedNormalize an `Arrayable<T>` value into an array. `undefined` and `null` become an empty array; a single value is wrapped; arrays are returned as-is (no copy).
Examples
ts
toArray(1) // => [1]ts
toArray([1, 2]) // => [1, 2]ts
toArray(undefined) // => []Signature
ts
export function toArray<Value>(value: Arrayable<Value> | null | undefined): Value[]{ ... }Type Parameters
ValueParameters
| Parameter | Type | Description |
|---|---|---|
value | Arrayable<Value> | null | undefined | The value to normalize |
Returns
Value[]The value as an array