MCPcopy Index your code
hub / github.com/Effect-TS/effect / zipParLaw

Function zipParLaw

packages/effect/test/Sink/zipping.test.ts:26–43  ·  view source on GitHub ↗
(
  stream: Stream.Stream<A>,
  sink1: Sink.Sink<B, A, A, E>,
  sink2: Sink.Sink<C, A, A, E>
)

Source from the content-addressed store, hash-verified

24 )
25
26const zipParLaw = <A, B, C, E>(
27 stream: Stream.Stream<A>,
28 sink1: Sink.Sink<B, A, A, E>,
29 sink2: Sink.Sink<C, A, A, E>
30): Effect.Effect<boolean> =>
31 pipe(
32 Effect.all({
33 zb: pipe(stream, Stream.run(sink1), Effect.either),
34 zc: pipe(stream, Stream.run(sink2), Effect.either),
35 zbc: pipe(stream, Stream.run(pipe(sink1, Sink.zip(sink2, { concurrent: true }))), Effect.either)
36 }),
37 Effect.map(({ zb, zbc, zc }) =>
38 Either.match(zbc, {
39 onLeft: (e) => (Either.isLeft(zb) && zb.left === e) || (Either.isLeft(zc) && zc.left === e),
40 onRight: ([b, c]) => Either.isRight(zb) && zb.right === b && Either.isRight(zc) && zc.right === c
41 })
42 )
43 )
44
45describe("Sink", () => {
46 it.effect("zipParLeft", () =>

Callers 1

zipping.test.tsFile · 0.85

Calls 4

zipMethod · 0.65
mapMethod · 0.65
pipeFunction · 0.50
runMethod · 0.45

Tested by

no test coverage detected