effect 3.16.7 → 3.16.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- let moduleVersion = "3.16.7";
1
+ let moduleVersion = "3.16.9";
2
2
  export const getCurrentVersion = () => moduleVersion;
3
3
  export const setCurrentVersion = version => {
4
4
  moduleVersion = version;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "effect",
3
- "version": "3.16.7",
3
+ "version": "3.16.9",
4
4
  "description": "The missing standard library for TypeScript, for writing production-grade software.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/src/Effect.ts CHANGED
@@ -16823,7 +16823,7 @@ export const filterOrFail: {
16823
16823
  <A, E2, B extends A>(
16824
16824
  refinement: Refinement<NoInfer<A>, B>,
16825
16825
  orFailWith: (a: EqualsWith<A, B, NoInfer<A>, Exclude<NoInfer<A>, B>>) => E2
16826
- ): <E, R>(self: Effect<A, E, R>) => Effect<B, E2 | E, R>
16826
+ ): <E, R>(self: Effect<A, E, R>) => Effect<NoInfer<B>, E2 | E, R>
16827
16827
  /**
16828
16828
  * Filters an effect, failing with a custom error if the predicate fails.
16829
16829
  *
@@ -16929,7 +16929,7 @@ export const filterOrFail: {
16929
16929
  self: Effect<A, E, R>,
16930
16930
  refinement: Refinement<A, B>,
16931
16931
  orFailWith: (a: EqualsWith<A, B, A, Exclude<A, B>>) => E2
16932
- ): Effect<B, E2 | E, R>
16932
+ ): Effect<NoInfer<B>, E2 | E, R>
16933
16933
  /**
16934
16934
  * Filters an effect, failing with a custom error if the predicate fails.
16935
16935
  *
@@ -17031,7 +17031,7 @@ export const filterOrFail: {
17031
17031
  * @since 2.0.0
17032
17032
  * @category Filtering
17033
17033
  */
17034
- <A, B extends A>(refinement: Refinement<NoInfer<A>, B>): <E, R>(self: Effect<A, E, R>) => Effect<B, Cause.NoSuchElementException | E, R>
17034
+ <A, B extends A>(refinement: Refinement<NoInfer<A>, B>): <E, R>(self: Effect<A, E, R>) => Effect<NoInfer<B>, Cause.NoSuchElementException | E, R>
17035
17035
  /**
17036
17036
  * Filters an effect, failing with a custom error if the predicate fails.
17037
17037
  *
@@ -17082,11 +17082,7 @@ export const filterOrFail: {
17082
17082
  * @since 2.0.0
17083
17083
  * @category Filtering
17084
17084
  */
17085
- <A>(predicate: Predicate<NoInfer<A>>): <E, R>(self: Effect<A, E, R>) => Effect<
17086
- A,
17087
- Cause.NoSuchElementException | E,
17088
- R
17089
- >
17085
+ <A>(predicate: Predicate<NoInfer<A>>): <E, R>(self: Effect<A, E, R>) => Effect<A, Cause.NoSuchElementException | E, R>
17090
17086
  /**
17091
17087
  * Filters an effect, failing with a custom error if the predicate fails.
17092
17088
  *
@@ -17137,7 +17133,7 @@ export const filterOrFail: {
17137
17133
  * @since 2.0.0
17138
17134
  * @category Filtering
17139
17135
  */
17140
- <A, E, R, B extends A>(self: Effect<A, E, R>, refinement: Refinement<A, B>): Effect<B, E | Cause.NoSuchElementException, R>
17136
+ <A, E, R, B extends A>(self: Effect<A, E, R>, refinement: Refinement<A, B>): Effect<NoInfer<B>, E | Cause.NoSuchElementException, R>
17141
17137
  /**
17142
17138
  * Filters an effect, failing with a custom error if the predicate fails.
17143
17139
  *
package/src/Stream.ts CHANGED
@@ -6629,6 +6629,32 @@ export const provideContext: {
6629
6629
  <A, E, R>(self: Stream<A, E, R>, context: Context.Context<R>): Stream<A, E>
6630
6630
  } = internal.provideContext
6631
6631
 
6632
+ /**
6633
+ * Provides the stream with some of its required context, which eliminates its
6634
+ * dependency on `R`.
6635
+ *
6636
+ * @since 3.16.9
6637
+ * @category context
6638
+ */
6639
+ export const provideSomeContext: {
6640
+ /**
6641
+ * Provides the stream with some of its required context, which eliminates its
6642
+ * dependency on `R`.
6643
+ *
6644
+ * @since 3.16.9
6645
+ * @category context
6646
+ */
6647
+ <R2>(context: Context.Context<R2>): <A, E, R>(self: Stream<A, E, R>) => Stream<A, E, Exclude<R, R2>>
6648
+ /**
6649
+ * Provides the stream with some of its required context, which eliminates its
6650
+ * dependency on `R`.
6651
+ *
6652
+ * @since 3.16.9
6653
+ * @category context
6654
+ */
6655
+ <A, E, R, R2>(self: Stream<A, E, R>, context: Context.Context<R2>): Stream<A, E, Exclude<R, R2>>
6656
+ } = internal.provideSomeContext
6657
+
6632
6658
  /**
6633
6659
  * Provides a `Layer` to the stream, which translates it to another level.
6634
6660
  *
@@ -639,7 +639,7 @@ export const filterOrFail: {
639
639
  <A, E2, B extends A>(
640
640
  refinement: Predicate.Refinement<Types.NoInfer<A>, B>,
641
641
  orFailWith: (a: Types.EqualsWith<A, B, Types.NoInfer<A>, Exclude<Types.NoInfer<A>, B>>) => E2
642
- ): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<B, E2 | E, R>
642
+ ): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<Types.NoInfer<B>, E2 | E, R>
643
643
  <A, E2>(
644
644
  predicate: Predicate.Predicate<Types.NoInfer<A>>,
645
645
  orFailWith: (a: Types.NoInfer<A>) => E2
@@ -648,7 +648,7 @@ export const filterOrFail: {
648
648
  self: Effect.Effect<A, E, R>,
649
649
  refinement: Predicate.Refinement<A, B>,
650
650
  orFailWith: (a: Types.EqualsWith<A, B, A, Exclude<A, B>>) => E2
651
- ): Effect.Effect<B, E2 | E, R>
651
+ ): Effect.Effect<Types.NoInfer<B>, E2 | E, R>
652
652
  <A, E, R, E2>(
653
653
  self: Effect.Effect<A, E, R>,
654
654
  predicate: Predicate.Predicate<A>,
@@ -656,14 +656,14 @@ export const filterOrFail: {
656
656
  ): Effect.Effect<A, E2 | E, R>
657
657
  <A, B extends A>(
658
658
  refinement: Predicate.Refinement<Types.NoInfer<A>, B>
659
- ): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<B, Cause.NoSuchElementException | E, R>
659
+ ): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<Types.NoInfer<B>, Cause.NoSuchElementException | E, R>
660
660
  <A>(
661
661
  predicate: Predicate.Predicate<Types.NoInfer<A>>
662
662
  ): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, Cause.NoSuchElementException | E, R>
663
663
  <A, E, R, B extends A>(
664
664
  self: Effect.Effect<A, E, R>,
665
665
  refinement: Predicate.Refinement<A, B>
666
- ): Effect.Effect<B, E | Cause.NoSuchElementException, R>
666
+ ): Effect.Effect<Types.NoInfer<B>, E | Cause.NoSuchElementException, R>
667
667
  <A, E, R>(
668
668
  self: Effect.Effect<A, E, R>,
669
669
  predicate: Predicate.Predicate<A>
@@ -5401,25 +5401,21 @@ export const repeatWith = dual<
5401
5401
  Ref.get(driver.iterationMeta)
5402
5402
  )
5403
5403
 
5404
- const scheduleOutput = pipe(driver.last, Effect.orDie, Effect.map(options.onSchedule))
5405
5404
  const process = pipe(self, provideLastIterationInfo, map(options.onElement), toChannel)
5406
5405
  const loop: Channel.Channel<Chunk.Chunk<C>, unknown, E, unknown, void, unknown, R | R2> = channel.unwrap(
5407
- Effect.match(driver.next(void 0), {
5408
- onFailure: () => core.void,
5409
- onSuccess: () =>
5410
- pipe(
5411
- process,
5412
- channel.zipRight(
5413
- pipe(
5414
- scheduleOutput,
5415
- Effect.map((c) => pipe(core.write(Chunk.of(c)), core.flatMap(() => loop))),
5416
- channel.unwrap
5417
- )
5406
+ Effect.match(
5407
+ driver.next(void 0),
5408
+ {
5409
+ onFailure: () => core.void,
5410
+ onSuccess: (output) =>
5411
+ core.flatMap(
5412
+ process,
5413
+ () => channel.zipRight(core.write(Chunk.of(options.onSchedule(output))), loop)
5418
5414
  )
5419
- )
5420
- })
5415
+ }
5416
+ )
5421
5417
  )
5422
- return new StreamImpl(pipe(process, channel.zipRight(loop)))
5418
+ return new StreamImpl(channel.zipRight(process, loop))
5423
5419
  }),
5424
5420
  unwrap
5425
5421
  )
@@ -7218,20 +7214,26 @@ export const toReadableStreamRuntime = dual<
7218
7214
 
7219
7215
  return new ReadableStream<A>({
7220
7216
  start(controller) {
7221
- fiber = runFork(runForEachChunk(self, (chunk) =>
7222
- latch.whenOpen(Effect.sync(() => {
7217
+ fiber = runFork(runForEachChunk(self, (chunk) => {
7218
+ if (chunk.length === 0) return Effect.void
7219
+ return latch.whenOpen(Effect.sync(() => {
7223
7220
  latch.unsafeClose()
7224
7221
  for (const item of chunk) {
7225
7222
  controller.enqueue(item)
7226
7223
  }
7227
7224
  currentResolve!()
7228
7225
  currentResolve = undefined
7229
- }))))
7226
+ }))
7227
+ }))
7230
7228
  fiber.addObserver((exit) => {
7231
- if (exit._tag === "Failure") {
7232
- controller.error(Cause.squash(exit.cause))
7233
- } else {
7234
- controller.close()
7229
+ try {
7230
+ if (exit._tag === "Failure") {
7231
+ controller.error(Cause.squash(exit.cause))
7232
+ } else {
7233
+ controller.close()
7234
+ }
7235
+ } catch {
7236
+ // ignore
7235
7237
  }
7236
7238
  })
7237
7239
  },
@@ -1,4 +1,4 @@
1
- let moduleVersion = "3.16.7"
1
+ let moduleVersion = "3.16.9"
2
2
 
3
3
  export const getCurrentVersion = () => moduleVersion
4
4