https://github.com/neosiae/prefill-array
Prefill an array with values
https://github.com/neosiae/prefill-array
Last synced: 3 months ago
JSON representation
Prefill an array with values
- Host: GitHub
- URL: https://github.com/neosiae/prefill-array
- Owner: neosiae
- License: mit
- Created: 2018-04-07T16:31:50.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-03-26T08:05:55.000Z (over 3 years ago)
- Last Synced: 2025-03-14T01:03:54.976Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 45.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# prefill-array
[](https://travis-ci.com/neosiae/prefill-array)
Prefill an array with values.
## Install
Install `prefill-array` using [npm](https://www.npmjs.com):
> npm install --save prefill-arrayOr via [yarn](https://yarnpkg.com/en):
> yarn add prefill-array## Usage
```javascript
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
```javascript
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