Package Exports
- to-array.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (to-array.js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
to-array.js
Converts primitives and objects (plain or array-like) to a sensible array representation for Node.js and the browser.
Examples
Array ... Array
toArray([1, 2, 3]);
//=> [1, 2, 3]
undefined/null ... Array
toArray(void 0 || null)
//=> []
String ... Array
toArray('id');
//=> ['id']
Delimited String ... Array
toArray('a,b,c', ',');
//=> ['a', 'b', 'c']
Number ... Array
toArray(42);
//=> [42]
DOM nodeList
var elements = document.getElementsByTagName('textarea');
toArray(elements);
//=> [ <textarea id="wgjc"></textarea>, <textarea id="wgjs"></textarea>, <textarea id="wgju"></textarea> ]
DOM classList
<div id="example" class="one two">
toArray(document.getElementById('example').classList);
//=> [ "one", "two" ]
Installation
% npm install to-array.js
% component install wilmoore/to-array.js
% bower install to-array.js
% jam install to-array.js
% volo add wilmoore/to-array.js
download
% curl -#O https://raw.github.com/wilmoore/to-array.js/master/to-array.js
use
<script src="to-array.js"></script>
Alternatives
- timoxley/to-array: slightly different semantics.
- _.toArray: I didn't want this:
_.toArray('hi') // ['h', 'i']
Building a release
% make to-array.js
% git commit …
% npm version minor
% git push
% git push --tags
% npm publish