Skip to content

Commit 398ac3e

Browse files
authored
EFF-704 Use arguments predicate for Stream.merge (#1739)
1 parent f90b9e7 commit 398ac3e

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"effect": patch
3+
---
4+
5+
Use predicate-based `dual` dispatch for `Stream.merge` so data-last calls with optional `options` are handled correctly.

packages/effect/src/Stream.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2863,7 +2863,7 @@ export const merge: {
28632863
} | undefined
28642864
): Stream<A | A2, E | E2, R | R2>
28652865
} = dual(
2866-
2,
2866+
(args) => isStream(args[0]) && isStream(args[1]),
28672867
<A, E, R, A2, E2, R2>(
28682868
self: Stream<A, E, R>,
28692869
that: Stream<A2, E2, R2>,

packages/effect/test/Stream.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3345,6 +3345,26 @@ describe("Stream", () => {
33453345
}))
33463346
})
33473347

3348+
describe("merge", () => {
3349+
it.effect("data-first with options", () =>
3350+
Effect.gen(function*() {
3351+
const result = yield* Stream.runCollect(
3352+
Stream.merge(Stream.make(1), Stream.never, { haltStrategy: "left" })
3353+
)
3354+
deepStrictEqual(result, [1])
3355+
}))
3356+
3357+
it.effect("data-last with options", () =>
3358+
Effect.gen(function*() {
3359+
const result = yield* pipe(
3360+
Stream.make(1),
3361+
Stream.merge(Stream.never, { haltStrategy: "left" }),
3362+
Stream.runCollect
3363+
)
3364+
deepStrictEqual(result, [1])
3365+
}))
3366+
})
3367+
33483368
describe("partition", () => {
33493369
it.effect("values", () =>
33503370
Effect.gen(function*() {

0 commit comments

Comments
 (0)