Home > polyethylene
A library for working with iterables and async iterables in a functional style, by transforming the iterations on the fly and getting results from them.
Remarks
The entry point for this library is the Poly namespace, and the main iterable classes are PolySyncIterable and PolyAsyncIterable.
Class
|
Description
|
AsyncIterableBuilder
|
A class that helps with building an AsyncIterable from a non-structured source.
In order to create the iteration, you must call the value, error and done methods with appropriate arguments.
|
PolyAsyncIterable
|
An AsyncIterable<T> with a suite of methods for transforming the iteration into other iterations or to get a single result from it.
This class works as an async version of PolySyncIterable, but all methods accept async function where possible and will always return either PolyAsyncIterables or a Promise to a value.
## Concurrency Many operations of this class accept as a final argument an options object than can specify some options for concurrent operations.
- The
concurrency option will specify how many times whatever func you pass is called before waiting for its results. Effectively, this is the number of promises that can be pending at the same time. If not specified, it will default to 0, meaning no concurrency. Must be a non-negative integer. - The bufferSize option will specify the size of the internal buffer used to store the pending and completed promises. Effectively, this is how many results will be prefetched. If not specified, it will default to concurrency , meaning no extra intermediate results are stored. Must be a positive integer greater or equal to concurrency .
A concurrency value of 0 acts the same as a 1 concurrency-wise, but disables the concurrency completely, preventing any values to be requested before actually needed.
Specifying concurrency greater or equal to 1 will make more elements be requested of the previous iterator than actually requested of the current one, similarly to PolyAsyncIterable.prefetch().
|
Abstract Class
|
Description
|
PolySyncIterable
|
A SyncIterable<T> with a suite of methods for transforming the iteration into other iterations or to get a single result from it.
The methods of this class are intended to resemble those of Array , with added utilities where appropriate and made for any kind of iterable.
|
Type Alias
|
Description
|
AsyncChunkingPredicate
|
A function that receives an element (elem ) of the iteration and the first and last element of a chunk, and returns a boolean value or a Promise to a boolean value representing whether elem should be added to the current chunk (if true ) or be the start of a new chunk (if false )
|
AsyncIndexedMapping
|
A function that receives an object (elem ) and its index in the iteration and returns a different object or a Promise to a different object
|
AsyncIndexedPredicate
|
A function that receives an object (elem ) and its index in the iteration and returns a boolean value or a Promise to a boolean value.
|
AsyncIndexedReducer
|
A function that receives an accumulated result, an element of an iteration, and returns a new accumulated result or a promise to a new accumulated result for the next call or as a final return value.
|
AsyncIndexedRunnable
|
A function that receives an object (elem ) and its index in the iteration and either returns a Promise to nothing or doesn't return anything
|
ChunkingPredicate
|
A function that receives an element (elem ) of the iteration and the first and last element of a chunk, and returns a boolean value representing whether elem should be added to the current chunk (if true ) or be the start of a new chunk (if false )
|
Comparator
|
A function that receives two objects elemA and elemB and returns a number value that is negative if elemA should be sorted before elemB , positive if elemA should be sorted after elemB , or 0 if they should be sorted at the same position.
|
IndexedMapping
|
A function that receives an object (elem ) and its index in the iteration and returns a different object
|
IndexedPredicate
|
A function that receives an object (elem ) and its index in the iteration and returns a boolean value.
|
IndexedReducer
|
A function that receives an accumulated result, an element of an iteration, and returns a new accumulated result for the next call or as a final return value.
|
IndexedRunnable
|
A function that receives an object (elem ) and its index in the iteration and doesn't return anything
|
IndexedTypePredicate
|
A function that receives an object (elem ) and its index in the iteration and returns a boolean value indicating if elem is of the generic type U
|
Tuple
|
A tuple of N elements of type T .
|