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

Function zipArrays

packages/effect/src/Stream.ts:3295–3310  ·  view source on GitHub ↗
(
  f: (left: AL, right: AR) => A
)

Source from the content-addressed store, hash-verified

3293): Stream<A, EL | ER, RL | RR> => zipWithArray(left, right, zipArrays(f)))
3294
3295const zipArrays = <AL, AR, A>(
3296 f: (left: AL, right: AR) => A
3297) =>
3298(
3299 leftArr: Arr.NonEmptyReadonlyArray<AL>,
3300 rightArr: Arr.NonEmptyReadonlyArray<AR>
3301) => {
3302 const minLength = Math.min(leftArr.length, rightArr.length)
3303 const result: Arr.NonEmptyArray<A> = [] as any
3304
3305 for (let i = 0; i < minLength; i++) {
3306 result.push(f(leftArr[i], rightArr[i]))
3307 }
3308
3309 return [result, leftArr.slice(minLength), rightArr.slice(minLength)] as const
3310}
3311
3312/**
3313 * Zips two streams by applying a function to non-empty arrays of elements.

Callers 1

Stream.tsFile · 0.85

Calls 2

pushMethod · 0.80
fFunction · 0.50

Tested by

no test coverage detected