MCPcopy Create free account
hub / github.com/Effect-TS/effect / zipWithPrevious

Function zipWithPrevious

packages/effect/src/Stream.ts:3678–3687  ·  view source on GitHub ↗
(self: Stream<A, E, R>)

Source from the content-addressed store, hash-verified

3676 * @since 2.0.0
3677 */
3678export const zipWithPrevious = <A, E, R>(self: Stream<A, E, R>): Stream<[Option.Option<A>, A], E, R> =>
3679 mapAccumArray(self, Option.none<A>, (acc, arr) => {
3680 const pairs = Arr.empty<[Option.Option<A>, A]>()
3681 for (let i = 0; i < arr.length; i++) {
3682 const value = arr[i]
3683 pairs.push([acc, value])
3684 acc = Option.some(arr[i])
3685 }
3686 return [acc, pairs]
3687 })
3688
3689/**
3690 * Zips each element with its previous and next values.

Callers

nothing calls this directly

Calls 2

pushMethod · 0.80
someMethod · 0.80

Tested by

no test coverage detected