Pull Overview
Pull Lines
are bases on native ECMAScript Iterables
:
interface Iterable<T> { [Symbol.iterator](): Iterator<T>;}
interface Iterator<T> { next(): IteratorResult<T>; return?(): void;}
interface IteratorResult<T> { value: T; done: boolean;}
Pull
is the most used type of pipelines. A Pull Line
is re-usable if its source is re-iterable.
Terms in releation to Pull Lines
:
iterable
-- an object implementing the Iterable protocol.operation
-- a function taking anIterable
of source items and returning anIterable
of result items.pipeline
-- an ordered sequence (array) ofoperations
.source
-- anIterable
which items will be processed. Many native objects areIterable
out of the box: arrays, maps, sets, strings.target
-- a function for extracting the result out of pipeline. Takes anIterable
and returns some value. Many native functions behave this way:Array.from()
,new Map()
,Object.fromEntries()
, etc.Targets
provided byUndercut
are mostly wrappers around those native functions/constructors for convenience. Feel free to use the originals.
type PullOperation = <T, R>(iterable: Iterable<T>) => Iterable<R>;
type PullPipeline = Array<PullOperation>;
type PullTarget = <T, R>(iterable: Iterable<T>) => R;