[Home](./index.md) > [polyethylene](./polyethylene.md) ## polyethylene package 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](./polyethylene.poly.md) namespace, and the main iterable classes are [PolySyncIterable](./polyethylene.polysynciterable.md) and [PolyAsyncIterable](./polyethylene.polyasynciterable.md). ## Classes
Class Description
[AsyncIterableBuilder](./polyethylene.asynciterablebuilder.md) A class that helps with building an [AsyncIterable](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator) from a non-structured source. In order to create the iteration, you must call the [value](./polyethylene.asynciterablebuilder.value.md), [error](./polyethylene.asynciterablebuilder.error.md) and [done](./polyethylene.asynciterablebuilder.done.md) methods with appropriate arguments.
[PolyAsyncIterable](./polyethylene.polyasynciterable.md) An `AsyncIterable` 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](./polyethylene.polysynciterable.md), 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](./polyethylene.concurrencyoptions.md) 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()](./polyethylene.polyasynciterable.prefetch.md).
## Abstract Classes
Abstract Class Description
[PolySyncIterable](./polyethylene.polysynciterable.md) A `SyncIterable` 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.
## Interfaces
Interface Description
[ConcurrencyOptions](./polyethylene.concurrencyoptions.md) Options for concurrency.
## Namespaces
Namespace Description
[Poly](./polyethylene.poly.md) Main namespace for the creation of [PolySyncIterable](./polyethylene.polysynciterable.md) and [PolyAsyncIterable](./polyethylene.polyasynciterable.md) objects.
## Type Aliases
Type Alias Description
[AsyncChunkingPredicate](./polyethylene.asyncchunkingpredicate.md) 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](./polyethylene.asyncindexedmapping.md) 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](./polyethylene.asyncindexedpredicate.md) 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](./polyethylene.asyncindexedreducer.md) 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](./polyethylene.asyncindexedrunnable.md) 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](./polyethylene.chunkingpredicate.md) 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](./polyethylene.comparator.md) 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](./polyethylene.indexedmapping.md) A function that receives an object (`elem`) and its `index` in the iteration and returns a different object
[IndexedPredicate](./polyethylene.indexedpredicate.md) A function that receives an object (`elem`) and its `index` in the iteration and returns a `boolean` value.
[IndexedReducer](./polyethylene.indexedreducer.md) 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](./polyethylene.indexedrunnable.md) A function that receives an object (`elem`) and its `index` in the iteration and doesn't return anything
[IndexedTypePredicate](./polyethylene.indexedtypepredicate.md) 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](./polyethylene.tuple.md) A tuple of `N` elements of type `T`.