JSPM

arrayify

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 114
  • Score
    100M100P100Q83686F
  • License MIT

Convert array like items or individual items into arrays

Package Exports

  • arrayify

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 (arrayify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

arrayify

Convert array like items or individual items into arrays (for both browser and server)

Build Status Dependency Status NPM version

Installation

npm install arrayify

Usage

// Array-likes
var divs = document.getElementsByTagName('div') // `NodeList` of `HTMLDivElement`
toArray(divs) // => Array of `HTMLDivElement`

(function() {
  toArray(arguments) // => [1, 2]
})(1, 2)

// Primitives
toArray('hello') // => ['hello']
toArray(12345) // => [12345]
toArray(/regex/) // => [/regex/]
toArray(null) // => [null]
toArray({}) // => [{}]
toArray(new Date) // => [Wed Nov 07 2012 04:40:26 GMT+1000 (EST)]

// Special cases
toArray(undefined) // => []
toArray(window) // => [window]
toArray('a.important', {query: true}) // => [DOM elements matching the query selector 'a.important']

License

This library is based off of work by @timoxley on the to-array component which is MIT licensed.

This library is therefore also MIT licensed.