0.0.3 • Published 7 years ago

seqnext v0.0.3

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

seqnext - Sequences

A library of for "Sequences" in TypeScript / JavaScript.

Written in TypeScript so you know the type definitions will always be valid and applicable.

Sequences

The foundation of a Sequence in code:

interface SeqNext<T> {
  (): [T, SeqNext<T>] | undefined;
}

You call a function, you get a value and another function poised to offer the next value.
Or you get null, telling you there are no more values to be had.

This abstraction allows for a lazy model which is very useful when dealing with large amounts of data where you don't want all the values. Or reading lines from a file. Or rows from a database. Or even reading an array.

Why would you want to use a Sequence for an Array? The level of abstraction means you can test an array now, a database read later. Also, there are a number of helpful tools for this Sequence.

This is inspired by Haskell's lazy paradigm and more concretely by Microsoft F# Sequences.

Test Code

Coming soon

Licence

MIT