Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/rimbu/core/mod.ts>Reducer.toArray

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
function Reducer.toArray
import { Reducer } from "https://deno.land/x/rimbu@1.2.0/core/mod.ts";
const { toArray } = Reducer;

Returns a Reducer that collects received input values in an array, and returns a copy of that array as an output value when requested.

Examples

Example 1

console.log(Stream.of(1, 2, 3).reduce(Reducer.toArray()))
// => [1, 2, 3]
console.log(Stream.of(1, 2, 3).reduce(Reducer.toArray({ reversed: true })))
// => [3, 2, 1]

Parameters

optional
options: { reversed?: boolean; } = [UNSUPPORTED]
  • (optional) object specifying the following properties
  • reversed: (optional) when true will create a reversed array