prefill-array

1.0.4 • Public • Published

prefill-array

Build Status

Prefill an array with values.

Install

Install prefill-array using npm:

npm install --save prefill-array

Or via yarn:

yarn add prefill-array

Usage

const prefill = require('prefill-array');
 
const leet = prefill(5, 1337);
console.log(leet);
// → [ 1337, 1337, 1337, 1337, 1337 ]
 
const recursive = prefill(4, prefill(2, '2D'));
console.log(recursive);
// → [ [ '2D', '2D' ], [ '2D', '2D' ], [ '2D', '2D' ], [ '2D', '2D' ] ]

Syntax

const newArray = prefill(number, value);

Parameters

number

   Number of elements to insert. Must be greater than or equal to zero.

value

   Value to use for filling.

Return value

Returns the filled array.

License

MIT

/prefill-array/

    Package Sidebar

    Install

    npm i prefill-array

    Weekly Downloads

    4

    Version

    1.0.4

    License

    MIT

    Unpacked Size

    20.3 kB

    Total Files

    8

    Last publish

    Collaborators

    • neosiae