list-range
Return an array of values within range, determined by
range(start, stop[, step])
ES6 implementation ofPython built-in range()
function
Features
- ES6
- Zero dependencies
- 100% test code coverage
Rules
start
andstep
are optional- If the
step
argument is omitted, it defaults to 1 - If the
start
argument is omitted, it defaults to 0 - All the arguments must be integers
step
can not be 0
Install
$ npm install list-range
Usage
const range = console// [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]console// []console// []console// [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]console// [0, 5, 10, 15, 20, 25]console// [0, 3, 6, 9]console// [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]console// []console// []console// [21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]console// []console// []console// [-1, -2, -3, -4]console// Error: All the arguments must be integersconsole// Error: Step value can not be 0
License
MIT © Nicolás Quiroz