castArray
Cast a value into an array
76 bytes
since v12.2.0
Usage
The castArray
function ensures that the input value is always returned as an array. If the input is already an array, it returns a shallow copy of the array. If the input is not an array, it wraps the input in a new array.
import * as _ from 'radashi'
_.castArray(1) // => [1]_.castArray([1, 2, 3]) // => [1, 2, 3]_.castArray('hello') // => ['hello']