effect 4.0.0-beta.6 → 4.0.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Cache.d.ts +2 -2
- package/dist/Cache.d.ts.map +1 -1
- package/dist/Cache.js +1 -1
- package/dist/Cache.js.map +1 -1
- package/dist/Combiner.d.ts +280 -13
- package/dist/Combiner.d.ts.map +1 -1
- package/dist/Combiner.js +198 -7
- package/dist/Combiner.js.map +1 -1
- package/dist/Config.d.ts +2 -2
- package/dist/Config.js +3 -3
- package/dist/Config.js.map +1 -1
- package/dist/DateTime.d.ts +23 -161
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/DateTime.js +6 -51
- package/dist/DateTime.js.map +1 -1
- package/dist/Duration.d.ts +12 -12
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +12 -12
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +13 -13
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +1 -1
- package/dist/Effect.js.map +1 -1
- package/dist/Formatter.d.ts +131 -47
- package/dist/Formatter.d.ts.map +1 -1
- package/dist/Formatter.js +228 -50
- package/dist/Formatter.js.map +1 -1
- package/dist/JsonSchema.d.ts +299 -10
- package/dist/JsonSchema.d.ts.map +1 -1
- package/dist/JsonSchema.js +323 -4
- package/dist/JsonSchema.js.map +1 -1
- package/dist/LayerMap.d.ts +4 -4
- package/dist/LayerMap.d.ts.map +1 -1
- package/dist/LogLevel.d.ts +27 -0
- package/dist/LogLevel.d.ts.map +1 -1
- package/dist/LogLevel.js +28 -100
- package/dist/LogLevel.js.map +1 -1
- package/dist/Logger.d.ts +4 -4
- package/dist/Logger.d.ts.map +1 -1
- package/dist/Metric.d.ts +2 -2
- package/dist/Metric.d.ts.map +1 -1
- package/dist/Metric.js +1 -1
- package/dist/Metric.js.map +1 -1
- package/dist/Pool.d.ts +1 -1
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +1 -1
- package/dist/Pool.js.map +1 -1
- package/dist/Random.d.ts +1 -1
- package/dist/Random.d.ts.map +1 -1
- package/dist/Random.js +3 -12
- package/dist/Random.js.map +1 -1
- package/dist/RcMap.d.ts +2 -2
- package/dist/RcMap.d.ts.map +1 -1
- package/dist/RcMap.js +1 -1
- package/dist/RcMap.js.map +1 -1
- package/dist/RcRef.d.ts +1 -1
- package/dist/RcRef.d.ts.map +1 -1
- package/dist/Reducer.d.ts +166 -7
- package/dist/Reducer.d.ts.map +1 -1
- package/dist/Reducer.js +135 -1
- package/dist/Reducer.js.map +1 -1
- package/dist/RequestResolver.d.ts +6 -6
- package/dist/RequestResolver.d.ts.map +1 -1
- package/dist/RequestResolver.js.map +1 -1
- package/dist/Schedule.d.ts +20 -11
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +23 -9
- package/dist/Schedule.js.map +1 -1
- package/dist/Schema.d.ts +4 -4
- package/dist/Schema.d.ts.map +1 -1
- package/dist/ScopedCache.d.ts +2 -2
- package/dist/ScopedCache.d.ts.map +1 -1
- package/dist/ScopedCache.js +1 -1
- package/dist/ScopedCache.js.map +1 -1
- package/dist/Stream.d.ts +19 -19
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +3 -3
- package/dist/Stream.js.map +1 -1
- package/dist/index.d.ts +258 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +258 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/dateTime.js +3 -11
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +2 -2
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/random.d.ts +2 -0
- package/dist/internal/random.d.ts.map +1 -0
- package/dist/internal/random.js +13 -0
- package/dist/internal/random.js.map +1 -0
- package/dist/internal/rcRef.js +1 -1
- package/dist/internal/rcRef.js.map +1 -1
- package/dist/testing/TestClock.d.ts +4 -4
- package/dist/testing/TestClock.d.ts.map +1 -1
- package/dist/testing/TestClock.js +1 -1
- package/dist/testing/TestClock.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +6 -6
- package/dist/testing/TestSchema.d.ts.map +1 -1
- package/dist/unstable/ai/AiError.d.ts +10 -10
- package/dist/unstable/ai/AiError.d.ts.map +1 -1
- package/dist/unstable/ai/Chat.d.ts +3 -3
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/Chat.js +2 -2
- package/dist/unstable/ai/Chat.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts +2 -2
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts +1 -1
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/Prompt.d.ts +17 -17
- package/dist/unstable/ai/Prompt.d.ts.map +1 -1
- package/dist/unstable/ai/Response.d.ts +23 -23
- package/dist/unstable/ai/Response.d.ts.map +1 -1
- package/dist/unstable/ai/Response.js +1 -1
- package/dist/unstable/ai/Response.js.map +1 -1
- package/dist/unstable/cluster/ClusterCron.d.ts +1 -1
- package/dist/unstable/cluster/ClusterCron.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterCron.js +1 -1
- package/dist/unstable/cluster/ClusterCron.js.map +1 -1
- package/dist/unstable/cluster/Entity.d.ts +3 -3
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/EntityResource.d.ts +2 -2
- package/dist/unstable/cluster/EntityResource.d.ts.map +1 -1
- package/dist/unstable/cluster/K8sHttpClient.js +1 -1
- package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts +2 -2
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +1 -1
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.d.ts +21 -21
- package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.js +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +1 -1
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/encoding/Sse.d.ts +2 -2
- package/dist/unstable/encoding/Sse.d.ts.map +1 -1
- package/dist/unstable/encoding/Sse.js.map +1 -1
- package/dist/unstable/http/Cookies.d.ts +1 -1
- package/dist/unstable/http/Cookies.d.ts.map +1 -1
- package/dist/unstable/http/Cookies.js +2 -2
- package/dist/unstable/http/Cookies.js.map +1 -1
- package/dist/unstable/http/HttpClient.d.ts +4 -4
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.d.ts +11 -11
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +8 -1
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpMethod.d.ts +4 -4
- package/dist/unstable/http/HttpMethod.d.ts.map +1 -1
- package/dist/unstable/http/HttpMethod.js +3 -3
- package/dist/unstable/http/HttpMethod.js.map +1 -1
- package/dist/unstable/observability/Otlp.d.ts +12 -12
- package/dist/unstable/observability/Otlp.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.d.ts +2 -2
- package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +1 -1
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/observability/OtlpLogger.d.ts +4 -4
- package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.d.ts +4 -4
- package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpTracer.d.ts +4 -4
- package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/unstable/persistence/Persistable.d.ts +2 -2
- package/dist/unstable/persistence/Persistable.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.d.ts +12 -12
- package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.js +6 -6
- package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
- package/dist/unstable/persistence/Persistence.d.ts +1 -1
- package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
- package/dist/unstable/persistence/Persistence.js +2 -2
- package/dist/unstable/persistence/Persistence.js.map +1 -1
- package/dist/unstable/persistence/RateLimiter.d.ts +3 -3
- package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/unstable/persistence/RateLimiter.js +1 -1
- package/dist/unstable/persistence/RateLimiter.js.map +1 -1
- package/dist/unstable/process/ChildProcess.d.ts +2 -2
- package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts +6 -6
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +3 -3
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.js +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.js +1 -1
- package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts +2 -2
- package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts +5 -26
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +3 -11
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts +4 -4
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/sql/SqlModel.d.ts +2 -2
- package/dist/unstable/sql/SqlModel.d.ts.map +1 -1
- package/dist/unstable/sql/SqlModel.js +3 -3
- package/dist/unstable/sql/SqlModel.js.map +1 -1
- package/dist/unstable/sql/SqlSchema.d.ts +16 -5
- package/dist/unstable/sql/SqlSchema.d.ts.map +1 -1
- package/dist/unstable/sql/SqlSchema.js +17 -7
- package/dist/unstable/sql/SqlSchema.js.map +1 -1
- package/dist/unstable/workflow/DurableClock.d.ts +3 -3
- package/dist/unstable/workflow/DurableClock.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableClock.js +3 -3
- package/dist/unstable/workflow/DurableClock.js.map +1 -1
- package/package.json +1 -1
- package/src/Cache.ts +3 -3
- package/src/Combiner.ts +280 -13
- package/src/Config.ts +3 -3
- package/src/DateTime.ts +24 -164
- package/src/Duration.ts +15 -15
- package/src/Effect.ts +15 -15
- package/src/Formatter.ts +252 -50
- package/src/JsonSchema.ts +383 -10
- package/src/LayerMap.ts +5 -5
- package/src/LogLevel.ts +31 -0
- package/src/Logger.ts +5 -5
- package/src/Metric.ts +4 -4
- package/src/Pool.ts +4 -4
- package/src/Random.ts +5 -14
- package/src/RcMap.ts +5 -5
- package/src/RcRef.ts +1 -1
- package/src/Reducer.ts +166 -7
- package/src/RequestResolver.ts +9 -9
- package/src/Schedule.ts +44 -25
- package/src/Schema.ts +4 -4
- package/src/ScopedCache.ts +3 -3
- package/src/Stream.ts +34 -34
- package/src/index.ts +258 -0
- package/src/internal/dateTime.ts +9 -30
- package/src/internal/effect.ts +21 -21
- package/src/internal/random.ts +20 -0
- package/src/internal/rcRef.ts +2 -2
- package/src/testing/TestClock.ts +5 -5
- package/src/testing/TestSchema.ts +8 -8
- package/src/unstable/ai/AiError.ts +1 -1
- package/src/unstable/ai/Chat.ts +10 -10
- package/src/unstable/ai/LanguageModel.ts +3 -3
- package/src/unstable/ai/McpServer.ts +2 -2
- package/src/unstable/ai/Prompt.ts +17 -17
- package/src/unstable/ai/Response.ts +23 -23
- package/src/unstable/cluster/ClusterCron.ts +2 -2
- package/src/unstable/cluster/Entity.ts +5 -5
- package/src/unstable/cluster/EntityResource.ts +4 -4
- package/src/unstable/cluster/K8sHttpClient.ts +1 -1
- package/src/unstable/cluster/MessageStorage.ts +1 -4
- package/src/unstable/cluster/Sharding.ts +3 -3
- package/src/unstable/cluster/ShardingConfig.ts +10 -11
- package/src/unstable/cluster/SqlRunnerStorage.ts +1 -1
- package/src/unstable/cluster/internal/entityManager.ts +3 -3
- package/src/unstable/encoding/Sse.ts +2 -4
- package/src/unstable/http/Cookies.ts +3 -3
- package/src/unstable/http/HttpClient.ts +4 -4
- package/src/unstable/http/HttpClientRequest.ts +15 -11
- package/src/unstable/http/HttpMethod.ts +16 -4
- package/src/unstable/observability/Otlp.ts +12 -12
- package/src/unstable/observability/OtlpExporter.ts +3 -3
- package/src/unstable/observability/OtlpLogger.ts +4 -4
- package/src/unstable/observability/OtlpMetrics.ts +4 -4
- package/src/unstable/observability/OtlpTracer.ts +4 -4
- package/src/unstable/persistence/Persistable.ts +2 -2
- package/src/unstable/persistence/PersistedQueue.ts +18 -18
- package/src/unstable/persistence/Persistence.ts +3 -3
- package/src/unstable/persistence/RateLimiter.ts +4 -4
- package/src/unstable/process/ChildProcess.ts +2 -2
- package/src/unstable/reactivity/Atom.ts +13 -13
- package/src/unstable/reactivity/AtomHttpApi.ts +3 -3
- package/src/unstable/reactivity/AtomRpc.ts +3 -3
- package/src/unstable/rpc/Rpc.ts +3 -3
- package/src/unstable/rpc/RpcClient.ts +8 -51
- package/src/unstable/socket/Socket.ts +4 -4
- package/src/unstable/sql/SqlModel.ts +5 -5
- package/src/unstable/sql/SqlSchema.ts +41 -25
- package/src/unstable/workflow/DurableClock.ts +8 -8
package/src/Stream.ts
CHANGED
|
@@ -472,7 +472,7 @@ export const fromEffectSchedule = <A, E, R, X, AS extends A, ES, RS>(
|
|
|
472
472
|
* @since 2.0.0
|
|
473
473
|
* @category Constructors
|
|
474
474
|
*/
|
|
475
|
-
export const tick = (interval: Duration.
|
|
475
|
+
export const tick = (interval: Duration.Input): Stream<void> =>
|
|
476
476
|
fromPull(Effect.sync(() => {
|
|
477
477
|
let first = true
|
|
478
478
|
const effect = Effect.succeed(Arr.of<void>(undefined))
|
|
@@ -3317,7 +3317,7 @@ export const timeout: {
|
|
|
3317
3317
|
* @since 2.0.0
|
|
3318
3318
|
* @category Rate Limiting
|
|
3319
3319
|
*/
|
|
3320
|
-
(duration: Duration.
|
|
3320
|
+
(duration: Duration.Input): <A, E, R>(self: Stream<A, E, R>) => Stream<A, E, R>
|
|
3321
3321
|
/**
|
|
3322
3322
|
* Ends the stream if it does not produce a value within the specified duration.
|
|
3323
3323
|
*
|
|
@@ -3341,10 +3341,10 @@ export const timeout: {
|
|
|
3341
3341
|
* @since 2.0.0
|
|
3342
3342
|
* @category Rate Limiting
|
|
3343
3343
|
*/
|
|
3344
|
-
<A, E, R>(self: Stream<A, E, R>, duration: Duration.
|
|
3344
|
+
<A, E, R>(self: Stream<A, E, R>, duration: Duration.Input): Stream<A, E, R>
|
|
3345
3345
|
} = dual(
|
|
3346
3346
|
2,
|
|
3347
|
-
<A, E, R>(self: Stream<A, E, R>, duration: Duration.
|
|
3347
|
+
<A, E, R>(self: Stream<A, E, R>, duration: Duration.Input): Stream<A, E, R> =>
|
|
3348
3348
|
transformPull(self, (pull, _scope) =>
|
|
3349
3349
|
Effect.succeed(Effect.timeoutOrElse(pull, {
|
|
3350
3350
|
duration,
|
|
@@ -12175,7 +12175,7 @@ export const debounce: {
|
|
|
12175
12175
|
* @since 2.0.0
|
|
12176
12176
|
* @category Rate Limiting
|
|
12177
12177
|
*/
|
|
12178
|
-
(duration: Duration.
|
|
12178
|
+
(duration: Duration.Input): <A, E, R>(self: Stream<A, E, R>) => Stream<A, E, R>
|
|
12179
12179
|
/**
|
|
12180
12180
|
* Drops earlier elements within the debounce window and emits only the latest element after the pause.
|
|
12181
12181
|
*
|
|
@@ -12199,15 +12199,15 @@ export const debounce: {
|
|
|
12199
12199
|
* @since 2.0.0
|
|
12200
12200
|
* @category Rate Limiting
|
|
12201
12201
|
*/
|
|
12202
|
-
<A, E, R>(self: Stream<A, E, R>, duration: Duration.
|
|
12202
|
+
<A, E, R>(self: Stream<A, E, R>, duration: Duration.Input): Stream<A, E, R>
|
|
12203
12203
|
} = dual(
|
|
12204
12204
|
2,
|
|
12205
|
-
<A, E, R>(self: Stream<A, E, R>, duration: Duration.
|
|
12205
|
+
<A, E, R>(self: Stream<A, E, R>, duration: Duration.Input): Stream<A, E, R> =>
|
|
12206
12206
|
transformPull(
|
|
12207
12207
|
self,
|
|
12208
12208
|
Effect.fnUntraced(function*(pull, scope) {
|
|
12209
12209
|
const clock = yield* Clock
|
|
12210
|
-
const durationMs = Duration.toMillis(Duration.
|
|
12210
|
+
const durationMs = Duration.toMillis(Duration.fromInputUnsafe(duration))
|
|
12211
12211
|
let lastArr: Arr.NonEmptyReadonlyArray<A> | undefined
|
|
12212
12212
|
let cause: Cause.Cause<Cause.Done | E> | undefined
|
|
12213
12213
|
let emitAtMs = Infinity
|
|
@@ -12347,7 +12347,7 @@ export const throttleEffect: {
|
|
|
12347
12347
|
options: {
|
|
12348
12348
|
readonly cost: (arr: Arr.NonEmptyReadonlyArray<A>) => Effect.Effect<number, E2, R2>
|
|
12349
12349
|
readonly units: number
|
|
12350
|
-
readonly duration: Duration.
|
|
12350
|
+
readonly duration: Duration.Input
|
|
12351
12351
|
readonly burst?: number | undefined
|
|
12352
12352
|
readonly strategy?: "enforce" | "shape" | undefined
|
|
12353
12353
|
}
|
|
@@ -12393,7 +12393,7 @@ export const throttleEffect: {
|
|
|
12393
12393
|
options: {
|
|
12394
12394
|
readonly cost: (arr: Arr.NonEmptyReadonlyArray<A>) => Effect.Effect<number, E2, R2>
|
|
12395
12395
|
readonly units: number
|
|
12396
|
-
readonly duration: Duration.
|
|
12396
|
+
readonly duration: Duration.Input
|
|
12397
12397
|
readonly burst?: number | undefined
|
|
12398
12398
|
readonly strategy?: "enforce" | "shape" | undefined
|
|
12399
12399
|
}
|
|
@@ -12405,7 +12405,7 @@ export const throttleEffect: {
|
|
|
12405
12405
|
options: {
|
|
12406
12406
|
readonly cost: (arr: Arr.NonEmptyReadonlyArray<A>) => Effect.Effect<number, E2, R2>
|
|
12407
12407
|
readonly units: number
|
|
12408
|
-
readonly duration: Duration.
|
|
12408
|
+
readonly duration: Duration.Input
|
|
12409
12409
|
readonly burst?: number | undefined
|
|
12410
12410
|
readonly strategy?: "enforce" | "shape" | undefined
|
|
12411
12411
|
}
|
|
@@ -12422,12 +12422,12 @@ const throttleEnforceEffect = <A, E, R, E2, R2>(
|
|
|
12422
12422
|
self: Stream<A, E, R>,
|
|
12423
12423
|
cost: (arr: Arr.NonEmptyReadonlyArray<A>) => Effect.Effect<number, E2, R2>,
|
|
12424
12424
|
units: number,
|
|
12425
|
-
duration: Duration.
|
|
12425
|
+
duration: Duration.Input,
|
|
12426
12426
|
burst: number
|
|
12427
12427
|
): Stream<A, E | E2, R | R2> =>
|
|
12428
12428
|
transformPull(self, (pull) =>
|
|
12429
12429
|
Effect.clockWith((clock) => {
|
|
12430
|
-
const durationMs = Duration.toMillis(Duration.
|
|
12430
|
+
const durationMs = Duration.toMillis(Duration.fromInputUnsafe(duration))
|
|
12431
12431
|
const max = units + burst < 0 ? Number.POSITIVE_INFINITY : units + burst
|
|
12432
12432
|
let tokens = units
|
|
12433
12433
|
let timestampMs = clock.currentTimeMillisUnsafe()
|
|
@@ -12458,12 +12458,12 @@ const throttleShapeEffect = <A, E, R, E2, R2>(
|
|
|
12458
12458
|
self: Stream<A, E, R>,
|
|
12459
12459
|
cost: (arr: Arr.NonEmptyReadonlyArray<A>) => Effect.Effect<number, E2, R2>,
|
|
12460
12460
|
units: number,
|
|
12461
|
-
duration: Duration.
|
|
12461
|
+
duration: Duration.Input,
|
|
12462
12462
|
burst: number
|
|
12463
12463
|
): Stream<A, E | E2, R | R2> =>
|
|
12464
12464
|
transformPull(self, (pull) =>
|
|
12465
12465
|
Effect.clockWith((clock) => {
|
|
12466
|
-
const durationMs = Duration.toMillis(Duration.
|
|
12466
|
+
const durationMs = Duration.toMillis(Duration.fromInputUnsafe(duration))
|
|
12467
12467
|
const max = units + burst < 0 ? Number.POSITIVE_INFINITY : units + burst
|
|
12468
12468
|
let tokens = units
|
|
12469
12469
|
let timestampMs = clock.currentTimeMillisUnsafe()
|
|
@@ -12576,7 +12576,7 @@ export const throttle: {
|
|
|
12576
12576
|
options: {
|
|
12577
12577
|
readonly cost: (arr: Arr.NonEmptyReadonlyArray<A>) => number
|
|
12578
12578
|
readonly units: number
|
|
12579
|
-
readonly duration: Duration.
|
|
12579
|
+
readonly duration: Duration.Input
|
|
12580
12580
|
readonly burst?: number | undefined
|
|
12581
12581
|
readonly strategy?: "enforce" | "shape" | undefined
|
|
12582
12582
|
}
|
|
@@ -12621,7 +12621,7 @@ export const throttle: {
|
|
|
12621
12621
|
options: {
|
|
12622
12622
|
readonly cost: (arr: Arr.NonEmptyReadonlyArray<A>) => number
|
|
12623
12623
|
readonly units: number
|
|
12624
|
-
readonly duration: Duration.
|
|
12624
|
+
readonly duration: Duration.Input
|
|
12625
12625
|
readonly burst?: number | undefined
|
|
12626
12626
|
readonly strategy?: "enforce" | "shape" | undefined
|
|
12627
12627
|
}
|
|
@@ -12633,7 +12633,7 @@ export const throttle: {
|
|
|
12633
12633
|
options: {
|
|
12634
12634
|
readonly cost: (arr: Arr.NonEmptyReadonlyArray<A>) => number
|
|
12635
12635
|
readonly units: number
|
|
12636
|
-
readonly duration: Duration.
|
|
12636
|
+
readonly duration: Duration.Input
|
|
12637
12637
|
readonly burst?: number | undefined
|
|
12638
12638
|
readonly strategy?: "enforce" | "shape" | undefined
|
|
12639
12639
|
}
|
|
@@ -12771,7 +12771,7 @@ export const groupedWithin: {
|
|
|
12771
12771
|
* @since 2.0.0
|
|
12772
12772
|
* @category Grouping
|
|
12773
12773
|
*/
|
|
12774
|
-
(chunkSize: number, duration: Duration.
|
|
12774
|
+
(chunkSize: number, duration: Duration.Input): <A, E, R>(self: Stream<A, E, R>) => Stream<Array<A>, E, R>
|
|
12775
12775
|
/**
|
|
12776
12776
|
* Partitions the stream into arrays, emitting when the chunk size is reached
|
|
12777
12777
|
* or the duration passes.
|
|
@@ -12795,11 +12795,11 @@ export const groupedWithin: {
|
|
|
12795
12795
|
* @since 2.0.0
|
|
12796
12796
|
* @category Grouping
|
|
12797
12797
|
*/
|
|
12798
|
-
<A, E, R>(self: Stream<A, E, R>, chunkSize: number, duration: Duration.
|
|
12798
|
+
<A, E, R>(self: Stream<A, E, R>, chunkSize: number, duration: Duration.Input): Stream<Array<A>, E, R>
|
|
12799
12799
|
} = dual(3, <A, E, R>(
|
|
12800
12800
|
self: Stream<A, E, R>,
|
|
12801
12801
|
chunkSize: number,
|
|
12802
|
-
duration: Duration.
|
|
12802
|
+
duration: Duration.Input
|
|
12803
12803
|
): Stream<Array<A>, E, R> =>
|
|
12804
12804
|
aggregateWithin(
|
|
12805
12805
|
self,
|
|
@@ -12874,7 +12874,7 @@ export const groupBy: {
|
|
|
12874
12874
|
f: (a: NoInfer<A>) => Effect.Effect<readonly [K, V], E2, R2>,
|
|
12875
12875
|
options?: {
|
|
12876
12876
|
readonly bufferSize?: number | undefined
|
|
12877
|
-
readonly idleTimeToLive?: Duration.
|
|
12877
|
+
readonly idleTimeToLive?: Duration.Input | undefined
|
|
12878
12878
|
}
|
|
12879
12879
|
): <E, R>(self: Stream<A, E, R>) => Stream<readonly [K, Stream<V>], E | E2, R | R2>
|
|
12880
12880
|
/**
|
|
@@ -12913,7 +12913,7 @@ export const groupBy: {
|
|
|
12913
12913
|
f: (a: NoInfer<A>) => Effect.Effect<readonly [K, V], E2, R2>,
|
|
12914
12914
|
options?: {
|
|
12915
12915
|
readonly bufferSize?: number | undefined
|
|
12916
|
-
readonly idleTimeToLive?: Duration.
|
|
12916
|
+
readonly idleTimeToLive?: Duration.Input | undefined
|
|
12917
12917
|
}
|
|
12918
12918
|
): Stream<readonly [K, Stream<V>], E | E2, R | R2>
|
|
12919
12919
|
} = dual((args) => isStream(args[0]), <A, E, R, K, V, E2, R2>(
|
|
@@ -12921,7 +12921,7 @@ export const groupBy: {
|
|
|
12921
12921
|
f: (a: NoInfer<A>) => Effect.Effect<readonly [K, V], E2, R2>,
|
|
12922
12922
|
options?: {
|
|
12923
12923
|
readonly bufferSize?: number | undefined
|
|
12924
|
-
readonly idleTimeToLive?: Duration.
|
|
12924
|
+
readonly idleTimeToLive?: Duration.Input | undefined
|
|
12925
12925
|
}
|
|
12926
12926
|
): Stream<readonly [K, Stream<V>], E | E2, R | R2> =>
|
|
12927
12927
|
groupByImpl(
|
|
@@ -13003,7 +13003,7 @@ export const groupByKey: {
|
|
|
13003
13003
|
f: (a: NoInfer<A>) => K,
|
|
13004
13004
|
options?: {
|
|
13005
13005
|
readonly bufferSize?: number | undefined
|
|
13006
|
-
readonly idleTimeToLive?: Duration.
|
|
13006
|
+
readonly idleTimeToLive?: Duration.Input | undefined
|
|
13007
13007
|
}
|
|
13008
13008
|
): <E, R>(self: Stream<A, E, R>) => Stream<readonly [K, Stream<A>], E, R>
|
|
13009
13009
|
/**
|
|
@@ -13040,7 +13040,7 @@ export const groupByKey: {
|
|
|
13040
13040
|
f: (a: NoInfer<A>) => K,
|
|
13041
13041
|
options?: {
|
|
13042
13042
|
readonly bufferSize?: number | undefined
|
|
13043
|
-
readonly idleTimeToLive?: Duration.
|
|
13043
|
+
readonly idleTimeToLive?: Duration.Input | undefined
|
|
13044
13044
|
}
|
|
13045
13045
|
): Stream<readonly [K, Stream<A>], E, R>
|
|
13046
13046
|
} = dual((args) => isStream(args[0]), <A, E, R, K>(
|
|
@@ -13048,7 +13048,7 @@ export const groupByKey: {
|
|
|
13048
13048
|
f: (a: NoInfer<A>) => K,
|
|
13049
13049
|
options?: {
|
|
13050
13050
|
readonly bufferSize?: number | undefined
|
|
13051
|
-
readonly idleTimeToLive?: Duration.
|
|
13051
|
+
readonly idleTimeToLive?: Duration.Input | undefined
|
|
13052
13052
|
}
|
|
13053
13053
|
): Stream<readonly [K, Stream<A>], E, R> =>
|
|
13054
13054
|
suspend(() => {
|
|
@@ -13146,7 +13146,7 @@ const groupByImpl = <A, E, R, K, V, E2, R2>(
|
|
|
13146
13146
|
) => Effect.Effect<void, E2, R2>,
|
|
13147
13147
|
options?: {
|
|
13148
13148
|
readonly bufferSize?: number | undefined
|
|
13149
|
-
readonly idleTimeToLive?: Duration.
|
|
13149
|
+
readonly idleTimeToLive?: Duration.Input | undefined
|
|
13150
13150
|
}
|
|
13151
13151
|
): Stream<readonly [K, Stream<V>], E | E2, R | R2> =>
|
|
13152
13152
|
transformPullBracket(
|
|
@@ -13880,12 +13880,12 @@ export const share: {
|
|
|
13880
13880
|
options: {
|
|
13881
13881
|
readonly capacity: "unbounded"
|
|
13882
13882
|
readonly replay?: number | undefined
|
|
13883
|
-
readonly idleTimeToLive?: Duration.
|
|
13883
|
+
readonly idleTimeToLive?: Duration.Input | undefined
|
|
13884
13884
|
} | {
|
|
13885
13885
|
readonly capacity: number
|
|
13886
13886
|
readonly strategy?: "sliding" | "dropping" | "suspend" | undefined
|
|
13887
13887
|
readonly replay?: number | undefined
|
|
13888
|
-
readonly idleTimeToLive?: Duration.
|
|
13888
|
+
readonly idleTimeToLive?: Duration.Input | undefined
|
|
13889
13889
|
}
|
|
13890
13890
|
): <A, E, R>(self: Stream<A, E, R>) => Effect.Effect<Stream<A, E>, never, Scope.Scope | R>
|
|
13891
13891
|
/**
|
|
@@ -13924,12 +13924,12 @@ export const share: {
|
|
|
13924
13924
|
options: {
|
|
13925
13925
|
readonly capacity: "unbounded"
|
|
13926
13926
|
readonly replay?: number | undefined
|
|
13927
|
-
readonly idleTimeToLive?: Duration.
|
|
13927
|
+
readonly idleTimeToLive?: Duration.Input | undefined
|
|
13928
13928
|
} | {
|
|
13929
13929
|
readonly capacity: number
|
|
13930
13930
|
readonly strategy?: "sliding" | "dropping" | "suspend" | undefined
|
|
13931
13931
|
readonly replay?: number | undefined
|
|
13932
|
-
readonly idleTimeToLive?: Duration.
|
|
13932
|
+
readonly idleTimeToLive?: Duration.Input | undefined
|
|
13933
13933
|
}
|
|
13934
13934
|
): Effect.Effect<Stream<A, E>, never, Scope.Scope | R>
|
|
13935
13935
|
} = dual(2, <A, E, R>(
|
|
@@ -13937,12 +13937,12 @@ export const share: {
|
|
|
13937
13937
|
options: {
|
|
13938
13938
|
readonly capacity: "unbounded"
|
|
13939
13939
|
readonly replay?: number | undefined
|
|
13940
|
-
readonly idleTimeToLive?: Duration.
|
|
13940
|
+
readonly idleTimeToLive?: Duration.Input | undefined
|
|
13941
13941
|
} | {
|
|
13942
13942
|
readonly capacity: number
|
|
13943
13943
|
readonly strategy?: "sliding" | "dropping" | "suspend" | undefined
|
|
13944
13944
|
readonly replay?: number | undefined
|
|
13945
|
-
readonly idleTimeToLive?: Duration.
|
|
13945
|
+
readonly idleTimeToLive?: Duration.Input | undefined
|
|
13946
13946
|
}
|
|
13947
13947
|
): Effect.Effect<Stream<A, E>, never, Scope.Scope | R> =>
|
|
13948
13948
|
Effect.map(
|
package/src/index.ts
CHANGED
|
@@ -444,6 +444,65 @@ export * as Chunk from "./Chunk.ts"
|
|
|
444
444
|
export * as Clock from "./Clock.ts"
|
|
445
445
|
|
|
446
446
|
/**
|
|
447
|
+
* A module for combining two values of the same type into one.
|
|
448
|
+
*
|
|
449
|
+
* A `Combiner<A>` wraps a single binary function `(self: A, that: A) => A`.
|
|
450
|
+
* It describes *how* two values merge but carries no initial/empty value
|
|
451
|
+
* (for that, see {@link Reducer} which extends `Combiner` with an
|
|
452
|
+
* `initialValue`).
|
|
453
|
+
*
|
|
454
|
+
* ## Mental model
|
|
455
|
+
*
|
|
456
|
+
* - **Combiner** – an object with a `combine(self, that)` method that returns
|
|
457
|
+
* a value of the same type.
|
|
458
|
+
* - **Argument order** – `self` is the "left" / accumulator side, `that` is
|
|
459
|
+
* the "right" / incoming side.
|
|
460
|
+
* - **No identity element** – unlike a monoid, a `Combiner` does not require
|
|
461
|
+
* a neutral element. Use {@link Reducer} when you need one.
|
|
462
|
+
* - **Purity** – all combiners produced by this module are pure; they never
|
|
463
|
+
* mutate their arguments.
|
|
464
|
+
* - **Composability** – combiners can be lifted into `Option`, `Struct`,
|
|
465
|
+
* `Tuple`, and other container types via helpers in those modules.
|
|
466
|
+
*
|
|
467
|
+
* ## Common tasks
|
|
468
|
+
*
|
|
469
|
+
* - Create a combiner from any binary function → {@link make}
|
|
470
|
+
* - Swap argument order → {@link flip}
|
|
471
|
+
* - Pick the smaller / larger of two values → {@link min} / {@link max}
|
|
472
|
+
* - Always keep the first or last value → {@link first} / {@link last}
|
|
473
|
+
* - Ignore both values and return a fixed result → {@link constant}
|
|
474
|
+
* - Insert a separator between combined values → {@link intercalate}
|
|
475
|
+
*
|
|
476
|
+
* ## Gotchas
|
|
477
|
+
*
|
|
478
|
+
* - `min` and `max` require an `Order<A>`, not a raw comparator. Import from
|
|
479
|
+
* e.g. `Number.Order` or `String.Order`.
|
|
480
|
+
* - `intercalate` is curried: call it with the separator first, then pass the
|
|
481
|
+
* base combiner.
|
|
482
|
+
* - A `Reducer` (which adds `initialValue`) is also a valid `Combiner` — you
|
|
483
|
+
* can pass a `Reducer` anywhere a `Combiner` is expected.
|
|
484
|
+
*
|
|
485
|
+
* ## Quickstart
|
|
486
|
+
*
|
|
487
|
+
* **Example** (combining strings with a separator)
|
|
488
|
+
*
|
|
489
|
+
* ```ts
|
|
490
|
+
* import { Combiner, String } from "effect"
|
|
491
|
+
*
|
|
492
|
+
* const csv = Combiner.intercalate(",")(String.ReducerConcat)
|
|
493
|
+
*
|
|
494
|
+
* console.log(csv.combine("a", "b"))
|
|
495
|
+
* // Output: "a,b"
|
|
496
|
+
*
|
|
497
|
+
* console.log(csv.combine(csv.combine("a", "b"), "c"))
|
|
498
|
+
* // Output: "a,b,c"
|
|
499
|
+
* ```
|
|
500
|
+
*
|
|
501
|
+
* ## See also
|
|
502
|
+
*
|
|
503
|
+
* - {@link make} – the primary constructor
|
|
504
|
+
* - {@link Combiner} – the core interface
|
|
505
|
+
*
|
|
447
506
|
* @since 4.0.0
|
|
448
507
|
*/
|
|
449
508
|
export * as Combiner from "./Combiner.ts"
|
|
@@ -1137,6 +1196,57 @@ export * as FileSystem from "./FileSystem.ts"
|
|
|
1137
1196
|
export * as Filter from "./Filter.ts"
|
|
1138
1197
|
|
|
1139
1198
|
/**
|
|
1199
|
+
* Utilities for converting arbitrary JavaScript values into human-readable
|
|
1200
|
+
* strings, with support for circular references, redaction, and common JS
|
|
1201
|
+
* types that `JSON.stringify` handles poorly.
|
|
1202
|
+
*
|
|
1203
|
+
* Mental model:
|
|
1204
|
+
* - A `Formatter<Value, Format>` is a callable `(value: Value) => Format`.
|
|
1205
|
+
* - {@link format} is the general-purpose pretty-printer: it handles
|
|
1206
|
+
* primitives, arrays, objects, `BigInt`, `Symbol`, `Date`, `RegExp`,
|
|
1207
|
+
* `Set`, `Map`, class instances, and circular references.
|
|
1208
|
+
* - {@link formatJson} is a safe `JSON.stringify` wrapper that silently
|
|
1209
|
+
* drops circular references and applies redaction.
|
|
1210
|
+
* - Both functions accept a `space` option for indentation control.
|
|
1211
|
+
*
|
|
1212
|
+
* Common tasks:
|
|
1213
|
+
* - Pretty-print any value for debugging / logging -> {@link format}
|
|
1214
|
+
* - Serialize to JSON safely (no circular throws) -> {@link formatJson}
|
|
1215
|
+
* - Format a single object property key -> {@link formatPropertyKey}
|
|
1216
|
+
* - Format a property path like `["a"]["b"]` -> {@link formatPath}
|
|
1217
|
+
* - Format a `Date` to ISO string safely -> {@link formatDate}
|
|
1218
|
+
*
|
|
1219
|
+
* Gotchas:
|
|
1220
|
+
* - {@link format} output is **not** valid JSON; use {@link formatJson} when
|
|
1221
|
+
* you need parseable JSON.
|
|
1222
|
+
* - {@link format} calls `toString()` on objects by default; pass
|
|
1223
|
+
* `ignoreToString: true` to disable.
|
|
1224
|
+
* - {@link formatJson} silently omits circular references (the key is
|
|
1225
|
+
* dropped from the output).
|
|
1226
|
+
* - Values implementing the `Redactable` protocol are automatically
|
|
1227
|
+
* redacted by both {@link format} and {@link formatJson}.
|
|
1228
|
+
*
|
|
1229
|
+
* **Example** (Pretty-print a value)
|
|
1230
|
+
*
|
|
1231
|
+
* ```ts
|
|
1232
|
+
* import { Formatter } from "effect"
|
|
1233
|
+
*
|
|
1234
|
+
* const obj = { name: "Alice", scores: [100, 97] }
|
|
1235
|
+
* console.log(Formatter.format(obj))
|
|
1236
|
+
* // {"name":"Alice","scores":[100,97]}
|
|
1237
|
+
*
|
|
1238
|
+
* console.log(Formatter.format(obj, { space: 2 }))
|
|
1239
|
+
* // {
|
|
1240
|
+
* // "name": "Alice",
|
|
1241
|
+
* // "scores": [
|
|
1242
|
+
* // 100,
|
|
1243
|
+
* // 97
|
|
1244
|
+
* // ]
|
|
1245
|
+
* // }
|
|
1246
|
+
* ```
|
|
1247
|
+
*
|
|
1248
|
+
* See also: {@link Formatter}, {@link format}, {@link formatJson}
|
|
1249
|
+
*
|
|
1140
1250
|
* @since 4.0.0
|
|
1141
1251
|
*/
|
|
1142
1252
|
export * as Formatter from "./Formatter.ts"
|
|
@@ -1401,6 +1511,89 @@ export * as JsonPatch from "./JsonPatch.ts"
|
|
|
1401
1511
|
export * as JsonPointer from "./JsonPointer.ts"
|
|
1402
1512
|
|
|
1403
1513
|
/**
|
|
1514
|
+
* Convert JSON Schema documents between dialects (Draft-07, Draft-2020-12,
|
|
1515
|
+
* OpenAPI 3.0, OpenAPI 3.1). All dialects are normalized to an internal
|
|
1516
|
+
* `Document<"draft-2020-12">` representation before optional conversion to
|
|
1517
|
+
* an output dialect.
|
|
1518
|
+
*
|
|
1519
|
+
* ## Mental model
|
|
1520
|
+
*
|
|
1521
|
+
* - **JsonSchema** — a plain object with string keys; represents any single
|
|
1522
|
+
* JSON Schema node.
|
|
1523
|
+
* - **Dialect** — one of `"draft-07"`, `"draft-2020-12"`, `"openapi-3.1"`,
|
|
1524
|
+
* or `"openapi-3.0"`.
|
|
1525
|
+
* - **Document** — a structured container holding a root `schema`, its
|
|
1526
|
+
* companion `definitions`, and the target `dialect`. Definitions are
|
|
1527
|
+
* stored separately from the root schema so they can be relocated when
|
|
1528
|
+
* converting between dialects.
|
|
1529
|
+
* - **MultiDocument** — same as `Document` but carries multiple root
|
|
1530
|
+
* schemas (at least one). Useful when generating several schemas that
|
|
1531
|
+
* share a single definitions pool.
|
|
1532
|
+
* - **Definitions** — a `Record<string, JsonSchema>` keyed by definition
|
|
1533
|
+
* name. The ref pointer prefix depends on the dialect.
|
|
1534
|
+
* - **`from*` functions** — parse a raw JSON Schema object into the
|
|
1535
|
+
* canonical `Document<"draft-2020-12">`.
|
|
1536
|
+
* - **`to*` functions** — convert from the canonical representation to a
|
|
1537
|
+
* specific output dialect.
|
|
1538
|
+
*
|
|
1539
|
+
* ## Common tasks
|
|
1540
|
+
*
|
|
1541
|
+
* - Parse a Draft-07 schema → {@link fromSchemaDraft07}
|
|
1542
|
+
* - Parse a Draft-2020-12 schema → {@link fromSchemaDraft2020_12}
|
|
1543
|
+
* - Parse an OpenAPI 3.1 schema → {@link fromSchemaOpenApi3_1}
|
|
1544
|
+
* - Parse an OpenAPI 3.0 schema → {@link fromSchemaOpenApi3_0}
|
|
1545
|
+
* - Convert to Draft-07 output → {@link toDocumentDraft07}
|
|
1546
|
+
* - Convert to OpenAPI 3.1 output → {@link toMultiDocumentOpenApi3_1}
|
|
1547
|
+
* - Resolve a `$ref` against definitions → {@link resolve$ref}
|
|
1548
|
+
* - Inline the root `$ref` of a document → {@link resolveTopLevel$ref}
|
|
1549
|
+
*
|
|
1550
|
+
* ## Gotchas
|
|
1551
|
+
*
|
|
1552
|
+
* - All `from*` functions normalize to `Document<"draft-2020-12">`
|
|
1553
|
+
* regardless of the input dialect.
|
|
1554
|
+
* - Unsupported or unrecognized JSON Schema keywords are silently dropped
|
|
1555
|
+
* during conversion.
|
|
1556
|
+
* - Draft-07 tuple syntax (`items` as array + `additionalItems`) is
|
|
1557
|
+
* converted to 2020-12 form (`prefixItems` + `items`), and vice-versa.
|
|
1558
|
+
* - OpenAPI 3.0 `nullable: true` is expanded into `type` arrays or
|
|
1559
|
+
* `anyOf` unions. The `nullable` keyword is removed.
|
|
1560
|
+
* - OpenAPI 3.0 singular `example` is converted to `examples` (array).
|
|
1561
|
+
* - {@link resolve$ref} only looks up the last segment of the ref path in
|
|
1562
|
+
* the definitions map; it does not follow arbitrary JSON Pointer paths.
|
|
1563
|
+
*
|
|
1564
|
+
* ## Quickstart
|
|
1565
|
+
*
|
|
1566
|
+
* **Example** (Parse a Draft-07 schema and convert to Draft-07 output)
|
|
1567
|
+
*
|
|
1568
|
+
* ```ts
|
|
1569
|
+
* import { JsonSchema } from "effect"
|
|
1570
|
+
*
|
|
1571
|
+
* const raw: JsonSchema.JsonSchema = {
|
|
1572
|
+
* type: "object",
|
|
1573
|
+
* properties: {
|
|
1574
|
+
* name: { type: "string" }
|
|
1575
|
+
* },
|
|
1576
|
+
* required: ["name"]
|
|
1577
|
+
* }
|
|
1578
|
+
*
|
|
1579
|
+
* // Parse into canonical form
|
|
1580
|
+
* const doc = JsonSchema.fromSchemaDraft07(raw)
|
|
1581
|
+
*
|
|
1582
|
+
* // Convert back to Draft-07
|
|
1583
|
+
* const draft07 = JsonSchema.toDocumentDraft07(doc)
|
|
1584
|
+
*
|
|
1585
|
+
* console.log(draft07.dialect) // "draft-07"
|
|
1586
|
+
* console.log(draft07.schema) // { type: "object", properties: { name: { type: "string" } }, required: ["name"] }
|
|
1587
|
+
* ```
|
|
1588
|
+
*
|
|
1589
|
+
* ## See also
|
|
1590
|
+
*
|
|
1591
|
+
* - {@link Document}
|
|
1592
|
+
* - {@link MultiDocument}
|
|
1593
|
+
* - {@link fromSchemaDraft07}
|
|
1594
|
+
* - {@link toDocumentDraft07}
|
|
1595
|
+
* - {@link resolve$ref}
|
|
1596
|
+
*
|
|
1404
1597
|
* @since 4.0.0
|
|
1405
1598
|
*/
|
|
1406
1599
|
export * as JsonSchema from "./JsonSchema.ts"
|
|
@@ -2457,6 +2650,71 @@ export * as Redactable from "./Redactable.ts"
|
|
|
2457
2650
|
export * as Redacted from "./Redacted.ts"
|
|
2458
2651
|
|
|
2459
2652
|
/**
|
|
2653
|
+
* A module for reducing collections of values into a single result.
|
|
2654
|
+
*
|
|
2655
|
+
* A `Reducer<A>` extends {@link Combiner.Combiner} by adding an
|
|
2656
|
+
* `initialValue` (identity element) and a `combineAll` method that folds an
|
|
2657
|
+
* entire collection. Think `Array.prototype.reduce`, but packaged as a
|
|
2658
|
+
* reusable, composable value.
|
|
2659
|
+
*
|
|
2660
|
+
* ## Mental model
|
|
2661
|
+
*
|
|
2662
|
+
* - **Reducer** – a {@link Combiner.Combiner} plus an `initialValue` and a
|
|
2663
|
+
* `combineAll` method.
|
|
2664
|
+
* - **initialValue** – the neutral/identity element. Combining any value with
|
|
2665
|
+
* `initialValue` should return the original value unchanged (e.g. `0` for
|
|
2666
|
+
* addition, `""` for string concatenation).
|
|
2667
|
+
* - **combineAll** – folds an `Iterable<A>` starting from `initialValue`.
|
|
2668
|
+
* When omitted from {@link make}, a default left-to-right fold is used.
|
|
2669
|
+
* - **Purity** – all reducers produced by this module are pure; they never
|
|
2670
|
+
* mutate their arguments.
|
|
2671
|
+
* - **Composability** – reducers can be lifted into `Option`, `Struct`,
|
|
2672
|
+
* `Tuple`, `Record`, and other container types via helpers in those modules.
|
|
2673
|
+
* - **Subtype of Combiner** – every `Reducer` is also a valid
|
|
2674
|
+
* `Combiner`, so you can pass a `Reducer` anywhere a `Combiner` is
|
|
2675
|
+
* expected.
|
|
2676
|
+
*
|
|
2677
|
+
* ## Common tasks
|
|
2678
|
+
*
|
|
2679
|
+
* - Create a reducer from a combine function and initial value → {@link make}
|
|
2680
|
+
* - Swap argument order → {@link flip}
|
|
2681
|
+
* - Combine two values without an initial value → use {@link Combiner.Combiner}
|
|
2682
|
+
* instead
|
|
2683
|
+
*
|
|
2684
|
+
* ## Gotchas
|
|
2685
|
+
*
|
|
2686
|
+
* - `combineAll` on an empty iterable returns `initialValue`, not an error.
|
|
2687
|
+
* - The default `combineAll` folds left-to-right. If your `combine` is not
|
|
2688
|
+
* associative, order matters. Pass a custom `combineAll` to {@link make} if
|
|
2689
|
+
* you need different traversal or short-circuiting.
|
|
2690
|
+
* - A `Reducer` is also a valid `Combiner` — but a `Combiner` is *not* a
|
|
2691
|
+
* `Reducer` (it lacks `initialValue`).
|
|
2692
|
+
*
|
|
2693
|
+
* ## Quickstart
|
|
2694
|
+
*
|
|
2695
|
+
* **Example** (summing a list of numbers)
|
|
2696
|
+
*
|
|
2697
|
+
* ```ts
|
|
2698
|
+
* import { Reducer } from "effect"
|
|
2699
|
+
*
|
|
2700
|
+
* const Sum = Reducer.make<number>((a, b) => a + b, 0)
|
|
2701
|
+
*
|
|
2702
|
+
* console.log(Sum.combine(3, 4))
|
|
2703
|
+
* // Output: 7
|
|
2704
|
+
*
|
|
2705
|
+
* console.log(Sum.combineAll([1, 2, 3, 4]))
|
|
2706
|
+
* // Output: 10
|
|
2707
|
+
*
|
|
2708
|
+
* console.log(Sum.combineAll([]))
|
|
2709
|
+
* // Output: 0
|
|
2710
|
+
* ```
|
|
2711
|
+
*
|
|
2712
|
+
* ## See also
|
|
2713
|
+
*
|
|
2714
|
+
* - {@link make} – the primary constructor
|
|
2715
|
+
* - {@link Reducer} – the core interface
|
|
2716
|
+
* - {@link Combiner.Combiner} – the parent interface (no `initialValue`)
|
|
2717
|
+
*
|
|
2460
2718
|
* @since 4.0.0
|
|
2461
2719
|
*/
|
|
2462
2720
|
export * as Reducer from "./Reducer.ts"
|
package/src/internal/dateTime.ts
CHANGED
|
@@ -12,7 +12,6 @@ import * as Inspectable from "../Inspectable.ts"
|
|
|
12
12
|
import * as order from "../Order.ts"
|
|
13
13
|
import { pipeArguments } from "../Pipeable.ts"
|
|
14
14
|
import * as Predicate from "../Predicate.ts"
|
|
15
|
-
import * as Result from "../Result.ts"
|
|
16
15
|
import type { Mutable } from "../Types.ts"
|
|
17
16
|
import * as UndefinedOr from "../UndefinedOr.ts"
|
|
18
17
|
import * as effect from "./effect.ts"
|
|
@@ -467,32 +466,12 @@ export const setZoneNamedUnsafe: {
|
|
|
467
466
|
|
|
468
467
|
/** @internal */
|
|
469
468
|
export const distance: {
|
|
470
|
-
(other: DateTime.DateTime): (self: DateTime.DateTime) => number
|
|
471
|
-
(self: DateTime.DateTime, other: DateTime.DateTime): number
|
|
472
|
-
} = dual(2, (self: DateTime.DateTime, other: DateTime.DateTime): number => toEpochMillis(other) - toEpochMillis(self))
|
|
473
|
-
|
|
474
|
-
/** @internal */
|
|
475
|
-
export const distanceDurationResult: {
|
|
476
|
-
(other: DateTime.DateTime): (self: DateTime.DateTime) => Result.Result<Duration.Duration, Duration.Duration>
|
|
477
|
-
(self: DateTime.DateTime, other: DateTime.DateTime): Result.Result<Duration.Duration, Duration.Duration>
|
|
478
|
-
} = dual(
|
|
479
|
-
2,
|
|
480
|
-
(self: DateTime.DateTime, other: DateTime.DateTime): Result.Result<Duration.Duration, Duration.Duration> => {
|
|
481
|
-
const diffMillis = distance(self, other)
|
|
482
|
-
return diffMillis > 0
|
|
483
|
-
? Result.succeed(Duration.millis(diffMillis))
|
|
484
|
-
: Result.fail(Duration.millis(-diffMillis))
|
|
485
|
-
}
|
|
486
|
-
)
|
|
487
|
-
|
|
488
|
-
/** @internal */
|
|
489
|
-
export const distanceDuration: {
|
|
490
469
|
(other: DateTime.DateTime): (self: DateTime.DateTime) => Duration.Duration
|
|
491
470
|
(self: DateTime.DateTime, other: DateTime.DateTime): Duration.Duration
|
|
492
471
|
} = dual(
|
|
493
472
|
2,
|
|
494
473
|
(self: DateTime.DateTime, other: DateTime.DateTime): Duration.Duration =>
|
|
495
|
-
Duration.millis(
|
|
474
|
+
Duration.millis(toEpochMillis(other) - toEpochMillis(self))
|
|
496
475
|
)
|
|
497
476
|
|
|
498
477
|
/** @internal */
|
|
@@ -911,22 +890,22 @@ export const match: {
|
|
|
911
890
|
|
|
912
891
|
/** @internal */
|
|
913
892
|
export const addDuration: {
|
|
914
|
-
(duration: Duration.
|
|
915
|
-
<A extends DateTime.DateTime>(self: A, duration: Duration.
|
|
893
|
+
(duration: Duration.Input): <A extends DateTime.DateTime>(self: A) => A
|
|
894
|
+
<A extends DateTime.DateTime>(self: A, duration: Duration.Input): A
|
|
916
895
|
} = dual(
|
|
917
896
|
2,
|
|
918
|
-
(self: DateTime.DateTime, duration: Duration.
|
|
919
|
-
mapEpochMillis(self, (millis) => millis + Duration.toMillis(Duration.
|
|
897
|
+
(self: DateTime.DateTime, duration: Duration.Input): DateTime.DateTime =>
|
|
898
|
+
mapEpochMillis(self, (millis) => millis + Duration.toMillis(Duration.fromInputUnsafe(duration)))
|
|
920
899
|
)
|
|
921
900
|
|
|
922
901
|
/** @internal */
|
|
923
902
|
export const subtractDuration: {
|
|
924
|
-
(duration: Duration.
|
|
925
|
-
<A extends DateTime.DateTime>(self: A, duration: Duration.
|
|
903
|
+
(duration: Duration.Input): <A extends DateTime.DateTime>(self: A) => A
|
|
904
|
+
<A extends DateTime.DateTime>(self: A, duration: Duration.Input): A
|
|
926
905
|
} = dual(
|
|
927
906
|
2,
|
|
928
|
-
(self: DateTime.DateTime, duration: Duration.
|
|
929
|
-
mapEpochMillis(self, (millis) => millis - Duration.toMillis(Duration.
|
|
907
|
+
(self: DateTime.DateTime, duration: Duration.Input): DateTime.DateTime =>
|
|
908
|
+
mapEpochMillis(self, (millis) => millis - Duration.toMillis(Duration.fromInputUnsafe(duration)))
|
|
930
909
|
)
|
|
931
910
|
|
|
932
911
|
const addMillis = (date: Date, amount: number): void => {
|