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.
- package/dist/cjs/internal/stream.js +21 -15
- package/dist/cjs/internal/stream.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/dts/internal/stream.d.ts.map +1 -1
- package/dist/esm/internal/stream.js +21 -15
- package/dist/esm/internal/stream.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/package.json +1 -1
- package/src/internal/stream.ts +24 -22
- package/src/internal/version.ts +1 -1
|
@@ -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:
|
|
1741
|
+
onSuccess: output => core.flatMap(process, () => channel.zipRight(core.write(Chunk.of(options.onSchedule(output))), loop))
|
|
1743
1742
|
}));
|
|
1744
|
-
return new StreamImpl(
|
|
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 =>
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
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
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
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
|
},
|