This package has been deprecated

Author message:

Use Array.from instead

create-array

1.2.0 • Public • Published

create-array Build Status

Create an array from a given size and a generator

Features

  • Compatible Node & browsers
  • Pre-allocate array for better performance.

Installation

Node & Browserify/Webpack

Installation of the npm package:

> npm install --save create-array

Then require the package:

var createArray = require('create-array');

Browser

You can directly use the build provided at unpkg.com:

<script src="https://unpkg.com/create-array@1/dist/create-array.js"></script>

Usage

var array = createArray(length, generator):

// From a value.
console.log(createArray(3, 'foo'));
// → ['foo', 'foo', 'foo']
 
// With a function.
console.log(createArray(3, function (i) {
  return 'item #' + i;
}));
// → ['item #0', 'item #1', 'item #2']

Contributions

Contributions are very welcomed, either on the documentation or on the code.

You may:

  • report any issue you've encountered;
  • fork and create a pull request.

License

ISC © Julien Fontanet

Dependencies (0)

    Dev Dependencies (6)

    Package Sidebar

    Install

    npm i create-array

    Weekly Downloads

    13

    Version

    1.2.0

    License

    ISC

    Unpacked Size

    4.06 kB

    Total Files

    4

    Last publish

    Collaborators

    • julien-f
    • marsaud