The castArrayIfExists function ensures that a non-nullish 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. Nullish values (null or undefined) are passed through as is.
Casts the given value to an array if it's not equal to null or
undefined. If the value is an array, it returns a shallow copy of
the array. Otherwise, it returns a new array containing the value.
Casts the given value to an array if it's not equal to null or
undefined. If the value is an array, it returns a shallow copy of
the array. Otherwise, it returns a new array containing the value.
Casts the given value to an array if it's not equal to null or
undefined. If the value is an array, it returns a shallow copy of
the array. Otherwise, it returns a new array containing the value.
Casts the given value to an array if it's not equal to null or
undefined. If the value is an array, it returns a shallow copy of
the array. Otherwise, it returns a new array containing the value.
Casts the given value to an array if it's not equal to null or
undefined. If the value is an array, it returns a shallow copy of
the array. Otherwise, it returns a new array containing the value.