effect 4.0.0-rc.118 → 4.0.1
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/README.md +17 -4
- package/dist/Array.d.ts +25 -25
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +16 -16
- package/dist/Array.js.map +1 -1
- package/dist/Cache.d.ts.map +1 -1
- package/dist/Cache.js +20 -16
- package/dist/Cache.js.map +1 -1
- package/dist/Cause.d.ts.map +1 -1
- package/dist/Cause.js +1 -1
- package/dist/Cause.js.map +1 -1
- package/dist/Chunk.d.ts +26 -26
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +15 -15
- package/dist/Chunk.js.map +1 -1
- package/dist/Effect.d.ts +167 -39
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +16 -10
- package/dist/Effect.js.map +1 -1
- package/dist/HashRing.d.ts.map +1 -1
- package/dist/HashRing.js +13 -5
- package/dist/HashRing.js.map +1 -1
- package/dist/MutableHashMap.d.ts.map +1 -1
- package/dist/MutableHashMap.js +4 -22
- package/dist/MutableHashMap.js.map +1 -1
- package/dist/Option.d.ts +17 -17
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js +6 -6
- package/dist/Option.js.map +1 -1
- package/dist/Pool.d.ts +9 -5
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +34 -41
- package/dist/Pool.js.map +1 -1
- package/dist/Queue.d.ts +19 -2
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +9 -4
- package/dist/Queue.js.map +1 -1
- package/dist/RcMap.d.ts.map +1 -1
- package/dist/RcMap.js +16 -1
- package/dist/RcMap.js.map +1 -1
- package/dist/Record.d.ts +14 -14
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js +10 -10
- package/dist/Record.js.map +1 -1
- package/dist/Schema.d.ts +37 -21
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +29 -10
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +116 -97
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +3 -1
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +3 -1
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/ScopedCache.d.ts.map +1 -1
- package/dist/ScopedCache.js +24 -16
- package/dist/ScopedCache.js.map +1 -1
- package/dist/Stream.d.ts +45 -6
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +55 -44
- package/dist/Stream.js.map +1 -1
- package/dist/ai/LanguageModel.d.ts +8 -0
- package/dist/ai/LanguageModel.d.ts.map +1 -1
- package/dist/ai/LanguageModel.js +13 -2
- package/dist/ai/LanguageModel.js.map +1 -1
- package/dist/ai/McpSchema.d.ts +402 -402
- package/dist/ai/McpSchema.d.ts.map +1 -1
- package/dist/ai/McpSchema.js +1 -1
- package/dist/ai/McpSchema.js.map +1 -1
- package/dist/ai/McpServer.d.ts.map +1 -1
- package/dist/ai/McpServer.js +11 -3
- package/dist/ai/McpServer.js.map +1 -1
- package/dist/ai/Response.d.ts.map +1 -1
- package/dist/ai/Response.js +22 -12
- package/dist/ai/Response.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js +1 -0
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js +1 -0
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js +1 -0
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js +1 -0
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2024_11_05.js +3 -1
- package/dist/ai/internal/mcpSchema/v2024_11_05.js.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.js +16 -3
- package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/cluster/MessageStorage.d.ts +32 -8
- package/dist/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/cluster/MessageStorage.js +2 -1
- package/dist/cluster/MessageStorage.js.map +1 -1
- package/dist/cluster/Sharding.d.ts +5 -2
- package/dist/cluster/Sharding.d.ts.map +1 -1
- package/dist/cluster/Sharding.js +15 -8
- package/dist/cluster/Sharding.js.map +1 -1
- package/dist/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/cluster/SqlMessageStorage.js +36 -16
- package/dist/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/cluster/SqlRunnerStorage.d.ts.map +1 -1
- package/dist/cluster/SqlRunnerStorage.js +30 -44
- package/dist/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/cluster/internal/entityManager.js +63 -62
- package/dist/cluster/internal/entityManager.js.map +1 -1
- package/dist/cluster/internal/interruptors.js +8 -0
- package/dist/cluster/internal/interruptors.js.map +1 -1
- package/dist/cluster/internal/resourceMap.js +39 -14
- package/dist/cluster/internal/resourceMap.js.map +1 -1
- package/dist/cluster/internal/resourceRef.js +168 -87
- package/dist/cluster/internal/resourceRef.js.map +1 -1
- package/dist/http/HttpEffect.d.ts +1 -0
- package/dist/http/HttpEffect.d.ts.map +1 -1
- package/dist/http/HttpEffect.js +29 -22
- package/dist/http/HttpEffect.js.map +1 -1
- package/dist/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/http/HttpMiddleware.js +3 -2
- package/dist/http/HttpMiddleware.js.map +1 -1
- package/dist/http/HttpStaticServer.d.ts.map +1 -1
- package/dist/http/HttpStaticServer.js +14 -0
- package/dist/http/HttpStaticServer.js.map +1 -1
- package/dist/http/HttpTraceContext.d.ts +1 -1
- package/dist/http/HttpTraceContext.d.ts.map +1 -1
- package/dist/http/HttpTraceContext.js +4 -4
- package/dist/http/HttpTraceContext.js.map +1 -1
- package/dist/http-api/HttpApiError.d.ts +1 -0
- package/dist/http-api/HttpApiError.d.ts.map +1 -1
- package/dist/http-api/HttpApiError.js +1 -0
- package/dist/http-api/HttpApiError.js.map +1 -1
- package/dist/internal/core.js +43 -2
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/dateTime.js +1 -1
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +138 -165
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/rcRef.js +59 -23
- package/dist/internal/rcRef.js.map +1 -1
- package/dist/internal/schema/annotations.js +1 -7
- package/dist/internal/schema/annotations.js.map +1 -1
- package/dist/internal/schema/codegen.js +56 -28
- package/dist/internal/schema/codegen.js.map +1 -1
- package/dist/internal/schema/fromJsonSchemaDocument.js +11 -8
- package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/toCodeDocument.js +10 -30
- package/dist/internal/schema/toCodeDocument.js.map +1 -1
- package/dist/internal/schema/toCodec.js +1 -15
- package/dist/internal/schema/toCodec.js.map +1 -1
- package/dist/internal/schema/toEquivalence.js +4 -3
- package/dist/internal/schema/toEquivalence.js.map +1 -1
- package/dist/internal/schema/toFormatter.js +4 -4
- package/dist/internal/schema/toFormatter.js.map +1 -1
- package/dist/reactivity/Atom.d.ts.map +1 -1
- package/dist/reactivity/Atom.js +6 -2
- package/dist/reactivity/Atom.js.map +1 -1
- package/dist/reactivity/AtomRpc.d.ts +3 -3
- package/dist/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/rpc/Rpc.d.ts +2 -2
- package/dist/rpc/Rpc.d.ts.map +1 -1
- package/dist/rpc/RpcClient.d.ts +7 -7
- package/dist/rpc/RpcClient.d.ts.map +1 -1
- package/dist/rpc/RpcClient.js +21 -16
- package/dist/rpc/RpcClient.js.map +1 -1
- package/dist/rpc/RpcMessage.d.ts +1 -1
- package/dist/rpc/RpcMessage.d.ts.map +1 -1
- package/dist/rpc/RpcServer.d.ts.map +1 -1
- package/dist/rpc/RpcServer.js +2 -2
- package/dist/rpc/RpcServer.js.map +1 -1
- package/dist/rpc/Utils.d.ts +2 -3
- package/dist/rpc/Utils.d.ts.map +1 -1
- package/dist/rpc/Utils.js +3 -4
- package/dist/rpc/Utils.js.map +1 -1
- package/dist/schema/SchemaCompiler/runtime.js +6 -1
- package/dist/schema/SchemaCompiler/runtime.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +234 -6
- package/dist/testing/TestSchema.d.ts.map +1 -1
- package/dist/testing/TestSchema.js +244 -25
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +1 -0
- package/dist/testing/index.js.map +1 -1
- package/dist/workflow/DurableDeferred.js +1 -1
- package/dist/workflow/DurableDeferred.js.map +1 -1
- package/dist/workflow/Workflow.js +1 -1
- package/dist/workflow/Workflow.js.map +1 -1
- package/dist/workflow/WorkflowEngine.d.ts +2 -0
- package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/workflow/WorkflowEngine.js +1 -0
- package/dist/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +1 -1
- package/src/Array.ts +31 -31
- package/src/Cache.ts +22 -16
- package/src/Cause.ts +1 -1
- package/src/Chunk.ts +29 -29
- package/src/Effect.ts +170 -39
- package/src/HashRing.ts +14 -5
- package/src/MutableHashMap.ts +4 -24
- package/src/Option.ts +19 -19
- package/src/Pool.ts +28 -36
- package/src/Queue.ts +26 -6
- package/src/RcMap.ts +26 -2
- package/src/Record.ts +20 -20
- package/src/Schema.ts +48 -24
- package/src/SchemaAST.ts +135 -115
- package/src/SchemaRepresentation.ts +3 -1
- package/src/ScopedCache.ts +27 -16
- package/src/Stream.ts +158 -88
- package/src/ai/LanguageModel.ts +27 -2
- package/src/ai/McpSchema.ts +3 -3
- package/src/ai/McpServer.ts +12 -3
- package/src/ai/Response.ts +27 -12
- package/src/ai/internal/mcpProtocol/v2024_11_05.ts +1 -0
- package/src/ai/internal/mcpProtocol/v2025_03_26.ts +1 -0
- package/src/ai/internal/mcpProtocol/v2025_06_18.ts +1 -0
- package/src/ai/internal/mcpProtocol/v2025_11_25.ts +1 -0
- package/src/ai/internal/mcpSchema/v2024_11_05.ts +4 -2
- package/src/cluster/ClusterWorkflowEngine.ts +26 -5
- package/src/cluster/MessageStorage.ts +22 -5
- package/src/cluster/Sharding.ts +32 -28
- package/src/cluster/SqlMessageStorage.ts +45 -21
- package/src/cluster/SqlRunnerStorage.ts +85 -113
- package/src/cluster/internal/entityManager.ts +68 -80
- package/src/cluster/internal/interruptors.ts +13 -0
- package/src/cluster/internal/resourceMap.ts +55 -17
- package/src/cluster/internal/resourceRef.ts +189 -96
- package/src/http/HttpEffect.ts +15 -9
- package/src/http/HttpMiddleware.ts +8 -2
- package/src/http/HttpStaticServer.ts +16 -0
- package/src/http/HttpTraceContext.ts +8 -4
- package/src/http-api/HttpApiError.ts +1 -0
- package/src/internal/core.ts +56 -2
- package/src/internal/dateTime.ts +3 -1
- package/src/internal/effect.ts +146 -173
- package/src/internal/rcRef.ts +83 -33
- package/src/internal/schema/annotations.ts +0 -9
- package/src/internal/schema/codegen.ts +90 -43
- package/src/internal/schema/fromJsonSchemaDocument.ts +5 -3
- package/src/internal/schema/toCodeDocument.ts +10 -47
- package/src/internal/schema/toCodec.ts +3 -16
- package/src/internal/schema/toEquivalence.ts +4 -5
- package/src/internal/schema/toFormatter.ts +4 -6
- package/src/reactivity/Atom.ts +6 -2
- package/src/reactivity/AtomRpc.ts +5 -5
- package/src/rpc/Rpc.ts +2 -2
- package/src/rpc/RpcClient.ts +35 -32
- package/src/rpc/RpcMessage.ts +1 -1
- package/src/rpc/RpcServer.ts +2 -1
- package/src/rpc/Utils.ts +4 -10
- package/src/schema/SchemaCompiler/runtime.ts +17 -1
- package/src/testing/TestSchema.ts +315 -63
- package/src/testing/index.ts +1 -0
- package/src/workflow/DurableDeferred.ts +1 -1
- package/src/workflow/Workflow.ts +1 -1
- package/src/workflow/WorkflowEngine.ts +4 -0
package/dist/Stream.js
CHANGED
|
@@ -5219,19 +5219,15 @@ export const mapAccumArrayEffect = /*#__PURE__*/dual(args => isStream(args[0]),
|
|
|
5219
5219
|
* @since 2.0.0
|
|
5220
5220
|
*/
|
|
5221
5221
|
export const scan = /*#__PURE__*/dual(3, (self, initial, f) => suspend(() => {
|
|
5222
|
-
|
|
5223
|
-
return fromChannel(Channel.mapAccum(self.channel,
|
|
5222
|
+
const seed = initial();
|
|
5223
|
+
return concat(succeed(seed), fromChannel(Channel.mapAccum(self.channel, () => seed, (state, arr) => {
|
|
5224
5224
|
const states = Arr.empty();
|
|
5225
|
-
if (isFirst) {
|
|
5226
|
-
isFirst = false;
|
|
5227
|
-
states.push(state);
|
|
5228
|
-
}
|
|
5229
5225
|
for (let index = 0; index < arr.length; index++) {
|
|
5230
5226
|
state = f(state, arr[index]);
|
|
5231
5227
|
states.push(state);
|
|
5232
5228
|
}
|
|
5233
5229
|
return [state, Arr.of(states)];
|
|
5234
|
-
}));
|
|
5230
|
+
})));
|
|
5235
5231
|
}));
|
|
5236
5232
|
/**
|
|
5237
5233
|
* Accumulates state effectfully and emits the initial state plus each accumulated state.
|
|
@@ -5405,31 +5401,30 @@ const throttleShapeEffect = (self, cost, units, duration, burst) => transformPul
|
|
|
5405
5401
|
const durationMs = Duration.toMillis(Duration.fromInputUnsafe(duration));
|
|
5406
5402
|
const max = units + burst < 0 ? Number.POSITIVE_INFINITY : units + burst;
|
|
5407
5403
|
let tokens = units;
|
|
5408
|
-
let
|
|
5404
|
+
let timestampNanos = clock.monotonicTimeNanosUnsafe();
|
|
5409
5405
|
return Effect.succeed(Effect.flatMap(pull, arr => Effect.flatMap(cost(arr), weight => {
|
|
5410
|
-
const
|
|
5411
|
-
const elapsed =
|
|
5406
|
+
const currentNanos = clock.monotonicTimeNanosUnsafe();
|
|
5407
|
+
const elapsed = Number(currentNanos - timestampNanos) / 1_000_000;
|
|
5412
5408
|
const cycles = elapsed / durationMs;
|
|
5413
5409
|
const sum = tokens + cycles * units;
|
|
5414
|
-
const available =
|
|
5410
|
+
const available = Math.min(sum, max);
|
|
5415
5411
|
const remaining = available - weight;
|
|
5416
5412
|
if (remaining >= 0) {
|
|
5417
5413
|
tokens = remaining;
|
|
5418
|
-
|
|
5414
|
+
timestampNanos = currentNanos;
|
|
5419
5415
|
return Effect.succeed(arr);
|
|
5420
5416
|
}
|
|
5421
|
-
// Calculate delay needed
|
|
5422
5417
|
const waitCycles = -remaining / units;
|
|
5423
5418
|
const delayMs = Math.max(0, waitCycles * durationMs);
|
|
5424
5419
|
if (delayMs > 0) {
|
|
5425
5420
|
return Effect.flatMap(Effect.sleep(delayMs), () => {
|
|
5426
5421
|
tokens = remaining;
|
|
5427
|
-
|
|
5422
|
+
timestampNanos = currentNanos;
|
|
5428
5423
|
return Effect.succeed(arr);
|
|
5429
5424
|
});
|
|
5430
5425
|
}
|
|
5431
5426
|
tokens = remaining;
|
|
5432
|
-
|
|
5427
|
+
timestampNanos = currentNanos;
|
|
5433
5428
|
return Effect.succeed(arr);
|
|
5434
5429
|
})));
|
|
5435
5430
|
}));
|
|
@@ -5515,8 +5510,9 @@ export const grouped = /*#__PURE__*/dual(2, (self, n) => chunks(rechunk(self, n)
|
|
|
5515
5510
|
*
|
|
5516
5511
|
* **Details**
|
|
5517
5512
|
*
|
|
5518
|
-
*
|
|
5519
|
-
* are
|
|
5513
|
+
* The duration starts when the first element of a group arrives, so an idle
|
|
5514
|
+
* stream does not wake up. Finite fractional chunk sizes are rounded down.
|
|
5515
|
+
* `NaN` and non-positive sizes are treated as `1`.
|
|
5520
5516
|
*
|
|
5521
5517
|
* **Example** (Grouping elements by size or time)
|
|
5522
5518
|
*
|
|
@@ -5784,6 +5780,18 @@ export const aggregate = /*#__PURE__*/dual(2, (self, sink) => aggregateWithin(se
|
|
|
5784
5780
|
* **Details**
|
|
5785
5781
|
*
|
|
5786
5782
|
* The schedule can flush the current aggregation even if the sink has not finished.
|
|
5783
|
+
* It is stepped at most once per aggregation, when the aggregation receives its
|
|
5784
|
+
* first element, with the previous aggregation's output as input. An aggregation
|
|
5785
|
+
* the sink completes immediately, such as one built from leftovers, may finish
|
|
5786
|
+
* without stepping the schedule.
|
|
5787
|
+
*
|
|
5788
|
+
* Time between aggregations is hidden from the schedule, so an idle stream does
|
|
5789
|
+
* not run it. Time-based schedules such as `Schedule.fixed` and
|
|
5790
|
+
* `Schedule.upTo({ duration })` only count time spent aggregating; use
|
|
5791
|
+
* `Schedule.spaced` for a flush timer.
|
|
5792
|
+
*
|
|
5793
|
+
* When the schedule ends, the stream emits the current aggregation and any sink
|
|
5794
|
+
* leftovers, then ends without pulling more from upstream.
|
|
5787
5795
|
*
|
|
5788
5796
|
* **Example** (Aggregating with a sink and schedule)
|
|
5789
5797
|
*
|
|
@@ -5813,55 +5821,58 @@ export const aggregateWithin = /*#__PURE__*/dual(3, (self, sink, schedule) => fr
|
|
|
5813
5821
|
const buffer = yield* Queue.make({
|
|
5814
5822
|
capacity: 0
|
|
5815
5823
|
});
|
|
5816
|
-
// upstream -> buffer
|
|
5817
5824
|
yield* pull.pipe(pullLatch.whenOpen, Effect.flatMap(arr => {
|
|
5818
5825
|
pullLatch.closeUnsafe();
|
|
5819
5826
|
return Queue.offer(buffer, arr);
|
|
5820
5827
|
}), Effect.forever,
|
|
5821
|
-
//
|
|
5828
|
+
// Keep autoYield enabled so the schedule can run.
|
|
5822
5829
|
Effect.catchCause(cause => Queue.failCause(buffer, cause)), Effect.forkIn(scope));
|
|
5823
|
-
// schedule
|
|
5830
|
+
// The schedule clock excludes time between aggregations.
|
|
5831
|
+
const clock = yield* Clock;
|
|
5832
|
+
const step = yield* Schedule.toStep(schedule);
|
|
5833
|
+
const hasInput = Latch.makeUnsafe(false);
|
|
5834
|
+
let scheduleTime = clock.currentTimeMillisUnsafe();
|
|
5835
|
+
let openedAt = 0;
|
|
5824
5836
|
let lastOutput = Option.none();
|
|
5825
5837
|
let leftover;
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
return Effect.flatMap(step(lastOutput), () => !sinkHasInput ? loop() : Queue.offer(buffer, scheduleStep));
|
|
5830
|
-
});
|
|
5831
|
-
const stepToBuffer = stepLoop.pipe(Effect.flatMap(() => Effect.never), Pull.catchDone(() => Cause.done()));
|
|
5832
|
-
// buffer -> sink
|
|
5833
|
-
const pullFromBuffer = Queue.take(buffer).pipe(Effect.flatMap(arr => {
|
|
5834
|
-
if (arr === scheduleStep) {
|
|
5835
|
-
return Cause.done();
|
|
5838
|
+
const onInput = chunk => {
|
|
5839
|
+
if (hasInput.openUnsafe()) {
|
|
5840
|
+
openedAt = clock.currentTimeMillisUnsafe();
|
|
5836
5841
|
}
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5842
|
+
return Effect.succeed(chunk);
|
|
5843
|
+
};
|
|
5844
|
+
const stepToBuffer = hasInput.await.pipe(Effect.flatMap(() => step(scheduleTime, lastOutput)), Effect.flatMap(([, delay]) => Effect.sleep(delay)), Effect.flatMap(() => Queue.offer(buffer, scheduleStep)),
|
|
5845
|
+
// End input so the sink drains leftovers without further upstream pulls.
|
|
5846
|
+
Pull.catchDone(() => Queue.end(buffer)), Effect.flatMap(() => Effect.never));
|
|
5840
5847
|
const sinkUpstream = Effect.suspend(() => {
|
|
5841
5848
|
if (leftover !== undefined) {
|
|
5842
5849
|
const chunk = leftover;
|
|
5843
5850
|
leftover = undefined;
|
|
5844
|
-
|
|
5845
|
-
return Effect.succeed(chunk);
|
|
5851
|
+
return onInput(chunk);
|
|
5846
5852
|
}
|
|
5847
|
-
|
|
5848
|
-
|
|
5853
|
+
if (buffer.state._tag === "Open") {
|
|
5854
|
+
pullLatch.openUnsafe();
|
|
5855
|
+
}
|
|
5856
|
+
return Effect.flatMap(Queue.take(buffer), arr => arr === scheduleStep ? Cause.done() : onInput(arr));
|
|
5849
5857
|
});
|
|
5850
|
-
const
|
|
5851
|
-
|
|
5852
|
-
|
|
5858
|
+
const emit = Effect.flatMap(([value, leftover_]) => {
|
|
5859
|
+
if (hasInput.isOpen()) {
|
|
5860
|
+
scheduleTime += clock.currentTimeMillisUnsafe() - openedAt;
|
|
5861
|
+
} else if (buffer.state._tag === "Done") {
|
|
5862
|
+
return Cause.done();
|
|
5863
|
+
}
|
|
5853
5864
|
lastOutput = Option.some(value);
|
|
5854
5865
|
leftover = leftover_;
|
|
5855
5866
|
return Effect.succeed(Arr.of(value));
|
|
5856
5867
|
});
|
|
5857
5868
|
return Effect.suspend(() => {
|
|
5858
|
-
// if the buffer has exited and there is no more data to process
|
|
5859
5869
|
if (buffer.state._tag === "Done" && leftover === undefined) {
|
|
5860
5870
|
return buffer.state.exit;
|
|
5861
5871
|
}
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
|
|
5872
|
+
hasInput.closeUnsafe();
|
|
5873
|
+
const pull = emit(Effect.suspend(() => sink.transform(sinkUpstream, scope)));
|
|
5874
|
+
return buffer.state._tag === "Open" ? Effect.raceFirst(pull, stepToBuffer) : pull;
|
|
5875
|
+
});
|
|
5865
5876
|
}))));
|
|
5866
5877
|
/**
|
|
5867
5878
|
* Creates a fixed-size tuple of streams that each emit
|