Skip to content

Commit

Permalink
renamed to mergeWithTag
Browse files Browse the repository at this point in the history
  • Loading branch information
jessekelly881 committed Sep 30, 2024
1 parent ecad546 commit a04169d
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .changeset/silver-tools-collect.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
"effect": patch
---

added Stream.mergeStruct
added Stream.mergeWithTag

Combines a struct of streams into a single stream of tagged values where the tag is the key of the struct.

```ts
import { Stream } from "effect"

// Stream.Stream<{ _tag: "a"; value: number; } | { _tag: "b"; value: string; }>
const stream = Stream.mergeStruct(
const stream = Stream.mergeWithTag(
{
a: Stream.make(0),
b: Stream.make("")
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/dtslint/Stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ Stream.zipLatestAll(numbers, numbersOrStrings, Stream.fail(new Error("")))
// -------------------------------------------------------------------------------------

// $ExpectType Stream<{ _tag: "a"; value: number; } | { _tag: "b"; value: string; }, NoSuchElementException, never>
Stream.mergeStruct({
Stream.mergeWithTag({
a: Stream.make(0).pipe(Stream.tap(() => new Cause.NoSuchElementException())),
b: Stream.make("")
}, { concurrency: 1 })
6 changes: 3 additions & 3 deletions packages/effect/src/Stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2902,12 +2902,12 @@ export const mergeAll: {
*
* @example
* // Stream.Stream<{ _tag: "a"; value: number; } | { _tag: "b"; value: string; }>
* const res = mergeStruct({
* const res = mergeWithTag({
* a: Stream.make(0),
* b: Stream.make("")
* })
*/
export const mergeStruct: {
export const mergeWithTag: {
<S extends { [k in string]: Stream<any, any, any> }>(
streams: S,
options: {
Expand All @@ -2927,7 +2927,7 @@ export const mergeStruct: {
Stream.Error<S[keyof S]>,
Stream.Context<S[keyof S]>
>
} = internal.mergeStruct
} = internal.mergeWithTag

/**
* Merges this stream and the specified stream together to a common element
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/internal/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4108,7 +4108,7 @@ export const mergeAll = dual<
>((args) => Symbol.iterator in args[0], (streams, options) => flatten(fromIterable(streams), options))
/** @internal */
export const mergeStruct: {
export const mergeWithTag: {
<S extends { [k in string]: Stream.Stream<any, any, any> }>(
streams: S,
options: {
Expand Down
4 changes: 2 additions & 2 deletions packages/effect/test/Stream/merging.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ describe("Stream", () => {
assert.deepStrictEqual(Array.from(result), [1])
}))

it.effect("mergeStruct", (ctx) =>
it.effect("mergeWithTag", (ctx) =>
Effect.gen(function*() {
const stream = Stream.mergeStruct({
const stream = Stream.mergeWithTag({
a: Stream.make(0),
b: Stream.make("")
}, { concurrency: 1 })
Expand Down

0 comments on commit a04169d

Please sign in to comment.