Sync/Async type selector
Any Generator
, Iterator
, or Iterable
, which can be coerced to a
EnhancedGenerator.
the value type produced by the Genable
An enhanced Generator
The value type yielded by the Generator
.
Selects for Sync or Async operation.
Returns the element type of a Genable
Returns the union of the element types of a tuple of generators.
a tuple type of Genable's.
Any Generator
, Iterator
, or Iterable
, which can be coerced to a
EnhancedGenerator.
A function which can be supplied to a reduce method.
For the case where an init value of type A will be supplied, use:
For the case where no init value will be supplied, use:
For cases where an init value may or may not be supplied:
For cases where A = T (for example, reducing a set of numbers to a number):
The accumulated result.
The individual element values supplied to be reduced.
the initial value for the reducer. If no init value is supplied, the first call will be T; otherwise it will be A.
either Sync or Async.
Sync/Async type selector
Sync/Async type selector
Predicate/type guard, returns true
if the argument satisfies the AsyncIterable
protocol (has a [Symbol.asyncIterator]
method).
Predicate/type guard, returns true
if the argument satisfies the AsyncIterable
protocol (has a [Symbol.asyncIterator]
method) and the AsyncIterator
protocol (a next() method).
Predicate/type guard, returns true
if the argument satisfies the AsyncIterator
protocol (has a next()
method).
Note: There is no way to statically distinguish between an Iterator
and an AsyncIterator
. You will get
runtime errors if you don't anticipate the distinction.
Predicate/type guard to determine if an object is (or looks like, structurally) a Generator.
Predicate/type guard, returns true
if the argument satisfies the Iterable
protocol (has a [Symbol.iterator]
method).
Predicate/type guard, returns true
if the argument satisfies the Iterable
protocol (has a [Symbol.iterator]
method) and the Iterator
protocol (a next() method).
Predicate/type guard, returns true
if the argument satisfies the Iterator
protocol (has a next()
method).
Note: There is no way to statically distinguish between an Iterator
and an AsyncIterator
. You will get
runtime errors if you don't anticipate the distinction.
(default = 0)
(default = Number.MAX_SAFE_INTEGER
)
(default = 1)
Coerce an object to an object that can act as a async generator (that is, satisfy both Iterator
and Iterable
).
If it is an AsyncIterator
but not AsyncIterable
, or AsyncIterable
but not AsyncIterator
,
it is wrapped in an async generator.
Coerce a Genable object to AsyncIterable
. If it is already an AsyncIterable
, it is returned
unchanged. If it is an AsyncIterator
, it is wrapped in an object with a [Symbol.asyncIterator]
method that returns the supplied iterator.
Similar to toAsyncGenerator, but does not require the presence of AsyncGenerator.return
or
AsyncGenerator.throw
methods.
Coerce an object to an object that can act as a generator (that is, satisfy both Iterator
and Iterable
).
If it is an Iterator
but not Iterable
, or Iterable
but not Iterator
, it is wrapped
in a generator.
Similar to toGenerator, but does not require the presence of Generator.return
or Generator.throw
methods.
Generated using TypeDoc
An extension to generators, that provides for operations like: