1.0.4 • Published 6 years ago

prefill-array v1.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

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

1.0.4

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

1.0.3

8 years ago