JSPM

new-array

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

create a new array filled with a value, or zero

Package Exports

  • new-array

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

Readme

new-array

stable

Creates a new dense array with the given size, optionally filled with a specified value.

var array = require('new-array')

array(2)
// > [ undefined, undefined ]

array(4, 0)
// > [ 0, 0, 0, 0 ]

array()
// > []

array(2).map((x, i) => i)
// > [0, 1]

Primarily motivated by the fact that new Array(n) produces an array of holes that does not play well with methods like Array#map().

Usage

NPM

arr = newArray(n[, value])

Returns a new dense array with length n (default 0), where each element is set to value (or undefined).

See Also

License

MIT, see LICENSE.md for details.