Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/neosiae/prefill-array
Prefill an array with values
https://github.com/neosiae/prefill-array
Last synced: 24 days 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 (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-03-26T08:05:55.000Z (over 2 years ago)
- Last Synced: 2024-10-02T12:47:59.221Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 45.9 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# prefill-array
[![Build Status](https://travis-ci.com/neosiae/prefill-array.svg?token=6vparaXCWUN3XaBxczAx&branch=master)](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