1.0.2 • Published 5 years ago

cast-array-x v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

cast-array-x

Casts value as an array if it's not one.

module.exports*

Casts value as an array if it's not one.

Kind: Exported member
Returns: * - The target.

ParamTypeDescription
value*The value to inspect.

Example

import castArray from 'cast-array-x';

console.log(castArray(1)); // [1]
console.log(castArray({a: 1})); // [{ 'a': 1 }]
console.log(castArray('abc')); // ['abc']
console.log(castArray(null)); // [null]
console.log(castArray(undefined)); // [undefined]
console.log(castArray()); // []
console.log(castArray([1, 2, 3])); // [1, 2, 3]