Range*
Another range array generator. Written in TypeScript, well tested, no floating-point BS, super fast and tiny.
Installation
yarn add rangestar
Examples
Supports generators...
const range = ; for const r of range console; // 0// 1// 2 for const r of range console; // 1// 2
...and arrays...
const a = range;console; // [0, 1, 2] const b = ;console; // [3, 3.1, 3.2, 3.3]
...and humans:
const lodashRange = ;const c = ;console; // [3, 3.1, 3.2, 3.3000000000000003]// WHAT THE F$#%?
API
The START
value will be included in the result, while STOP
will not.
Range generator
// From 0 to STOP:range.rangeGeneratorSTOP: number: Generator<number> // From START to STOP with optional STEP:range.rangeGeneratorSTART: number, STOP: number, STEP?: number: Generator<number>
Range array
Same concept.
// From 0 to STOP:range.rangeGeneratorSTOP: number: number // From START to STOP with optional STEP:range.rangeGeneratorSTART: number, STOP: number, STEP?: number: number
Benchmarks
Use yarn benchmark
to run the benchmarks. Python and Bash are required.
Library | Results |
---|---|
Range* | 14.424ms |
Lodash | 13.017ms |
range | 19.874ms |
Python range |
20.853ms |
Credits
This library is based on Lodash's range function.