Skip to main content

Function: reduceConcur()

Returns the result of reducing the concurIterable using asyncReducer.

Informally, an initial accumulator is created using AsyncReducer.create. Then each value in concurIterable 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 concurIterable is ready before promises from AsyncReducer.add resolve.

If asyncReducer is an async optional reducer (no AsyncReducer.create method), then an empty concur iterable is returned if concurIterable is empty. Otherwise, an concur iterable containing the result of reducing using the first value of the concur iterable as the initial accumulator is returned.

Like Array.prototype.reduce, but for concur 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!

reduceConcur(asyncReducer, concurIterable)

reduceConcur<Value, Acc, Finished, This>(asyncReducer, concurIterable): Promise<Finished>

Returns the result of reducing the concurIterable using asyncReducer.

Informally, an initial accumulator is created using AsyncReducer.create. Then each value in concurIterable 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 concurIterable is ready before promises from AsyncReducer.add resolve.

If asyncReducer is an async optional reducer (no AsyncReducer.create method), then an empty concur iterable is returned if concurIterable is empty. Otherwise, an concur iterable containing the result of reducing using the first value of the concur iterable as the initial accumulator is returned.

Like Array.prototype.reduce, but for concur iterables.

Type Parameters

Value

Acc

Finished

This

Parameters

asyncReducer: RawAsyncReducerWithFinish<Value, Acc, Finished, This> | RawReducerWithFinish<Value, Acc, Finished, This>

concurIterable: ConcurIterable<Value>

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

reducers.d.ts:667

reduceConcur(asyncReducer)

reduceConcur<Value, Acc, Finished, This>(asyncReducer): (concurIterable) => Promise<Finished>

Returns the result of reducing the concurIterable using asyncReducer.

Informally, an initial accumulator is created using AsyncReducer.create. Then each value in concurIterable 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 concurIterable is ready before promises from AsyncReducer.add resolve.

If asyncReducer is an async optional reducer (no AsyncReducer.create method), then an empty concur iterable is returned if concurIterable is empty. Otherwise, an concur iterable containing the result of reducing using the first value of the concur iterable as the initial accumulator is returned.

Like Array.prototype.reduce, but for concur iterables.

Type Parameters

Value

Acc

Finished

This

Parameters

asyncReducer: RawAsyncReducerWithFinish<Value, Acc, Finished, This> | RawReducerWithFinish<Value, Acc, Finished, This>

Returns

Function

Parameters

concurIterable: ConcurIterable<Value>

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

reducers.d.ts:673

reduceConcur(asyncReducer, concurIterable)

reduceConcur<Value, Acc, This>(asyncReducer, concurIterable): Promise<Acc>

Returns the result of reducing the concurIterable using asyncReducer.

Informally, an initial accumulator is created using AsyncReducer.create. Then each value in concurIterable 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 concurIterable is ready before promises from AsyncReducer.add resolve.

If asyncReducer is an async optional reducer (no AsyncReducer.create method), then an empty concur iterable is returned if concurIterable is empty. Otherwise, an concur iterable containing the result of reducing using the first value of the concur iterable as the initial accumulator is returned.

Like Array.prototype.reduce, but for concur iterables.

Type Parameters

Value

Acc

This

Parameters

asyncReducer: RawAsyncReducerWithoutFinish<Value, Acc, This> | RawReducerWithoutFinish<Value, Acc, This>

concurIterable: ConcurIterable<Value>

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

reducers.d.ts:679

reduceConcur(asyncReducer)

reduceConcur<Value, Acc, This>(asyncReducer): (concurIterable) => Promise<Acc>

Returns the result of reducing the concurIterable using asyncReducer.

Informally, an initial accumulator is created using AsyncReducer.create. Then each value in concurIterable 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 concurIterable is ready before promises from AsyncReducer.add resolve.

If asyncReducer is an async optional reducer (no AsyncReducer.create method), then an empty concur iterable is returned if concurIterable is empty. Otherwise, an concur iterable containing the result of reducing using the first value of the concur iterable as the initial accumulator is returned.

Like Array.prototype.reduce, but for concur iterables.

Type Parameters

Value

Acc

This

Parameters

asyncReducer: RawAsyncReducerWithoutFinish<Value, Acc, This> | RawReducerWithoutFinish<Value, Acc, This>

Returns

Function

Parameters

concurIterable: ConcurIterable<Value>

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

reducers.d.ts:685

reduceConcur(asyncReducer, concurIterable)

reduceConcur<Value, Finished, This>(asyncReducer, concurIterable): ConcurOptional<Finished>

Returns the result of reducing the concurIterable using asyncReducer.

Informally, an initial accumulator is created using AsyncReducer.create. Then each value in concurIterable 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 concurIterable is ready before promises from AsyncReducer.add resolve.

If asyncReducer is an async optional reducer (no AsyncReducer.create method), then an empty concur iterable is returned if concurIterable is empty. Otherwise, an concur iterable containing the result of reducing using the first value of the concur iterable as the initial accumulator is returned.

Like Array.prototype.reduce, but for concur iterables.

