effect 4.0.0-beta.4 → 4.0.0-beta.6
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/Cause.d.ts +1 -1
- package/dist/Cause.d.ts.map +1 -1
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +6 -4
- package/dist/Channel.js.map +1 -1
- package/dist/Config.d.ts +1 -1
- package/dist/Data.d.ts +3 -2
- package/dist/Data.d.ts.map +1 -1
- package/dist/Data.js +9 -8
- package/dist/Data.js.map +1 -1
- package/dist/Effect.d.ts +0 -226
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +0 -118
- package/dist/Effect.js.map +1 -1
- package/dist/Encoding.d.ts +194 -0
- package/dist/Encoding.d.ts.map +1 -0
- package/dist/Encoding.js +352 -0
- package/dist/Encoding.js.map +1 -0
- package/dist/Equal.js.map +1 -1
- package/dist/FileSystem.d.ts +1 -1
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +5 -5
- package/dist/FileSystem.js.map +1 -1
- package/dist/Filter.d.ts +30 -1
- package/dist/Filter.d.ts.map +1 -1
- package/dist/Filter.js +15 -0
- package/dist/Filter.js.map +1 -1
- package/dist/Formatter.js +1 -1
- package/dist/Formatter.js.map +1 -1
- package/dist/Graph.d.ts.map +1 -1
- package/dist/Graph.js +2 -2
- package/dist/Graph.js.map +1 -1
- package/dist/Latch.d.ts +109 -0
- package/dist/Latch.d.ts.map +1 -0
- package/dist/Latch.js +72 -0
- package/dist/Latch.js.map +1 -0
- package/dist/Pipeable.d.ts +17 -0
- package/dist/Pipeable.d.ts.map +1 -1
- package/dist/Pipeable.js +19 -1
- package/dist/Pipeable.js.map +1 -1
- package/dist/PlatformError.d.ts +8 -7
- package/dist/PlatformError.d.ts.map +1 -1
- package/dist/PlatformError.js +2 -2
- package/dist/PlatformError.js.map +1 -1
- package/dist/Pool.d.ts +5 -3
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +6 -4
- package/dist/Pool.js.map +1 -1
- package/dist/PubSub.d.ts +3 -2
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +3 -2
- package/dist/PubSub.js.map +1 -1
- package/dist/Request.d.ts +1 -1
- package/dist/Request.d.ts.map +1 -1
- package/dist/Request.js +2 -1
- package/dist/Request.js.map +1 -1
- package/dist/RequestResolver.d.ts +0 -20
- package/dist/RequestResolver.d.ts.map +1 -1
- package/dist/RequestResolver.js +0 -20
- package/dist/RequestResolver.js.map +1 -1
- package/dist/Schedule.d.ts +2 -2
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +30 -16
- package/dist/Schedule.js.map +1 -1
- package/dist/Schema.d.ts +192 -42
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +385 -71
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaGetter.d.ts +2 -2
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +12 -14
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +44 -43
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +5 -2
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +37 -0
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +80 -0
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/Semaphore.d.ts +211 -0
- package/dist/Semaphore.d.ts.map +1 -0
- package/dist/{PartitionedSemaphore.js → Semaphore.js} +97 -13
- package/dist/Semaphore.js.map +1 -0
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +9 -8
- package/dist/Stream.js.map +1 -1
- package/dist/Struct.d.ts +16 -0
- package/dist/Struct.d.ts.map +1 -1
- package/dist/Struct.js +22 -0
- package/dist/Struct.js.map +1 -1
- package/dist/SubscriptionRef.d.ts +2 -1
- package/dist/SubscriptionRef.d.ts.map +1 -1
- package/dist/SubscriptionRef.js +2 -1
- package/dist/SubscriptionRef.js.map +1 -1
- package/dist/SynchronizedRef.d.ts +2 -1
- package/dist/SynchronizedRef.d.ts.map +1 -1
- package/dist/SynchronizedRef.js +2 -1
- package/dist/SynchronizedRef.js.map +1 -1
- package/dist/Types.d.ts +14 -6
- package/dist/Types.d.ts.map +1 -1
- package/dist/index.d.ts +14 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -5
- package/dist/index.js.map +1 -1
- package/dist/internal/core.js +11 -3
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/rcRef.js +2 -1
- package/dist/internal/rcRef.js.map +1 -1
- package/dist/testing/TestClock.d.ts +3 -2
- package/dist/testing/TestClock.d.ts.map +1 -1
- package/dist/testing/TestClock.js +5 -3
- package/dist/testing/TestClock.js.map +1 -1
- package/dist/unstable/ai/AiError.d.ts +39 -39
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/Chat.js +2 -1
- package/dist/unstable/ai/Chat.js.map +1 -1
- package/dist/unstable/ai/McpSchema.d.ts +51 -51
- package/dist/unstable/ai/Prompt.d.ts +20 -20
- package/dist/unstable/ai/Response.d.ts +25 -25
- package/dist/unstable/cli/CliError.d.ts +5 -5
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +2 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/Entity.d.ts +2 -1
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/Envelope.d.ts +1 -1
- package/dist/unstable/cluster/K8sHttpClient.d.ts +1 -1
- package/dist/unstable/cluster/Message.d.ts +5 -5
- package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/MessageStorage.js +2 -1
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Reply.d.ts +3 -3
- package/dist/unstable/cluster/Runner.d.ts +1 -1
- package/dist/unstable/cluster/Runners.d.ts.map +1 -1
- package/dist/unstable/cluster/Runners.js +4 -3
- package/dist/unstable/cluster/Runners.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +7 -5
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +4 -3
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/cluster/internal/entityReaper.js +2 -1
- package/dist/unstable/cluster/internal/entityReaper.js.map +1 -1
- package/dist/unstable/cluster/internal/resourceRef.js +2 -1
- package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.d.ts +36 -36
- package/dist/unstable/encoding/Sse.d.ts +1 -1
- package/dist/unstable/eventlog/EventJournal.d.ts +1 -1
- package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLog.js +2 -1
- package/dist/unstable/eventlog/EventLog.js.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts +5 -5
- package/dist/unstable/http/Cookies.d.ts +1 -1
- package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
- package/dist/unstable/http/HttpEffect.js +18 -26
- package/dist/unstable/http/HttpEffect.js.map +1 -1
- package/dist/unstable/http/Multipart.d.ts +2 -2
- package/dist/unstable/http/UrlParams.d.ts +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +2 -2
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.d.ts +6 -0
- package/dist/unstable/httpapi/HttpApiScalar.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.js.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.js +6 -6
- package/dist/unstable/persistence/KeyValueStore.js.map +1 -1
- package/dist/unstable/persistence/PersistedCache.d.ts +6 -5
- package/dist/unstable/persistence/PersistedCache.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedCache.js +2 -1
- package/dist/unstable/persistence/PersistedCache.js.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.js +6 -5
- package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.d.ts +6 -0
- package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +12 -9
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/Hydration.d.ts +39 -0
- package/dist/unstable/reactivity/Hydration.d.ts.map +1 -0
- package/dist/unstable/reactivity/Hydration.js +76 -0
- package/dist/unstable/reactivity/Hydration.js.map +1 -0
- package/dist/unstable/reactivity/index.d.ts +4 -0
- package/dist/unstable/reactivity/index.d.ts.map +1 -1
- package/dist/unstable/reactivity/index.js +4 -0
- package/dist/unstable/reactivity/index.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +3 -2
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +5 -3
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/rpc/Utils.d.ts.map +1 -1
- package/dist/unstable/rpc/Utils.js +2 -1
- package/dist/unstable/rpc/Utils.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +3 -2
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/sql/Statement.js +0 -1
- package/dist/unstable/sql/Statement.js.map +1 -1
- package/dist/unstable/workers/Worker.d.ts.map +1 -1
- package/dist/unstable/workers/Worker.js +2 -1
- package/dist/unstable/workers/Worker.js.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.js +2 -2
- package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts +2 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +2 -1
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +1 -2
- package/src/Cause.ts +1 -1
- package/src/Channel.ts +6 -4
- package/src/Data.ts +10 -9
- package/src/Effect.ts +0 -246
- package/src/Encoding.ts +879 -0
- package/src/Equal.ts +2 -2
- package/src/FileSystem.ts +7 -8
- package/src/Filter.ts +48 -1
- package/src/Formatter.ts +1 -1
- package/src/Graph.ts +8 -5
- package/src/Latch.ts +112 -0
- package/src/Pipeable.ts +32 -1
- package/src/PlatformError.ts +5 -5
- package/src/Pool.ts +9 -7
- package/src/PubSub.ts +10 -9
- package/src/Request.ts +3 -2
- package/src/RequestResolver.ts +0 -20
- package/src/Schedule.ts +217 -115
- package/src/Schema.ts +567 -105
- package/src/SchemaGetter.ts +12 -14
- package/src/SchemaRepresentation.ts +5 -2
- package/src/SchemaTransformation.ts +104 -0
- package/src/Semaphore.ts +356 -0
- package/src/Stream.ts +9 -8
- package/src/Struct.ts +26 -0
- package/src/SubscriptionRef.ts +3 -2
- package/src/SynchronizedRef.ts +3 -2
- package/src/Types.ts +12 -2
- package/src/index.ts +17 -6
- package/src/internal/core.ts +10 -2
- package/src/internal/effect.ts +3 -2
- package/src/internal/rcRef.ts +2 -1
- package/src/testing/TestClock.ts +8 -6
- package/src/unstable/ai/AiError.ts +1 -1
- package/src/unstable/ai/Chat.ts +2 -1
- package/src/unstable/ai/Prompt.ts +20 -20
- package/src/unstable/ai/Response.ts +22 -22
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +3 -2
- package/src/unstable/cluster/Entity.ts +2 -1
- package/src/unstable/cluster/Envelope.ts +1 -1
- package/src/unstable/cluster/MessageStorage.ts +2 -1
- package/src/unstable/cluster/Runners.ts +6 -5
- package/src/unstable/cluster/Sharding.ts +8 -6
- package/src/unstable/cluster/internal/entityManager.ts +6 -5
- package/src/unstable/cluster/internal/entityReaper.ts +2 -1
- package/src/unstable/cluster/internal/resourceRef.ts +2 -1
- package/src/unstable/eventlog/EventLog.ts +2 -1
- package/src/unstable/http/HttpEffect.ts +17 -25
- package/src/unstable/http/Multipart.ts +2 -2
- package/src/unstable/http/UrlParams.ts +1 -1
- package/src/unstable/httpapi/HttpApiBuilder.ts +2 -2
- package/src/unstable/httpapi/HttpApiScalar.ts +6 -0
- package/src/unstable/persistence/KeyValueStore.ts +6 -6
- package/src/unstable/persistence/PersistedCache.ts +20 -9
- package/src/unstable/persistence/PersistedQueue.ts +7 -6
- package/src/unstable/process/ChildProcessSpawner.ts +6 -0
- package/src/unstable/reactivity/Atom.ts +7 -5
- package/src/unstable/reactivity/Hydration.ts +112 -0
- package/src/unstable/reactivity/index.ts +5 -0
- package/src/unstable/rpc/RpcClient.ts +4 -3
- package/src/unstable/rpc/RpcServer.ts +6 -4
- package/src/unstable/rpc/Utils.ts +2 -1
- package/src/unstable/socket/Socket.ts +3 -2
- package/src/unstable/sql/Statement.ts +0 -1
- package/src/unstable/workers/Worker.ts +2 -1
- package/src/unstable/workflow/DurableDeferred.ts +2 -2
- package/src/unstable/workflow/WorkflowEngine.ts +3 -2
- package/dist/PartitionedSemaphore.d.ts +0 -52
- package/dist/PartitionedSemaphore.d.ts.map +0 -1
- package/dist/PartitionedSemaphore.js.map +0 -1
- package/dist/encoding/Base64.d.ts +0 -67
- package/dist/encoding/Base64.d.ts.map +0 -1
- package/dist/encoding/Base64.js +0 -146
- package/dist/encoding/Base64.js.map +0 -1
- package/dist/encoding/Base64Url.d.ts +0 -60
- package/dist/encoding/Base64Url.d.ts.map +0 -1
- package/dist/encoding/Base64Url.js +0 -89
- package/dist/encoding/Base64Url.js.map +0 -1
- package/dist/encoding/EncodingError.d.ts +0 -31
- package/dist/encoding/EncodingError.d.ts.map +0 -1
- package/dist/encoding/EncodingError.js +0 -22
- package/dist/encoding/EncodingError.js.map +0 -1
- package/dist/encoding/Hex.d.ts +0 -61
- package/dist/encoding/Hex.d.ts.map +0 -1
- package/dist/encoding/Hex.js +0 -115
- package/dist/encoding/Hex.js.map +0 -1
- package/dist/encoding/index.d.ts +0 -26
- package/dist/encoding/index.d.ts.map +0 -1
- package/dist/encoding/index.js +0 -27
- package/dist/encoding/index.js.map +0 -1
- package/src/PartitionedSemaphore.ts +0 -182
- package/src/encoding/Base64.ts +0 -366
- package/src/encoding/Base64Url.ts +0 -104
- package/src/encoding/EncodingError.ts +0 -35
- package/src/encoding/Hex.ts +0 -390
- package/src/encoding/index.ts +0 -31
package/src/Schedule.ts
CHANGED
|
@@ -36,7 +36,7 @@ import * as Duration from "./Duration.ts"
|
|
|
36
36
|
import type { Effect } from "./Effect.ts"
|
|
37
37
|
import type { LazyArg } from "./Function.ts"
|
|
38
38
|
import { constant, dual, identity } from "./Function.ts"
|
|
39
|
-
|
|
39
|
+
import { isEffect } from "./internal/core.ts"
|
|
40
40
|
import * as effect from "./internal/effect.ts"
|
|
41
41
|
import { type Pipeable, pipeArguments } from "./Pipeable.ts"
|
|
42
42
|
import { hasProperty } from "./Predicate.ts"
|
|
@@ -1140,116 +1140,211 @@ export const andThenResult: {
|
|
|
1140
1140
|
} = dual(2, <Output, Input, Error, Env, Output2, Input2, Error2, Env2>(
|
|
1141
1141
|
self: Schedule<Output, Input, Error, Env>,
|
|
1142
1142
|
other: Schedule<Output2, Input2, Error2, Env2>
|
|
1143
|
-
): Schedule<Result.Result<
|
|
1144
|
-
fromStep(effect.
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1143
|
+
): Schedule<Result.Result<Output, Output2>, Input & Input2, Error | Error2, Env | Env2> =>
|
|
1144
|
+
fromStep(effect.sync(() => {
|
|
1145
|
+
let currentSide = 0
|
|
1146
|
+
let currentStep:
|
|
1147
|
+
| undefined
|
|
1148
|
+
| ((now: number, input: Input & Input2) => Pull.Pull<
|
|
1149
|
+
[Result.Result<Output, Output2>, Duration.Duration],
|
|
1149
1150
|
Error | Error2,
|
|
1150
|
-
Output
|
|
1151
|
+
Result.Result<Output, Output2>,
|
|
1151
1152
|
Env | Env2
|
|
1152
|
-
>
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1153
|
+
>)
|
|
1154
|
+
const left = map(self, Result.succeed)
|
|
1155
|
+
const right = map(other, Result.fail)
|
|
1156
|
+
return function recur(
|
|
1157
|
+
now,
|
|
1158
|
+
input
|
|
1159
|
+
): Pull.Pull<
|
|
1160
|
+
[Result.Result<Output, Output2>, Duration.Duration],
|
|
1161
|
+
Error | Error2,
|
|
1162
|
+
Result.Result<Output, Output2>,
|
|
1163
|
+
Env | Env2
|
|
1164
|
+
> {
|
|
1165
|
+
if (currentStep) return currentStep(now, input)
|
|
1166
|
+
return toStep<
|
|
1167
|
+
/**
|
|
1168
|
+
* Returns a new `Schedule` that will first execute the left (i.e. `self`)
|
|
1169
|
+
* schedule to completion. Once the left schedule is complete, the right (i.e.
|
|
1170
|
+
* `other`) schedule will be executed to completion.
|
|
1171
|
+
*
|
|
1172
|
+
* The output of the resulting schedule is a `Result` where outputs of the
|
|
1173
|
+
* left schedule are emitted as `Result.Err<Output>` and outputs of the right
|
|
1174
|
+
* schedule are emitted as `Result.Ok<Output>`.
|
|
1175
|
+
*
|
|
1176
|
+
* @example
|
|
1177
|
+
* ```ts
|
|
1178
|
+
* import { Console, Effect, Result, Schedule } from "effect"
|
|
1179
|
+
*
|
|
1180
|
+
* // Track which phase of the schedule we're in
|
|
1181
|
+
* const phaseTracker = Schedule.andThenResult(
|
|
1182
|
+
* Schedule.exponential("100 millis").pipe(Schedule.take(2)),
|
|
1183
|
+
* Schedule.spaced("500 millis").pipe(Schedule.take(2))
|
|
1184
|
+
* )
|
|
1185
|
+
*
|
|
1186
|
+
* const program = Effect.gen(function*() {
|
|
1187
|
+
* yield* Effect.repeat(
|
|
1188
|
+
* Effect.gen(function*() {
|
|
1189
|
+
* yield* Console.log("Task executed")
|
|
1190
|
+
* return "task-result"
|
|
1191
|
+
* }),
|
|
1192
|
+
* phaseTracker.pipe(
|
|
1193
|
+
* Schedule.tapOutput((result) =>
|
|
1194
|
+
* Result.match(result, {
|
|
1195
|
+
* onFailure: (phase1Output) => Console.log(`Phase 1: ${phase1Output}`),
|
|
1196
|
+
* onSuccess: (phase2Output) => Console.log(`Phase 2: ${phase2Output}`)
|
|
1197
|
+
* })
|
|
1198
|
+
* )
|
|
1199
|
+
* )
|
|
1200
|
+
* )
|
|
1201
|
+
* })
|
|
1202
|
+
* ```
|
|
1203
|
+
*
|
|
1204
|
+
* @since 2.0.0
|
|
1205
|
+
* @category sequencing
|
|
1206
|
+
*/
|
|
1207
|
+
Result.Result<Output, Output2>,
|
|
1208
|
+
/**
|
|
1209
|
+
* Returns a new `Schedule` that will first execute the left (i.e. `self`)
|
|
1210
|
+
* schedule to completion. Once the left schedule is complete, the right (i.e.
|
|
1211
|
+
* `other`) schedule will be executed to completion.
|
|
1212
|
+
*
|
|
1213
|
+
* The output of the resulting schedule is a `Result` where outputs of the
|
|
1214
|
+
* left schedule are emitted as `Result.Err<Output>` and outputs of the right
|
|
1215
|
+
* schedule are emitted as `Result.Ok<Output>`.
|
|
1216
|
+
*
|
|
1217
|
+
* @example
|
|
1218
|
+
* ```ts
|
|
1219
|
+
* import { Console, Effect, Result, Schedule } from "effect"
|
|
1220
|
+
*
|
|
1221
|
+
* // Track which phase of the schedule we're in
|
|
1222
|
+
* const phaseTracker = Schedule.andThenResult(
|
|
1223
|
+
* Schedule.exponential("100 millis").pipe(Schedule.take(2)),
|
|
1224
|
+
* Schedule.spaced("500 millis").pipe(Schedule.take(2))
|
|
1225
|
+
* )
|
|
1226
|
+
*
|
|
1227
|
+
* const program = Effect.gen(function*() {
|
|
1228
|
+
* yield* Effect.repeat(
|
|
1229
|
+
* Effect.gen(function*() {
|
|
1230
|
+
* yield* Console.log("Task executed")
|
|
1231
|
+
* return "task-result"
|
|
1232
|
+
* }),
|
|
1233
|
+
* phaseTracker.pipe(
|
|
1234
|
+
* Schedule.tapOutput((result) =>
|
|
1235
|
+
* Result.match(result, {
|
|
1236
|
+
* onFailure: (phase1Output) => Console.log(`Phase 1: ${phase1Output}`),
|
|
1237
|
+
* onSuccess: (phase2Output) => Console.log(`Phase 2: ${phase2Output}`)
|
|
1238
|
+
* })
|
|
1239
|
+
* )
|
|
1240
|
+
* )
|
|
1241
|
+
* )
|
|
1242
|
+
* })
|
|
1243
|
+
* ```
|
|
1244
|
+
*
|
|
1245
|
+
* @since 2.0.0
|
|
1246
|
+
* @category sequencing
|
|
1247
|
+
*/
|
|
1248
|
+
Input & Input2,
|
|
1249
|
+
/**
|
|
1250
|
+
* Returns a new `Schedule` that will first execute the left (i.e. `self`)
|
|
1251
|
+
* schedule to completion. Once the left schedule is complete, the right (i.e.
|
|
1252
|
+
* `other`) schedule will be executed to completion.
|
|
1253
|
+
*
|
|
1254
|
+
* The output of the resulting schedule is a `Result` where outputs of the
|
|
1255
|
+
* left schedule are emitted as `Result.Err<Output>` and outputs of the right
|
|
1256
|
+
* schedule are emitted as `Result.Ok<Output>`.
|
|
1257
|
+
*
|
|
1258
|
+
* @example
|
|
1259
|
+
* ```ts
|
|
1260
|
+
* import { Console, Effect, Result, Schedule } from "effect"
|
|
1261
|
+
*
|
|
1262
|
+
* // Track which phase of the schedule we're in
|
|
1263
|
+
* const phaseTracker = Schedule.andThenResult(
|
|
1264
|
+
* Schedule.exponential("100 millis").pipe(Schedule.take(2)),
|
|
1265
|
+
* Schedule.spaced("500 millis").pipe(Schedule.take(2))
|
|
1266
|
+
* )
|
|
1267
|
+
*
|
|
1268
|
+
* const program = Effect.gen(function*() {
|
|
1269
|
+
* yield* Effect.repeat(
|
|
1270
|
+
* Effect.gen(function*() {
|
|
1271
|
+
* yield* Console.log("Task executed")
|
|
1272
|
+
* return "task-result"
|
|
1273
|
+
* }),
|
|
1274
|
+
* phaseTracker.pipe(
|
|
1275
|
+
* Schedule.tapOutput((result) =>
|
|
1276
|
+
* Result.match(result, {
|
|
1277
|
+
* onFailure: (phase1Output) => Console.log(`Phase 1: ${phase1Output}`),
|
|
1278
|
+
* onSuccess: (phase2Output) => Console.log(`Phase 2: ${phase2Output}`)
|
|
1279
|
+
* })
|
|
1280
|
+
* )
|
|
1281
|
+
* )
|
|
1282
|
+
* )
|
|
1283
|
+
* })
|
|
1284
|
+
* ```
|
|
1285
|
+
*
|
|
1286
|
+
* @since 2.0.0
|
|
1287
|
+
* @category sequencing
|
|
1288
|
+
*/
|
|
1289
|
+
Error | Error2,
|
|
1290
|
+
/**
|
|
1291
|
+
* Returns a new `Schedule` that will first execute the left (i.e. `self`)
|
|
1292
|
+
* schedule to completion. Once the left schedule is complete, the right (i.e.
|
|
1293
|
+
* `other`) schedule will be executed to completion.
|
|
1294
|
+
*
|
|
1295
|
+
* The output of the resulting schedule is a `Result` where outputs of the
|
|
1296
|
+
* left schedule are emitted as `Result.Err<Output>` and outputs of the right
|
|
1297
|
+
* schedule are emitted as `Result.Ok<Output>`.
|
|
1298
|
+
*
|
|
1299
|
+
* @example
|
|
1300
|
+
* ```ts
|
|
1301
|
+
* import { Console, Effect, Result, Schedule } from "effect"
|
|
1302
|
+
*
|
|
1303
|
+
* // Track which phase of the schedule we're in
|
|
1304
|
+
* const phaseTracker = Schedule.andThenResult(
|
|
1305
|
+
* Schedule.exponential("100 millis").pipe(Schedule.take(2)),
|
|
1306
|
+
* Schedule.spaced("500 millis").pipe(Schedule.take(2))
|
|
1307
|
+
* )
|
|
1308
|
+
*
|
|
1309
|
+
* const program = Effect.gen(function*() {
|
|
1310
|
+
* yield* Effect.repeat(
|
|
1311
|
+
* Effect.gen(function*() {
|
|
1312
|
+
* yield* Console.log("Task executed")
|
|
1313
|
+
* return "task-result"
|
|
1314
|
+
* }),
|
|
1315
|
+
* phaseTracker.pipe(
|
|
1316
|
+
* Schedule.tapOutput((result) =>
|
|
1317
|
+
* Result.match(result, {
|
|
1318
|
+
* onFailure: (phase1Output) => Console.log(`Phase 1: ${phase1Output}`),
|
|
1319
|
+
* onSuccess: (phase2Output) => Console.log(`Phase 2: ${phase2Output}`)
|
|
1320
|
+
* })
|
|
1321
|
+
* )
|
|
1322
|
+
* )
|
|
1323
|
+
* )
|
|
1324
|
+
* })
|
|
1325
|
+
* ```
|
|
1326
|
+
*
|
|
1327
|
+
* @since 2.0.0
|
|
1328
|
+
* @category sequencing
|
|
1329
|
+
*/
|
|
1330
|
+
Env | Env2
|
|
1331
|
+
>(currentSide === 0 ? left : right).pipe(
|
|
1332
|
+
effect.flatMap((step) => {
|
|
1333
|
+
currentSide++
|
|
1334
|
+
if (currentSide === 1) {
|
|
1335
|
+
currentStep = (now, input) =>
|
|
1336
|
+
Pull.catchDone(step(now, input), (_) => {
|
|
1337
|
+
currentStep = undefined
|
|
1338
|
+
return recur(now, input)
|
|
1339
|
+
})
|
|
1340
|
+
return currentStep(now, input)
|
|
1341
|
+
}
|
|
1342
|
+
currentStep = step
|
|
1343
|
+
return currentStep(now, input)
|
|
1344
|
+
})
|
|
1345
|
+
);
|
|
1346
|
+
};
|
|
1347
|
+
})))
|
|
1253
1348
|
|
|
1254
1349
|
/**
|
|
1255
1350
|
* Combines two `Schedule`s by recurring if both of the two schedules want
|
|
@@ -4050,7 +4145,7 @@ export const map: {
|
|
|
4050
4145
|
* @since 2.0.0
|
|
4051
4146
|
* @category mapping
|
|
4052
4147
|
*/
|
|
4053
|
-
<Output, Output2, Error2 = never, Env2 = never>(f: (output: Output) => Effect<Output2, Error2, Env2>): <Input, Error, Env>(
|
|
4148
|
+
<Output, Output2, Error2 = never, Env2 = never>(f: (output: Output) => Output2 | Effect<Output2, Error2, Env2>): <Input, Error, Env>(
|
|
4054
4149
|
self: Schedule<Output, Input, Error, Env>
|
|
4055
4150
|
) => Schedule<Output2, Input, Error | Error2, Env | Env2>
|
|
4056
4151
|
/**
|
|
@@ -4117,17 +4212,24 @@ export const map: {
|
|
|
4117
4212
|
*/
|
|
4118
4213
|
<Output, Input, Error, Env, Output2, Error2 = never, Env2 = never>(
|
|
4119
4214
|
self: Schedule<Output, Input, Error, Env>,
|
|
4120
|
-
f: (output: Output) => Effect<Output2, Error2, Env2>
|
|
4215
|
+
f: (output: Output) => Output2 | Effect<Output2, Error2, Env2>
|
|
4121
4216
|
): Schedule<Output2, Input, Error | Error2, Env | Env2>
|
|
4122
4217
|
} = dual(2, <Output, Input, Error, Env, Output2, Error2 = never, Env2 = never>(
|
|
4123
4218
|
self: Schedule<Output, Input, Error, Env>,
|
|
4124
|
-
f: (output: Output) => Effect<Output2, Error2, Env2>
|
|
4219
|
+
f: (output: Output) => Output2 | Effect<Output2, Error2, Env2>
|
|
4125
4220
|
): Schedule<Output2, Input, Error | Error2, Env | Env2> => {
|
|
4126
4221
|
const handle = Pull.matchEffect({
|
|
4127
|
-
onSuccess: ([output, duration]: [Output, Duration.Duration]) =>
|
|
4128
|
-
|
|
4222
|
+
onSuccess: ([output, duration]: [Output, Duration.Duration]) => {
|
|
4223
|
+
const result = f(output)
|
|
4224
|
+
if (!isEffect(result)) return effect.succeed([result, duration] as [Output2, Duration.Duration])
|
|
4225
|
+
return effect.map(result, (output) => [output, duration] as [Output2, Duration.Duration])
|
|
4226
|
+
},
|
|
4129
4227
|
onFailure: effect.failCause<Error>,
|
|
4130
|
-
onDone: (output: Output) =>
|
|
4228
|
+
onDone: (output: Output) => {
|
|
4229
|
+
const result = f(output)
|
|
4230
|
+
if (!isEffect(result)) return Cause.done(result as Output2)
|
|
4231
|
+
return effect.flatMap(result, Cause.done)
|
|
4232
|
+
}
|
|
4131
4233
|
})
|
|
4132
4234
|
return fromStep(effect.map(toStep(self), (step) => (now, input) => handle(step(now, input))))
|
|
4133
4235
|
})
|