The type yielded from the AsyncLazyIterable
The generator to be wrapped in the AsyncLazyIterable
Returns a new AsyncLazyIterable that ignores the first items values from the base generator before yielding.
The number of values to ignore from the generator
A new AsyncLazyIterable, for chaining
Returns a new AsyncLazyIterable that ignores values from the base generator until the provided predicate is false.
A new AsyncLazyIterable, for chaining
Returns a new AsyncLazyIterable that yields the values returned from calling the provided generator with values from the base generator.
Can be considered a generalisation of the other lazy processing methods, and is useful when more complex processing is required;
for example, when stateful knowledge of past values is needed.
A new AsyncLazyIterable, for chaining
Returns a new AsyncLazyIterable that yields only those values from the base generator for which the provided predicate is true.
A new AsyncLazyIterable, for chaining
Returns a new AsyncLazyIterable that yields the result of applying the provided callback to values from the base generator.
The type returned by the callback
A new AsyncLazyIterable, for chaining
Performs an effectful callback effect for each value yielded from the base generator,
and returns a new AsyncLazyIterable that just passes the values on. Can be considered a helper function
for an effectful map on the identity function, or a lazy version of forEach.
A new AsyncLazyIterable, for chaining
Returns a new AsyncLazyIterable that yields the first items number of values from the base generator.
The number of values to take from the generator
A new AsyncLazyIterable, for chaining
Returns a new AsyncLazyIterable that yields values from the base generator until the provided predicate is false.
This is different to filter in that no values after the first false response are yielded.
A new AsyncLazyIterable, for chaining
Tests values yielded from the AsyncLazyIterable against the given predicate, returning true if it is satisfied every time.
As an eager method, calling every will trigger an evaluation of the AsyncLazyIterable. Since values cannot be re-yielded once run,
it may be more appropriate to use the standard Array method for some use cases.
A Promise that resolves to true if every value satisfies the given predicate, else false.
Returns the first value yielded by the AsyncLazyIterable that satisfies the given predicate.
As an eager method, calling find will trigger an evaluation of the AsyncLazyIterable. Since values cannot be re-yielded once run,
it may be more appropriate to use the standard Array method for some use cases.
A Promise that resolves to the value of the first element that satisfies the given predicate, or undefined if no value exists.
Similar to runEffect, calls the given callback for each value yielded from the AsyncLazyIterable, but does not return a new iterable.
As an eager method, calling forEach will trigger an evaluation of the AsyncLazyIterable. Since values cannot be re-yielded once run,
it may be more appropriate to use the standard Array method for some use cases.
Determines if the AsyncLazyIterable yielded a given value search.
As an eager method, calling includes will trigger an evaluation of the AsyncLazyIterable. Since values cannot be re-yielded once run,
it may be more appropriate to use the standard Array method for some use cases.
The value to search for.
A Promise that resolves to true if the given value was yielded, else false.
Returns the index of the value that matches the given search value; in a AsyncLazyIterable, this translates to the number of values that have been yielded before an instance of search is found.
As an eager method, calling indexOf will trigger an evaluation of the AsyncLazyIterable. Since values cannot be re-yielded once run,
it may be more appropriate to use the standard Array method for some use cases.
The value to search for.
A Promise that resolves to how many values had been yielded from the AsyncLazyIterable before search, or -1 if search is never yielded.
Returns the last index of the value that matches the given search value; in a AsyncLazyIterable, this translates to the number of values that have been yielded before the last instance of search is found.
As an eager method, calling lastIndexOf will trigger an evaluation of the AsyncLazyIterable. Since values cannot be re-yielded once run,
it may be more appropriate to use the standard Array method for some use cases. The AsyncLazyIterable must also be finite for this method to work.
Note the difference between this method and the standard Array implementation; because a AsyncLazyIterable encapsulates a stream of values that have yet to be fully evaluated,
lastIndexOf cannot search backwards, and so this method on its own is likely much less efficient.
The value to search for.
A Promise that resolves to how many values had been yielded from the AsyncLazyIterable before the last instance of search, or -1 if search is never yielded.
Returns a Promise to an object with two properties: value, and done. value holds the next value of the iteration sequence,
based on the current state of the internal generator. done is true if the last value of the generator has already been consumed,
otherwise false.
The result from one iteration of the generator
Applies the given reducer function for each value yielded from the AsyncLazyIterable, returning a single output value.
As an eager method, calling reduce will trigger an evaluation of the AsyncLazyIterable. Since values cannot be re-yielded once run,
it may be more appropriate to use the standard Array method for some use cases.
The type of the accumulated value
The function to apply for each value yielded
The initial value for the accumulator
A Promise that resolves to the final result of the reduction
Tests values yielded from the AsyncLazyIterable against the given predicate, returning true if it is satisfied at least once.
As an eager method, calling some will trigger an evaluation of the AsyncLazyIterable. Since values cannot be re-yielded once run,
it may be more appropriate to use the standard Array method for some use cases.
A Promise that resolves to true if at least one value satisfies the given predicate, else false.
Returns a standard Array containing the values yielded from the AsyncLazyIterable in order.
This triggers a full evaluation of the AsyncLazyIterable, resolving each value in serial and building an Array; thus, the Promise returned from this method will not resolve until value has been resolved.
It also means that the AsyncLazyIterable must not be infinite.
A new Array instance
Convert this AsyncLazyIterable into an LazyIterable.
This triggers a full evaluation of the AsyncLazyIterable, resolving each value in serial and feeding the resultant list
into a LazyIterable; thus, the Promise returned from this method will not resolve until value has been resolved.
It also means that the AsyncLazyIterable must not be infinite.
A Promise that resolves to a new LazyIterable
Converts an AsyncIterable into a new AsyncLazyIterable. The input can be anything that implements the @@asyncIterator method.
To create a AsyncLazyIterable from an AsyncGenerator, the standard constructor function can be used.
The type returned from the input iterable
A new AsyncLazyIterable
Generated using TypeDoc
James Errington james.errington@protonmail.com
1.0.0
A wrapper class that encapsulates a lazyily-evaluated iterable, where each value can be generated by some async action. Note that while the actions individually can be async i.e. not guaranteed to return immediately, they are generated in serial; when iterating a AsyncLazyIterable, the first element must be generated before the second can start. This is not always the preferred behaviour, and it may be the case that methods such as
Promise.allare more suited in some use cases, when async actions can be run in parallel.