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

Function zipChunks

packages/effect/src/internal/stream.ts:8710–8725  ·  view source on GitHub ↗
(
  left: Chunk.Chunk<A>,
  right: Chunk.Chunk<B>,
  f: (a: A, b: B) => C
)

Source from the content-addressed store, hash-verified

8708
8709/** @internal */
8710const zipChunks = <A, B, C>(
8711 left: Chunk.Chunk<A>,
8712 right: Chunk.Chunk<B>,
8713 f: (a: A, b: B) => C
8714): [Chunk.Chunk<C>, Either.Either<Chunk.Chunk<B>, Chunk.Chunk<A>>] => {
8715 if (left.length > right.length) {
8716 return [
8717 pipe(left, Chunk.take(right.length), Chunk.zipWith(right, f)),
8718 Either.left(pipe(left, Chunk.drop(right.length)))
8719 ]
8720 }
8721 return [
8722 pipe(left, Chunk.zipWith(pipe(right, Chunk.take(left.length)), f)),
8723 Either.right(pipe(right, Chunk.drop(left.length)))
8724 ]
8725}
8726
8727// Do notation
8728

Callers 2

zipFunction · 0.85
stream.tsFile · 0.85

Calls 2

pipeFunction · 0.70
takeMethod · 0.65

Tested by

no test coverage detected