create-arr
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

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

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.

Package Sidebar

Install

npm i create-arr

Weekly Downloads

3

Version

1.1.1

License

MIT

Unpacked Size

4.75 kB

Total Files

6

Last publish

Collaborators

  • blaumeise20