iters
v1.0.0
Published
ES6 Iteration Protocol based Functional Programming Library
Downloads
1
Readme
iter
ES6 Iteration Protocol based Functional Programming Library
Want you have a pretty document? Please, PR it.
usage
forEach
import { iter } from "iter";
const items = [3, 6, 5, 7, 3, 0];
for (const item of iter(items).filter(item => item % 2 === 0)) {
console.log(item);
}
// 6
// 3
toArray
import "iter";
const items = [3, 6, 5, 7, 3, 0];
const result = iter(items)
.map(item => item * 2)
.toArray();
console.log(result); // [6, 12, 10, 14, 6, 0]
chunk
import "iter";
const items = [3, 6, 5, 7, 3, 0];
for (const item of iter(items).chunk(2)) {
console.log(item);
}
// [3, 6]
// [5, 7]
// [3, 0]
infinite
import { iter } from "iter";
for (const index of iter.range(1, 5)) {
console.log(index);
}
// 1
// 2
// 3
// 4