xr

x-range

Lazy range iterator for JavaScript, with lazy versions of Map and Filter.

Showing:

Popularity

Downloads/wk

0

GitHub Stars

0

Maintenance

Last Commit

4yrs ago

Contributors

2

Package

Dependencies

0

Size (min+gzip)

0.5KB

License

ISC

Type Definitions

Tree-Shakeable

No?

Categories

Readme

x-range

Lazy range iterator for JavaScript, with a lazy version of map and other functional tools


Usage

xRange(start,end,increment)   Lazy iterator with up to three parameters.

var xRange = require('x-range');

var r = new xRange(0,4,1);   //=> 0,1,2,3
var r = new xRange(0,4);     //=> 0,1,2,3
var r = new xRange(4);       //=> 0,1,2,3
var r = new xRange(5,0,-2);  //=> 5,3,1

xMap   Lazy mapping function. Array not created until needed. cb(val,index)

var r = new xRange(4);

//cb(val,index)
r.xMap(increment).xMap(increment);  //=> 2,3,4,5
r.xMap(increment).xMap(increment).toArray();  //=> returns [2,3,4,5]

forEach, map, filter, reduce, toArray   Each work as expected.

var r = new xRange(4);

//cb(val,index)
r.xMap(increment).forEach(print);  //=> prints 1,2,3,4
r.xMap(increment).map(increment);  //=> returns [2,3,4,5]
r.xMap(increment).filter(isEven);  //=> returns [2,4]
//cb(acc,val,index)
r.xMap(increment).reduce(sum);     //=> returns 10

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100