Package: effect
Module: Array
Creates overlapping sliding windows of size n.
When to use
Use to process sequences with a moving window, such as for computing running averages or detecting patterns.
Details
Returns an empty array if n <= 0 or the array has fewer than n elements.
Each window is a tuple of exactly n elements.
Example (Creating sliding windows)
import { Array } from "effect"
console.log(Array.window([1, 2, 3, 4, 5], 3)) // [[1, 2, 3], [2, 3, 4], [3, 4, 5]]
console.log(Array.window([1, 2, 3, 4, 5], 6)) // []
See
chunksOf — non-overlapping chunksSignature
declare const window: { <N extends number>(n: N): <A>(self: Iterable<A>) => Array<TupleOf<N, A>>; <A, N extends number>(self: Iterable<A>, n: N): Array<TupleOf<N, A>>; }
Since v3.13.2