Create a TransformStream that reduces all values to a single value
The reducer function to apply to each chunk
The initial value
A TransformStream that emits the final reduced value when the stream closes
// Sum all numbers in a streamconst stream = readable.pipeThrough(reduce((a, b) => a + b));const [sum] = await toArray(stream); // Gets the single reduced value Copy
// Sum all numbers in a streamconst stream = readable.pipeThrough(reduce((a, b) => a + b));const [sum] = await toArray(stream); // Gets the single reduced value
Create a TransformStream that reduces all values to a single value