0.0.5 • Published 13 years ago
consequence v0.0.5
ConSequence.js
ConSequence.js - a library providing functional helpers for generators
examples
methods
range(from, to)
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 3map(it, fun)
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 9filter(it, fun)
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 5reject(it, fun)
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 6install (only for node.js)
With npm do:
npm install consequencetodos
license
MIT
