@langchain/langgraph 1.0.7 → 1.0.12
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/package.json +7 -7
- package/CHANGELOG.md +0 -286
- package/dist/_virtual/rolldown_runtime.cjs +0 -25
- package/dist/channels/any_value.cjs +0 -46
- package/dist/channels/any_value.cjs.map +0 -1
- package/dist/channels/any_value.d.cts +0 -24
- package/dist/channels/any_value.d.cts.map +0 -1
- package/dist/channels/any_value.d.ts +0 -24
- package/dist/channels/any_value.d.ts.map +0 -1
- package/dist/channels/any_value.js +0 -46
- package/dist/channels/any_value.js.map +0 -1
- package/dist/channels/base.cjs +0 -102
- package/dist/channels/base.cjs.map +0 -1
- package/dist/channels/base.d.cts +0 -79
- package/dist/channels/base.d.cts.map +0 -1
- package/dist/channels/base.d.ts +0 -79
- package/dist/channels/base.d.ts.map +0 -1
- package/dist/channels/base.js +0 -97
- package/dist/channels/base.js.map +0 -1
- package/dist/channels/binop.cjs +0 -49
- package/dist/channels/binop.cjs.map +0 -1
- package/dist/channels/binop.d.cts +0 -22
- package/dist/channels/binop.d.cts.map +0 -1
- package/dist/channels/binop.d.ts +0 -22
- package/dist/channels/binop.d.ts.map +0 -1
- package/dist/channels/binop.js +0 -49
- package/dist/channels/binop.js.map +0 -1
- package/dist/channels/dynamic_barrier_value.cjs +0 -76
- package/dist/channels/dynamic_barrier_value.cjs.map +0 -1
- package/dist/channels/dynamic_barrier_value.d.cts +0 -42
- package/dist/channels/dynamic_barrier_value.d.cts.map +0 -1
- package/dist/channels/dynamic_barrier_value.d.ts +0 -42
- package/dist/channels/dynamic_barrier_value.d.ts.map +0 -1
- package/dist/channels/dynamic_barrier_value.js +0 -76
- package/dist/channels/dynamic_barrier_value.js.map +0 -1
- package/dist/channels/ephemeral_value.cjs +0 -46
- package/dist/channels/ephemeral_value.cjs.map +0 -1
- package/dist/channels/ephemeral_value.d.cts +0 -22
- package/dist/channels/ephemeral_value.d.cts.map +0 -1
- package/dist/channels/ephemeral_value.d.ts +0 -22
- package/dist/channels/ephemeral_value.d.ts.map +0 -1
- package/dist/channels/ephemeral_value.js +0 -46
- package/dist/channels/ephemeral_value.js.map +0 -1
- package/dist/channels/index.cjs +0 -21
- package/dist/channels/index.d.cts +0 -9
- package/dist/channels/index.d.ts +0 -9
- package/dist/channels/index.js +0 -10
- package/dist/channels/last_value.cjs +0 -98
- package/dist/channels/last_value.cjs.map +0 -1
- package/dist/channels/last_value.d.cts +0 -44
- package/dist/channels/last_value.d.cts.map +0 -1
- package/dist/channels/last_value.d.ts +0 -44
- package/dist/channels/last_value.d.ts.map +0 -1
- package/dist/channels/last_value.js +0 -97
- package/dist/channels/last_value.js.map +0 -1
- package/dist/channels/named_barrier_value.cjs +0 -118
- package/dist/channels/named_barrier_value.cjs.map +0 -1
- package/dist/channels/named_barrier_value.d.cts +0 -46
- package/dist/channels/named_barrier_value.d.cts.map +0 -1
- package/dist/channels/named_barrier_value.d.ts +0 -46
- package/dist/channels/named_barrier_value.d.ts.map +0 -1
- package/dist/channels/named_barrier_value.js +0 -116
- package/dist/channels/named_barrier_value.js.map +0 -1
- package/dist/channels/topic.cjs +0 -65
- package/dist/channels/topic.cjs.map +0 -1
- package/dist/channels/topic.d.cts +0 -32
- package/dist/channels/topic.d.cts.map +0 -1
- package/dist/channels/topic.d.ts +0 -32
- package/dist/channels/topic.d.ts.map +0 -1
- package/dist/channels/topic.js +0 -65
- package/dist/channels/topic.js.map +0 -1
- package/dist/constants.cjs +0 -406
- package/dist/constants.cjs.map +0 -1
- package/dist/constants.d.cts +0 -285
- package/dist/constants.d.cts.map +0 -1
- package/dist/constants.d.ts +0 -285
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -362
- package/dist/constants.js.map +0 -1
- package/dist/errors.cjs +0 -163
- package/dist/errors.cjs.map +0 -1
- package/dist/errors.d.cts +0 -81
- package/dist/errors.d.cts.map +0 -1
- package/dist/errors.d.ts +0 -81
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -146
- package/dist/errors.js.map +0 -1
- package/dist/func/index.cjs +0 -301
- package/dist/func/index.cjs.map +0 -1
- package/dist/func/index.d.cts +0 -293
- package/dist/func/index.d.cts.map +0 -1
- package/dist/func/index.d.ts +0 -293
- package/dist/func/index.d.ts.map +0 -1
- package/dist/func/index.js +0 -298
- package/dist/func/index.js.map +0 -1
- package/dist/func/types.d.cts +0 -64
- package/dist/func/types.d.cts.map +0 -1
- package/dist/func/types.d.ts +0 -64
- package/dist/func/types.d.ts.map +0 -1
- package/dist/graph/annotation.cjs +0 -101
- package/dist/graph/annotation.cjs.map +0 -1
- package/dist/graph/annotation.d.cts +0 -116
- package/dist/graph/annotation.d.cts.map +0 -1
- package/dist/graph/annotation.d.ts +0 -116
- package/dist/graph/annotation.d.ts.map +0 -1
- package/dist/graph/annotation.js +0 -99
- package/dist/graph/annotation.js.map +0 -1
- package/dist/graph/graph.cjs +0 -423
- package/dist/graph/graph.cjs.map +0 -1
- package/dist/graph/graph.d.cts +0 -132
- package/dist/graph/graph.d.cts.map +0 -1
- package/dist/graph/graph.d.ts +0 -132
- package/dist/graph/graph.d.ts.map +0 -1
- package/dist/graph/graph.js +0 -420
- package/dist/graph/graph.js.map +0 -1
- package/dist/graph/index.cjs +0 -5
- package/dist/graph/index.js +0 -7
- package/dist/graph/message.cjs +0 -99
- package/dist/graph/message.cjs.map +0 -1
- package/dist/graph/message.d.cts +0 -40
- package/dist/graph/message.d.cts.map +0 -1
- package/dist/graph/message.d.ts +0 -40
- package/dist/graph/message.d.ts.map +0 -1
- package/dist/graph/message.js +0 -95
- package/dist/graph/message.js.map +0 -1
- package/dist/graph/messages_annotation.cjs +0 -110
- package/dist/graph/messages_annotation.cjs.map +0 -1
- package/dist/graph/messages_annotation.d.cts +0 -112
- package/dist/graph/messages_annotation.d.cts.map +0 -1
- package/dist/graph/messages_annotation.d.ts +0 -112
- package/dist/graph/messages_annotation.d.ts.map +0 -1
- package/dist/graph/messages_annotation.js +0 -107
- package/dist/graph/messages_annotation.js.map +0 -1
- package/dist/graph/state.cjs +0 -501
- package/dist/graph/state.cjs.map +0 -1
- package/dist/graph/state.d.cts +0 -236
- package/dist/graph/state.d.cts.map +0 -1
- package/dist/graph/state.d.ts +0 -236
- package/dist/graph/state.d.ts.map +0 -1
- package/dist/graph/state.js +0 -499
- package/dist/graph/state.js.map +0 -1
- package/dist/graph/zod/index.cjs +0 -10
- package/dist/graph/zod/index.d.cts +0 -3
- package/dist/graph/zod/index.d.ts +0 -3
- package/dist/graph/zod/index.js +0 -5
- package/dist/graph/zod/meta.cjs +0 -145
- package/dist/graph/zod/meta.cjs.map +0 -1
- package/dist/graph/zod/meta.d.cts +0 -116
- package/dist/graph/zod/meta.d.cts.map +0 -1
- package/dist/graph/zod/meta.d.ts +0 -116
- package/dist/graph/zod/meta.d.ts.map +0 -1
- package/dist/graph/zod/meta.js +0 -141
- package/dist/graph/zod/meta.js.map +0 -1
- package/dist/graph/zod/plugin.cjs +0 -41
- package/dist/graph/zod/plugin.cjs.map +0 -1
- package/dist/graph/zod/plugin.js +0 -41
- package/dist/graph/zod/plugin.js.map +0 -1
- package/dist/graph/zod/schema.cjs +0 -99
- package/dist/graph/zod/schema.cjs.map +0 -1
- package/dist/graph/zod/schema.d.cts +0 -38
- package/dist/graph/zod/schema.d.cts.map +0 -1
- package/dist/graph/zod/schema.d.ts +0 -38
- package/dist/graph/zod/schema.d.ts.map +0 -1
- package/dist/graph/zod/schema.js +0 -94
- package/dist/graph/zod/schema.js.map +0 -1
- package/dist/graph/zod/zod-registry.cjs +0 -43
- package/dist/graph/zod/zod-registry.cjs.map +0 -1
- package/dist/graph/zod/zod-registry.d.cts +0 -51
- package/dist/graph/zod/zod-registry.d.cts.map +0 -1
- package/dist/graph/zod/zod-registry.d.ts +0 -51
- package/dist/graph/zod/zod-registry.d.ts.map +0 -1
- package/dist/graph/zod/zod-registry.js +0 -41
- package/dist/graph/zod/zod-registry.js.map +0 -1
- package/dist/hash.cjs +0 -271
- package/dist/hash.cjs.map +0 -1
- package/dist/hash.js +0 -269
- package/dist/hash.js.map +0 -1
- package/dist/index.cjs +0 -112
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -26
- package/dist/index.d.ts +0 -26
- package/dist/index.js +0 -22
- package/dist/index.js.map +0 -1
- package/dist/interrupt.cjs +0 -82
- package/dist/interrupt.cjs.map +0 -1
- package/dist/interrupt.d.cts +0 -58
- package/dist/interrupt.d.cts.map +0 -1
- package/dist/interrupt.d.ts +0 -58
- package/dist/interrupt.d.ts.map +0 -1
- package/dist/interrupt.js +0 -81
- package/dist/interrupt.js.map +0 -1
- package/dist/prebuilt/agentName.cjs +0 -153
- package/dist/prebuilt/agentName.cjs.map +0 -1
- package/dist/prebuilt/agentName.d.cts +0 -42
- package/dist/prebuilt/agentName.d.cts.map +0 -1
- package/dist/prebuilt/agentName.d.ts +0 -42
- package/dist/prebuilt/agentName.d.ts.map +0 -1
- package/dist/prebuilt/agentName.js +0 -152
- package/dist/prebuilt/agentName.js.map +0 -1
- package/dist/prebuilt/agent_executor.cjs +0 -44
- package/dist/prebuilt/agent_executor.cjs.map +0 -1
- package/dist/prebuilt/agent_executor.d.cts +0 -58
- package/dist/prebuilt/agent_executor.d.cts.map +0 -1
- package/dist/prebuilt/agent_executor.d.ts +0 -58
- package/dist/prebuilt/agent_executor.d.ts.map +0 -1
- package/dist/prebuilt/agent_executor.js +0 -44
- package/dist/prebuilt/agent_executor.js.map +0 -1
- package/dist/prebuilt/chat_agent_executor.cjs +0 -68
- package/dist/prebuilt/chat_agent_executor.cjs.map +0 -1
- package/dist/prebuilt/chat_agent_executor.d.cts +0 -23
- package/dist/prebuilt/chat_agent_executor.d.cts.map +0 -1
- package/dist/prebuilt/chat_agent_executor.d.ts +0 -23
- package/dist/prebuilt/chat_agent_executor.d.ts.map +0 -1
- package/dist/prebuilt/chat_agent_executor.js +0 -67
- package/dist/prebuilt/chat_agent_executor.js.map +0 -1
- package/dist/prebuilt/index.cjs +0 -15
- package/dist/prebuilt/index.d.cts +0 -8
- package/dist/prebuilt/index.d.ts +0 -8
- package/dist/prebuilt/index.js +0 -8
- package/dist/prebuilt/interrupt.d.cts +0 -61
- package/dist/prebuilt/interrupt.d.cts.map +0 -1
- package/dist/prebuilt/interrupt.d.ts +0 -61
- package/dist/prebuilt/interrupt.d.ts.map +0 -1
- package/dist/prebuilt/react_agent_executor.cjs +0 -344
- package/dist/prebuilt/react_agent_executor.cjs.map +0 -1
- package/dist/prebuilt/react_agent_executor.d.cts +0 -230
- package/dist/prebuilt/react_agent_executor.d.cts.map +0 -1
- package/dist/prebuilt/react_agent_executor.d.ts +0 -230
- package/dist/prebuilt/react_agent_executor.d.ts.map +0 -1
- package/dist/prebuilt/react_agent_executor.js +0 -342
- package/dist/prebuilt/react_agent_executor.js.map +0 -1
- package/dist/prebuilt/tool_executor.cjs +0 -48
- package/dist/prebuilt/tool_executor.cjs.map +0 -1
- package/dist/prebuilt/tool_executor.d.cts +0 -42
- package/dist/prebuilt/tool_executor.d.cts.map +0 -1
- package/dist/prebuilt/tool_executor.d.ts +0 -42
- package/dist/prebuilt/tool_executor.d.ts.map +0 -1
- package/dist/prebuilt/tool_executor.js +0 -47
- package/dist/prebuilt/tool_executor.js.map +0 -1
- package/dist/prebuilt/tool_node.cjs +0 -248
- package/dist/prebuilt/tool_node.cjs.map +0 -1
- package/dist/prebuilt/tool_node.d.cts +0 -182
- package/dist/prebuilt/tool_node.d.cts.map +0 -1
- package/dist/prebuilt/tool_node.d.ts +0 -182
- package/dist/prebuilt/tool_node.d.ts.map +0 -1
- package/dist/prebuilt/tool_node.js +0 -246
- package/dist/prebuilt/tool_node.js.map +0 -1
- package/dist/pregel/algo.cjs +0 -573
- package/dist/pregel/algo.cjs.map +0 -1
- package/dist/pregel/algo.d.cts +0 -13
- package/dist/pregel/algo.d.cts.map +0 -1
- package/dist/pregel/algo.d.ts +0 -13
- package/dist/pregel/algo.d.ts.map +0 -1
- package/dist/pregel/algo.js +0 -567
- package/dist/pregel/algo.js.map +0 -1
- package/dist/pregel/call.cjs +0 -53
- package/dist/pregel/call.cjs.map +0 -1
- package/dist/pregel/call.js +0 -50
- package/dist/pregel/call.js.map +0 -1
- package/dist/pregel/debug.cjs +0 -175
- package/dist/pregel/debug.cjs.map +0 -1
- package/dist/pregel/debug.js +0 -169
- package/dist/pregel/debug.js.map +0 -1
- package/dist/pregel/index.cjs +0 -1170
- package/dist/pregel/index.cjs.map +0 -1
- package/dist/pregel/index.d.cts +0 -546
- package/dist/pregel/index.d.cts.map +0 -1
- package/dist/pregel/index.d.ts +0 -546
- package/dist/pregel/index.d.ts.map +0 -1
- package/dist/pregel/index.js +0 -1168
- package/dist/pregel/index.js.map +0 -1
- package/dist/pregel/io.cjs +0 -140
- package/dist/pregel/io.cjs.map +0 -1
- package/dist/pregel/io.js +0 -135
- package/dist/pregel/io.js.map +0 -1
- package/dist/pregel/loop.cjs +0 -548
- package/dist/pregel/loop.cjs.map +0 -1
- package/dist/pregel/loop.js +0 -547
- package/dist/pregel/loop.js.map +0 -1
- package/dist/pregel/messages.cjs +0 -108
- package/dist/pregel/messages.cjs.map +0 -1
- package/dist/pregel/messages.js +0 -107
- package/dist/pregel/messages.js.map +0 -1
- package/dist/pregel/read.cjs +0 -152
- package/dist/pregel/read.cjs.map +0 -1
- package/dist/pregel/read.d.cts +0 -51
- package/dist/pregel/read.d.cts.map +0 -1
- package/dist/pregel/read.d.ts +0 -51
- package/dist/pregel/read.d.ts.map +0 -1
- package/dist/pregel/read.js +0 -150
- package/dist/pregel/read.js.map +0 -1
- package/dist/pregel/remote.cjs +0 -349
- package/dist/pregel/remote.cjs.map +0 -1
- package/dist/pregel/remote.d.cts +0 -123
- package/dist/pregel/remote.d.cts.map +0 -1
- package/dist/pregel/remote.d.ts +0 -123
- package/dist/pregel/remote.d.ts.map +0 -1
- package/dist/pregel/remote.js +0 -348
- package/dist/pregel/remote.js.map +0 -1
- package/dist/pregel/retry.cjs +0 -92
- package/dist/pregel/retry.cjs.map +0 -1
- package/dist/pregel/retry.js +0 -92
- package/dist/pregel/retry.js.map +0 -1
- package/dist/pregel/runnable_types.d.cts +0 -49
- package/dist/pregel/runnable_types.d.cts.map +0 -1
- package/dist/pregel/runnable_types.d.ts +0 -49
- package/dist/pregel/runnable_types.d.ts.map +0 -1
- package/dist/pregel/runner.cjs +0 -228
- package/dist/pregel/runner.cjs.map +0 -1
- package/dist/pregel/runner.js +0 -228
- package/dist/pregel/runner.js.map +0 -1
- package/dist/pregel/stream.cjs +0 -199
- package/dist/pregel/stream.cjs.map +0 -1
- package/dist/pregel/stream.js +0 -196
- package/dist/pregel/stream.js.map +0 -1
- package/dist/pregel/types.cjs +0 -27
- package/dist/pregel/types.cjs.map +0 -1
- package/dist/pregel/types.d.cts +0 -453
- package/dist/pregel/types.d.cts.map +0 -1
- package/dist/pregel/types.d.ts +0 -453
- package/dist/pregel/types.d.ts.map +0 -1
- package/dist/pregel/types.js +0 -25
- package/dist/pregel/types.js.map +0 -1
- package/dist/pregel/utils/config.cjs +0 -122
- package/dist/pregel/utils/config.cjs.map +0 -1
- package/dist/pregel/utils/config.d.cts +0 -36
- package/dist/pregel/utils/config.d.cts.map +0 -1
- package/dist/pregel/utils/config.d.ts +0 -36
- package/dist/pregel/utils/config.d.ts.map +0 -1
- package/dist/pregel/utils/config.js +0 -115
- package/dist/pregel/utils/config.js.map +0 -1
- package/dist/pregel/utils/index.cjs +0 -103
- package/dist/pregel/utils/index.cjs.map +0 -1
- package/dist/pregel/utils/index.d.cts +0 -51
- package/dist/pregel/utils/index.d.cts.map +0 -1
- package/dist/pregel/utils/index.d.ts +0 -51
- package/dist/pregel/utils/index.d.ts.map +0 -1
- package/dist/pregel/utils/index.js +0 -97
- package/dist/pregel/utils/index.js.map +0 -1
- package/dist/pregel/utils/subgraph.cjs +0 -19
- package/dist/pregel/utils/subgraph.cjs.map +0 -1
- package/dist/pregel/utils/subgraph.js +0 -17
- package/dist/pregel/utils/subgraph.js.map +0 -1
- package/dist/pregel/validate.cjs +0 -45
- package/dist/pregel/validate.cjs.map +0 -1
- package/dist/pregel/validate.js +0 -44
- package/dist/pregel/validate.js.map +0 -1
- package/dist/pregel/write.cjs +0 -97
- package/dist/pregel/write.cjs.map +0 -1
- package/dist/pregel/write.d.cts +0 -35
- package/dist/pregel/write.d.cts.map +0 -1
- package/dist/pregel/write.d.ts +0 -35
- package/dist/pregel/write.d.ts.map +0 -1
- package/dist/pregel/write.js +0 -95
- package/dist/pregel/write.js.map +0 -1
- package/dist/remote.cjs +0 -3
- package/dist/remote.d.cts +0 -2
- package/dist/remote.d.ts +0 -2
- package/dist/remote.js +0 -3
- package/dist/setup/async_local_storage.cjs +0 -12
- package/dist/setup/async_local_storage.cjs.map +0 -1
- package/dist/setup/async_local_storage.js +0 -11
- package/dist/setup/async_local_storage.js.map +0 -1
- package/dist/utils.cjs +0 -88
- package/dist/utils.cjs.map +0 -1
- package/dist/utils.d.cts +0 -32
- package/dist/utils.d.cts.map +0 -1
- package/dist/utils.d.ts +0 -32
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -81
- package/dist/utils.js.map +0 -1
- package/dist/web.cjs +0 -96
- package/dist/web.d.cts +0 -23
- package/dist/web.d.ts +0 -23
- package/dist/web.js +0 -15
- package/dist/writer.cjs +0 -15
- package/dist/writer.cjs.map +0 -1
- package/dist/writer.d.cts +0 -7
- package/dist/writer.d.cts.map +0 -1
- package/dist/writer.d.ts +0 -7
- package/dist/writer.d.ts.map +0 -1
- package/dist/writer.js +0 -14
- package/dist/writer.js.map +0 -1
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { EmptyChannelError, InvalidUpdateError } from "../errors.js";
|
|
2
|
-
import { BaseChannel } from "./base.js";
|
|
3
|
-
|
|
4
|
-
//#region src/channels/last_value.ts
|
|
5
|
-
/**
|
|
6
|
-
* Stores the last value received, can receive at most one value per step.
|
|
7
|
-
*
|
|
8
|
-
* Since `update` is only called once per step and value can only be of length 1,
|
|
9
|
-
* LastValue always stores the last value of a single node. If multiple nodes attempt to
|
|
10
|
-
* write to this channel in a single step, an error will be thrown.
|
|
11
|
-
* @internal
|
|
12
|
-
*/
|
|
13
|
-
var LastValue = class LastValue extends BaseChannel {
|
|
14
|
-
lc_graph_name = "LastValue";
|
|
15
|
-
value = [];
|
|
16
|
-
constructor(initialValueFactory) {
|
|
17
|
-
super();
|
|
18
|
-
this.initialValueFactory = initialValueFactory;
|
|
19
|
-
if (initialValueFactory) this.value = [initialValueFactory()];
|
|
20
|
-
}
|
|
21
|
-
fromCheckpoint(checkpoint) {
|
|
22
|
-
const empty = new LastValue(this.initialValueFactory);
|
|
23
|
-
if (typeof checkpoint !== "undefined") empty.value = [checkpoint];
|
|
24
|
-
return empty;
|
|
25
|
-
}
|
|
26
|
-
update(values) {
|
|
27
|
-
if (values.length === 0) return false;
|
|
28
|
-
if (values.length !== 1) throw new InvalidUpdateError("LastValue can only receive one value per step.", { lc_error_code: "INVALID_CONCURRENT_GRAPH_UPDATE" });
|
|
29
|
-
this.value = [values[values.length - 1]];
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
get() {
|
|
33
|
-
if (this.value.length === 0) throw new EmptyChannelError();
|
|
34
|
-
return this.value[0];
|
|
35
|
-
}
|
|
36
|
-
checkpoint() {
|
|
37
|
-
if (this.value.length === 0) throw new EmptyChannelError();
|
|
38
|
-
return this.value[0];
|
|
39
|
-
}
|
|
40
|
-
isAvailable() {
|
|
41
|
-
return this.value.length !== 0;
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* Stores the last value received, but only made available after finish().
|
|
46
|
-
* Once made available, clears the value.
|
|
47
|
-
*/
|
|
48
|
-
var LastValueAfterFinish = class LastValueAfterFinish extends BaseChannel {
|
|
49
|
-
lc_graph_name = "LastValueAfterFinish";
|
|
50
|
-
value = [];
|
|
51
|
-
finished = false;
|
|
52
|
-
fromCheckpoint(checkpoint) {
|
|
53
|
-
const empty = new LastValueAfterFinish();
|
|
54
|
-
if (typeof checkpoint !== "undefined") {
|
|
55
|
-
const [value, finished] = checkpoint;
|
|
56
|
-
empty.value = [value];
|
|
57
|
-
empty.finished = finished;
|
|
58
|
-
}
|
|
59
|
-
return empty;
|
|
60
|
-
}
|
|
61
|
-
update(values) {
|
|
62
|
-
if (values.length === 0) return false;
|
|
63
|
-
this.finished = false;
|
|
64
|
-
this.value = [values[values.length - 1]];
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
get() {
|
|
68
|
-
if (this.value.length === 0 || !this.finished) throw new EmptyChannelError();
|
|
69
|
-
return this.value[0];
|
|
70
|
-
}
|
|
71
|
-
checkpoint() {
|
|
72
|
-
if (this.value.length === 0) return void 0;
|
|
73
|
-
return [this.value[0], this.finished];
|
|
74
|
-
}
|
|
75
|
-
consume() {
|
|
76
|
-
if (this.finished) {
|
|
77
|
-
this.finished = false;
|
|
78
|
-
this.value = [];
|
|
79
|
-
return true;
|
|
80
|
-
}
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
finish() {
|
|
84
|
-
if (!this.finished && this.value.length > 0) {
|
|
85
|
-
this.finished = true;
|
|
86
|
-
return true;
|
|
87
|
-
}
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
isAvailable() {
|
|
91
|
-
return this.value.length !== 0 && this.finished;
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
//#endregion
|
|
96
|
-
export { LastValue, LastValueAfterFinish };
|
|
97
|
-
//# sourceMappingURL=last_value.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"last_value.js","names":["initialValueFactory?: () => Value"],"sources":["../../src/channels/last_value.ts"],"sourcesContent":["import { EmptyChannelError, InvalidUpdateError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\n/**\n * Stores the last value received, can receive at most one value per step.\n *\n * Since `update` is only called once per step and value can only be of length 1,\n * LastValue always stores the last value of a single node. If multiple nodes attempt to\n * write to this channel in a single step, an error will be thrown.\n * @internal\n */\nexport class LastValue<Value> extends BaseChannel<Value, Value, Value> {\n lc_graph_name = \"LastValue\";\n\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [] = [];\n\n constructor(protected initialValueFactory?: () => Value) {\n super();\n if (initialValueFactory) {\n this.value = [initialValueFactory()];\n }\n }\n\n fromCheckpoint(checkpoint?: Value) {\n const empty = new LastValue<Value>(this.initialValueFactory);\n if (typeof checkpoint !== \"undefined\") {\n empty.value = [checkpoint];\n }\n\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n if (values.length === 0) {\n return false;\n }\n if (values.length !== 1) {\n throw new InvalidUpdateError(\n \"LastValue can only receive one value per step.\",\n { lc_error_code: \"INVALID_CONCURRENT_GRAPH_UPDATE\" }\n );\n }\n\n // eslint-disable-next-line prefer-destructuring\n this.value = [values[values.length - 1]];\n return true;\n }\n\n get(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n checkpoint(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n isAvailable(): boolean {\n return this.value.length !== 0;\n }\n}\n\n/**\n * Stores the last value received, but only made available after finish().\n * Once made available, clears the value.\n */\nexport class LastValueAfterFinish<Value> extends BaseChannel<\n Value,\n Value,\n [Value, boolean]\n> {\n lc_graph_name = \"LastValueAfterFinish\";\n\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [] = [];\n\n finished: boolean = false;\n\n fromCheckpoint(checkpoint?: [Value, boolean]) {\n const empty = new LastValueAfterFinish<Value>();\n if (typeof checkpoint !== \"undefined\") {\n const [value, finished] = checkpoint;\n empty.value = [value];\n empty.finished = finished;\n }\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n if (values.length === 0) {\n return false;\n }\n\n this.finished = false;\n // eslint-disable-next-line prefer-destructuring\n this.value = [values[values.length - 1]];\n return true;\n }\n\n get(): Value {\n if (this.value.length === 0 || !this.finished) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n checkpoint(): [Value, boolean] | undefined {\n if (this.value.length === 0) return undefined;\n return [this.value[0], this.finished];\n }\n\n consume(): boolean {\n if (this.finished) {\n this.finished = false;\n this.value = [];\n return true;\n }\n return false;\n }\n\n finish(): boolean {\n if (!this.finished && this.value.length > 0) {\n this.finished = true;\n return true;\n }\n return false;\n }\n\n isAvailable(): boolean {\n return this.value.length !== 0 && this.finished;\n }\n}\n"],"mappings":";;;;;;;;;;;;AAWA,IAAa,YAAb,MAAa,kBAAyB,YAAiC;CACrE,gBAAgB;CAGhB,QAAsB;CAEtB,YAAY,AAAUA,qBAAmC;AACvD;EADoB;AAEpB,MAAI,oBACF,MAAK,QAAQ,CAAC;;CAIlB,eAAe,YAAoB;EACjC,MAAM,QAAQ,IAAI,UAAiB,KAAK;AACxC,MAAI,OAAO,eAAe,YACxB,OAAM,QAAQ,CAAC;AAGjB,SAAO;;CAGT,OAAO,QAA0B;AAC/B,MAAI,OAAO,WAAW,EACpB,QAAO;AAET,MAAI,OAAO,WAAW,EACpB,OAAM,IAAI,mBACR,kDACA,EAAE,eAAe;AAKrB,OAAK,QAAQ,CAAC,OAAO,OAAO,SAAS;AACrC,SAAO;;CAGT,MAAa;AACX,MAAI,KAAK,MAAM,WAAW,EACxB,OAAM,IAAI;AAEZ,SAAO,KAAK,MAAM;;CAGpB,aAAoB;AAClB,MAAI,KAAK,MAAM,WAAW,EACxB,OAAM,IAAI;AAEZ,SAAO,KAAK,MAAM;;CAGpB,cAAuB;AACrB,SAAO,KAAK,MAAM,WAAW;;;;;;;AAQjC,IAAa,uBAAb,MAAa,6BAAoC,YAI/C;CACA,gBAAgB;CAGhB,QAAsB;CAEtB,WAAoB;CAEpB,eAAe,YAA+B;EAC5C,MAAM,QAAQ,IAAI;AAClB,MAAI,OAAO,eAAe,aAAa;GACrC,MAAM,CAAC,OAAO,YAAY;AAC1B,SAAM,QAAQ,CAAC;AACf,SAAM,WAAW;;AAEnB,SAAO;;CAGT,OAAO,QAA0B;AAC/B,MAAI,OAAO,WAAW,EACpB,QAAO;AAGT,OAAK,WAAW;AAEhB,OAAK,QAAQ,CAAC,OAAO,OAAO,SAAS;AACrC,SAAO;;CAGT,MAAa;AACX,MAAI,KAAK,MAAM,WAAW,KAAK,CAAC,KAAK,SACnC,OAAM,IAAI;AAEZ,SAAO,KAAK,MAAM;;CAGpB,aAA2C;AACzC,MAAI,KAAK,MAAM,WAAW,EAAG,QAAO;AACpC,SAAO,CAAC,KAAK,MAAM,IAAI,KAAK;;CAG9B,UAAmB;AACjB,MAAI,KAAK,UAAU;AACjB,QAAK,WAAW;AAChB,QAAK,QAAQ;AACb,UAAO;;AAET,SAAO;;CAGT,SAAkB;AAChB,MAAI,CAAC,KAAK,YAAY,KAAK,MAAM,SAAS,GAAG;AAC3C,QAAK,WAAW;AAChB,UAAO;;AAET,SAAO;;CAGT,cAAuB;AACrB,SAAO,KAAK,MAAM,WAAW,KAAK,KAAK"}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
const require_errors = require('../errors.cjs');
|
|
2
|
-
const require_base = require('./base.cjs');
|
|
3
|
-
|
|
4
|
-
//#region src/channels/named_barrier_value.ts
|
|
5
|
-
const areSetsEqual = (a, b) => a.size === b.size && [...a].every((value) => b.has(value));
|
|
6
|
-
/**
|
|
7
|
-
* A channel that waits until all named values are received before making the value available.
|
|
8
|
-
*
|
|
9
|
-
* This ensures that if node N and node M both write to channel C, the value of C will not be updated
|
|
10
|
-
* until N and M have completed updating.
|
|
11
|
-
*/
|
|
12
|
-
var NamedBarrierValue = class NamedBarrierValue extends require_base.BaseChannel {
|
|
13
|
-
lc_graph_name = "NamedBarrierValue";
|
|
14
|
-
names;
|
|
15
|
-
seen;
|
|
16
|
-
constructor(names) {
|
|
17
|
-
super();
|
|
18
|
-
this.names = names;
|
|
19
|
-
this.seen = /* @__PURE__ */ new Set();
|
|
20
|
-
}
|
|
21
|
-
fromCheckpoint(checkpoint) {
|
|
22
|
-
const empty = new NamedBarrierValue(this.names);
|
|
23
|
-
if (typeof checkpoint !== "undefined") empty.seen = new Set(checkpoint);
|
|
24
|
-
return empty;
|
|
25
|
-
}
|
|
26
|
-
update(values) {
|
|
27
|
-
let updated = false;
|
|
28
|
-
for (const nodeName of values) if (this.names.has(nodeName)) {
|
|
29
|
-
if (!this.seen.has(nodeName)) {
|
|
30
|
-
this.seen.add(nodeName);
|
|
31
|
-
updated = true;
|
|
32
|
-
}
|
|
33
|
-
} else throw new require_errors.InvalidUpdateError(`Value ${JSON.stringify(nodeName)} not in names ${JSON.stringify(this.names)}`);
|
|
34
|
-
return updated;
|
|
35
|
-
}
|
|
36
|
-
get() {
|
|
37
|
-
if (!areSetsEqual(this.names, this.seen)) throw new require_errors.EmptyChannelError();
|
|
38
|
-
return void 0;
|
|
39
|
-
}
|
|
40
|
-
checkpoint() {
|
|
41
|
-
return [...this.seen];
|
|
42
|
-
}
|
|
43
|
-
consume() {
|
|
44
|
-
if (this.seen && this.names && areSetsEqual(this.seen, this.names)) {
|
|
45
|
-
this.seen = /* @__PURE__ */ new Set();
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
isAvailable() {
|
|
51
|
-
return !!this.names && areSetsEqual(this.names, this.seen);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* A channel that waits until all named values are received before making the value ready to be made available.
|
|
56
|
-
* It is only made available after finish() is called.
|
|
57
|
-
* @internal
|
|
58
|
-
*/
|
|
59
|
-
var NamedBarrierValueAfterFinish = class NamedBarrierValueAfterFinish extends require_base.BaseChannel {
|
|
60
|
-
lc_graph_name = "NamedBarrierValueAfterFinish";
|
|
61
|
-
names;
|
|
62
|
-
seen;
|
|
63
|
-
finished;
|
|
64
|
-
constructor(names) {
|
|
65
|
-
super();
|
|
66
|
-
this.names = names;
|
|
67
|
-
this.seen = /* @__PURE__ */ new Set();
|
|
68
|
-
this.finished = false;
|
|
69
|
-
}
|
|
70
|
-
fromCheckpoint(checkpoint) {
|
|
71
|
-
const empty = new NamedBarrierValueAfterFinish(this.names);
|
|
72
|
-
if (typeof checkpoint !== "undefined") {
|
|
73
|
-
const [seen, finished] = checkpoint;
|
|
74
|
-
empty.seen = new Set(seen);
|
|
75
|
-
empty.finished = finished;
|
|
76
|
-
}
|
|
77
|
-
return empty;
|
|
78
|
-
}
|
|
79
|
-
update(values) {
|
|
80
|
-
let updated = false;
|
|
81
|
-
for (const nodeName of values) if (this.names.has(nodeName) && !this.seen.has(nodeName)) {
|
|
82
|
-
this.seen.add(nodeName);
|
|
83
|
-
updated = true;
|
|
84
|
-
} else if (!this.names.has(nodeName)) throw new require_errors.InvalidUpdateError(`Value ${JSON.stringify(nodeName)} not in names ${JSON.stringify(this.names)}`);
|
|
85
|
-
return updated;
|
|
86
|
-
}
|
|
87
|
-
get() {
|
|
88
|
-
if (!this.finished || !areSetsEqual(this.names, this.seen)) throw new require_errors.EmptyChannelError();
|
|
89
|
-
return void 0;
|
|
90
|
-
}
|
|
91
|
-
checkpoint() {
|
|
92
|
-
return [[...this.seen], this.finished];
|
|
93
|
-
}
|
|
94
|
-
consume() {
|
|
95
|
-
if (this.finished && this.seen && this.names && areSetsEqual(this.seen, this.names)) {
|
|
96
|
-
this.seen = /* @__PURE__ */ new Set();
|
|
97
|
-
this.finished = false;
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
finish() {
|
|
103
|
-
if (!this.finished && !!this.names && areSetsEqual(this.names, this.seen)) {
|
|
104
|
-
this.finished = true;
|
|
105
|
-
return true;
|
|
106
|
-
}
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
isAvailable() {
|
|
110
|
-
return this.finished && !!this.names && areSetsEqual(this.names, this.seen);
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
//#endregion
|
|
115
|
-
exports.NamedBarrierValue = NamedBarrierValue;
|
|
116
|
-
exports.NamedBarrierValueAfterFinish = NamedBarrierValueAfterFinish;
|
|
117
|
-
exports.areSetsEqual = areSetsEqual;
|
|
118
|
-
//# sourceMappingURL=named_barrier_value.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"named_barrier_value.cjs","names":["BaseChannel","InvalidUpdateError","EmptyChannelError"],"sources":["../../src/channels/named_barrier_value.ts"],"sourcesContent":["import { EmptyChannelError, InvalidUpdateError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\nexport const areSetsEqual = <T>(a: Set<T>, b: Set<T>) =>\n a.size === b.size && [...a].every((value) => b.has(value));\n\n/**\n * A channel that waits until all named values are received before making the value available.\n *\n * This ensures that if node N and node M both write to channel C, the value of C will not be updated\n * until N and M have completed updating.\n */\nexport class NamedBarrierValue<Value> extends BaseChannel<\n void,\n Value,\n Value[]\n> {\n lc_graph_name = \"NamedBarrierValue\";\n\n names: Set<Value>; // Names of nodes that we want to wait for.\n\n seen: Set<Value>;\n\n constructor(names: Set<Value>) {\n super();\n this.names = names;\n this.seen = new Set<Value>();\n }\n\n fromCheckpoint(checkpoint?: Value[]) {\n const empty = new NamedBarrierValue<Value>(this.names);\n if (typeof checkpoint !== \"undefined\") {\n empty.seen = new Set(checkpoint);\n }\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n let updated = false;\n for (const nodeName of values) {\n if (this.names.has(nodeName)) {\n if (!this.seen.has(nodeName)) {\n this.seen.add(nodeName);\n updated = true;\n }\n } else {\n throw new InvalidUpdateError(\n `Value ${JSON.stringify(nodeName)} not in names ${JSON.stringify(\n this.names\n )}`\n );\n }\n }\n return updated;\n }\n\n // If we have not yet seen all the node names we want to wait for,\n // throw an error to prevent continuing.\n get(): void {\n if (!areSetsEqual(this.names, this.seen)) {\n throw new EmptyChannelError();\n }\n return undefined;\n }\n\n checkpoint(): Value[] {\n return [...this.seen];\n }\n\n consume(): boolean {\n if (this.seen && this.names && areSetsEqual(this.seen, this.names)) {\n this.seen = new Set<Value>();\n return true;\n }\n return false;\n }\n\n isAvailable(): boolean {\n return !!this.names && areSetsEqual(this.names, this.seen);\n }\n}\n\n/**\n * A channel that waits until all named values are received before making the value ready to be made available.\n * It is only made available after finish() is called.\n * @internal\n */\nexport class NamedBarrierValueAfterFinish<Value> extends BaseChannel<\n void,\n Value,\n [Value[], boolean]\n> {\n lc_graph_name = \"NamedBarrierValueAfterFinish\";\n\n names: Set<Value>; // Names of nodes that we want to wait for.\n\n seen: Set<Value>;\n\n finished: boolean;\n\n constructor(names: Set<Value>) {\n super();\n this.names = names;\n this.seen = new Set<Value>();\n this.finished = false;\n }\n\n fromCheckpoint(checkpoint?: [Value[], boolean]) {\n const empty = new NamedBarrierValueAfterFinish<Value>(this.names);\n if (typeof checkpoint !== \"undefined\") {\n const [seen, finished] = checkpoint;\n empty.seen = new Set(seen);\n empty.finished = finished;\n }\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n let updated = false;\n for (const nodeName of values) {\n if (this.names.has(nodeName) && !this.seen.has(nodeName)) {\n this.seen.add(nodeName);\n updated = true;\n } else if (!this.names.has(nodeName)) {\n throw new InvalidUpdateError(\n `Value ${JSON.stringify(nodeName)} not in names ${JSON.stringify(\n this.names\n )}`\n );\n }\n }\n return updated;\n }\n\n get(): void {\n if (!this.finished || !areSetsEqual(this.names, this.seen)) {\n throw new EmptyChannelError();\n }\n return undefined;\n }\n\n checkpoint(): [Value[], boolean] {\n return [[...this.seen], this.finished];\n }\n\n consume(): boolean {\n if (\n this.finished &&\n this.seen &&\n this.names &&\n areSetsEqual(this.seen, this.names)\n ) {\n this.seen = new Set<Value>();\n this.finished = false;\n return true;\n }\n return false;\n }\n\n finish(): boolean {\n if (!this.finished && !!this.names && areSetsEqual(this.names, this.seen)) {\n this.finished = true;\n return true;\n }\n return false;\n }\n\n isAvailable(): boolean {\n return this.finished && !!this.names && areSetsEqual(this.names, this.seen);\n }\n}\n"],"mappings":";;;;AAGA,MAAa,gBAAmB,GAAW,MACzC,EAAE,SAAS,EAAE,QAAQ,CAAC,GAAG,GAAG,OAAO,UAAU,EAAE,IAAI;;;;;;;AAQrD,IAAa,oBAAb,MAAa,0BAAiCA,yBAI5C;CACA,gBAAgB;CAEhB;CAEA;CAEA,YAAY,OAAmB;AAC7B;AACA,OAAK,QAAQ;AACb,OAAK,uBAAO,IAAI;;CAGlB,eAAe,YAAsB;EACnC,MAAM,QAAQ,IAAI,kBAAyB,KAAK;AAChD,MAAI,OAAO,eAAe,YACxB,OAAM,OAAO,IAAI,IAAI;AAEvB,SAAO;;CAGT,OAAO,QAA0B;EAC/B,IAAI,UAAU;AACd,OAAK,MAAM,YAAY,OACrB,KAAI,KAAK,MAAM,IAAI,WACjB;OAAI,CAAC,KAAK,KAAK,IAAI,WAAW;AAC5B,SAAK,KAAK,IAAI;AACd,cAAU;;QAGZ,OAAM,IAAIC,kCACR,SAAS,KAAK,UAAU,UAAU,gBAAgB,KAAK,UACrD,KAAK;AAKb,SAAO;;CAKT,MAAY;AACV,MAAI,CAAC,aAAa,KAAK,OAAO,KAAK,MACjC,OAAM,IAAIC;AAEZ,SAAO;;CAGT,aAAsB;AACpB,SAAO,CAAC,GAAG,KAAK;;CAGlB,UAAmB;AACjB,MAAI,KAAK,QAAQ,KAAK,SAAS,aAAa,KAAK,MAAM,KAAK,QAAQ;AAClE,QAAK,uBAAO,IAAI;AAChB,UAAO;;AAET,SAAO;;CAGT,cAAuB;AACrB,SAAO,CAAC,CAAC,KAAK,SAAS,aAAa,KAAK,OAAO,KAAK;;;;;;;;AASzD,IAAa,+BAAb,MAAa,qCAA4CF,yBAIvD;CACA,gBAAgB;CAEhB;CAEA;CAEA;CAEA,YAAY,OAAmB;AAC7B;AACA,OAAK,QAAQ;AACb,OAAK,uBAAO,IAAI;AAChB,OAAK,WAAW;;CAGlB,eAAe,YAAiC;EAC9C,MAAM,QAAQ,IAAI,6BAAoC,KAAK;AAC3D,MAAI,OAAO,eAAe,aAAa;GACrC,MAAM,CAAC,MAAM,YAAY;AACzB,SAAM,OAAO,IAAI,IAAI;AACrB,SAAM,WAAW;;AAEnB,SAAO;;CAGT,OAAO,QAA0B;EAC/B,IAAI,UAAU;AACd,OAAK,MAAM,YAAY,OACrB,KAAI,KAAK,MAAM,IAAI,aAAa,CAAC,KAAK,KAAK,IAAI,WAAW;AACxD,QAAK,KAAK,IAAI;AACd,aAAU;aACD,CAAC,KAAK,MAAM,IAAI,UACzB,OAAM,IAAIC,kCACR,SAAS,KAAK,UAAU,UAAU,gBAAgB,KAAK,UACrD,KAAK;AAKb,SAAO;;CAGT,MAAY;AACV,MAAI,CAAC,KAAK,YAAY,CAAC,aAAa,KAAK,OAAO,KAAK,MACnD,OAAM,IAAIC;AAEZ,SAAO;;CAGT,aAAiC;AAC/B,SAAO,CAAC,CAAC,GAAG,KAAK,OAAO,KAAK;;CAG/B,UAAmB;AACjB,MACE,KAAK,YACL,KAAK,QACL,KAAK,SACL,aAAa,KAAK,MAAM,KAAK,QAC7B;AACA,QAAK,uBAAO,IAAI;AAChB,QAAK,WAAW;AAChB,UAAO;;AAET,SAAO;;CAGT,SAAkB;AAChB,MAAI,CAAC,KAAK,YAAY,CAAC,CAAC,KAAK,SAAS,aAAa,KAAK,OAAO,KAAK,OAAO;AACzE,QAAK,WAAW;AAChB,UAAO;;AAET,SAAO;;CAGT,cAAuB;AACrB,SAAO,KAAK,YAAY,CAAC,CAAC,KAAK,SAAS,aAAa,KAAK,OAAO,KAAK"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { BaseChannel } from "./base.cjs";
|
|
2
|
-
|
|
3
|
-
//#region src/channels/named_barrier_value.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* A channel that waits until all named values are received before making the value available.
|
|
7
|
-
*
|
|
8
|
-
* This ensures that if node N and node M both write to channel C, the value of C will not be updated
|
|
9
|
-
* until N and M have completed updating.
|
|
10
|
-
*/
|
|
11
|
-
declare class NamedBarrierValue<Value> extends BaseChannel<void, Value, Value[]> {
|
|
12
|
-
lc_graph_name: string;
|
|
13
|
-
names: Set<Value>; // Names of nodes that we want to wait for.
|
|
14
|
-
seen: Set<Value>;
|
|
15
|
-
constructor(names: Set<Value>);
|
|
16
|
-
fromCheckpoint(checkpoint?: Value[]): this;
|
|
17
|
-
update(values: Value[]): boolean;
|
|
18
|
-
// If we have not yet seen all the node names we want to wait for,
|
|
19
|
-
// throw an error to prevent continuing.
|
|
20
|
-
get(): void;
|
|
21
|
-
checkpoint(): Value[];
|
|
22
|
-
consume(): boolean;
|
|
23
|
-
isAvailable(): boolean;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* A channel that waits until all named values are received before making the value ready to be made available.
|
|
27
|
-
* It is only made available after finish() is called.
|
|
28
|
-
* @internal
|
|
29
|
-
*/
|
|
30
|
-
declare class NamedBarrierValueAfterFinish<Value> extends BaseChannel<void, Value, [Value[], boolean]> {
|
|
31
|
-
lc_graph_name: string;
|
|
32
|
-
names: Set<Value>; // Names of nodes that we want to wait for.
|
|
33
|
-
seen: Set<Value>;
|
|
34
|
-
finished: boolean;
|
|
35
|
-
constructor(names: Set<Value>);
|
|
36
|
-
fromCheckpoint(checkpoint?: [Value[], boolean]): this;
|
|
37
|
-
update(values: Value[]): boolean;
|
|
38
|
-
get(): void;
|
|
39
|
-
checkpoint(): [Value[], boolean];
|
|
40
|
-
consume(): boolean;
|
|
41
|
-
finish(): boolean;
|
|
42
|
-
isAvailable(): boolean;
|
|
43
|
-
}
|
|
44
|
-
//#endregion
|
|
45
|
-
export { NamedBarrierValue, NamedBarrierValueAfterFinish };
|
|
46
|
-
//# sourceMappingURL=named_barrier_value.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"named_barrier_value.d.cts","names":["BaseChannel","areSetsEqual","T","Set","NamedBarrierValue","Value","NamedBarrierValueAfterFinish"],"sources":["../../src/channels/named_barrier_value.d.ts"],"sourcesContent":["import { BaseChannel } from \"./base.js\";\nexport declare const areSetsEqual: <T>(a: Set<T>, b: Set<T>) => boolean;\n/**\n * A channel that waits until all named values are received before making the value available.\n *\n * This ensures that if node N and node M both write to channel C, the value of C will not be updated\n * until N and M have completed updating.\n */\nexport declare class NamedBarrierValue<Value> extends BaseChannel<void, Value, Value[]> {\n lc_graph_name: string;\n names: Set<Value>; // Names of nodes that we want to wait for.\n seen: Set<Value>;\n constructor(names: Set<Value>);\n fromCheckpoint(checkpoint?: Value[]): this;\n update(values: Value[]): boolean;\n // If we have not yet seen all the node names we want to wait for,\n // throw an error to prevent continuing.\n get(): void;\n checkpoint(): Value[];\n consume(): boolean;\n isAvailable(): boolean;\n}\n/**\n * A channel that waits until all named values are received before making the value ready to be made available.\n * It is only made available after finish() is called.\n * @internal\n */\nexport declare class NamedBarrierValueAfterFinish<Value> extends BaseChannel<void, Value, [\n Value[],\n boolean\n]> {\n lc_graph_name: string;\n names: Set<Value>; // Names of nodes that we want to wait for.\n seen: Set<Value>;\n finished: boolean;\n constructor(names: Set<Value>);\n fromCheckpoint(checkpoint?: [Value[], boolean]): this;\n update(values: Value[]): boolean;\n get(): void;\n checkpoint(): [Value[], boolean];\n consume(): boolean;\n finish(): boolean;\n isAvailable(): boolean;\n}\n"],"mappings":";;;;;AAQA;;;;;AAEWG,cAFUC,iBAEVD,CAAAA,KAAAA,CAAAA,SAF2CH,WAE3CG,CAAAA,IAAAA,EAF6DE,KAE7DF,EAFoEE,KAEpEF,EAAAA,CAAAA,CAAAA;eACGE,EAAAA,MAAAA;OAAJF,EADCA,GACDA,CADKE,KACLF,CAAAA,CAAAA,CAAAA;MACiBE,EADjBF,GACiBE,CADbA,KACaA,CAAAA;aAAJF,CAAAA,KAAAA,EAAAA,GAAAA,CAAIE,KAAJF,CAAAA;gBACSE,CAAAA,UAAAA,CAAAA,EAAAA,KAAAA,EAAAA,CAAAA,EAAAA,IAAAA;QACbA,CAAAA,MAAAA,EAAAA,KAAAA,EAAAA,CAAAA,EAAAA,OAAAA;;;;EAaEC,UAAAA,CAAAA,CAAAA,EATHD,KASGC,EAAAA;EAA4B,OAAA,CAAA,CAAA,EAAA,OAAA;aAAkCD,CAAAA,CAAAA,EAAAA,OAAAA;;;;;;;AAQ5DF,cARFG,4BAQEH,CAAAA,KAAAA,CAAAA,SAR0CH,WAQ1CG,CAAAA,IAAAA,EAR4DE,KAQ5DF,EAAAA,CAPnBE,KAQ6BA,EAAAA,SACdA;eAV8CL,EAAAA,MAAAA;SAKtDG,IAAIE;QACLF,IAAIE;;qBAESF,IAAIE;+BACMA;iBACdA;;iBAEAA"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { BaseChannel } from "./base.js";
|
|
2
|
-
|
|
3
|
-
//#region src/channels/named_barrier_value.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* A channel that waits until all named values are received before making the value available.
|
|
7
|
-
*
|
|
8
|
-
* This ensures that if node N and node M both write to channel C, the value of C will not be updated
|
|
9
|
-
* until N and M have completed updating.
|
|
10
|
-
*/
|
|
11
|
-
declare class NamedBarrierValue<Value> extends BaseChannel<void, Value, Value[]> {
|
|
12
|
-
lc_graph_name: string;
|
|
13
|
-
names: Set<Value>; // Names of nodes that we want to wait for.
|
|
14
|
-
seen: Set<Value>;
|
|
15
|
-
constructor(names: Set<Value>);
|
|
16
|
-
fromCheckpoint(checkpoint?: Value[]): this;
|
|
17
|
-
update(values: Value[]): boolean;
|
|
18
|
-
// If we have not yet seen all the node names we want to wait for,
|
|
19
|
-
// throw an error to prevent continuing.
|
|
20
|
-
get(): void;
|
|
21
|
-
checkpoint(): Value[];
|
|
22
|
-
consume(): boolean;
|
|
23
|
-
isAvailable(): boolean;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* A channel that waits until all named values are received before making the value ready to be made available.
|
|
27
|
-
* It is only made available after finish() is called.
|
|
28
|
-
* @internal
|
|
29
|
-
*/
|
|
30
|
-
declare class NamedBarrierValueAfterFinish<Value> extends BaseChannel<void, Value, [Value[], boolean]> {
|
|
31
|
-
lc_graph_name: string;
|
|
32
|
-
names: Set<Value>; // Names of nodes that we want to wait for.
|
|
33
|
-
seen: Set<Value>;
|
|
34
|
-
finished: boolean;
|
|
35
|
-
constructor(names: Set<Value>);
|
|
36
|
-
fromCheckpoint(checkpoint?: [Value[], boolean]): this;
|
|
37
|
-
update(values: Value[]): boolean;
|
|
38
|
-
get(): void;
|
|
39
|
-
checkpoint(): [Value[], boolean];
|
|
40
|
-
consume(): boolean;
|
|
41
|
-
finish(): boolean;
|
|
42
|
-
isAvailable(): boolean;
|
|
43
|
-
}
|
|
44
|
-
//#endregion
|
|
45
|
-
export { NamedBarrierValue, NamedBarrierValueAfterFinish };
|
|
46
|
-
//# sourceMappingURL=named_barrier_value.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"named_barrier_value.d.ts","names":["BaseChannel","areSetsEqual","T","Set","NamedBarrierValue","Value","NamedBarrierValueAfterFinish"],"sources":["../../src/channels/named_barrier_value.d.ts"],"sourcesContent":["import { BaseChannel } from \"./base.js\";\nexport declare const areSetsEqual: <T>(a: Set<T>, b: Set<T>) => boolean;\n/**\n * A channel that waits until all named values are received before making the value available.\n *\n * This ensures that if node N and node M both write to channel C, the value of C will not be updated\n * until N and M have completed updating.\n */\nexport declare class NamedBarrierValue<Value> extends BaseChannel<void, Value, Value[]> {\n lc_graph_name: string;\n names: Set<Value>; // Names of nodes that we want to wait for.\n seen: Set<Value>;\n constructor(names: Set<Value>);\n fromCheckpoint(checkpoint?: Value[]): this;\n update(values: Value[]): boolean;\n // If we have not yet seen all the node names we want to wait for,\n // throw an error to prevent continuing.\n get(): void;\n checkpoint(): Value[];\n consume(): boolean;\n isAvailable(): boolean;\n}\n/**\n * A channel that waits until all named values are received before making the value ready to be made available.\n * It is only made available after finish() is called.\n * @internal\n */\nexport declare class NamedBarrierValueAfterFinish<Value> extends BaseChannel<void, Value, [\n Value[],\n boolean\n]> {\n lc_graph_name: string;\n names: Set<Value>; // Names of nodes that we want to wait for.\n seen: Set<Value>;\n finished: boolean;\n constructor(names: Set<Value>);\n fromCheckpoint(checkpoint?: [Value[], boolean]): this;\n update(values: Value[]): boolean;\n get(): void;\n checkpoint(): [Value[], boolean];\n consume(): boolean;\n finish(): boolean;\n isAvailable(): boolean;\n}\n"],"mappings":";;;;;AAQA;;;;;AAEWG,cAFUC,iBAEVD,CAAAA,KAAAA,CAAAA,SAF2CH,WAE3CG,CAAAA,IAAAA,EAF6DE,KAE7DF,EAFoEE,KAEpEF,EAAAA,CAAAA,CAAAA;eACGE,EAAAA,MAAAA;OAAJF,EADCA,GACDA,CADKE,KACLF,CAAAA,CAAAA,CAAAA;MACiBE,EADjBF,GACiBE,CADbA,KACaA,CAAAA;aAAJF,CAAAA,KAAAA,EAAAA,GAAAA,CAAIE,KAAJF,CAAAA;gBACSE,CAAAA,UAAAA,CAAAA,EAAAA,KAAAA,EAAAA,CAAAA,EAAAA,IAAAA;QACbA,CAAAA,MAAAA,EAAAA,KAAAA,EAAAA,CAAAA,EAAAA,OAAAA;;;;EAaEC,UAAAA,CAAAA,CAAAA,EATHD,KASGC,EAAAA;EAA4B,OAAA,CAAA,CAAA,EAAA,OAAA;aAAkCD,CAAAA,CAAAA,EAAAA,OAAAA;;;;;;;AAQ5DF,cARFG,4BAQEH,CAAAA,KAAAA,CAAAA,SAR0CH,WAQ1CG,CAAAA,IAAAA,EAR4DE,KAQ5DF,EAAAA,CAPnBE,KAQ6BA,EAAAA,SACdA;eAV8CL,EAAAA,MAAAA;SAKtDG,IAAIE;QACLF,IAAIE;;qBAESF,IAAIE;+BACMA;iBACdA;;iBAEAA"}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { EmptyChannelError, InvalidUpdateError } from "../errors.js";
|
|
2
|
-
import { BaseChannel } from "./base.js";
|
|
3
|
-
|
|
4
|
-
//#region src/channels/named_barrier_value.ts
|
|
5
|
-
const areSetsEqual = (a, b) => a.size === b.size && [...a].every((value) => b.has(value));
|
|
6
|
-
/**
|
|
7
|
-
* A channel that waits until all named values are received before making the value available.
|
|
8
|
-
*
|
|
9
|
-
* This ensures that if node N and node M both write to channel C, the value of C will not be updated
|
|
10
|
-
* until N and M have completed updating.
|
|
11
|
-
*/
|
|
12
|
-
var NamedBarrierValue = class NamedBarrierValue extends BaseChannel {
|
|
13
|
-
lc_graph_name = "NamedBarrierValue";
|
|
14
|
-
names;
|
|
15
|
-
seen;
|
|
16
|
-
constructor(names) {
|
|
17
|
-
super();
|
|
18
|
-
this.names = names;
|
|
19
|
-
this.seen = /* @__PURE__ */ new Set();
|
|
20
|
-
}
|
|
21
|
-
fromCheckpoint(checkpoint) {
|
|
22
|
-
const empty = new NamedBarrierValue(this.names);
|
|
23
|
-
if (typeof checkpoint !== "undefined") empty.seen = new Set(checkpoint);
|
|
24
|
-
return empty;
|
|
25
|
-
}
|
|
26
|
-
update(values) {
|
|
27
|
-
let updated = false;
|
|
28
|
-
for (const nodeName of values) if (this.names.has(nodeName)) {
|
|
29
|
-
if (!this.seen.has(nodeName)) {
|
|
30
|
-
this.seen.add(nodeName);
|
|
31
|
-
updated = true;
|
|
32
|
-
}
|
|
33
|
-
} else throw new InvalidUpdateError(`Value ${JSON.stringify(nodeName)} not in names ${JSON.stringify(this.names)}`);
|
|
34
|
-
return updated;
|
|
35
|
-
}
|
|
36
|
-
get() {
|
|
37
|
-
if (!areSetsEqual(this.names, this.seen)) throw new EmptyChannelError();
|
|
38
|
-
return void 0;
|
|
39
|
-
}
|
|
40
|
-
checkpoint() {
|
|
41
|
-
return [...this.seen];
|
|
42
|
-
}
|
|
43
|
-
consume() {
|
|
44
|
-
if (this.seen && this.names && areSetsEqual(this.seen, this.names)) {
|
|
45
|
-
this.seen = /* @__PURE__ */ new Set();
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
isAvailable() {
|
|
51
|
-
return !!this.names && areSetsEqual(this.names, this.seen);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* A channel that waits until all named values are received before making the value ready to be made available.
|
|
56
|
-
* It is only made available after finish() is called.
|
|
57
|
-
* @internal
|
|
58
|
-
*/
|
|
59
|
-
var NamedBarrierValueAfterFinish = class NamedBarrierValueAfterFinish extends BaseChannel {
|
|
60
|
-
lc_graph_name = "NamedBarrierValueAfterFinish";
|
|
61
|
-
names;
|
|
62
|
-
seen;
|
|
63
|
-
finished;
|
|
64
|
-
constructor(names) {
|
|
65
|
-
super();
|
|
66
|
-
this.names = names;
|
|
67
|
-
this.seen = /* @__PURE__ */ new Set();
|
|
68
|
-
this.finished = false;
|
|
69
|
-
}
|
|
70
|
-
fromCheckpoint(checkpoint) {
|
|
71
|
-
const empty = new NamedBarrierValueAfterFinish(this.names);
|
|
72
|
-
if (typeof checkpoint !== "undefined") {
|
|
73
|
-
const [seen, finished] = checkpoint;
|
|
74
|
-
empty.seen = new Set(seen);
|
|
75
|
-
empty.finished = finished;
|
|
76
|
-
}
|
|
77
|
-
return empty;
|
|
78
|
-
}
|
|
79
|
-
update(values) {
|
|
80
|
-
let updated = false;
|
|
81
|
-
for (const nodeName of values) if (this.names.has(nodeName) && !this.seen.has(nodeName)) {
|
|
82
|
-
this.seen.add(nodeName);
|
|
83
|
-
updated = true;
|
|
84
|
-
} else if (!this.names.has(nodeName)) throw new InvalidUpdateError(`Value ${JSON.stringify(nodeName)} not in names ${JSON.stringify(this.names)}`);
|
|
85
|
-
return updated;
|
|
86
|
-
}
|
|
87
|
-
get() {
|
|
88
|
-
if (!this.finished || !areSetsEqual(this.names, this.seen)) throw new EmptyChannelError();
|
|
89
|
-
return void 0;
|
|
90
|
-
}
|
|
91
|
-
checkpoint() {
|
|
92
|
-
return [[...this.seen], this.finished];
|
|
93
|
-
}
|
|
94
|
-
consume() {
|
|
95
|
-
if (this.finished && this.seen && this.names && areSetsEqual(this.seen, this.names)) {
|
|
96
|
-
this.seen = /* @__PURE__ */ new Set();
|
|
97
|
-
this.finished = false;
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
finish() {
|
|
103
|
-
if (!this.finished && !!this.names && areSetsEqual(this.names, this.seen)) {
|
|
104
|
-
this.finished = true;
|
|
105
|
-
return true;
|
|
106
|
-
}
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
isAvailable() {
|
|
110
|
-
return this.finished && !!this.names && areSetsEqual(this.names, this.seen);
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
//#endregion
|
|
115
|
-
export { NamedBarrierValue, NamedBarrierValueAfterFinish, areSetsEqual };
|
|
116
|
-
//# sourceMappingURL=named_barrier_value.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"named_barrier_value.js","names":[],"sources":["../../src/channels/named_barrier_value.ts"],"sourcesContent":["import { EmptyChannelError, InvalidUpdateError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\nexport const areSetsEqual = <T>(a: Set<T>, b: Set<T>) =>\n a.size === b.size && [...a].every((value) => b.has(value));\n\n/**\n * A channel that waits until all named values are received before making the value available.\n *\n * This ensures that if node N and node M both write to channel C, the value of C will not be updated\n * until N and M have completed updating.\n */\nexport class NamedBarrierValue<Value> extends BaseChannel<\n void,\n Value,\n Value[]\n> {\n lc_graph_name = \"NamedBarrierValue\";\n\n names: Set<Value>; // Names of nodes that we want to wait for.\n\n seen: Set<Value>;\n\n constructor(names: Set<Value>) {\n super();\n this.names = names;\n this.seen = new Set<Value>();\n }\n\n fromCheckpoint(checkpoint?: Value[]) {\n const empty = new NamedBarrierValue<Value>(this.names);\n if (typeof checkpoint !== \"undefined\") {\n empty.seen = new Set(checkpoint);\n }\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n let updated = false;\n for (const nodeName of values) {\n if (this.names.has(nodeName)) {\n if (!this.seen.has(nodeName)) {\n this.seen.add(nodeName);\n updated = true;\n }\n } else {\n throw new InvalidUpdateError(\n `Value ${JSON.stringify(nodeName)} not in names ${JSON.stringify(\n this.names\n )}`\n );\n }\n }\n return updated;\n }\n\n // If we have not yet seen all the node names we want to wait for,\n // throw an error to prevent continuing.\n get(): void {\n if (!areSetsEqual(this.names, this.seen)) {\n throw new EmptyChannelError();\n }\n return undefined;\n }\n\n checkpoint(): Value[] {\n return [...this.seen];\n }\n\n consume(): boolean {\n if (this.seen && this.names && areSetsEqual(this.seen, this.names)) {\n this.seen = new Set<Value>();\n return true;\n }\n return false;\n }\n\n isAvailable(): boolean {\n return !!this.names && areSetsEqual(this.names, this.seen);\n }\n}\n\n/**\n * A channel that waits until all named values are received before making the value ready to be made available.\n * It is only made available after finish() is called.\n * @internal\n */\nexport class NamedBarrierValueAfterFinish<Value> extends BaseChannel<\n void,\n Value,\n [Value[], boolean]\n> {\n lc_graph_name = \"NamedBarrierValueAfterFinish\";\n\n names: Set<Value>; // Names of nodes that we want to wait for.\n\n seen: Set<Value>;\n\n finished: boolean;\n\n constructor(names: Set<Value>) {\n super();\n this.names = names;\n this.seen = new Set<Value>();\n this.finished = false;\n }\n\n fromCheckpoint(checkpoint?: [Value[], boolean]) {\n const empty = new NamedBarrierValueAfterFinish<Value>(this.names);\n if (typeof checkpoint !== \"undefined\") {\n const [seen, finished] = checkpoint;\n empty.seen = new Set(seen);\n empty.finished = finished;\n }\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n let updated = false;\n for (const nodeName of values) {\n if (this.names.has(nodeName) && !this.seen.has(nodeName)) {\n this.seen.add(nodeName);\n updated = true;\n } else if (!this.names.has(nodeName)) {\n throw new InvalidUpdateError(\n `Value ${JSON.stringify(nodeName)} not in names ${JSON.stringify(\n this.names\n )}`\n );\n }\n }\n return updated;\n }\n\n get(): void {\n if (!this.finished || !areSetsEqual(this.names, this.seen)) {\n throw new EmptyChannelError();\n }\n return undefined;\n }\n\n checkpoint(): [Value[], boolean] {\n return [[...this.seen], this.finished];\n }\n\n consume(): boolean {\n if (\n this.finished &&\n this.seen &&\n this.names &&\n areSetsEqual(this.seen, this.names)\n ) {\n this.seen = new Set<Value>();\n this.finished = false;\n return true;\n }\n return false;\n }\n\n finish(): boolean {\n if (!this.finished && !!this.names && areSetsEqual(this.names, this.seen)) {\n this.finished = true;\n return true;\n }\n return false;\n }\n\n isAvailable(): boolean {\n return this.finished && !!this.names && areSetsEqual(this.names, this.seen);\n }\n}\n"],"mappings":";;;;AAGA,MAAa,gBAAmB,GAAW,MACzC,EAAE,SAAS,EAAE,QAAQ,CAAC,GAAG,GAAG,OAAO,UAAU,EAAE,IAAI;;;;;;;AAQrD,IAAa,oBAAb,MAAa,0BAAiC,YAI5C;CACA,gBAAgB;CAEhB;CAEA;CAEA,YAAY,OAAmB;AAC7B;AACA,OAAK,QAAQ;AACb,OAAK,uBAAO,IAAI;;CAGlB,eAAe,YAAsB;EACnC,MAAM,QAAQ,IAAI,kBAAyB,KAAK;AAChD,MAAI,OAAO,eAAe,YACxB,OAAM,OAAO,IAAI,IAAI;AAEvB,SAAO;;CAGT,OAAO,QAA0B;EAC/B,IAAI,UAAU;AACd,OAAK,MAAM,YAAY,OACrB,KAAI,KAAK,MAAM,IAAI,WACjB;OAAI,CAAC,KAAK,KAAK,IAAI,WAAW;AAC5B,SAAK,KAAK,IAAI;AACd,cAAU;;QAGZ,OAAM,IAAI,mBACR,SAAS,KAAK,UAAU,UAAU,gBAAgB,KAAK,UACrD,KAAK;AAKb,SAAO;;CAKT,MAAY;AACV,MAAI,CAAC,aAAa,KAAK,OAAO,KAAK,MACjC,OAAM,IAAI;AAEZ,SAAO;;CAGT,aAAsB;AACpB,SAAO,CAAC,GAAG,KAAK;;CAGlB,UAAmB;AACjB,MAAI,KAAK,QAAQ,KAAK,SAAS,aAAa,KAAK,MAAM,KAAK,QAAQ;AAClE,QAAK,uBAAO,IAAI;AAChB,UAAO;;AAET,SAAO;;CAGT,cAAuB;AACrB,SAAO,CAAC,CAAC,KAAK,SAAS,aAAa,KAAK,OAAO,KAAK;;;;;;;;AASzD,IAAa,+BAAb,MAAa,qCAA4C,YAIvD;CACA,gBAAgB;CAEhB;CAEA;CAEA;CAEA,YAAY,OAAmB;AAC7B;AACA,OAAK,QAAQ;AACb,OAAK,uBAAO,IAAI;AAChB,OAAK,WAAW;;CAGlB,eAAe,YAAiC;EAC9C,MAAM,QAAQ,IAAI,6BAAoC,KAAK;AAC3D,MAAI,OAAO,eAAe,aAAa;GACrC,MAAM,CAAC,MAAM,YAAY;AACzB,SAAM,OAAO,IAAI,IAAI;AACrB,SAAM,WAAW;;AAEnB,SAAO;;CAGT,OAAO,QAA0B;EAC/B,IAAI,UAAU;AACd,OAAK,MAAM,YAAY,OACrB,KAAI,KAAK,MAAM,IAAI,aAAa,CAAC,KAAK,KAAK,IAAI,WAAW;AACxD,QAAK,KAAK,IAAI;AACd,aAAU;aACD,CAAC,KAAK,MAAM,IAAI,UACzB,OAAM,IAAI,mBACR,SAAS,KAAK,UAAU,UAAU,gBAAgB,KAAK,UACrD,KAAK;AAKb,SAAO;;CAGT,MAAY;AACV,MAAI,CAAC,KAAK,YAAY,CAAC,aAAa,KAAK,OAAO,KAAK,MACnD,OAAM,IAAI;AAEZ,SAAO;;CAGT,aAAiC;AAC/B,SAAO,CAAC,CAAC,GAAG,KAAK,OAAO,KAAK;;CAG/B,UAAmB;AACjB,MACE,KAAK,YACL,KAAK,QACL,KAAK,SACL,aAAa,KAAK,MAAM,KAAK,QAC7B;AACA,QAAK,uBAAO,IAAI;AAChB,QAAK,WAAW;AAChB,UAAO;;AAET,SAAO;;CAGT,SAAkB;AAChB,MAAI,CAAC,KAAK,YAAY,CAAC,CAAC,KAAK,SAAS,aAAa,KAAK,OAAO,KAAK,OAAO;AACzE,QAAK,WAAW;AAChB,UAAO;;AAET,SAAO;;CAGT,cAAuB;AACrB,SAAO,KAAK,YAAY,CAAC,CAAC,KAAK,SAAS,aAAa,KAAK,OAAO,KAAK"}
|
package/dist/channels/topic.cjs
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
const require_errors = require('../errors.cjs');
|
|
2
|
-
const require_base = require('./base.cjs');
|
|
3
|
-
|
|
4
|
-
//#region src/channels/topic.ts
|
|
5
|
-
/**
|
|
6
|
-
* A configurable PubSub Topic.
|
|
7
|
-
*/
|
|
8
|
-
var Topic = class Topic extends require_base.BaseChannel {
|
|
9
|
-
lc_graph_name = "Topic";
|
|
10
|
-
unique = false;
|
|
11
|
-
accumulate = false;
|
|
12
|
-
seen;
|
|
13
|
-
values;
|
|
14
|
-
constructor(fields) {
|
|
15
|
-
super();
|
|
16
|
-
this.unique = fields?.unique ?? this.unique;
|
|
17
|
-
this.accumulate = fields?.accumulate ?? this.accumulate;
|
|
18
|
-
this.seen = /* @__PURE__ */ new Set();
|
|
19
|
-
this.values = [];
|
|
20
|
-
}
|
|
21
|
-
fromCheckpoint(checkpoint) {
|
|
22
|
-
const empty = new Topic({
|
|
23
|
-
unique: this.unique,
|
|
24
|
-
accumulate: this.accumulate
|
|
25
|
-
});
|
|
26
|
-
if (typeof checkpoint !== "undefined") {
|
|
27
|
-
empty.seen = new Set(checkpoint[0]);
|
|
28
|
-
empty.values = checkpoint[1];
|
|
29
|
-
}
|
|
30
|
-
return empty;
|
|
31
|
-
}
|
|
32
|
-
update(values) {
|
|
33
|
-
let updated = false;
|
|
34
|
-
if (!this.accumulate) {
|
|
35
|
-
updated = this.values.length > 0;
|
|
36
|
-
this.values = [];
|
|
37
|
-
}
|
|
38
|
-
const flatValues = values.flat();
|
|
39
|
-
if (flatValues.length > 0) if (this.unique) {
|
|
40
|
-
for (const value of flatValues) if (!this.seen.has(value)) {
|
|
41
|
-
updated = true;
|
|
42
|
-
this.seen.add(value);
|
|
43
|
-
this.values.push(value);
|
|
44
|
-
}
|
|
45
|
-
} else {
|
|
46
|
-
updated = true;
|
|
47
|
-
this.values.push(...flatValues);
|
|
48
|
-
}
|
|
49
|
-
return updated;
|
|
50
|
-
}
|
|
51
|
-
get() {
|
|
52
|
-
if (this.values.length === 0) throw new require_errors.EmptyChannelError();
|
|
53
|
-
return this.values;
|
|
54
|
-
}
|
|
55
|
-
checkpoint() {
|
|
56
|
-
return [[...this.seen], this.values];
|
|
57
|
-
}
|
|
58
|
-
isAvailable() {
|
|
59
|
-
return this.values.length !== 0;
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
//#endregion
|
|
64
|
-
exports.Topic = Topic;
|
|
65
|
-
//# sourceMappingURL=topic.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"topic.cjs","names":["BaseChannel","EmptyChannelError"],"sources":["../../src/channels/topic.ts"],"sourcesContent":["import { EmptyChannelError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\n/**\n * A configurable PubSub Topic.\n */\nexport class Topic<Value> extends BaseChannel<\n Array<Value>,\n Value | Value[],\n [Value[], Value[]]\n> {\n lc_graph_name = \"Topic\";\n\n unique = false;\n\n accumulate = false;\n\n seen: Set<Value>;\n\n values: Value[];\n\n constructor(fields?: {\n /**\n * Whether to only add unique values to the topic. If `true`, only unique values (using reference equality) will be added to the topic.\n */\n unique?: boolean;\n /**\n * Whether to accumulate values across steps. If `false`, the channel will be emptied after each step.\n */\n accumulate?: boolean;\n }) {\n super();\n\n this.unique = fields?.unique ?? this.unique;\n this.accumulate = fields?.accumulate ?? this.accumulate;\n // State\n this.seen = new Set<Value>();\n this.values = [];\n }\n\n public fromCheckpoint(checkpoint?: [Value[], Value[]]) {\n const empty = new Topic<Value>({\n unique: this.unique,\n accumulate: this.accumulate,\n });\n if (typeof checkpoint !== \"undefined\") {\n empty.seen = new Set(checkpoint[0]);\n // eslint-disable-next-line prefer-destructuring\n empty.values = checkpoint[1];\n }\n return empty as this;\n }\n\n public update(values: Array<Value | Value[]>): boolean {\n let updated = false;\n if (!this.accumulate) {\n updated = this.values.length > 0;\n this.values = [];\n }\n const flatValues = values.flat() as Value[];\n if (flatValues.length > 0) {\n if (this.unique) {\n for (const value of flatValues) {\n if (!this.seen.has(value)) {\n updated = true;\n this.seen.add(value);\n this.values.push(value);\n }\n }\n } else {\n updated = true;\n this.values.push(...flatValues);\n }\n }\n return updated;\n }\n\n public get(): Array<Value> {\n if (this.values.length === 0) {\n throw new EmptyChannelError();\n }\n return this.values;\n }\n\n public checkpoint(): [Value[], Value[]] {\n return [[...this.seen], this.values];\n }\n\n isAvailable(): boolean {\n return this.values.length !== 0;\n }\n}\n"],"mappings":";;;;;;;AAMA,IAAa,QAAb,MAAa,cAAqBA,yBAIhC;CACA,gBAAgB;CAEhB,SAAS;CAET,aAAa;CAEb;CAEA;CAEA,YAAY,QAST;AACD;AAEA,OAAK,SAAS,QAAQ,UAAU,KAAK;AACrC,OAAK,aAAa,QAAQ,cAAc,KAAK;AAE7C,OAAK,uBAAO,IAAI;AAChB,OAAK,SAAS;;CAGhB,AAAO,eAAe,YAAiC;EACrD,MAAM,QAAQ,IAAI,MAAa;GAC7B,QAAQ,KAAK;GACb,YAAY,KAAK;;AAEnB,MAAI,OAAO,eAAe,aAAa;AACrC,SAAM,OAAO,IAAI,IAAI,WAAW;AAEhC,SAAM,SAAS,WAAW;;AAE5B,SAAO;;CAGT,AAAO,OAAO,QAAyC;EACrD,IAAI,UAAU;AACd,MAAI,CAAC,KAAK,YAAY;AACpB,aAAU,KAAK,OAAO,SAAS;AAC/B,QAAK,SAAS;;EAEhB,MAAM,aAAa,OAAO;AAC1B,MAAI,WAAW,SAAS,EACtB,KAAI,KAAK,QACP;QAAK,MAAM,SAAS,WAClB,KAAI,CAAC,KAAK,KAAK,IAAI,QAAQ;AACzB,cAAU;AACV,SAAK,KAAK,IAAI;AACd,SAAK,OAAO,KAAK;;SAGhB;AACL,aAAU;AACV,QAAK,OAAO,KAAK,GAAG;;AAGxB,SAAO;;CAGT,AAAO,MAAoB;AACzB,MAAI,KAAK,OAAO,WAAW,EACzB,OAAM,IAAIC;AAEZ,SAAO,KAAK;;CAGd,AAAO,aAAiC;AACtC,SAAO,CAAC,CAAC,GAAG,KAAK,OAAO,KAAK;;CAG/B,cAAuB;AACrB,SAAO,KAAK,OAAO,WAAW"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { BaseChannel } from "./base.cjs";
|
|
2
|
-
|
|
3
|
-
//#region src/channels/topic.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* A configurable PubSub Topic.
|
|
7
|
-
*/
|
|
8
|
-
declare class Topic<Value> extends BaseChannel<Array<Value>, Value | Value[], [Value[], Value[]]> {
|
|
9
|
-
lc_graph_name: string;
|
|
10
|
-
unique: boolean;
|
|
11
|
-
accumulate: boolean;
|
|
12
|
-
seen: Set<Value>;
|
|
13
|
-
values: Value[];
|
|
14
|
-
constructor(fields?: {
|
|
15
|
-
/**
|
|
16
|
-
* Whether to only add unique values to the topic. If `true`, only unique values (using reference equality) will be added to the topic.
|
|
17
|
-
*/
|
|
18
|
-
unique?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Whether to accumulate values across steps. If `false`, the channel will be emptied after each step.
|
|
21
|
-
*/
|
|
22
|
-
accumulate?: boolean;
|
|
23
|
-
});
|
|
24
|
-
fromCheckpoint(checkpoint?: [Value[], Value[]]): this;
|
|
25
|
-
update(values: Array<Value | Value[]>): boolean;
|
|
26
|
-
get(): Array<Value>;
|
|
27
|
-
checkpoint(): [Value[], Value[]];
|
|
28
|
-
isAvailable(): boolean;
|
|
29
|
-
}
|
|
30
|
-
//#endregion
|
|
31
|
-
export { Topic };
|
|
32
|
-
//# sourceMappingURL=topic.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"topic.d.cts","names":["BaseChannel","Topic","Value","Array","Set"],"sources":["../../src/channels/topic.d.ts"],"sourcesContent":["import { BaseChannel } from \"./base.js\";\n/**\n * A configurable PubSub Topic.\n */\nexport declare class Topic<Value> extends BaseChannel<Array<Value>, Value | Value[], [\n Value[],\n Value[]\n]> {\n lc_graph_name: string;\n unique: boolean;\n accumulate: boolean;\n seen: Set<Value>;\n values: Value[];\n constructor(fields?: {\n /**\n * Whether to only add unique values to the topic. If `true`, only unique values (using reference equality) will be added to the topic.\n */\n unique?: boolean;\n /**\n * Whether to accumulate values across steps. If `false`, the channel will be emptied after each step.\n */\n accumulate?: boolean;\n });\n fromCheckpoint(checkpoint?: [Value[], Value[]]): this;\n update(values: Array<Value | Value[]>): boolean;\n get(): Array<Value>;\n checkpoint(): [Value[], Value[]];\n isAvailable(): boolean;\n}\n"],"mappings":";;;;;;AAIA;AAA0B,cAALC,KAAK,CAAA,KAAA,CAAA,SAAgBD,WAAhB,CAA4BG,KAA5B,CAAkCD,KAAlC,CAAA,EAA0CA,KAA1C,GAAkDA,KAAlD,EAAA,EAAA,CACtBA,KADwDA,EAAAA,EAExDA,KAFkDC,EAAAA;eAAsBD,EAAAA,MAAAA;QACxEA,EAAAA,OAAAA;YACAA,EAAAA,OAAAA;MAKUA,EAAJE,GAAIF,CAAAA,KAAAA,CAAAA;QAAJE,EACEF,KADFE,EAAAA;aACEF,CAAAA,OAAAA,EAAAA;IAWqBA;;;IACAA,MAAAA,CAAAA,EAAAA,OAAAA;IAAdC;;;IAEAD,UAAAA,CAAAA,EAAAA,OAAAA;;gBAtBuBF,CAAAA,UAAAA,CAAAA,EAAAA,CAmBTE,KAnBSF,EAAAA,EAmBAE,KAnBAF,EAAAA,CAAAA,CAAAA,EAAAA,IAAAA;iBAoBvBG,MAAMD,QAAQA;SACtBC,MAAMD;iBACEA,SAASA"}
|
package/dist/channels/topic.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { BaseChannel } from "./base.js";
|
|
2
|
-
|
|
3
|
-
//#region src/channels/topic.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* A configurable PubSub Topic.
|
|
7
|
-
*/
|
|
8
|
-
declare class Topic<Value> extends BaseChannel<Array<Value>, Value | Value[], [Value[], Value[]]> {
|
|
9
|
-
lc_graph_name: string;
|
|
10
|
-
unique: boolean;
|
|
11
|
-
accumulate: boolean;
|
|
12
|
-
seen: Set<Value>;
|
|
13
|
-
values: Value[];
|
|
14
|
-
constructor(fields?: {
|
|
15
|
-
/**
|
|
16
|
-
* Whether to only add unique values to the topic. If `true`, only unique values (using reference equality) will be added to the topic.
|
|
17
|
-
*/
|
|
18
|
-
unique?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Whether to accumulate values across steps. If `false`, the channel will be emptied after each step.
|
|
21
|
-
*/
|
|
22
|
-
accumulate?: boolean;
|
|
23
|
-
});
|
|
24
|
-
fromCheckpoint(checkpoint?: [Value[], Value[]]): this;
|
|
25
|
-
update(values: Array<Value | Value[]>): boolean;
|
|
26
|
-
get(): Array<Value>;
|
|
27
|
-
checkpoint(): [Value[], Value[]];
|
|
28
|
-
isAvailable(): boolean;
|
|
29
|
-
}
|
|
30
|
-
//#endregion
|
|
31
|
-
export { Topic };
|
|
32
|
-
//# sourceMappingURL=topic.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"topic.d.ts","names":["BaseChannel","Topic","Value","Array","Set"],"sources":["../../src/channels/topic.d.ts"],"sourcesContent":["import { BaseChannel } from \"./base.js\";\n/**\n * A configurable PubSub Topic.\n */\nexport declare class Topic<Value> extends BaseChannel<Array<Value>, Value | Value[], [\n Value[],\n Value[]\n]> {\n lc_graph_name: string;\n unique: boolean;\n accumulate: boolean;\n seen: Set<Value>;\n values: Value[];\n constructor(fields?: {\n /**\n * Whether to only add unique values to the topic. If `true`, only unique values (using reference equality) will be added to the topic.\n */\n unique?: boolean;\n /**\n * Whether to accumulate values across steps. If `false`, the channel will be emptied after each step.\n */\n accumulate?: boolean;\n });\n fromCheckpoint(checkpoint?: [Value[], Value[]]): this;\n update(values: Array<Value | Value[]>): boolean;\n get(): Array<Value>;\n checkpoint(): [Value[], Value[]];\n isAvailable(): boolean;\n}\n"],"mappings":";;;;;;AAIA;AAA0B,cAALC,KAAK,CAAA,KAAA,CAAA,SAAgBD,WAAhB,CAA4BG,KAA5B,CAAkCD,KAAlC,CAAA,EAA0CA,KAA1C,GAAkDA,KAAlD,EAAA,EAAA,CACtBA,KADwDA,EAAAA,EAExDA,KAFkDC,EAAAA;eAAsBD,EAAAA,MAAAA;QACxEA,EAAAA,OAAAA;YACAA,EAAAA,OAAAA;MAKUA,EAAJE,GAAIF,CAAAA,KAAAA,CAAAA;QAAJE,EACEF,KADFE,EAAAA;aACEF,CAAAA,OAAAA,EAAAA;IAWqBA;;;IACAA,MAAAA,CAAAA,EAAAA,OAAAA;IAAdC;;;IAEAD,UAAAA,CAAAA,EAAAA,OAAAA;;gBAtBuBF,CAAAA,UAAAA,CAAAA,EAAAA,CAmBTE,KAnBSF,EAAAA,EAmBAE,KAnBAF,EAAAA,CAAAA,CAAAA,EAAAA,IAAAA;iBAoBvBG,MAAMD,QAAQA;SACtBC,MAAMD;iBACEA,SAASA"}
|