Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/blaumeise20/create-arr
https://github.com/blaumeise20/create-arr
Last synced: 5 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/blaumeise20/create-arr
- Owner: blaumeise20
- License: mit
- Created: 2021-06-29T10:08:52.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-12-04T19:00:20.000Z (about 3 years ago)
- Last Synced: 2024-12-19T22:02:42.236Z (17 days ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# create-arr
Utility to create arrays from simple parameters. Improved version of C#'s `Enumerable.Range`.
## Installation
Install the package like this:
```
npm install --save create-arr
```## Usage
```js
const arr = require("create-arr");console.log(arr(3, 5)); // [5, 5, 5]
console.log(arr(1, 4)); // [4]
console.log(arr(5, i => i*2)); // [0, 2, 4, 6, 8]console.log(arr.r(5)); // [0, 1, 2, 3, 4]
console.log(arr.r(1, 5)); // [1, 2, 3, 4, 5]
console.log(arr.r(6, 3, v => v*2)); // [12, 14, 16]
console.log(arr.r(6, 3, (v, i) => v + i)); // [6, 8, 10]
```## Licence
This project is licenced under the MIT licence. Read it [here](LICENCE).