deltas
deltas<
T,D>(iterable,subtract):IterableIterator<D>
Defined in: packages/core/src/iterable/deltas.ts:23
Yields the difference between each element and the one before it.
subtract is required rather than defaulting to numeric subtraction: the
operation is the caller’s, which is what keeps this out of the math packages
— nothing here computes on numbers, it only applies what it is given.
Arguments reach subtract as (current, previous), so numeric subtraction
makes an increase positive.
An input of fewer than two elements yields nothing, so there is always one fewer delta than there are elements.
Time complexity: O(1) per element, plus whatever subtract costs.
Type Parameters
Section titled “Type Parameters”T
D
Parameters
Section titled “Parameters”iterable
Section titled “iterable”Iterable<T>
The input iterable.
subtract
Section titled “subtract”Callable<[T, T], D>
Computes the difference between an element and its predecessor.
Returns
Section titled “Returns”IterableIterator<D>
An iterator over the consecutive differences.