Function: reduceAsync()
Returns the result of reducing the asyncIterable
using asyncReducer
.
Informally, an initial accumulator is created using
AsyncReducer.create. Then each value in asyncIterable
is added to
the accumulator and the current accumulator is updated using
AsyncReducer.add. Finally, the resulting accumulator is transformed
using AsyncReducer.finish if specified. Multiple accumulators may be
created, added to, and then combined if supported via
AsyncReducer.combine and the next value of asyncIterable
is ready
before promises from AsyncReducer.add resolve.
If asyncReducer
is an async optional reducer (no
AsyncReducer.create method), then an empty async iterable is returned
if asyncIterable
is empty. Otherwise, an async iterable containing the
result of reducing using the first value of the async iterable as the initial
accumulator is returned.
Like Array.prototype.reduce
, but for async iterables.
Example
console.log(
await pipe(
asAsync([`Hello`, `World!`, `What`, `an`, `interesting`, `program!`]),
reduceAsync((a, b) => `${a} ${b}`),
getAsync,
),
)
//=> Hello World! What an interesting program!
console.log(
await pipe(
asAsync([`Hello`, `World!`, `What`, `an`, `interesting`, `program!`]),
reduceAsync({ create: () => ``, add: (a, b) => `${a} ${b}` }),
),
)
//=> Hello World! What an interesting program!
reduceAsync(asyncReducer, asyncIterable)
reduceAsync<
Value
,Acc
,Finished
,This
>(asyncReducer
,asyncIterable
):Promise
<Finished
>
Returns the result of reducing the asyncIterable
using asyncReducer
.
Informally, an initial accumulator is created using
AsyncReducer.create. Then each value in asyncIterable
is added to
the accumulator and the current accumulator is updated using
AsyncReducer.add. Finally, the resulting accumulator is transformed
using AsyncReducer.finish if specified. Multiple accumulators may be
created, added to, and then combined if supported via
AsyncReducer.combine and the next value of asyncIterable
is ready
before promises from AsyncReducer.add resolve.
If asyncReducer
is an async optional reducer (no
AsyncReducer.create method), then an empty async iterable is returned
if asyncIterable
is empty. Otherwise, an async iterable containing the
result of reducing using the first value of the async iterable as the initial
accumulator is returned.
Like Array.prototype.reduce
, but for async iterables.
Type Parameters
• Value
• Acc
• Finished
• This
Parameters
• asyncReducer: RawAsyncReducerWithFinish
<Value
, Acc
, Finished
, This
> | RawReducerWithFinish
<Value
, Acc
, Finished
, This
>
• asyncIterable: AsyncIterable
<Value
, any
, any
>
Returns
Promise
<Finished
>
Example
console.log(
await pipe(
asAsync([`Hello`, `World!`, `What`, `an`, `interesting`, `program!`]),
reduceAsync((a, b) => `${a} ${b}`),
getAsync,
),
)
//=> Hello World! What an interesting program!
console.log(
await pipe(
asAsync([`Hello`, `World!`, `What`, `an`, `interesting`, `program!`]),
reduceAsync({ create: () => ``, add: (a, b) => `${a} ${b}` }),
),
)
//=> Hello World! What an interesting program!
Defined in
reduceAsync(asyncReducer)
reduceAsync<
Value
,Acc
,Finished
,This
>(asyncReducer
): (asyncIterable
) =>Promise
<Finished
>
Returns the result of reducing the asyncIterable
using asyncReducer
.
Informally, an initial accumulator is created using
AsyncReducer.create. Then each value in asyncIterable
is added to
the accumulator and the current accumulator is updated using
AsyncReducer.add. Finally, the resulting accumulator is transformed
using AsyncReducer.finish if specified. Multiple accumulators may be
created, added to, and then combined if supported via
AsyncReducer.combine and the next value of asyncIterable
is ready
before promises from AsyncReducer.add resolve.
If asyncReducer
is an async optional reducer (no
AsyncReducer.create method), then an empty async iterable is returned
if asyncIterable
is empty. Otherwise, an async iterable containing the
result of reducing using the first value of the async iterable as the initial
accumulator is returned.
Like Array.prototype.reduce
, but for async iterables.
Type Parameters
• Value
• Acc
• Finished
• This
Parameters
• asyncReducer: RawAsyncReducerWithFinish
<Value
, Acc
, Finished
, This
> | RawReducerWithFinish
<Value
, Acc
, Finished
, This
>
Returns
Function
Parameters
• asyncIterable: AsyncIterable
<Value
, any
, any
>
Returns
Promise
<Finished
>
Example
console.log(
await pipe(
asAsync([`Hello`, `World!`, `What`, `an`, `interesting`, `program!`]),
reduceAsync((a, b) => `${a} ${b}`),
getAsync,
),
)
//=> Hello World! What an interesting program!
console.log(
await pipe(
asAsync([`Hello`, `World!`, `What`, `an`, `interesting`, `program!`]),
reduceAsync({ create: () => ``, add: (a, b) => `${a} ${b}` }),
),
)
//=> Hello World! What an interesting program!
Defined in
reduceAsync(asyncReducer, asyncIterable)
reduceAsync<
Value
,Acc
,This
>(asyncReducer
,asyncIterable
):Promise
<Acc
>
Returns the result of reducing the asyncIterable
using asyncReducer
.
Informally, an initial accumulator is created using
AsyncReducer.create. Then each value in asyncIterable
is added to
the accumulator and the current accumulator is updated using
AsyncReducer.add. Finally, the resulting accumulator is transformed
using AsyncReducer.finish if specified. Multiple accumulators may be
created, added to, and then combined if supported via
AsyncReducer.combine and the next value of asyncIterable
is ready
before promises from AsyncReducer.add resolve.
If asyncReducer
is an async optional reducer (no
AsyncReducer.create method), then an empty async iterable is returned
if asyncIterable
is empty. Otherwise, an async iterable containing the
result of reducing using the first value of the async iterable as the initial
accumulator is returned.
Like Array.prototype.reduce
, but for async iterables.
Type Parameters
• Value
• Acc
• This
Parameters
• asyncReducer: RawAsyncReducerWithoutFinish
<Value
, Acc
, This
> | RawReducerWithoutFinish
<Value
, Acc
, This
>
• asyncIterable: AsyncIterable
<Value
, any
, any
>
Returns
Promise
<Acc
>
Example
console.log(
await pipe(
asAsync([`Hello`, `World!`, `What`, `an`, `interesting`, `program!`]),
reduceAsync((a, b) => `${a} ${b}`),
getAsync,
),
)
//=> Hello World! What an interesting program!
console.log(
await pipe(
asAsync([`Hello`, `World!`, `What`, `an`, `interesting`, `program!`]),
reduceAsync({ create: () => ``, add: (a, b) => `${a} ${b}` }),
),
)
//=> Hello World! What an interesting program!
Defined in
reduceAsync(asyncReducer)
reduceAsync<
Value
,Acc
,This
>(asyncReducer
): (asyncIterable
) =>Promise
<Acc
>
Returns the result of reducing the asyncIterable
using asyncReducer
.
Informally, an initial accumulator is created using
AsyncReducer.create. Then each value in asyncIterable
is added to
the accumulator and the current accumulator is updated using
AsyncReducer.add. Finally, the resulting accumulator is transformed
using AsyncReducer.finish if specified. Multiple accumulators may be
created, added to, and then combined if supported via
AsyncReducer.combine and the next value of asyncIterable
is ready
before promises from AsyncReducer.add resolve.
If asyncReducer
is an async optional reducer (no
AsyncReducer.create method), then an empty async iterable is returned
if asyncIterable
is empty. Otherwise, an async iterable containing the
result of reducing using the first value of the async iterable as the initial
accumulator is returned.
Like Array.prototype.reduce
, but for async iterables.
Type Parameters
• Value
• Acc
• This
Parameters
• asyncReducer: RawAsyncReducerWithoutFinish
<Value
, Acc
, This
> | RawReducerWithoutFinish
<Value
, Acc
, This
>
Returns
Function
Parameters
• asyncIterable: AsyncIterable
<Value
, any
, any
>
Returns
Promise
<Acc
>
Example
console.log(
await pipe(
asAsync([`Hello`, `World!`, `What`, `an`, `interesting`, `program!`]),
reduceAsync((a, b) => `${a} ${b}`),
getAsync,
),
)
//=> Hello World! What an interesting program!
console.log(
await pipe(
asAsync([`Hello`, `World!`, `What`, `an`, `interesting`, `program!`]),
reduceAsync({ create: () => ``, add: (a, b) => `${a} ${b}` }),
),
)
//=> Hello World! What an interesting program!
Defined in
reduceAsync(asyncReducer, asyncIterable)
reduceAsync<
Value
,Finished
,This
>(asyncReducer
,asyncIterable
):AsyncOptional
<Finished
>
Returns the result of reducing the asyncIterable
using asyncReducer
.
Informally, an initial accumulator is created using
AsyncReducer.create. Then each value in asyncIterable
is added to
the accumulator and the current accumulator is updated using
AsyncReducer.add. Finally, the resulting accumulator is transformed
using AsyncReducer.finish if specified. Multiple accumulators may be
created, added to, and then combined if supported via
AsyncReducer.combine and the next value of asyncIterable
is ready
before promises from AsyncReducer.add resolve.
If asyncReducer
is an async optional reducer (no
AsyncReducer.create method), then an empty async iterable is returned
if asyncIterable
is empty. Otherwise, an async iterable containing the
result of reducing using the first value of the async iterable as the initial
accumulator is returned.
Like Array.prototype.reduce
, but for async iterables.
Type Parameters
• Value
• Finished
• This
Parameters
• asyncReducer: RawAsyncOptionalReducerWithFinish
<Value
, Finished
, This
> | RawOptionalReducerWithFinish
<Value
, Finished
, This
>
• asyncIterable: AsyncIterable
<Value
, any
, any
>
Returns
AsyncOptional
<Finished
>
Example
console.log(
await pipe(
asAsync([`Hello`, `World!`, `What`, `an`, `interesting`, `program!`]),
reduceAsync((a, b) => `${a} ${b}`),
getAsync,
),
)
//=> Hello World! What an interesting program!
console.log(
await pipe(
asAsync([`Hello`, `World!`, `What`, `an`, `interesting`, `program!`]),
reduceAsync({ create: () => ``, add: (a, b) => `${a} ${b}` }),
),
)
//=> Hello World! What an interesting program!
Defined in
reduceAsync(asyncReducer)
reduceAsync<
Value
,Finished
,This
>(asyncReducer
): (asyncIterable
) =>AsyncOptional
<Finished
>
Returns the result of reducing the asyncIterable
using asyncReducer
.
Informally, an initial accumulator is created using
AsyncReducer.create. Then each value in asyncIterable
is added to
the accumulator and the current accumulator is updated using
AsyncReducer.add. Finally, the resulting accumulator is transformed
using AsyncReducer.finish if specified. Multiple accumulators may be
created, added to, and then combined if supported via
AsyncReducer.combine and the next value of asyncIterable
is ready
before promises from AsyncReducer.add resolve.
If asyncReducer
is an async optional reducer (no
AsyncReducer.create method), then an empty async iterable is returned
if asyncIterable
is empty. Otherwise, an async iterable containing the
result of reducing using the first value of the async iterable as the initial
accumulator is returned.
Like Array.prototype.reduce
, but for async iterables.
Type Parameters
• Value
• Finished
• This
Parameters
• asyncReducer: RawAsyncOptionalReducerWithFinish
<Value
, Finished
, This
> | RawOptionalReducerWithFinish
<Value
, Finished
, This
>
Returns
Function
Parameters
• asyncIterable: AsyncIterable
<Value
, any
, any
>
Returns
AsyncOptional
<Finished
>
Example
console.log(
await pipe(
asAsync([`Hello`, `World!`, `What`, `an`, `interesting`, `program!`]),
reduceAsync((a, b) => `${a} ${b}`),
getAsync,
),
)
//=> Hello World! What an interesting program!
console.log(
await pipe(
asAsync([`Hello`, `World!`, `What`, `an`, `interesting`, `program!`]),
reduceAsync({ create: () => ``, add: (a, b) => `${a} ${b}` }),
),
)
//=> Hello World! What an interesting program!
Defined in
reduceAsync(asyncReducer, asyncIterable)
reduceAsync<
Value
,This
>(asyncReducer
,asyncIterable
):AsyncOptional
<Value
>
Returns the result of reducing the asyncIterable
using asyncReducer
.
Informally, an initial accumulator is created using
AsyncReducer.create. Then each value in asyncIterable
is added to
the accumulator and the current accumulator is updated using
AsyncReducer.add. Finally, the resulting accumulator is transformed
using AsyncReducer.finish if specified. Multiple accumulators may be
created, added to, and then combined if supported via
AsyncReducer.combine and the next value of asyncIterable
is ready
before promises from AsyncReducer.add resolve.
If asyncReducer
is an async optional reducer (no
AsyncReducer.create method), then an empty async iterable is returned
if asyncIterable
is empty. Otherwise, an async iterable containing the
result of reducing using the first value of the async iterable as the initial
accumulator is returned.
Like Array.prototype.reduce
, but for async iterables.
Type Parameters
• Value
• This
Parameters
• asyncReducer: RawAsyncOptionalReducerWithoutFinish
<Value
, This
> | RawOptionalReducerWithoutFinish
<Value
, This
>
• asyncIterable: AsyncIterable
<Value
, any
, any
>
Returns
AsyncOptional
<Value
>
Example
console.log(
await pipe(
asAsync([`Hello`, `World!`, `What`, `an`, `interesting`, `program!`]),
reduceAsync((a, b) => `${a} ${b}`),
getAsync,
),
)
//=> Hello World! What an interesting program!
console.log(
await pipe(
asAsync([`Hello`, `World!`, `What`, `an`, `interesting`, `program!`]),
reduceAsync({ create: () => ``, add: (a, b) => `${a} ${b}` }),
),
)
//=> Hello World! What an interesting program!
Defined in
reduceAsync(asyncReducer)
reduceAsync<
Value
,This
>(asyncReducer
): (asyncIterable
) =>AsyncOptional
<Value
>
Returns the result of reducing the asyncIterable
using asyncReducer
.
Informally, an initial accumulator is created using
AsyncReducer.create. Then each value in asyncIterable
is added to
the accumulator and the current accumulator is updated using
AsyncReducer.add. Finally, the resulting accumulator is transformed
using AsyncReducer.finish if specified. Multiple accumulators may be
created, added to, and then combined if supported via
AsyncReducer.combine and the next value of asyncIterable
is ready
before promises from AsyncReducer.add resolve.
If asyncReducer
is an async optional reducer (no
AsyncReducer.create method), then an empty async iterable is returned
if asyncIterable
is empty. Otherwise, an async iterable containing the
result of reducing using the first value of the async iterable as the initial
accumulator is returned.
Like Array.prototype.reduce
, but for async iterables.
Type Parameters
• Value
• This
Parameters
• asyncReducer: RawAsyncOptionalReducerWithoutFinish
<Value
, This
> | RawOptionalReducerWithoutFinish
<Value
, This
>
Returns
Function
Parameters
• asyncIterable: AsyncIterable
<Value
, any
, any
>
Returns
AsyncOptional
<Value
>
Example
console.log(
await pipe(
asAsync([`Hello`, `World!`, `What`, `an`, `interesting`, `program!`]),
reduceAsync((a, b) => `${a} ${b}`),
getAsync,
),
)
//=> Hello World! What an interesting program!
console.log(
await pipe(
asAsync([`Hello`, `World!`, `What`, `an`, `interesting`, `program!`]),
reduceAsync({ create: () => ``, add: (a, b) => `${a} ${b}` }),
),
)
//=> Hello World! What an interesting program!
Defined in
reduceAsync(asyncReducer, asyncIterable)
reduceAsync<
Value
>(asyncReducer
,asyncIterable
):AsyncOptional
<Value
>
Returns the result of reducing the asyncIterable
using asyncReducer
.
Informally, an initial accumulator is created using
AsyncReducer.create. Then each value in asyncIterable
is added to
the accumulator and the current accumulator is updated using
AsyncReducer.add. Finally, the resulting accumulator is transformed
using AsyncReducer.finish if specified. Multiple accumulators may be
created, added to, and then combined if supported via
AsyncReducer.combine and the next value of asyncIterable
is ready
before promises from AsyncReducer.add resolve.
If asyncReducer
is an async optional reducer (no
AsyncReducer.create method), then an empty async iterable is returned
if asyncIterable
is empty. Otherwise, an async iterable containing the
result of reducing using the first value of the async iterable as the initial
accumulator is returned.
Like Array.prototype.reduce
, but for async iterables.
Type Parameters
• Value
Parameters
• asyncReducer: AsyncFunctionReducer
<Value
> | FunctionReducer
<Value
>
• asyncIterable: AsyncIterable
<Value
, any
, any
>
Returns
AsyncOptional
<Value
>
Example
console.log(
await pipe(
asAsync([`Hello`, `World!`, `What`, `an`, `interesting`, `program!`]),
reduceAsync((a, b) => `${a} ${b}`),
getAsync,
),
)
//=> Hello World! What an interesting program!
console.log(
await pipe(
asAsync([`Hello`, `World!`, `What`, `an`, `interesting`, `program!`]),
reduceAsync({ create: () => ``, add: (a, b) => `${a} ${b}` }),
),
)
//=> Hello World! What an interesting program!
Defined in
reduceAsync(asyncReducer)
reduceAsync<
Value
>(asyncReducer
): (asyncIterable
) =>AsyncOptional
<Value
>
Returns the result of reducing the asyncIterable
using asyncReducer
.
Informally, an initial accumulator is created using
AsyncReducer.create. Then each value in asyncIterable
is added to
the accumulator and the current accumulator is updated using
AsyncReducer.add. Finally, the resulting accumulator is transformed
using AsyncReducer.finish if specified. Multiple accumulators may be
created, added to, and then combined if supported via
AsyncReducer.combine and the next value of asyncIterable
is ready
before promises from AsyncReducer.add resolve.
If asyncReducer
is an async optional reducer (no
AsyncReducer.create method), then an empty async iterable is returned
if asyncIterable
is empty. Otherwise, an async iterable containing the
result of reducing using the first value of the async iterable as the initial
accumulator is returned.
Like Array.prototype.reduce
, but for async iterables.
Type Parameters
• Value
Parameters
• asyncReducer: AsyncFunctionReducer
<Value
> | FunctionReducer
<Value
>
Returns
Function
Parameters
• asyncIterable: AsyncIterable
<Value
, any
, any
>
Returns
AsyncOptional
<Value
>
Example
console.log(
await pipe(
asAsync([`Hello`, `World!`, `What`, `an`, `interesting`, `program!`]),
reduceAsync((a, b) => `${a} ${b}`),
getAsync,
),
)
//=> Hello World! What an interesting program!
console.log(
await pipe(
asAsync([`Hello`, `World!`, `What`, `an`, `interesting`, `program!`]),
reduceAsync({ create: () => ``, add: (a, b) => `${a} ${b}` }),
),
)
//=> Hello World! What an interesting program!