Home > polyethylene > 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.
Signature:
export default class PolySyncIterable<T> implements Iterable<T>
Implements: Iterable<T>
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the PolySyncIterable
class.
Method | Modifiers | Description |
---|---|---|
[Symbol.iterator]() | Allows this class to work as a regular Iterable<T> |
|
append(other) | Return a new iteration that will iterate over this , then over other . |
|
async() | Return an async version of this same iteration. | |
chunk(num) | Return an iteration of arrays of size num (except possibly the last) containing groupings of elements of this iteration. |
|
chunkWhile(func) | Return an iteration of arrays with elements of this separated based on the result of calling func(elements) . |
|
complete() | Perform this iteration doing nothing. | |
concat(other) | Return a new iteration that will iterate over this , then over other . |
|
drop(num) | Return a new iteration that skips the first num elements. If there were less than num elements in the iteration, no elements are yielded. |
|
dropLast(num) | Return a new iteration that skips the last num elements. If there were less than num elements in the iteration, no elements are yielded. |
|
dropWhile(func) | Return a new iteration that skips the first few elements for which func(element) returns true . |
|
every(func) | Returns true if calling func(element) returns true for every element, and false otherwise |
|
filter(func) | Return an iteration of the elements of this for which func(element) returns true . |
|
filter(func) | Return an iteration of the elements of this for which func(element) returns true . |
|
filterNotNullish() | Return an iteration of all the elements as this that aren't null or undefined . |
|
find(func) | Returns the first element for which func(element) returns true , or undefined if it never does. |
|
find(func) | Returns the first element for which func(element) returns true , or undefined if it never does. |
|
flat(this) | Return an iteration of the yielded elements of the sub-iterables. | |
flatMap(func) | Return an iteration of elements of the sub-iterables that result from calling func(element) for every element in this . |
|
flatten(this) | Return an iteration of the yielded elements of the sub-iterables. | |
forEach(func) | Call a function for each element of this iteration. |
|
groupBy(func) | Return an iteration of group pairs, where the first element is a _group key_ and the second is an iterable of all the elements for which func(element) returned the key. |
|
includes(obj) | Returns whether an element is present in this iteration. | |
join(glue) | Return the result of joining the elements of this with the given glue , or ',' if no glue is given. |
|
map(func) | Return an iteration of the result of calling func(element) for every element in this . |
|
prepend(other) | Return a new iteration that will iterate over other , then over this . |
|
reduce(reducer, init) | Returns the result of calling the passed reducer for all elements of the iteration and the result of the previous call to reducer , starting by passing init or, if not present, the first element of the iteration. |
|
reduce(reducer, init) | Returns the result of calling the passed reducer for all elements of the iteration and the result of the previous call to reducer , starting by passing init . |
|
reverse() | Return an iteration of the elements of this in reverse order. |
|
slice(start, end) | Return a new iteration that starts from the start th element (included) and ends at the end th element (excluded) of this . |
|
some(func) | Returns true if calling func(element) returns true for at least one element, and false otherwise |
|
sort(func) | Return an iteration of the elements of this sorted according to func |
|
take(num) | Return a new iteration that iterates only over the first num elements. If there were less than than num elements in the iteration, all elements are yielded with no additions. |
|
takeLast(num) | Return a new iteration that iterates only over the last num elements. If there were less than than num elements in the iteration, all elements are yielded with no additions. |
|
takeWhile(func) | Return a new iteration that yields the first few elements for which func(element) returns true . |
|
tap(func) | Return an iteration of the same elements as this after calling func(element) for all elements. |
|
toArray() | Return an array of all elements of this iteration in the same order that were yielded. | |
toMap(this) | Return a Map made from the entries of this . This method is roughly equivalent to calling new Map(iter.toArray()) . |
|
toObject(this) | Return an object made from the entries of this . This method is roughly equivalent to calling Object.fromEntires(iter.toArray()) . |
|
toPartitionArrays(func) | Splits this iteration into two arrays, one with elements for which func(element) returns true (the _truthy elements_) and one for which it returns false (the _falsy elements_). |
|
toPartitionArrays(func) | Splits this iteration into two arrays, one with elements for which func(element) returns true (the _truthy elements_) and one for which it returns false (the _falsy elements_). |
|
unique(func) | Return an iteration of unique elements, where two elements are considered equal if the result of func(element) is the same for both elements. |