0.0.5 • Published 11 years ago

consequence v0.0.5

Weekly downloads
2
License
-
Repository
github
Last release
11 years ago

ConSequence.js

ConSequence.js - a library providing functional helpers for generators

build status

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 3

map(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 9

filter(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 5

reject(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 6

install (only for node.js)

With npm do:

npm install consequence

todos

license

MIT

0.0.6-1

11 years ago

0.0.6

11 years ago

0.0.5

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago

0.0.0

11 years ago