Cast a value to an array.
Install with npm
$ npm i cast-to-array --save
var arrayify = require('cast-to-array');
returns an empty array when value is null or undefined
arrayify(null);
arrayify(undefined);
//=> []
casts a non-array value to an array
arrayify('abc');
//=> ['abc']
arrayify(/xyz/);
//=> [/xyz/]
arrayify(new RegExp('.'));
//=> [new RegExp('.')]
arrayify([[]]);
//=> [[]]
arrayify({});
//=> [{}]
returns an array directly
arrayify(['foo']);
//=> ['foo']
arrayify([]);
//=> []
[].map(f) for older browsers | homepageInstall dev dependencies:
$ npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Jon Schlinkert
Copyright © 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb-cli on November 06, 2015.