effect 3.10.19 → 3.11.0
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/BigDecimal.js +125 -24
- package/dist/cjs/BigDecimal.js.map +1 -1
- package/dist/cjs/Channel.js +44 -4
- package/dist/cjs/Channel.js.map +1 -1
- package/dist/cjs/Config.js +8 -1
- package/dist/cjs/Config.js.map +1 -1
- package/dist/cjs/Context.js +26 -1
- package/dist/cjs/Context.js.map +1 -1
- package/dist/cjs/Cron.js +75 -67
- package/dist/cjs/Cron.js.map +1 -1
- package/dist/cjs/DateTime.js +114 -664
- package/dist/cjs/DateTime.js.map +1 -1
- package/dist/cjs/Effect.js +82 -4
- package/dist/cjs/Effect.js.map +1 -1
- package/dist/cjs/Inspectable.js +8 -4
- package/dist/cjs/Inspectable.js.map +1 -1
- package/dist/cjs/JSONSchema.js.map +1 -1
- package/dist/cjs/Micro.js +1099 -1072
- package/dist/cjs/Micro.js.map +1 -1
- package/dist/cjs/STM.js.map +1 -1
- package/dist/cjs/Schema.js +57 -8
- package/dist/cjs/Schema.js.map +1 -1
- package/dist/cjs/Sink.js +9 -1
- package/dist/cjs/Sink.js.map +1 -1
- package/dist/cjs/Stream.js +25 -7
- package/dist/cjs/Stream.js.map +1 -1
- package/dist/cjs/Utils.js +7 -1
- package/dist/cjs/Utils.js.map +1 -1
- package/dist/cjs/internal/channel/channelExecutor.js +5 -9
- package/dist/cjs/internal/channel/channelExecutor.js.map +1 -1
- package/dist/cjs/internal/channel.js +156 -130
- package/dist/cjs/internal/channel.js.map +1 -1
- package/dist/cjs/internal/config.js +13 -4
- package/dist/cjs/internal/config.js.map +1 -1
- package/dist/cjs/internal/context.js +46 -3
- package/dist/cjs/internal/context.js.map +1 -1
- package/dist/cjs/internal/dateTime.js +747 -0
- package/dist/cjs/internal/dateTime.js.map +1 -0
- package/dist/cjs/internal/fiberRuntime.js +34 -11
- package/dist/cjs/internal/fiberRuntime.js.map +1 -1
- package/dist/cjs/internal/groupBy.js +9 -3
- package/dist/cjs/internal/groupBy.js.map +1 -1
- package/dist/cjs/internal/layer.js +1 -1
- package/dist/cjs/internal/layer.js.map +1 -1
- package/dist/cjs/internal/mailbox.js +1 -1
- package/dist/cjs/internal/mailbox.js.map +1 -1
- package/dist/cjs/internal/sink.js +25 -21
- package/dist/cjs/internal/sink.js.map +1 -1
- package/dist/cjs/internal/stream.js +70 -71
- package/dist/cjs/internal/stream.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/cjs/internal/version.js.map +1 -1
- package/dist/dts/BigDecimal.d.ts +56 -1
- package/dist/dts/BigDecimal.d.ts.map +1 -1
- package/dist/dts/Channel.d.ts +66 -5
- package/dist/dts/Channel.d.ts.map +1 -1
- package/dist/dts/Config.d.ts +23 -1
- package/dist/dts/Config.d.ts.map +1 -1
- package/dist/dts/Context.d.ts +111 -0
- package/dist/dts/Context.d.ts.map +1 -1
- package/dist/dts/Cron.d.ts +15 -6
- package/dist/dts/Cron.d.ts.map +1 -1
- package/dist/dts/DateTime.d.ts +40 -49
- package/dist/dts/DateTime.d.ts.map +1 -1
- package/dist/dts/Effect.d.ts +88 -1
- package/dist/dts/Effect.d.ts.map +1 -1
- package/dist/dts/Inspectable.d.ts.map +1 -1
- package/dist/dts/JSONSchema.d.ts +1 -0
- package/dist/dts/JSONSchema.d.ts.map +1 -1
- package/dist/dts/Micro.d.ts +875 -872
- package/dist/dts/Micro.d.ts.map +1 -1
- package/dist/dts/STM.d.ts +2 -0
- package/dist/dts/STM.d.ts.map +1 -1
- package/dist/dts/Schema.d.ts +32 -0
- package/dist/dts/Schema.d.ts.map +1 -1
- package/dist/dts/Sink.d.ts +8 -0
- package/dist/dts/Sink.d.ts.map +1 -1
- package/dist/dts/Stream.d.ts +50 -32
- package/dist/dts/Stream.d.ts.map +1 -1
- package/dist/dts/Utils.d.ts +4 -0
- package/dist/dts/Utils.d.ts.map +1 -1
- package/dist/dts/internal/context.d.ts +1 -1
- package/dist/dts/internal/context.d.ts.map +1 -1
- package/dist/dts/internal/dateTime.d.ts +2 -0
- package/dist/dts/internal/dateTime.d.ts.map +1 -0
- package/dist/dts/internal/fiberRuntime.d.ts.map +1 -1
- package/dist/dts/internal/stream.d.ts.map +1 -1
- package/dist/esm/BigDecimal.js +119 -20
- package/dist/esm/BigDecimal.js.map +1 -1
- package/dist/esm/Channel.js +42 -2
- package/dist/esm/Channel.js.map +1 -1
- package/dist/esm/Config.js +7 -0
- package/dist/esm/Config.js.map +1 -1
- package/dist/esm/Context.js +25 -0
- package/dist/esm/Context.js.map +1 -1
- package/dist/esm/Cron.js +75 -67
- package/dist/esm/Cron.js.map +1 -1
- package/dist/esm/DateTime.js +112 -627
- package/dist/esm/DateTime.js.map +1 -1
- package/dist/esm/Effect.js +77 -0
- package/dist/esm/Effect.js.map +1 -1
- package/dist/esm/Inspectable.js +8 -4
- package/dist/esm/Inspectable.js.map +1 -1
- package/dist/esm/JSONSchema.js.map +1 -1
- package/dist/esm/Micro.js +1077 -1047
- package/dist/esm/Micro.js.map +1 -1
- package/dist/esm/STM.js.map +1 -1
- package/dist/esm/Schema.js +54 -0
- package/dist/esm/Schema.js.map +1 -1
- package/dist/esm/Sink.js +8 -0
- package/dist/esm/Sink.js.map +1 -1
- package/dist/esm/Stream.js +23 -5
- package/dist/esm/Stream.js.map +1 -1
- package/dist/esm/Utils.js +5 -0
- package/dist/esm/Utils.js.map +1 -1
- package/dist/esm/internal/channel/channelExecutor.js +5 -7
- package/dist/esm/internal/channel/channelExecutor.js.map +1 -1
- package/dist/esm/internal/channel.js +152 -129
- package/dist/esm/internal/channel.js.map +1 -1
- package/dist/esm/internal/config.js +11 -3
- package/dist/esm/internal/config.js.map +1 -1
- package/dist/esm/internal/context.js +42 -2
- package/dist/esm/internal/context.js.map +1 -1
- package/dist/esm/internal/dateTime.js +704 -0
- package/dist/esm/internal/dateTime.js.map +1 -0
- package/dist/esm/internal/fiberRuntime.js +31 -9
- package/dist/esm/internal/fiberRuntime.js.map +1 -1
- package/dist/esm/internal/groupBy.js +9 -3
- package/dist/esm/internal/groupBy.js.map +1 -1
- package/dist/esm/internal/layer.js +1 -1
- package/dist/esm/internal/layer.js.map +1 -1
- package/dist/esm/internal/mailbox.js +1 -1
- package/dist/esm/internal/mailbox.js.map +1 -1
- package/dist/esm/internal/sink.js +23 -20
- package/dist/esm/internal/sink.js.map +1 -1
- package/dist/esm/internal/stream.js +66 -69
- package/dist/esm/internal/stream.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/dist/esm/internal/version.js.map +1 -1
- package/package.json +1 -1
- package/src/BigDecimal.ts +131 -21
- package/src/Channel.ts +81 -5
- package/src/Config.ts +24 -1
- package/src/Context.ts +119 -0
- package/src/Cron.ts +85 -68
- package/src/DateTime.ts +155 -757
- package/src/Effect.ts +340 -1
- package/src/Inspectable.ts +11 -7
- package/src/JSONSchema.ts +1 -0
- package/src/Micro.ts +2005 -1757
- package/src/STM.ts +2 -0
- package/src/Schema.ts +60 -0
- package/src/Sink.ts +11 -0
- package/src/Stream.ts +55 -44
- package/src/Utils.ts +8 -0
- package/src/internal/channel/channelExecutor.ts +37 -33
- package/src/internal/channel.ts +504 -467
- package/src/internal/config.ts +18 -6
- package/src/internal/context.ts +56 -4
- package/src/internal/dateTime.ts +1126 -0
- package/src/internal/fiberRuntime.ts +35 -16
- package/src/internal/groupBy.ts +13 -22
- package/src/internal/layer.ts +5 -8
- package/src/internal/mailbox.ts +6 -4
- package/src/internal/sink.ts +55 -35
- package/src/internal/stream.ts +299 -299
- package/src/internal/version.ts +1 -1
|
@@ -30,7 +30,6 @@ import * as Tuple from "../Tuple.js";
|
|
|
30
30
|
import * as channel from "./channel.js";
|
|
31
31
|
import * as channelExecutor from "./channel/channelExecutor.js";
|
|
32
32
|
import * as MergeStrategy from "./channel/mergeStrategy.js";
|
|
33
|
-
import * as singleProducerAsyncInput from "./channel/singleProducerAsyncInput.js";
|
|
34
33
|
import * as core from "./core-stream.js";
|
|
35
34
|
import * as doNotation from "./doNotation.js";
|
|
36
35
|
import { RingBuffer } from "./ringBuffer.js";
|
|
@@ -97,7 +96,7 @@ export const aggregateWithin = /*#__PURE__*/dual(3, (self, sink, schedule) => fi
|
|
|
97
96
|
/** @internal */
|
|
98
97
|
export const aggregateWithinEither = /*#__PURE__*/dual(3, (self, sink, schedule) => {
|
|
99
98
|
const layer = Effect.all([Handoff.make(), Ref.make(SinkEndReason.ScheduleEnd), Ref.make(Chunk.empty()), Schedule.driver(schedule), Ref.make(false), Ref.make(false)]);
|
|
100
|
-
return
|
|
99
|
+
return fromEffect(layer).pipe(flatMap(([handoff, sinkEndReason, sinkLeftovers, scheduleDriver, consumed, endAfterEmit]) => {
|
|
101
100
|
const handoffProducer = core.readWithCause({
|
|
102
101
|
onInput: input => core.flatMap(core.fromEffect(pipe(handoff, Handoff.offer(HandoffSignal.emit(input)), Effect.when(() => Chunk.isNonEmpty(input)))), () => handoffProducer),
|
|
103
102
|
onFailure: cause => core.fromEffect(Handoff.offer(handoff, HandoffSignal.halt(cause))),
|
|
@@ -129,7 +128,7 @@ export const aggregateWithinEither = /*#__PURE__*/dual(3, (self, sink, schedule)
|
|
|
129
128
|
}), channel.unwrap);
|
|
130
129
|
const timeout = lastB => scheduleDriver.next(lastB);
|
|
131
130
|
const scheduledAggregator = (sinkFiber, scheduleFiber, scope) => {
|
|
132
|
-
const forkSink = pipe(Ref.set(consumed, false), Effect.zipRight(Ref.set(endAfterEmit, false)), Effect.zipRight(pipe(handoffConsumer, channel.pipeToOrFail(_sink.toChannel(sink)), core.collectElements,
|
|
131
|
+
const forkSink = pipe(Ref.set(consumed, false), Effect.zipRight(Ref.set(endAfterEmit, false)), Effect.zipRight(pipe(handoffConsumer, channel.pipeToOrFail(_sink.toChannel(sink)), core.collectElements, channel.run, Effect.forkIn(scope))));
|
|
133
132
|
const handleSide = (leftovers, b, c) => pipe(Ref.set(sinkLeftovers, Chunk.flatten(leftovers)), Effect.zipRight(Effect.map(Ref.get(sinkEndReason), reason => {
|
|
134
133
|
switch (reason._tag) {
|
|
135
134
|
case SinkEndReason.OP_SCHEDULE_END:
|
|
@@ -162,7 +161,7 @@ export const aggregateWithinEither = /*#__PURE__*/dual(3, (self, sink, schedule)
|
|
|
162
161
|
})
|
|
163
162
|
}));
|
|
164
163
|
};
|
|
165
|
-
return
|
|
164
|
+
return unwrapScopedWith(scope => core.pipeTo(toChannel(self), handoffProducer).pipe(channel.run, Effect.forkIn(scope), Effect.zipRight(channel.pipeToOrFail(handoffConsumer, _sink.toChannel(sink)).pipe(core.collectElements, channel.run, Effect.forkIn(scope), Effect.flatMap(sinkFiber => timeout(Option.none()).pipe(Effect.forkIn(scope), Effect.map(scheduleFiber => new StreamImpl(scheduledAggregator(sinkFiber, scheduleFiber, scope)))))))));
|
|
166
165
|
}));
|
|
167
166
|
});
|
|
168
167
|
/** @internal */
|
|
@@ -361,7 +360,7 @@ const bufferSignal = (scoped, bufferChannel) => {
|
|
|
361
360
|
}))));
|
|
362
361
|
return process;
|
|
363
362
|
};
|
|
364
|
-
return channel.unwrapScoped(pipe(scoped, Effect.flatMap(queue => pipe(Deferred.make(), Effect.tap(start => Deferred.succeed(start, void 0)), Effect.flatMap(start => pipe(Ref.make(start), Effect.flatMap(ref => pipe(bufferChannel, core.pipeTo(producer(queue, ref)),
|
|
363
|
+
return channel.unwrapScoped(pipe(scoped, Effect.flatMap(queue => pipe(Deferred.make(), Effect.tap(start => Deferred.succeed(start, void 0)), Effect.flatMap(start => pipe(Ref.make(start), Effect.flatMap(ref => pipe(bufferChannel, core.pipeTo(producer(queue, ref)), channel.runScoped, Effect.forkScoped)), Effect.as(consumer(queue))))))));
|
|
365
364
|
};
|
|
366
365
|
/** @internal */
|
|
367
366
|
export const catchAll = /*#__PURE__*/dual(2, (self, f) => catchAllCause(self, cause => Either.match(Cause.failureOrCause(cause), {
|
|
@@ -429,26 +428,18 @@ export const chunksWith = /*#__PURE__*/dual(2, (self, f) => flattenChunks(f(chun
|
|
|
429
428
|
const unsome = effect => Effect.catchAll(Effect.asSome(effect), o => o._tag === "None" ? Effect.succeedNone : Effect.fail(o.value));
|
|
430
429
|
/** @internal */
|
|
431
430
|
export const combine = /*#__PURE__*/dual(4, (self, that, s, f) => {
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
const
|
|
441
|
-
const
|
|
442
|
-
yield* $(toChannel(self), channel.concatMap(channel.writeChunk), core.pipeTo(producer(left, latchL)), channelExecutor.runScoped, Effect.forkScoped);
|
|
443
|
-
yield* $(toChannel(that), channel.concatMap(channel.writeChunk), core.pipeTo(producer(right, latchR)), channelExecutor.runScoped, Effect.forkScoped);
|
|
444
|
-
const pullLeft = pipe(latchL, Handoff.offer(void 0),
|
|
445
|
-
// TODO: remove
|
|
446
|
-
Effect.zipRight(pipe(Handoff.take(left), Effect.flatMap(exit => Effect.suspend(() => exit)))));
|
|
447
|
-
const pullRight = pipe(latchR, Handoff.offer(void 0),
|
|
448
|
-
// TODO: remove
|
|
449
|
-
Effect.zipRight(pipe(Handoff.take(right), Effect.flatMap(exit => Effect.suspend(() => exit)))));
|
|
431
|
+
function producer(handoff, latch) {
|
|
432
|
+
return core.fromEffect(Handoff.take(latch)).pipe(channel.zipRight(core.readWithCause({
|
|
433
|
+
onInput: input => core.flatMap(core.fromEffect(Handoff.offer(handoff, Exit.succeed(input))), () => producer(handoff, latch)),
|
|
434
|
+
onFailure: cause => core.fromEffect(Handoff.offer(handoff, Exit.failCause(pipe(cause, Cause.map(Option.some))))),
|
|
435
|
+
onDone: () => core.flatMap(core.fromEffect(Handoff.offer(handoff, Exit.fail(Option.none()))), () => producer(handoff, latch))
|
|
436
|
+
})));
|
|
437
|
+
}
|
|
438
|
+
return new StreamImpl(channel.unwrapScopedWith(scope => Effect.all([Handoff.make(), Handoff.make(), Handoff.make(), Handoff.make()]).pipe(Effect.tap(([left, _, latchL]) => toChannel(self).pipe(channel.concatMap(channel.writeChunk), core.pipeTo(producer(left, latchL)), channelExecutor.runIn(scope), Effect.forkIn(scope))), Effect.tap(([, right, _, rightL]) => toChannel(that).pipe(channel.concatMap(channel.writeChunk), core.pipeTo(producer(right, rightL)), channelExecutor.runIn(scope), Effect.forkIn(scope))), Effect.map(([left, right, latchL, latchR]) => {
|
|
439
|
+
const pullLeft = Handoff.offer(latchL, void 0).pipe(Effect.zipRight(Handoff.take(left).pipe(Effect.flatMap(identity))));
|
|
440
|
+
const pullRight = Handoff.offer(latchR, void 0).pipe(Effect.zipRight(Handoff.take(right).pipe(Effect.flatMap(identity))));
|
|
450
441
|
return toChannel(unfoldEffect(s, s => Effect.flatMap(f(s, pullLeft, pullRight), unsome)));
|
|
451
|
-
})));
|
|
442
|
+
}))));
|
|
452
443
|
});
|
|
453
444
|
/** @internal */
|
|
454
445
|
export const combineChunks = /*#__PURE__*/dual(4, (self, that, s, f) => {
|
|
@@ -457,11 +448,11 @@ export const combineChunks = /*#__PURE__*/dual(4, (self, that, s, f) => {
|
|
|
457
448
|
onFailure: cause => core.fromEffect(Handoff.offer(handoff, InternalTake.failCause(cause))),
|
|
458
449
|
onDone: () => core.fromEffect(Handoff.offer(handoff, InternalTake.end))
|
|
459
450
|
}));
|
|
460
|
-
return new StreamImpl(
|
|
461
|
-
const pullLeft =
|
|
462
|
-
const pullRight =
|
|
451
|
+
return new StreamImpl(channel.unwrapScopedWith(scope => Effect.all([Handoff.make(), Handoff.make(), Handoff.make(), Handoff.make()]).pipe(Effect.tap(([left, _, latchL]) => core.pipeTo(toChannel(self), producer(left, latchL)).pipe(channelExecutor.runIn(scope), Effect.forkIn(scope))), Effect.tap(([_, right, __, latchR]) => core.pipeTo(toChannel(that), producer(right, latchR)).pipe(channelExecutor.runIn(scope), Effect.forkIn(scope))), Effect.map(([left, right, latchL, latchR]) => {
|
|
452
|
+
const pullLeft = Handoff.offer(latchL, void 0).pipe(Effect.zipRight(Handoff.take(left).pipe(Effect.flatMap(InternalTake.done))));
|
|
453
|
+
const pullRight = Handoff.offer(latchR, void 0).pipe(Effect.zipRight(Handoff.take(right).pipe(Effect.flatMap(InternalTake.done))));
|
|
463
454
|
return toChannel(unfoldChunkEffect(s, s => Effect.flatMap(f(s, pullLeft, pullRight), unsome)));
|
|
464
|
-
})
|
|
455
|
+
}))));
|
|
465
456
|
});
|
|
466
457
|
/** @internal */
|
|
467
458
|
export const concat = /*#__PURE__*/dual(2, (self, that) => new StreamImpl(pipe(toChannel(self), channel.zipRight(toChannel(that)))));
|
|
@@ -476,21 +467,24 @@ export const crossRight = /*#__PURE__*/dual(2, (left, right) => flatMap(left, ()
|
|
|
476
467
|
/** @internal */
|
|
477
468
|
export const crossWith = /*#__PURE__*/dual(3, (left, right, f) => pipe(left, flatMap(a => pipe(right, map(b => f(a, b))))));
|
|
478
469
|
/** @internal */
|
|
479
|
-
export const debounce = /*#__PURE__*/dual(2, (self, duration) =>
|
|
480
|
-
const
|
|
470
|
+
export const debounce = /*#__PURE__*/dual(2, (self, duration) => unwrapScopedWith(scope => Effect.gen(function* () {
|
|
471
|
+
const handoff = yield* Handoff.make();
|
|
472
|
+
function enqueue(last) {
|
|
473
|
+
return Clock.sleep(duration).pipe(Effect.as(last), Effect.forkIn(scope), Effect.map(fiber => consumer(DebounceState.previous(fiber))));
|
|
474
|
+
}
|
|
481
475
|
const producer = core.readWithCause({
|
|
482
476
|
onInput: input => Option.match(Chunk.last(input), {
|
|
483
477
|
onNone: () => producer,
|
|
484
|
-
onSome:
|
|
478
|
+
onSome: elem => core.fromEffect(Handoff.offer(handoff, HandoffSignal.emit(Chunk.of(elem)))).pipe(core.flatMap(() => producer))
|
|
485
479
|
}),
|
|
486
480
|
onFailure: cause => core.fromEffect(Handoff.offer(handoff, HandoffSignal.halt(cause))),
|
|
487
481
|
onDone: () => core.fromEffect(Handoff.offer(handoff, HandoffSignal.end(SinkEndReason.UpstreamEnd)))
|
|
488
482
|
});
|
|
489
|
-
|
|
483
|
+
function consumer(state) {
|
|
490
484
|
switch (state._tag) {
|
|
491
485
|
case DebounceState.OP_NOT_STARTED:
|
|
492
486
|
{
|
|
493
|
-
return
|
|
487
|
+
return channel.unwrap(Handoff.take(handoff).pipe(Effect.map(signal => {
|
|
494
488
|
switch (signal._tag) {
|
|
495
489
|
case HandoffSignal.OP_EMIT:
|
|
496
490
|
{
|
|
@@ -505,39 +499,39 @@ export const debounce = /*#__PURE__*/dual(2, (self, duration) => pipe(singleProd
|
|
|
505
499
|
return core.void;
|
|
506
500
|
}
|
|
507
501
|
}
|
|
508
|
-
})
|
|
502
|
+
})));
|
|
509
503
|
}
|
|
510
504
|
case DebounceState.OP_PREVIOUS:
|
|
511
505
|
{
|
|
512
|
-
return channel.unwrap(Effect.raceWith(Fiber.join(state.fiber),
|
|
506
|
+
return channel.unwrap(Handoff.take(handoff).pipe(Effect.forkIn(scope), Effect.flatMap(handoffFiber => Effect.raceWith(Fiber.join(state.fiber), Fiber.join(handoffFiber), {
|
|
513
507
|
onSelfDone: (leftExit, current) => Exit.match(leftExit, {
|
|
514
|
-
onFailure: cause =>
|
|
515
|
-
onSuccess: chunk => Effect.succeed(
|
|
508
|
+
onFailure: cause => Fiber.interrupt(current).pipe(Effect.as(core.failCause(cause))),
|
|
509
|
+
onSuccess: chunk => Fiber.interrupt(current).pipe(Effect.zipRight(Effect.succeed(core.write(chunk).pipe(core.flatMap(() => consumer(DebounceState.current(handoffFiber)))))))
|
|
516
510
|
}),
|
|
517
511
|
onOtherDone: (rightExit, previous) => Exit.match(rightExit, {
|
|
518
|
-
onFailure: cause =>
|
|
512
|
+
onFailure: cause => Fiber.interrupt(previous).pipe(Effect.as(core.failCause(cause))),
|
|
519
513
|
onSuccess: signal => {
|
|
520
514
|
switch (signal._tag) {
|
|
521
515
|
case HandoffSignal.OP_EMIT:
|
|
522
516
|
{
|
|
523
|
-
return
|
|
517
|
+
return Fiber.interrupt(previous).pipe(Effect.zipRight(enqueue(signal.elements)));
|
|
524
518
|
}
|
|
525
519
|
case HandoffSignal.OP_HALT:
|
|
526
520
|
{
|
|
527
|
-
return
|
|
521
|
+
return Fiber.interrupt(previous).pipe(Effect.as(core.failCause(signal.cause)));
|
|
528
522
|
}
|
|
529
523
|
case HandoffSignal.OP_END:
|
|
530
524
|
{
|
|
531
|
-
return
|
|
525
|
+
return Fiber.join(previous).pipe(Effect.map(chunk => core.write(chunk).pipe(channel.zipRight(core.void))));
|
|
532
526
|
}
|
|
533
527
|
}
|
|
534
528
|
}
|
|
535
529
|
})
|
|
536
|
-
}));
|
|
530
|
+
}))));
|
|
537
531
|
}
|
|
538
532
|
case DebounceState.OP_CURRENT:
|
|
539
533
|
{
|
|
540
|
-
return
|
|
534
|
+
return channel.unwrap(Fiber.join(state.fiber).pipe(Effect.map(signal => {
|
|
541
535
|
switch (signal._tag) {
|
|
542
536
|
case HandoffSignal.OP_EMIT:
|
|
543
537
|
{
|
|
@@ -552,13 +546,12 @@ export const debounce = /*#__PURE__*/dual(2, (self, duration) => pipe(singleProd
|
|
|
552
546
|
return core.void;
|
|
553
547
|
}
|
|
554
548
|
}
|
|
555
|
-
})
|
|
549
|
+
})));
|
|
556
550
|
}
|
|
557
551
|
}
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
})))), unwrap));
|
|
552
|
+
}
|
|
553
|
+
return scopedWith(scope => core.pipeTo(toChannel(self), producer).pipe(channelExecutor.runIn(scope), Effect.forkIn(scope))).pipe(crossRight(new StreamImpl(consumer(DebounceState.notStarted))));
|
|
554
|
+
})));
|
|
562
555
|
/** @internal */
|
|
563
556
|
export const die = defect => fromEffect(Effect.die(defect));
|
|
564
557
|
/** @internal */
|
|
@@ -630,7 +623,7 @@ export const distributedWithDynamicCallback = /*#__PURE__*/dual(4, (self, maximu
|
|
|
630
623
|
/** @internal */
|
|
631
624
|
export const drain = self => new StreamImpl(channel.drain(toChannel(self)));
|
|
632
625
|
/** @internal */
|
|
633
|
-
export const drainFork = /*#__PURE__*/dual(2, (self, that) =>
|
|
626
|
+
export const drainFork = /*#__PURE__*/dual(2, (self, that) => fromEffect(Deferred.make()).pipe(flatMap(backgroundDied => scopedWith(scope => toChannel(that).pipe(channel.drain, channelExecutor.runIn(scope), Effect.catchAllCause(cause => Deferred.failCause(backgroundDied, cause)), Effect.forkIn(scope))).pipe(crossRight(interruptWhenDeferred(self, backgroundDied))))));
|
|
634
627
|
/** @internal */
|
|
635
628
|
export const drop = /*#__PURE__*/dual(2, (self, n) => {
|
|
636
629
|
const loop = r => core.readWith({
|
|
@@ -1143,7 +1136,7 @@ export const haltWhen = /*#__PURE__*/dual(2, (self, effect) => {
|
|
|
1143
1136
|
onSuccess: () => core.void
|
|
1144
1137
|
})
|
|
1145
1138
|
})), channel.unwrap);
|
|
1146
|
-
return new StreamImpl(pipe(Effect.
|
|
1139
|
+
return new StreamImpl(channel.unwrapScopedWith(scope => effect.pipe(Effect.forkIn(scope), Effect.map(fiber => toChannel(self).pipe(core.pipeTo(writer(fiber)))))));
|
|
1147
1140
|
});
|
|
1148
1141
|
/** @internal */
|
|
1149
1142
|
export const haltAfter = /*#__PURE__*/dual(2, (self, duration) => pipe(self, haltWhen(Clock.sleep(duration))));
|
|
@@ -1173,7 +1166,7 @@ export const interleaveWith = /*#__PURE__*/dual(3, (self, that, decider) => {
|
|
|
1173
1166
|
onFailure: cause => core.fromEffect(Handoff.offer(handoff, InternalTake.failCause(cause))),
|
|
1174
1167
|
onDone: () => core.fromEffect(Handoff.offer(handoff, InternalTake.end))
|
|
1175
1168
|
});
|
|
1176
|
-
return new StreamImpl(channel.
|
|
1169
|
+
return new StreamImpl(channel.unwrapScopedWith(scope => pipe(Handoff.make(), Effect.zip(Handoff.make()), Effect.tap(([left]) => toChannel(self).pipe(channel.concatMap(channel.writeChunk), core.pipeTo(producer(left)), channelExecutor.runIn(scope), Effect.forkIn(scope))), Effect.tap(([_, right]) => toChannel(that).pipe(channel.concatMap(channel.writeChunk), core.pipeTo(producer(right)), channelExecutor.runIn(scope), Effect.forkIn(scope))), Effect.map(([left, right]) => {
|
|
1177
1170
|
const process = (leftDone, rightDone) => core.readWithCause({
|
|
1178
1171
|
onInput: bool => {
|
|
1179
1172
|
if (bool && !leftDone) {
|
|
@@ -1495,7 +1488,7 @@ export const prepend = /*#__PURE__*/dual(2, (self, values) => new StreamImpl(cha
|
|
|
1495
1488
|
/** @internal */
|
|
1496
1489
|
export const provideContext = /*#__PURE__*/dual(2, (self, context) => new StreamImpl(pipe(toChannel(self), core.provideContext(context))));
|
|
1497
1490
|
/** @internal */
|
|
1498
|
-
export const provideLayer = /*#__PURE__*/dual(2, (self, layer) => new StreamImpl(channel.
|
|
1491
|
+
export const provideLayer = /*#__PURE__*/dual(2, (self, layer) => new StreamImpl(channel.unwrapScopedWith(scope => Layer.buildWithScope(layer, scope).pipe(Effect.map(env => pipe(toChannel(self), core.provideContext(env)))))));
|
|
1499
1492
|
/** @internal */
|
|
1500
1493
|
export const provideService = /*#__PURE__*/dual(3, (self, tag, resource) => provideServiceEffect(self, tag, Effect.succeed(resource)));
|
|
1501
1494
|
/** @internal */
|
|
@@ -1682,43 +1675,43 @@ export const retry = /*#__PURE__*/dual(2, (self, schedule) => Schedule.driver(sc
|
|
|
1682
1675
|
return loop;
|
|
1683
1676
|
}), channel.unwrap, fromChannel));
|
|
1684
1677
|
/** @internal */
|
|
1685
|
-
export const run = /*#__PURE__*/dual(2, (self, sink) =>
|
|
1678
|
+
export const run = /*#__PURE__*/dual(2, (self, sink) => toChannel(self).pipe(channel.pipeToOrFail(_sink.toChannel(sink)), channel.runDrain));
|
|
1686
1679
|
/** @internal */
|
|
1687
|
-
export const runCollect = self =>
|
|
1680
|
+
export const runCollect = self => run(self, _sink.collectAll());
|
|
1688
1681
|
/** @internal */
|
|
1689
|
-
export const runCount = self =>
|
|
1682
|
+
export const runCount = self => run(self, _sink.count);
|
|
1690
1683
|
/** @internal */
|
|
1691
|
-
export const runDrain = self =>
|
|
1684
|
+
export const runDrain = self => run(self, _sink.drain);
|
|
1692
1685
|
/** @internal */
|
|
1693
|
-
export const runFold = /*#__PURE__*/dual(3, (self, s, f) =>
|
|
1686
|
+
export const runFold = /*#__PURE__*/dual(3, (self, s, f) => runFoldWhile(self, s, constTrue, f));
|
|
1694
1687
|
/** @internal */
|
|
1695
|
-
export const runFoldEffect = /*#__PURE__*/dual(3, (self, s, f) =>
|
|
1688
|
+
export const runFoldEffect = /*#__PURE__*/dual(3, (self, s, f) => runFoldWhileEffect(self, s, constTrue, f));
|
|
1696
1689
|
/** @internal */
|
|
1697
1690
|
export const runFoldScoped = /*#__PURE__*/dual(3, (self, s, f) => pipe(self, runFoldWhileScoped(s, constTrue, f)));
|
|
1698
1691
|
/** @internal */
|
|
1699
1692
|
export const runFoldScopedEffect = /*#__PURE__*/dual(3, (self, s, f) => pipe(self, runFoldWhileScopedEffect(s, constTrue, f)));
|
|
1700
1693
|
/** @internal */
|
|
1701
|
-
export const runFoldWhile = /*#__PURE__*/dual(4, (self, s, cont, f) =>
|
|
1694
|
+
export const runFoldWhile = /*#__PURE__*/dual(4, (self, s, cont, f) => run(self, _sink.fold(s, cont, f)));
|
|
1702
1695
|
/** @internal */
|
|
1703
|
-
export const runFoldWhileEffect = /*#__PURE__*/dual(4, (self, s, cont, f) =>
|
|
1696
|
+
export const runFoldWhileEffect = /*#__PURE__*/dual(4, (self, s, cont, f) => run(self, _sink.foldEffect(s, cont, f)));
|
|
1704
1697
|
/** @internal */
|
|
1705
1698
|
export const runFoldWhileScoped = /*#__PURE__*/dual(4, (self, s, cont, f) => pipe(self, runScoped(_sink.fold(s, cont, f))));
|
|
1706
1699
|
/** @internal */
|
|
1707
1700
|
export const runFoldWhileScopedEffect = /*#__PURE__*/dual(4, (self, s, cont, f) => pipe(self, runScoped(_sink.foldEffect(s, cont, f))));
|
|
1708
1701
|
/** @internal */
|
|
1709
|
-
export const runForEach = /*#__PURE__*/dual(2, (self, f) =>
|
|
1702
|
+
export const runForEach = /*#__PURE__*/dual(2, (self, f) => run(self, _sink.forEach(f)));
|
|
1710
1703
|
/** @internal */
|
|
1711
|
-
export const runForEachChunk = /*#__PURE__*/dual(2, (self, f) =>
|
|
1704
|
+
export const runForEachChunk = /*#__PURE__*/dual(2, (self, f) => run(self, _sink.forEachChunk(f)));
|
|
1712
1705
|
/** @internal */
|
|
1713
1706
|
export const runForEachChunkScoped = /*#__PURE__*/dual(2, (self, f) => pipe(self, runScoped(_sink.forEachChunk(f))));
|
|
1714
1707
|
/** @internal */
|
|
1715
1708
|
export const runForEachScoped = /*#__PURE__*/dual(2, (self, f) => pipe(self, runScoped(_sink.forEach(f))));
|
|
1716
1709
|
/** @internal */
|
|
1717
|
-
export const runForEachWhile = /*#__PURE__*/dual(2, (self, f) =>
|
|
1710
|
+
export const runForEachWhile = /*#__PURE__*/dual(2, (self, f) => run(self, _sink.forEachWhile(f)));
|
|
1718
1711
|
/** @internal */
|
|
1719
1712
|
export const runForEachWhileScoped = /*#__PURE__*/dual(2, (self, f) => pipe(self, runScoped(_sink.forEachWhile(f))));
|
|
1720
1713
|
/** @internal */
|
|
1721
|
-
export const runHead = self =>
|
|
1714
|
+
export const runHead = self => run(self, _sink.head());
|
|
1722
1715
|
/** @internal */
|
|
1723
1716
|
export const runIntoPubSub = /*#__PURE__*/dual(2, (self, pubsub) => pipe(self, runIntoQueue(pubsub)));
|
|
1724
1717
|
/** @internal */
|
|
@@ -1732,7 +1725,7 @@ export const runIntoQueueElementsScoped = /*#__PURE__*/dual(2, (self, queue) =>
|
|
|
1732
1725
|
onFailure: cause => core.fromEffect(Queue.offer(queue, Exit.failCause(Cause.map(cause, Option.some)))),
|
|
1733
1726
|
onDone: () => core.fromEffect(Queue.offer(queue, Exit.fail(Option.none())))
|
|
1734
1727
|
});
|
|
1735
|
-
return pipe(core.pipeTo(toChannel(self), writer), channel.drain,
|
|
1728
|
+
return pipe(core.pipeTo(toChannel(self), writer), channel.drain, channel.runScoped, Effect.asVoid);
|
|
1736
1729
|
});
|
|
1737
1730
|
/** @internal */
|
|
1738
1731
|
export const runIntoQueueScoped = /*#__PURE__*/dual(2, (self, queue) => {
|
|
@@ -1741,14 +1734,14 @@ export const runIntoQueueScoped = /*#__PURE__*/dual(2, (self, queue) => {
|
|
|
1741
1734
|
onFailure: cause => core.write(InternalTake.failCause(cause)),
|
|
1742
1735
|
onDone: () => core.write(InternalTake.end)
|
|
1743
1736
|
});
|
|
1744
|
-
return pipe(core.pipeTo(toChannel(self), writer), channel.mapOutEffect(take => Queue.offer(queue, take)), channel.drain,
|
|
1737
|
+
return pipe(core.pipeTo(toChannel(self), writer), channel.mapOutEffect(take => Queue.offer(queue, take)), channel.drain, channel.runScoped, Effect.asVoid);
|
|
1745
1738
|
});
|
|
1746
1739
|
/** @internal */
|
|
1747
|
-
export const runLast = self =>
|
|
1740
|
+
export const runLast = self => run(self, _sink.last());
|
|
1748
1741
|
/** @internal */
|
|
1749
|
-
export const runScoped = /*#__PURE__*/dual(2, (self, sink) => pipe(toChannel(self), channel.pipeToOrFail(_sink.toChannel(sink)), channel.drain,
|
|
1742
|
+
export const runScoped = /*#__PURE__*/dual(2, (self, sink) => pipe(toChannel(self), channel.pipeToOrFail(_sink.toChannel(sink)), channel.drain, channel.runScoped));
|
|
1750
1743
|
/** @internal */
|
|
1751
|
-
export const runSum = self =>
|
|
1744
|
+
export const runSum = self => run(self, _sink.sum);
|
|
1752
1745
|
/** @internal */
|
|
1753
1746
|
export const scan = /*#__PURE__*/dual(3, (self, s, f) => pipe(self, scanEffect(s, (s, a) => Effect.succeed(f(s, a)))));
|
|
1754
1747
|
/** @internal */
|
|
@@ -1794,6 +1787,8 @@ export const scanEffect = /*#__PURE__*/dual(3, (self, s, f) => new StreamImpl(pi
|
|
|
1794
1787
|
/** @internal */
|
|
1795
1788
|
export const scoped = effect => new StreamImpl(channel.ensuring(channel.scoped(pipe(effect, Effect.map(Chunk.of))), Effect.void));
|
|
1796
1789
|
/** @internal */
|
|
1790
|
+
export const scopedWith = f => new StreamImpl(channel.scopedWith(scope => f(scope).pipe(Effect.map(Chunk.of))));
|
|
1791
|
+
/** @internal */
|
|
1797
1792
|
export const some = self => pipe(self, mapError(Option.some), someOrFail(() => Option.none()));
|
|
1798
1793
|
/** @internal */
|
|
1799
1794
|
export const someOrElse = /*#__PURE__*/dual(2, (self, fallback) => pipe(self, map(Option.getOrElse(fallback))));
|
|
@@ -2239,6 +2234,8 @@ export const unwrap = effect => flatten(fromEffect(effect));
|
|
|
2239
2234
|
/** @internal */
|
|
2240
2235
|
export const unwrapScoped = effect => flatten(scoped(effect));
|
|
2241
2236
|
/** @internal */
|
|
2237
|
+
export const unwrapScopedWith = f => flatten(scopedWith(scope => f(scope)));
|
|
2238
|
+
/** @internal */
|
|
2242
2239
|
export const updateService = /*#__PURE__*/dual(3, (self, tag, f) => pipe(self, mapInputContext(context => pipe(context, Context.add(tag, f(pipe(context, Context.unsafeGet(tag))))))));
|
|
2243
2240
|
/** @internal */
|
|
2244
2241
|
export const when = /*#__PURE__*/dual(2, (self, test) => pipe(self, whenEffect(Effect.sync(test))));
|