# to-array.js

> Converts primitives and objects (plain or array-like) to a sensible array representation for Node.js and the browser.

Latest version **0.10.0** (published 2014-11-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install to-array.js
pnpm add to-array.js
yarn add to-array.js
bun add to-array.js
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.10.0 |
| Published | 2014-11-14 |
| First published | 2013-11-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Wil Moore III |
| Maintainers | wilmoore |
| Keywords | string-to-array, string, array, array-like, to-array, toArray |

## Links

- npm: https://www.npmjs.com/package/to-array.js
- Repository: https://github.com/wilmoore/to-array.js
- Issues: https://github.com/wilmoore/to-array.js/issues
- npm.io page: https://npm.io/package/to-array.js

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 0.10.0 (latest) — 2014-11-14
- 0.9.0 — 2014-11-14
- 0.8.0 — 2014-11-14
- 0.7.0 — 2014-11-14
- 0.6.0 — 2014-10-03
- 0.5.0 — 2014-10-03
- 0.3.0 — 2013-12-17
- 0.2.0 — 2013-11-23

## README

# to-array.js

[![Build Status](http://img.shields.io/travis/wilmoore/to-array.js.svg)](https://travis-ci.org/wilmoore/to-array.js) [![NPM version](http://img.shields.io/npm/v/to-array.js.svg)](https://www.npmjs.org/package/to-array.js) [![NPM downloads](http://img.shields.io/npm/dm/to-array.js.svg)](https://www.npmjs.org/package/to-array.js) [![LICENSE](http://img.shields.io/npm/l/to-array.js.svg)](license)

> 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

```html
<div id="example" class="one two">
```

    toArray(document.getElementById('example').classList);
    //=> [ "one", "two" ]

## Installation

[npm](https://npmjs.org/package/to-array.js)

    % npm install to-array.js

[component](http://component.io/wilmoore/to-array.js)

    % component install wilmoore/to-array.js

[bower](http://sindresorhus.com/bower-components/)

    % bower install to-array.js

[jam](http://jamjs.org/packages/#/details/to-array.js)

    % jam install to-array.js

[volo](http://volojs.org)

    % volo add wilmoore/to-array.js

[manual][]

1. download

        % curl -#O https://raw.github.com/wilmoore/to-array.js/master/to-array.js

2. use

        <script src="to-array.js"></script>

## Alternatives

- [timoxley/to-array][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

## License

  [MIT](license)

[Node.js]:  http://nodejs.org
[manual]:   http://yuiblog.com/blog/2006/06/01/global-domination/
[to-array]: https://github.com/timoxley/to-array
[_.toArray]: http://underscorejs.org/#toArray

---
_Source: https://npm.io/package/to-array.js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
