The type yielded from the LazyIterable
The generator to be wrapped in the LazyIterable
Returns a new LazyIterable that ignores the first items
values from the base generator before yielding.
The number of values to ignore from the generator
A new LazyIterable, for chaining
Returns a new LazyIterable that ignores values from the base generator until the provided predicate
is false.
A new LazyIterable, for chaining
Returns a new LazyIterable 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 LazyIterable, for chaining
Returns a new LazyIterable that yields only those values from the base generator for which the provided predicate
is true
.
A new LazyIterable, for chaining
Returns a new LazyIterable that yields the result of applying the provided callback
to values from the base generator.
The type returned by the callback
A new LazyIterable, for chaining
Performs an effectful callback effect
for each value yielded from the base generator,
and returns a new LazyIterable 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 LazyIterable, for chaining
Returns a new LazyIterable that yields the first items
number of values from the base generator.
The number of values to take from the generator
A new LazyIterable, for chaining
Returns a new LazyIterable 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 LazyIterable, for chaining
Tests values yielded from the LazyIterable against the given predicate
, returning true
if it is satisfied every time.
As an eager method, calling every
will trigger an evaluation of the LazyIterable. Since values cannot be re-yielded once run,
it may be more appropriate to use the standard Array
method for some use cases.
true
if every value satisfies the given predicate
, else false
.
Returns the first value yielded by the LazyIterable that satisfies the given predicate
.
As an eager method, calling find
will trigger an evaluation of the LazyIterable. 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 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 LazyIterable, but does not return a new iterable.
As an eager method, calling forEach
will trigger an evaluation of the LazyIterable. 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 LazyIterable yielded a given value search
.
As an eager method, calling includes
will trigger an evaluation of the LazyIterable. 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.
true
if the given value was yielded, else false
.
Returns the index of the value that matches the given search
value; in a LazyIterable, 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 LazyIterable. 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.
How many values had been yielded from the LazyIterable before search
, or -1 if search
is never yielded.
Returns a string formed by concatenating each element yielded from the LazyIterable, separated by the given separator, or a comma ',' if none is provided.
If only one value is yielded, that value is returned as a string with no seperator. If no values are yielded, an empty string is returned.
As an eager method, calling join
will trigger an evaluation of the LazyIterable. Since values cannot be re-yielded once run,
it may be more appropriate to use the standard Array
method for some use cases.
The string that will separate elements in the final string. Defaults to comma ',' if none is provided.
A string with each element of the LazyIterable joined.
Returns the last index of the value that matches the given search
value; in a LazyIterable, 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 LazyIterable. Since values cannot be re-yielded once run,
it may be more appropriate to use the standard Array
method for some use cases. The LazyIterable must also be finite for this method to work.
Note the difference between this method and the standard Array
implementation; because a LazyIterable 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.
How many values had been yielded from the LazyIterable before the last instance of search
, or -1 if search
is never yielded.
Returns 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 LazyIterable, returning a single output value.
As an eager method, calling reduce
will trigger an evaluation of the LazyIterable. 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
The final result of the reduction
Returns a new LazyIterable that yields the values of the original LazyIterable in reverse order.
As an eager method, calling reverse
will trigger an evaluation of the LazyIterable. Since values cannot be re-yielded once run,
it may be more appropriate to use the standard Array
method for some use cases.
A new LazyIterable, for chaining
Tests values yielded from the LazyIterable 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 LazyIterable. Since values cannot be re-yielded once run,
it may be more appropriate to use the standard Array
method for some use cases.
true
if at least one value satisfies the given predicate
, else false
.
Returns a standard Array
containing the values yielded from the LazyIterable in order.
This is an eager method, which means it requires the evaluation of the LazyIterable; therefore, you must ensure that the underlying LazyIterable is not infinite.
As this method relies on the standard Array.from()
method, it returns a shallow copied Array
.
A new Array
instance
Convert this LazyIterable into an AsyncLazyIterable, which allows for async methods to be performed on the values yielded.
A new AsyncLazyIterable
Converts an Iterable
into a new LazyIterable. The input can be anything that implements the @@iterator
method;
common built-in iterables include Array
, String
, Set
, and Map
.
The type returned from the input iterable
A new LazyIterable
Generated using TypeDoc
James Errington james.errington@protonmail.com
1.0.0
A wrapper class that encapsulates a lazyily-evaluated iterable; a synchronous list of values that are generated on-demand.