Skip to main content
Module

x/rimbu/mod.ts>Transformer.window

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

Returns a transformer that produces windows/collections of windowSize size, each window starting skipAmount of elements after the previous, and optionally collected by a custom reducer.

Examples

Example 1

Stream.of(1, 2, 3, 4, 5, 6)
  .transform(Transformer.window(3))
  .toArray()
// => [[1, 2, 3], [4, 5, 6]]

type

{ <T>(windowSize: number, skipAmount?: number): Transformer<T, T[]>; <T, R>(
windowSize: number,
skipAmount?: number,
collector?: Reducer<T, R>,
): Transformer<T, R>; }