jsrange
An extremely simple range lib, for expanding "1..3,5..7"-like strings into [1, 2, 3, 5, 6, 7]
Install
npm install --save jsrange
Examples
var range = require('jsrange');
range("2 .. 100 x 2");
range("-20 .. 30 x 3");
range("2, 10, 11");
range("20 .. 12, 12 .. 20 x 3");
Specifics on Syntax
- You have any number of
,
-deliminated sections. Each section will be represented in the result, in order. - Each section should be one of these types:
- A single value.
(eg: "5"
or "-20"
.) - A start and an end value separated by
..
.
(eg: "1..42"
or "7 .. -13"
) - A start and an end value separated by
..
, with a positive step value after a x
.
(eg: "1 .. 10 x 3"
or "22 .. -13 x 5"
)
License
MIT