wrapInArray
Commons
stable
Normalise a value into an array: null/undefined becomes [], an existing array passes through untouched, and any other value is wrapped in a single-element array.
API
Signature
Full TypeScript signature sourced from the util file.
API
Parameters
Input parameters accepted by this util.
- vrequiredT | null | undefined
- The value to normalise. May be a scalar, an array, null, or undefined.
API
Return value
The value returned by this util.
- [] for null/undefined, the original array when v is already an array, or [v] for any other value.
Usage
Examples
Ready-to-paste usage snippets.
Scalar, array and null inputs