The Kolibri Sequence facility is an extension of the standard
Iteration
protocols that are in the JavaScript stdlib since 2016
and have been upgraded considerably with Baseline 2025 that introduced
new
Iterator functions like map, filter, reduce, forEach, flatMap, and more.
This cheat sheet shows how to use Kolibri Sequences and how they play nicely together
with the stdlib iteration features. For full coverage, see the Kolibri sequence test cases and
additional demos and examples.
A few things to keep in mind that make all Kolibri Sequences and their operators special:
- all constructors and operators are thoroughly typed, documented, and tested
- Sequences are immutable, lazy, compositional, and pure (as long as the callback functions are pure)
- Sequences can be infinite
- names of operators that should only be called on finite sequences end with a $ character (e.g.
reduce$)
- non-terminal operators can be chained (they are monoidal where possible)
- Sequences provide "fusion optimization" by design
- all operators are available as instance methods as well as utility functions in curried
style for eta reduction, pipelining, and custom operators
- Sequences - along with Pair, Tuple, MayBe, and JSON - are monadic and can therefore be used
with JINQ like in from(...).where(...).select(...).result()