consequence

library providing functional helpers for generators

ConSequence.js

ConSequence.js - a library providing functional helpers for generators

examples

methods

Creates a generator containing an arithmetic progression starting with the value from up to including value to.

let it = cons.range(1, 3);
console.log(it.next(), it.next(), it.next()); // prints 1 2 3 

Creates a generator containing the result of applying fun to all values of it.

let it = cons.map(cons.range(1, 3), function (x) { return x * x });
console.log(it.next(), it.next(), it.next()); // prints 1 4 9 

Creates a generator containing values of it where the predicate fun holds.

let it = cons.filter(cons.range(1, 6), function (x) { return x % 2 });
console.log(it.next(), it.next(), it.next()); // prints 1 3 5 

Creates a generator containing values of it where the predicate fun does not hold.

let it = cons.reject(cons.range(1, 6), function (x) { return x % 2 });
console.log(it.next(), it.next(), it.next()); // prints 2 4 6 

install (only for node.js)

With npm do:

npm install consequence

todos

license

MIT