npm install cast-to-array> Cast a value to an array.
Install with npm
``sh`
$ npm i cast-to-array --save
`js`
var arrayify = require('cast-to-array');
returns an empty array when value is null or undefined
`js`
arrayify(null);
arrayify(undefined);
//=> []
casts a non-array value to an array
`js
arrayify('abc');
//=> ['abc']
arrayify(/xyz/);
//=> [/xyz/]
arrayify(new RegExp('.'));
//=> [new RegExp('.')]
arrayify([[]]);
//=> [[]]
arrayify({});
//=> [{}]
`
returns an array directly
`js
arrayify(['foo']);
//=> ['foo']
arrayify([]);
//=> []
`
* arr-map: Faster, node.js focused alternative to JavaScript's native array map. | homepage
* array-last: Get the last or last n elements in an array. | homepage
* array-map: [].map(f) for older browsers | homepage
* array-sum: Add up all of the numbers in an array of numbers. Works when non-numbers are… more | homepage
* array-xor: Returns the symmetric difference (exclusive-or) of an array of elements (elements that are present in… more | homepage
Install dev dependencies:
`sh``
$ npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Jon Schlinkert
+ github/jonschlinkert
+ twitter/jonschlinkert
Copyright © 2015 Jon Schlinkert
Released under the MIT license.
*
_This file was generated by verb-cli on November 06, 2015._