Type Parameters

Value

Finished

This

Parameters

asyncReducer: RawAsyncOptionalReducerWithFinish<Value, Finished, This> | RawOptionalReducerWithFinish<Value, Finished, This>

concurIterable: ConcurIterable<Value>

Returns

ConcurOptional<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

reducers.d.ts:691

reduceConcur(asyncReducer)

reduceConcur<Value, Finished, This>(asyncReducer): (concurIterable) => ConcurOptional<Finished>

Returns the result of reducing the concurIterable using asyncReducer.

Informally, an initial accumulator is created using AsyncReducer.create. Then each value in concurIterable 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 concurIterable is ready before promises from AsyncReducer.add resolve.

If asyncReducer is an async optional reducer (no AsyncReducer.create method), then an empty concur iterable is returned if concurIterable is empty. Otherwise, an concur iterable containing the result of reducing using the first value of the concur iterable as the initial accumulator is returned.

Like Array.prototype.reduce, but for concur iterables.

Type Parameters

Value

Finished

This

Parameters

asyncReducer: RawAsyncOptionalReducerWithFinish<Value, Finished, This> | RawOptionalReducerWithFinish<Value, Finished, This>

Returns

Function

Parameters

concurIterable: ConcurIterable<Value>

Returns

ConcurOptional<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

reducers.d.ts:697

reduceConcur(asyncReducer, concurIterable)

reduceConcur<Value, This>(asyncReducer, concurIterable): ConcurOptional<Value>

Returns the result of reducing the concurIterable using asyncReducer.

Informally, an initial accumulator is created using AsyncReducer.create. Then each value in concurIterable 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 concurIterable is ready before promises from AsyncReducer.add resolve.

If asyncReducer is an async optional reducer (no AsyncReducer.create method), then an empty concur iterable is returned if concurIterable is empty. Otherwise, an concur iterable containing the result of reducing using the first value of the concur iterable as the initial accumulator is returned.

Like Array.prototype.reduce, but for concur iterables.

Type Parameters

Value

This

Parameters

asyncReducer: RawAsyncOptionalReducerWithoutFinish<Value, This> | RawOptionalReducerWithoutFinish<Value, This>

concurIterable: ConcurIterable<Value>

Returns

ConcurOptional<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

reducers.d.ts:703

reduceConcur(asyncReducer)

reduceConcur<Value, This>(asyncReducer): (concurIterable) => ConcurOptional<Value>

Returns the result of reducing the concurIterable using asyncReducer.

Informally, an initial accumulator is created using AsyncReducer.create. Then each value in concurIterable 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 concurIterable is ready before promises from AsyncReducer.add resolve.

If asyncReducer is an async optional reducer (no AsyncReducer.create method), then an empty concur iterable is returned if concurIterable is empty. Otherwise, an concur iterable containing the result of reducing using the first value of the concur iterable as the initial accumulator is returned.

Like Array.prototype.reduce, but for concur iterables.

Type Parameters

Value

This

Parameters

asyncReducer: RawAsyncOptionalReducerWithoutFinish<Value, This> | RawOptionalReducerWithoutFinish<Value, This>

Returns

Function

Parameters

concurIterable: ConcurIterable<Value>

Returns

ConcurOptional<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

reducers.d.ts:709

reduceConcur(asyncReducer, concurIterable)

reduceConcur<Value>(asyncReducer, concurIterable): ConcurOptional<Value>

Returns the result of reducing the concurIterable using asyncReducer.

Informally, an initial accumulator is created using AsyncReducer.create. Then each value in concurIterable 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 concurIterable is ready before promises from AsyncReducer.add resolve.

If asyncReducer is an async optional reducer (no AsyncReducer.create method), then an empty concur iterable is returned if concurIterable is empty. Otherwise, an concur iterable containing the result of reducing using the first value of the concur iterable as the initial accumulator is returned.

Like Array.prototype.reduce, but for concur iterables.

Type Parameters

Value

Parameters

asyncReducer: FunctionReducer<Value> | AsyncFunctionReducer<Value>

concurIterable: ConcurIterable<Value>

Returns

ConcurOptional<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

reducers.d.ts:715

reduceConcur(asyncReducer)

reduceConcur<Value>(asyncReducer): (concurIterable) => ConcurOptional<Value>

Returns the result of reducing the concurIterable using asyncReducer.

Informally, an initial accumulator is created using AsyncReducer.create. Then each value in concurIterable 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 concurIterable is ready before promises from AsyncReducer.add resolve.

If asyncReducer is an async optional reducer (no AsyncReducer.create method), then an empty concur iterable is returned if concurIterable is empty. Otherwise, an concur iterable containing the result of reducing using the first value of the concur iterable as the initial accumulator is returned.

Like Array.prototype.reduce, but for concur iterables.

Type Parameters

Value

Parameters

asyncReducer: AsyncFunctionReducer<Value> | FunctionReducer<Value>

Returns

Function

Parameters

concurIterable: ConcurIterable<Value>

Returns

ConcurOptional<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

reducers.d.ts:719