Create a sequence which repeats the same value X number of times. The length of the sequence defaults to Infinity.
// Creates a sequence of 5 true values.
const sequence: Seq<boolean> = repeat(true, 5)
// Creates a sequence of 0 which repeats infinitely.
const sequence: Seq<number> = repeat(0)
type repeat = <T>(value: T, times = Infinity) => Seq<T>
repeatedly
Creates a sequence which pulls from an impure callback to generate the sequence. The second parameter can cap the length of the sequence. By default, it will call the callback infinitely to generate values. Useful for asking about current time or cache values.
const sequence: Seq<Date> = repeatedly(() => new Date())
type repeatedly = <T>(value: () => T, times = Infinity) => Seq<T>
empty
A sequence with nothing in it. Useful as a "no op" for certain code-paths when joining sequences together.
const sequence: Seq<never> = empty()
type empty = () => Seq<never>
zip
Takes two sequences and lazily combines them to produce a tuple with the current step in each of the two positions. Useful for zipping a sequence of keys with a sequence of values, before converting to a Map of key to value.
type zip = <T1, T2>(
seq1: Seq<T1>,
seq2: Seq<T2>,
) => Seq<[T1 | undefined, T2 | undefined]>
zipWith
Takes two sequences and lazily combines them to produce an arbitrary value by mapping the current value of the two positions through a user-supplied function. Useful for table (row/col) math.
Takes three sequences and lazily combines them to produce an arbitrary value by mapping the current value of the three positions through a user-supplied function.