import { Transformer } from "https://deno.land/x/rimbu@1.2.0/stream/main/transformer.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
Example 1
Stream.of(1, 2, 3, 4, 5, 6)
.transform(Transformer.window(3))
.toArray()
// => [[1, 2, 3], [4, 5, 6]]
type
{ <T, R>(windowSize: number, options: { skipAmount?: number | undefined; collector: Reducer<T, R>; }): Transformer<T, R>; <T>(windowSize: number, options?: { skipAmount?: number | undefined; collector?: undefined; }): Transformer<T, T[]>; }