effect 3.16.7 → 3.16.8

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.
@@ -1735,13 +1735,12 @@ exports.repeatValue = repeatValue;
1735
1735
  const repeatWith = exports.repeatWith = /*#__PURE__*/(0, _Function.dual)(3, (self, schedule, options) => {
1736
1736
  return (0, _Function.pipe)(Schedule.driver(schedule), Effect.map(driver => {
1737
1737
  const provideLastIterationInfo = provideServiceEffect(Schedule.CurrentIterationMetadata, Ref.get(driver.iterationMeta));
1738
- const scheduleOutput = (0, _Function.pipe)(driver.last, Effect.orDie, Effect.map(options.onSchedule));
1739
1738
  const process = (0, _Function.pipe)(self, provideLastIterationInfo, map(options.onElement), toChannel);
1740
1739
  const loop = channel.unwrap(Effect.match(driver.next(void 0), {
1741
1740
  onFailure: () => core.void,
1742
- onSuccess: () => (0, _Function.pipe)(process, channel.zipRight((0, _Function.pipe)(scheduleOutput, Effect.map(c => (0, _Function.pipe)(core.write(Chunk.of(c)), core.flatMap(() => loop))), channel.unwrap)))
1741
+ onSuccess: output => core.flatMap(process, () => channel.zipRight(core.write(Chunk.of(options.onSchedule(output))), loop))
1743
1742
  }));
1744
- return new StreamImpl((0, _Function.pipe)(process, channel.zipRight(loop)));
1743
+ return new StreamImpl(channel.zipRight(process, loop));
1745
1744
  }), unwrap);
1746
1745
  });
1747
1746
  const repeatWithSchedule = (value, schedule) => repeatEffectWithSchedule(Effect.succeed(value), schedule);
@@ -2280,19 +2279,26 @@ const toReadableStreamRuntime = exports.toReadableStreamRuntime = /*#__PURE__*/(
2280
2279
  const latch = Effect.unsafeMakeLatch(false);
2281
2280
  return new ReadableStream({
2282
2281
  start(controller) {
2283
- fiber = runFork(runForEachChunk(self, chunk => latch.whenOpen(Effect.sync(() => {
2284
- latch.unsafeClose();
2285
- for (const item of chunk) {
2286
- controller.enqueue(item);
2287
- }
2288
- currentResolve();
2289
- currentResolve = undefined;
2290
- }))));
2282
+ fiber = runFork(runForEachChunk(self, chunk => {
2283
+ if (chunk.length === 0) return Effect.void;
2284
+ return latch.whenOpen(Effect.sync(() => {
2285
+ latch.unsafeClose();
2286
+ for (const item of chunk) {
2287
+ controller.enqueue(item);
2288
+ }
2289
+ currentResolve();
2290
+ currentResolve = undefined;
2291
+ }));
2292
+ }));
2291
2293
  fiber.addObserver(exit => {
2292
- if (exit._tag === "Failure") {
2293
- controller.error(Cause.squash(exit.cause));
2294
- } else {
2295
- controller.close();
2294
+ try {
2295
+ if (exit._tag === "Failure") {
2296
+ controller.error(Cause.squash(exit.cause));
2297
+ } else {
2298
+ controller.close();
2299
+ }
2300
+ } catch {
2301
+ // ignore
2296
2302
  }
2297
2303
  });
2298
2304
  },