There's synchronous and asynchronous ops, but all of them has the same interface. Simple and easy.
Returns an array with all iterator values.
Warning: If iterator is infinite it never returns a value and, if synchronous operation it would be stop main thread.
array() -> return [x1, ..., xi]
Receives a positive integer named n and returns a value in the n position.
If iterator breaks before n position, return undefined.
at(n) -> return xn
Receives n iterators and returns an iterator. This one emit all values of each iterator in order of the arguments insertion, starting by the original iterator.
For example:
numbers -> 0, 1, 2, 3, 4, 5
chars -> a, b, c, d, e, f
concat(numbers, chars) -> 0, 1, 2, 3, 4, 5, a, b, c, d, e, f
concat(it1, ..., itn) -> yield xni
Receives an integer that represents how many values do you want to skip and returns the same iterator but with the dropped values.
drop(n) -> yield xi > n
Work as Array.prototype.every.
Work as Array.prototype.filter.
Work as Array.prototype.find.
NOTE: Returns a Iterator with one or no value.
Returns first iterator value.
first() -> return x0
In the case you have an iterators of iterators and you want to flatten, this is your op.
flat() -> yield xij
Combine the ops flat() and map(f).
flat() -> yield f(xij)
Works as Array.prototype.forEach.
Works as Array.prototype.join.
Returns last iterator value.
last() -> return xlength - 1
Work as Array.prototype.map.
Receives n iterators and returns an iterator. This one emit all values of each iterator and emits sequencially each value in the same position.
For example:
numbers -> 0, 1, 2, 3, 4, 5
chars -> a, b, c, d, e, f
merge(numbers, chars) -> 0, a, 1, b, 2, c, 3, d, 4, e, 5, f
merge(it1, ..., itn) -> yield xin
Calls all high over functions / ops taking like parameter the result of before call. The first argument is the original iterator (this).
pipe(f0, ..., fn) -> fn(f0(this))
Works as Array.prototype.reduce.
Works as Array.prototype.some.
Takes a range of iterator values from 0 to n.
take(n) -> yield xi < n
Iterate and takes a value in the same position from two iterators (original iterator and it) and calls a function with two arguments where first argument is original iterator value and second the other iterator's value.
If one of iterators close, it close other too.
For example:
numbers -> 0, 1, 2, 3, 4, 5
chars -> a, b, c, d, e, f
numbers.zip(chars, f) -> f(0, a), f(1, b), f(2, c), f(3, d), f(4, e), f(5, f)
zip(it, f) -> yield f(thisi, iti)