iterable-joiner
v1.0.3
Published
combine multiple Iterable or AsyncIterable objects into one
Downloads
4
Maintainers
Readme
iterable-joiner
What's included?
Two AsyncIterable Joiner Implementations
- IterableJoiner.Async.Equitable - provides values from all AsyncIterables with the same priority.
- IterableJoiner.Async.Priority - provides values from all AsyncIterables with priority given to the first AsyncIterable with decreasing priority for each subsequent AsyncIterable.
Two Iterable Joiner Implementations
- IterableJoiner.Sync.Equitable - provides values from all Iterables in a round-robin fashion.
- IterableJoiner.Sync.Priority - provides values from all Iterables exhausting each Iterator before continuing to the next.
Abstract joiners
- Write your own algorithm for how to iterate through multiple iterators.
Importing
const { IterableJoiner } = require ( "iterable-joiner" );
import { IterableJoiner } from "iterable-joiner";
IterableJoiner.Async
IterableJoiner.Async.Equitable.join( [ ... asyncIterables ] )
IterableJoiner.Async.Priority.join( [ ... asyncIterables ] )
- asyncIterables <AsyncIterable[]> (optional) one or more asyncIterables that you want to join.
- Returns <AsyncIterable> an aggregation of the provided AsyncIterables.
asyncJoiner.iterables
- a read-only in-order array of the iterables that have been added to the joiner
asyncJoiner.addIterable( asyncIterable[, idx ] )
- asyncIterable <AsyncIterable> the asyncIterable being added.
- idx <number> (optional) the index of the internal array to add the iterable at. If idx>0, the value will be unshifted onto the front of the array, if idx>iterables.length, it will be pushed. Default is to push to the end of the array.
- Returns <boolean> false if parameters have incorrect types or the asyncIterator has already been added
asyncJoiner.removeIterable( asyncIterable )
- asyncIterable <AsyncIterable> the asyncIterable being removed
- Returns <boolean> false if asyncIterator doesn't exist in the joiner
IterableJoiner.Sync
IterableJoiner.Sync.Equitable.join( [ ... iterables ] )
IterableJoiner.Sync.Priority.join( [ ... iterables ] )
- iterables <Iterable[]> (optional) one or more asyncIterables that you want to join.
- Returns <Iterable> an aggregation of the provided Iterables.
syncJoiner.iterables
- a read-only in-order array of the iterables that have been added to the joiner
syncJoiner.addIterable( iterable[, idx ] )
- iterable <Iterable> the Iterable being added.
- idx <number> (optional) the index of the internal array to add the iterable at. If idx>0, the value will be unshifted onto the front of the array, if idx>iterables.length, it will be pushed. Default is to push to the end of the array.
- Returns <boolean> false if parameters have incorrect types or the iterator has already been added
syncJoiner.removeIterable( iterable )
- iterable <Iterable> the Iterable being removed
- Returns <boolean> false if Iterator doesn't exist in the joiner