Skip to content

neosiae/prefill-array

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Prefill an array with values

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published