effect 3.12.11 → 3.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -49
- package/dist/cjs/Channel.js.map +1 -1
- package/dist/cjs/DateTime.js +17 -1
- package/dist/cjs/DateTime.js.map +1 -1
- package/dist/cjs/Differ.js.map +1 -1
- package/dist/cjs/Duration.js +128 -1
- package/dist/cjs/Duration.js.map +1 -1
- package/dist/cjs/Effect.js +175 -37
- package/dist/cjs/Effect.js.map +1 -1
- package/dist/cjs/Either.js +2 -1
- package/dist/cjs/Either.js.map +1 -1
- package/dist/cjs/FiberHandle.js +54 -21
- package/dist/cjs/FiberHandle.js.map +1 -1
- package/dist/cjs/FiberMap.js +51 -24
- package/dist/cjs/FiberMap.js.map +1 -1
- package/dist/cjs/FiberSet.js +50 -17
- package/dist/cjs/FiberSet.js.map +1 -1
- package/dist/cjs/HashMap.js +19 -1
- package/dist/cjs/HashMap.js.map +1 -1
- package/dist/cjs/HashSet.js +9 -1
- package/dist/cjs/HashSet.js.map +1 -1
- package/dist/cjs/Layer.js +21 -1
- package/dist/cjs/Layer.js.map +1 -1
- package/dist/cjs/Match.js +659 -38
- package/dist/cjs/Match.js.map +1 -1
- package/dist/cjs/RcMap.js +11 -1
- package/dist/cjs/RcMap.js.map +1 -1
- package/dist/cjs/Reloadable.js.map +1 -1
- package/dist/cjs/STM.js.map +1 -1
- package/dist/cjs/Schedule.js +1074 -309
- package/dist/cjs/Schedule.js.map +1 -1
- package/dist/cjs/Schema.js +73 -1
- package/dist/cjs/Schema.js.map +1 -1
- package/dist/cjs/Stream.js.map +1 -1
- package/dist/cjs/internal/channel.js.map +1 -1
- package/dist/cjs/internal/core-effect.js.map +1 -1
- package/dist/cjs/internal/core.js +27 -3
- package/dist/cjs/internal/core.js.map +1 -1
- package/dist/cjs/internal/dateTime.js +4 -1
- package/dist/cjs/internal/dateTime.js.map +1 -1
- package/dist/cjs/internal/differ.js +4 -0
- package/dist/cjs/internal/differ.js.map +1 -1
- package/dist/cjs/internal/effect/circular.js +3 -2
- package/dist/cjs/internal/effect/circular.js.map +1 -1
- package/dist/cjs/internal/fiberRuntime.js +21 -7
- package/dist/cjs/internal/fiberRuntime.js.map +1 -1
- package/dist/cjs/internal/hashMap.js +10 -1
- package/dist/cjs/internal/hashMap.js.map +1 -1
- package/dist/cjs/internal/keyedPool.js +1 -1
- package/dist/cjs/internal/keyedPool.js.map +1 -1
- package/dist/cjs/internal/layer.js.map +1 -1
- package/dist/cjs/internal/rcMap.js +86 -56
- package/dist/cjs/internal/rcMap.js.map +1 -1
- package/dist/cjs/internal/reloadable.js.map +1 -1
- package/dist/cjs/internal/schedule.js.map +1 -1
- package/dist/cjs/internal/sink.js.map +1 -1
- package/dist/cjs/internal/stm/stm.js.map +1 -1
- package/dist/cjs/internal/stream.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/cjs/internal/version.js.map +1 -1
- package/dist/dts/Channel.d.ts +4 -4
- package/dist/dts/Channel.d.ts.map +1 -1
- package/dist/dts/DateTime.d.ts +16 -0
- package/dist/dts/DateTime.d.ts.map +1 -1
- package/dist/dts/Differ.d.ts +2 -1
- package/dist/dts/Differ.d.ts.map +1 -1
- package/dist/dts/Duration.d.ts +64 -0
- package/dist/dts/Duration.d.ts.map +1 -1
- package/dist/dts/Effect.d.ts +402 -30
- package/dist/dts/Effect.d.ts.map +1 -1
- package/dist/dts/Either.d.ts +7 -0
- package/dist/dts/Either.d.ts.map +1 -1
- package/dist/dts/FiberHandle.d.ts +26 -0
- package/dist/dts/FiberHandle.d.ts.map +1 -1
- package/dist/dts/FiberMap.d.ts +26 -0
- package/dist/dts/FiberMap.d.ts.map +1 -1
- package/dist/dts/FiberSet.d.ts +25 -0
- package/dist/dts/FiberSet.d.ts.map +1 -1
- package/dist/dts/HashMap.d.ts +38 -0
- package/dist/dts/HashMap.d.ts.map +1 -1
- package/dist/dts/HashSet.d.ts +7 -0
- package/dist/dts/HashSet.d.ts.map +1 -1
- package/dist/dts/Layer.d.ts +32 -13
- package/dist/dts/Layer.d.ts.map +1 -1
- package/dist/dts/Match.d.ts +731 -48
- package/dist/dts/Match.d.ts.map +1 -1
- package/dist/dts/RcMap.d.ts +32 -0
- package/dist/dts/RcMap.d.ts.map +1 -1
- package/dist/dts/Reloadable.d.ts +13 -13
- package/dist/dts/Reloadable.d.ts.map +1 -1
- package/dist/dts/STM.d.ts +4 -4
- package/dist/dts/STM.d.ts.map +1 -1
- package/dist/dts/Schedule.d.ts +2294 -633
- package/dist/dts/Schedule.d.ts.map +1 -1
- package/dist/dts/Schema.d.ts +40 -4
- package/dist/dts/Schema.d.ts.map +1 -1
- package/dist/dts/Stream.d.ts +8 -8
- package/dist/dts/Stream.d.ts.map +1 -1
- package/dist/dts/Trie.d.ts +7 -7
- package/dist/dts/Trie.d.ts.map +1 -1
- package/dist/dts/index.d.ts +25 -0
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/internal/stm/stm.d.ts +2 -2
- package/dist/dts/internal/stm/stm.d.ts.map +1 -1
- package/dist/esm/Channel.js.map +1 -1
- package/dist/esm/DateTime.js +16 -0
- package/dist/esm/DateTime.js.map +1 -1
- package/dist/esm/Differ.js.map +1 -1
- package/dist/esm/Duration.js +124 -0
- package/dist/esm/Duration.js.map +1 -1
- package/dist/esm/Effect.js +170 -32
- package/dist/esm/Effect.js.map +1 -1
- package/dist/esm/Either.js +7 -0
- package/dist/esm/Either.js.map +1 -1
- package/dist/esm/FiberHandle.js +48 -18
- package/dist/esm/FiberHandle.js.map +1 -1
- package/dist/esm/FiberMap.js +46 -22
- package/dist/esm/FiberMap.js.map +1 -1
- package/dist/esm/FiberSet.js +45 -15
- package/dist/esm/FiberSet.js.map +1 -1
- package/dist/esm/HashMap.js +17 -0
- package/dist/esm/HashMap.js.map +1 -1
- package/dist/esm/HashSet.js +7 -0
- package/dist/esm/HashSet.js.map +1 -1
- package/dist/esm/Layer.js +20 -0
- package/dist/esm/Layer.js.map +1 -1
- package/dist/esm/Match.js +665 -40
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/RcMap.js +10 -0
- package/dist/esm/RcMap.js.map +1 -1
- package/dist/esm/Reloadable.js.map +1 -1
- package/dist/esm/STM.js.map +1 -1
- package/dist/esm/Schedule.js +1074 -309
- package/dist/esm/Schedule.js.map +1 -1
- package/dist/esm/Schema.js +71 -0
- package/dist/esm/Schema.js.map +1 -1
- package/dist/esm/Stream.js.map +1 -1
- package/dist/esm/index.js +25 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/internal/channel.js.map +1 -1
- package/dist/esm/internal/core-effect.js.map +1 -1
- package/dist/esm/internal/core.js +23 -0
- package/dist/esm/internal/core.js.map +1 -1
- package/dist/esm/internal/dateTime.js +2 -0
- package/dist/esm/internal/dateTime.js.map +1 -1
- package/dist/esm/internal/differ.js +4 -0
- package/dist/esm/internal/differ.js.map +1 -1
- package/dist/esm/internal/effect/circular.js +3 -2
- package/dist/esm/internal/effect/circular.js.map +1 -1
- package/dist/esm/internal/fiberRuntime.js +18 -5
- package/dist/esm/internal/fiberRuntime.js.map +1 -1
- package/dist/esm/internal/hashMap.js +9 -0
- package/dist/esm/internal/hashMap.js.map +1 -1
- package/dist/esm/internal/keyedPool.js +1 -1
- package/dist/esm/internal/keyedPool.js.map +1 -1
- package/dist/esm/internal/layer.js.map +1 -1
- package/dist/esm/internal/rcMap.js +85 -55
- package/dist/esm/internal/rcMap.js.map +1 -1
- package/dist/esm/internal/reloadable.js.map +1 -1
- package/dist/esm/internal/schedule.js.map +1 -1
- package/dist/esm/internal/sink.js.map +1 -1
- package/dist/esm/internal/stm/stm.js.map +1 -1
- package/dist/esm/internal/stream.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/dist/esm/internal/version.js.map +1 -1
- package/package.json +2 -1
- package/src/Channel.ts +14 -17
- package/src/DateTime.ts +17 -8
- package/src/Differ.ts +2 -1
- package/src/Duration.ts +147 -0
- package/src/Effect.ts +528 -140
- package/src/Either.ts +9 -0
- package/src/FiberHandle.ts +95 -35
- package/src/FiberMap.ts +104 -39
- package/src/FiberSet.ts +93 -24
- package/src/HashMap.ts +40 -0
- package/src/HashSet.ts +8 -0
- package/src/Layer.ts +94 -40
- package/src/Match.ts +733 -49
- package/src/RcMap.ts +34 -0
- package/src/Reloadable.ts +17 -27
- package/src/STM.ts +10 -17
- package/src/Schedule.ts +2325 -653
- package/src/Schema.ts +81 -4
- package/src/Stream.ts +26 -33
- package/src/Trie.ts +7 -7
- package/src/index.ts +25 -0
- package/src/internal/channel.ts +37 -39
- package/src/internal/core-effect.ts +84 -84
- package/src/internal/core.ts +80 -0
- package/src/internal/dateTime.ts +3 -0
- package/src/internal/differ.ts +4 -0
- package/src/internal/effect/circular.ts +3 -2
- package/src/internal/fiberRuntime.ts +31 -6
- package/src/internal/hashMap.ts +16 -0
- package/src/internal/keyedPool.ts +1 -1
- package/src/internal/layer.ts +52 -52
- package/src/internal/rcMap.ts +131 -89
- package/src/internal/reloadable.ts +25 -28
- package/src/internal/schedule.ts +29 -23
- package/src/internal/sink.ts +16 -15
- package/src/internal/stm/stm.ts +54 -46
- package/src/internal/stream.ts +100 -100
- package/src/internal/version.ts +1 -1
package/src/Schedule.ts
CHANGED
|
@@ -20,31 +20,49 @@ import type * as Types from "./Types.js"
|
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* @since 2.0.0
|
|
23
|
-
* @category
|
|
23
|
+
* @category Symbols
|
|
24
24
|
*/
|
|
25
25
|
export const ScheduleTypeId: unique symbol = internal.ScheduleTypeId
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* @since 2.0.0
|
|
29
|
-
* @category
|
|
29
|
+
* @category Symbols
|
|
30
30
|
*/
|
|
31
31
|
export type ScheduleTypeId = typeof ScheduleTypeId
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* @since 2.0.0
|
|
35
|
-
* @category
|
|
35
|
+
* @category Symbols
|
|
36
36
|
*/
|
|
37
37
|
export const ScheduleDriverTypeId: unique symbol = internal.ScheduleDriverTypeId
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* @since 2.0.0
|
|
41
|
-
* @category
|
|
41
|
+
* @category Symbols
|
|
42
42
|
*/
|
|
43
43
|
export type ScheduleDriverTypeId = typeof ScheduleDriverTypeId
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
-
* A `Schedule<Out, In, R>` defines a recurring schedule, which consumes
|
|
47
|
-
*
|
|
46
|
+
* A `Schedule<Out, In, R>` defines a recurring schedule, which consumes values
|
|
47
|
+
* of type `In`, and which returns values of type `Out`.
|
|
48
|
+
*
|
|
49
|
+
* The `Schedule` type is structured as follows:
|
|
50
|
+
*
|
|
51
|
+
* ```text
|
|
52
|
+
* ┌─── The type of output produced by the schedule
|
|
53
|
+
* │ ┌─── The type of input consumed by the schedule
|
|
54
|
+
* │ │ ┌─── Additional requirements for the schedule
|
|
55
|
+
* ▼ ▼ ▼
|
|
56
|
+
* Schedule<Out, In, Requirements>
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* A schedule operates by consuming values of type `In` (such as errors in the
|
|
60
|
+
* case of `Effect.retry`, or values in the case of `Effect.repeat`) and
|
|
61
|
+
* producing values of type `Out`. It determines when to halt or continue the
|
|
62
|
+
* execution based on input values and its internal state.
|
|
63
|
+
*
|
|
64
|
+
* The inclusion of a `Requirements` parameter allows the schedule to leverage
|
|
65
|
+
* additional services or resources as needed.
|
|
48
66
|
*
|
|
49
67
|
* Schedules are defined as a possibly infinite set of intervals spread out over
|
|
50
68
|
* time. Each interval defines a window in which recurrence is possible.
|
|
@@ -53,11 +71,14 @@ export type ScheduleDriverTypeId = typeof ScheduleDriverTypeId
|
|
|
53
71
|
* each interval produced by a schedule is used as the moment when the effect
|
|
54
72
|
* will be executed again.
|
|
55
73
|
*
|
|
56
|
-
* Schedules
|
|
74
|
+
* Schedules can be composed in different ways:
|
|
57
75
|
*
|
|
58
|
-
* - Union:
|
|
59
|
-
*
|
|
60
|
-
* -
|
|
76
|
+
* - Union: Combines two schedules and recurs if either schedule wants to
|
|
77
|
+
* continue, using the shorter delay.
|
|
78
|
+
* - Intersection: Combines two schedules and recurs only if both schedules want
|
|
79
|
+
* to continue, using the longer delay.
|
|
80
|
+
* - Sequencing: Combines two schedules by running the first one fully, then
|
|
81
|
+
* switching to the second.
|
|
61
82
|
*
|
|
62
83
|
* In addition, schedule inputs and outputs can be transformed, filtered (to
|
|
63
84
|
* terminate a schedule early in response to some input or output), and so
|
|
@@ -67,7 +88,7 @@ export type ScheduleDriverTypeId = typeof ScheduleDriverTypeId
|
|
|
67
88
|
* and the companion object for `Schedule` contains all common types of
|
|
68
89
|
* schedules, both for performing retrying, as well as performing repetition.
|
|
69
90
|
*
|
|
70
|
-
* @category
|
|
91
|
+
* @category Model
|
|
71
92
|
* @since 2.0.0
|
|
72
93
|
*/
|
|
73
94
|
export interface Schedule<out Out, in In = unknown, out R = never> extends Schedule.Variance<Out, In, R>, Pipeable {
|
|
@@ -91,7 +112,7 @@ export interface Schedule<out Out, in In = unknown, out R = never> extends Sched
|
|
|
91
112
|
export declare namespace Schedule {
|
|
92
113
|
/**
|
|
93
114
|
* @since 2.0.0
|
|
94
|
-
* @category
|
|
115
|
+
* @category Models
|
|
95
116
|
*/
|
|
96
117
|
export interface Variance<out Out, in In, out R> {
|
|
97
118
|
readonly [ScheduleTypeId]: {
|
|
@@ -115,7 +136,7 @@ export declare namespace Schedule {
|
|
|
115
136
|
|
|
116
137
|
/**
|
|
117
138
|
* @since 2.0.0
|
|
118
|
-
* @category
|
|
139
|
+
* @category Models
|
|
119
140
|
*/
|
|
120
141
|
export interface ScheduleDriver<out Out, in In = unknown, out R = never> extends Schedule.DriverVariance<Out, In, R> {
|
|
121
142
|
readonly state: Effect.Effect<unknown>
|
|
@@ -125,11 +146,22 @@ export interface ScheduleDriver<out Out, in In = unknown, out R = never> extends
|
|
|
125
146
|
}
|
|
126
147
|
|
|
127
148
|
/**
|
|
128
|
-
*
|
|
129
|
-
*
|
|
149
|
+
* Creates a new schedule with a custom state and step function.
|
|
150
|
+
*
|
|
151
|
+
* **Details**
|
|
152
|
+
*
|
|
153
|
+
* This function constructs a `Schedule` by defining its initial state and a
|
|
154
|
+
* step function, which determines how the schedule progresses over time. The
|
|
155
|
+
* step function is called on each iteration with the current time, an input
|
|
156
|
+
* value, and the schedule's current state. It returns the next state, an output
|
|
157
|
+
* value, and a decision on whether the schedule should continue or stop.
|
|
158
|
+
*
|
|
159
|
+
* This function is useful for creating custom scheduling logic that goes beyond
|
|
160
|
+
* predefined schedules like fixed intervals or exponential backoff. It allows
|
|
161
|
+
* full control over how the schedule behaves at each step.
|
|
130
162
|
*
|
|
131
163
|
* @since 2.0.0
|
|
132
|
-
* @category
|
|
164
|
+
* @category Constructors
|
|
133
165
|
*/
|
|
134
166
|
export const makeWithState: <S, In, Out, R = never>(
|
|
135
167
|
initial: S,
|
|
@@ -141,63 +173,108 @@ export const makeWithState: <S, In, Out, R = never>(
|
|
|
141
173
|
) => Schedule<Out, In, R> = internal.makeWithState
|
|
142
174
|
|
|
143
175
|
/**
|
|
144
|
-
*
|
|
176
|
+
* Checks whether a given value is a `Schedule`.
|
|
145
177
|
*
|
|
146
178
|
* @since 2.0.0
|
|
147
|
-
* @category
|
|
179
|
+
* @category Guards
|
|
148
180
|
*/
|
|
149
181
|
export const isSchedule: (u: unknown) => u is Schedule<unknown, never, unknown> = internal.isSchedule
|
|
150
182
|
|
|
151
183
|
/**
|
|
152
|
-
*
|
|
153
|
-
*
|
|
184
|
+
* Adds a delay to every interval in a schedule.
|
|
185
|
+
*
|
|
186
|
+
* **Details**
|
|
187
|
+
*
|
|
188
|
+
* This function modifies a given schedule by applying an additional delay to
|
|
189
|
+
* every interval it defines. The delay is determined by the provided function,
|
|
190
|
+
* which takes the schedule's output and returns a delay duration.
|
|
191
|
+
*
|
|
192
|
+
* @see {@link addDelayEffect} If you need to compute the delay using an effectful function.
|
|
154
193
|
*
|
|
155
194
|
* @since 2.0.0
|
|
156
|
-
* @category
|
|
195
|
+
* @category Timing & Delay
|
|
157
196
|
*/
|
|
158
197
|
export const addDelay: {
|
|
159
198
|
/**
|
|
160
|
-
*
|
|
161
|
-
*
|
|
199
|
+
* Adds a delay to every interval in a schedule.
|
|
200
|
+
*
|
|
201
|
+
* **Details**
|
|
202
|
+
*
|
|
203
|
+
* This function modifies a given schedule by applying an additional delay to
|
|
204
|
+
* every interval it defines. The delay is determined by the provided function,
|
|
205
|
+
* which takes the schedule's output and returns a delay duration.
|
|
206
|
+
*
|
|
207
|
+
* @see {@link addDelayEffect} If you need to compute the delay using an effectful function.
|
|
162
208
|
*
|
|
163
209
|
* @since 2.0.0
|
|
164
|
-
* @category
|
|
210
|
+
* @category Timing & Delay
|
|
165
211
|
*/
|
|
166
212
|
<Out>(f: (out: Out) => Duration.DurationInput): <In, R>(self: Schedule<Out, In, R>) => Schedule<Out, In, R>
|
|
167
213
|
/**
|
|
168
|
-
*
|
|
169
|
-
*
|
|
214
|
+
* Adds a delay to every interval in a schedule.
|
|
215
|
+
*
|
|
216
|
+
* **Details**
|
|
217
|
+
*
|
|
218
|
+
* This function modifies a given schedule by applying an additional delay to
|
|
219
|
+
* every interval it defines. The delay is determined by the provided function,
|
|
220
|
+
* which takes the schedule's output and returns a delay duration.
|
|
221
|
+
*
|
|
222
|
+
* @see {@link addDelayEffect} If you need to compute the delay using an effectful function.
|
|
170
223
|
*
|
|
171
224
|
* @since 2.0.0
|
|
172
|
-
* @category
|
|
225
|
+
* @category Timing & Delay
|
|
173
226
|
*/
|
|
174
227
|
<Out, In, R>(self: Schedule<Out, In, R>, f: (out: Out) => Duration.DurationInput): Schedule<Out, In, R>
|
|
175
228
|
} = internal.addDelay
|
|
176
229
|
|
|
177
230
|
/**
|
|
178
|
-
*
|
|
179
|
-
*
|
|
231
|
+
* Adds an effectfully computed delay to every interval in a schedule.
|
|
232
|
+
*
|
|
233
|
+
* **Details**
|
|
234
|
+
*
|
|
235
|
+
* This function modifies a given schedule by applying an additional delay to
|
|
236
|
+
* each interval, where the delay is determined by an effectful function. The
|
|
237
|
+
* function takes the schedule’s output and returns an effect that produces a
|
|
238
|
+
* delay duration.
|
|
239
|
+
*
|
|
240
|
+
* @see {@link addDelay} If you need to compute the delay using a pure function.
|
|
180
241
|
*
|
|
181
242
|
* @since 2.0.0
|
|
182
|
-
* @category
|
|
243
|
+
* @category Timing & Delay
|
|
183
244
|
*/
|
|
184
245
|
export const addDelayEffect: {
|
|
185
246
|
/**
|
|
186
|
-
*
|
|
187
|
-
*
|
|
247
|
+
* Adds an effectfully computed delay to every interval in a schedule.
|
|
248
|
+
*
|
|
249
|
+
* **Details**
|
|
250
|
+
*
|
|
251
|
+
* This function modifies a given schedule by applying an additional delay to
|
|
252
|
+
* each interval, where the delay is determined by an effectful function. The
|
|
253
|
+
* function takes the schedule’s output and returns an effect that produces a
|
|
254
|
+
* delay duration.
|
|
255
|
+
*
|
|
256
|
+
* @see {@link addDelay} If you need to compute the delay using a pure function.
|
|
188
257
|
*
|
|
189
258
|
* @since 2.0.0
|
|
190
|
-
* @category
|
|
259
|
+
* @category Timing & Delay
|
|
191
260
|
*/
|
|
192
261
|
<Out, R2>(
|
|
193
262
|
f: (out: Out) => Effect.Effect<Duration.DurationInput, never, R2>
|
|
194
263
|
): <In, R>(self: Schedule<Out, In, R>) => Schedule<Out, In, R2 | R>
|
|
195
264
|
/**
|
|
196
|
-
*
|
|
197
|
-
*
|
|
265
|
+
* Adds an effectfully computed delay to every interval in a schedule.
|
|
266
|
+
*
|
|
267
|
+
* **Details**
|
|
268
|
+
*
|
|
269
|
+
* This function modifies a given schedule by applying an additional delay to
|
|
270
|
+
* each interval, where the delay is determined by an effectful function. The
|
|
271
|
+
* function takes the schedule’s output and returns an effect that produces a
|
|
272
|
+
* delay duration.
|
|
273
|
+
*
|
|
274
|
+
* @see {@link addDelay} If you need to compute the delay using a pure function.
|
|
198
275
|
*
|
|
199
276
|
* @since 2.0.0
|
|
200
|
-
* @category
|
|
277
|
+
* @category Timing & Delay
|
|
201
278
|
*/
|
|
202
279
|
<Out, In, R, R2>(
|
|
203
280
|
self: Schedule<Out, In, R>,
|
|
@@ -206,26 +283,68 @@ export const addDelayEffect: {
|
|
|
206
283
|
} = internal.addDelayEffect
|
|
207
284
|
|
|
208
285
|
/**
|
|
209
|
-
*
|
|
286
|
+
* Runs two schedules sequentially, merging their outputs.
|
|
287
|
+
*
|
|
288
|
+
* **Details**
|
|
289
|
+
*
|
|
290
|
+
* This function executes two schedules one after the other. The first schedule
|
|
291
|
+
* runs to completion, and then the second schedule begins execution. Unlike
|
|
292
|
+
* {@link andThenEither}, this function merges the outputs instead of wrapping
|
|
293
|
+
* them in `Either`, allowing both schedules to contribute their results
|
|
294
|
+
* directly.
|
|
295
|
+
*
|
|
296
|
+
* This is useful when a workflow consists of two phases where the second phase
|
|
297
|
+
* should start only after the first one has fully completed.
|
|
298
|
+
*
|
|
299
|
+
* @see {@link andThenEither} If you need to keep track of which schedule
|
|
300
|
+
* produced each result.
|
|
210
301
|
*
|
|
211
302
|
* @since 2.0.0
|
|
212
|
-
* @category
|
|
303
|
+
* @category Sequential Composition
|
|
213
304
|
*/
|
|
214
305
|
export const andThen: {
|
|
215
306
|
/**
|
|
216
|
-
*
|
|
307
|
+
* Runs two schedules sequentially, merging their outputs.
|
|
308
|
+
*
|
|
309
|
+
* **Details**
|
|
310
|
+
*
|
|
311
|
+
* This function executes two schedules one after the other. The first schedule
|
|
312
|
+
* runs to completion, and then the second schedule begins execution. Unlike
|
|
313
|
+
* {@link andThenEither}, this function merges the outputs instead of wrapping
|
|
314
|
+
* them in `Either`, allowing both schedules to contribute their results
|
|
315
|
+
* directly.
|
|
316
|
+
*
|
|
317
|
+
* This is useful when a workflow consists of two phases where the second phase
|
|
318
|
+
* should start only after the first one has fully completed.
|
|
319
|
+
*
|
|
320
|
+
* @see {@link andThenEither} If you need to keep track of which schedule
|
|
321
|
+
* produced each result.
|
|
217
322
|
*
|
|
218
323
|
* @since 2.0.0
|
|
219
|
-
* @category
|
|
324
|
+
* @category Sequential Composition
|
|
220
325
|
*/
|
|
221
326
|
<Out2, In2, R2>(
|
|
222
327
|
that: Schedule<Out2, In2, R2>
|
|
223
328
|
): <Out, In, R>(self: Schedule<Out, In, R>) => Schedule<Out2 | Out, In & In2, R2 | R>
|
|
224
329
|
/**
|
|
225
|
-
*
|
|
330
|
+
* Runs two schedules sequentially, merging their outputs.
|
|
331
|
+
*
|
|
332
|
+
* **Details**
|
|
333
|
+
*
|
|
334
|
+
* This function executes two schedules one after the other. The first schedule
|
|
335
|
+
* runs to completion, and then the second schedule begins execution. Unlike
|
|
336
|
+
* {@link andThenEither}, this function merges the outputs instead of wrapping
|
|
337
|
+
* them in `Either`, allowing both schedules to contribute their results
|
|
338
|
+
* directly.
|
|
339
|
+
*
|
|
340
|
+
* This is useful when a workflow consists of two phases where the second phase
|
|
341
|
+
* should start only after the first one has fully completed.
|
|
342
|
+
*
|
|
343
|
+
* @see {@link andThenEither} If you need to keep track of which schedule
|
|
344
|
+
* produced each result.
|
|
226
345
|
*
|
|
227
346
|
* @since 2.0.0
|
|
228
|
-
* @category
|
|
347
|
+
* @category Sequential Composition
|
|
229
348
|
*/
|
|
230
349
|
<Out, In, R, Out2, In2, R2>(
|
|
231
350
|
self: Schedule<Out, In, R>,
|
|
@@ -234,29 +353,68 @@ export const andThen: {
|
|
|
234
353
|
} = internal.andThen
|
|
235
354
|
|
|
236
355
|
/**
|
|
237
|
-
*
|
|
238
|
-
*
|
|
356
|
+
* Runs two schedules sequentially, collecting results in an `Either`.
|
|
357
|
+
*
|
|
358
|
+
* **Details**
|
|
359
|
+
*
|
|
360
|
+
* This function combines two schedules in sequence. The first schedule runs to
|
|
361
|
+
* completion, and then the second schedule starts and runs to completion as
|
|
362
|
+
* well. The outputs of both schedules are collected into an `Either` structure:
|
|
363
|
+
* - `Either.Left` contains the output of the second schedule.
|
|
364
|
+
* - `Either.Right` contains the output of the first schedule.
|
|
365
|
+
*
|
|
366
|
+
* This is useful when you need to switch from one schedule to another after the
|
|
367
|
+
* first one finishes, while still keeping track of which schedule produced each
|
|
368
|
+
* result.
|
|
369
|
+
*
|
|
370
|
+
* @see {@link andThen} If you need to merge the outputs of both schedules.
|
|
239
371
|
*
|
|
240
372
|
* @since 2.0.0
|
|
241
|
-
* @category
|
|
373
|
+
* @category Sequential Composition
|
|
242
374
|
*/
|
|
243
375
|
export const andThenEither: {
|
|
244
376
|
/**
|
|
245
|
-
*
|
|
246
|
-
*
|
|
377
|
+
* Runs two schedules sequentially, collecting results in an `Either`.
|
|
378
|
+
*
|
|
379
|
+
* **Details**
|
|
380
|
+
*
|
|
381
|
+
* This function combines two schedules in sequence. The first schedule runs to
|
|
382
|
+
* completion, and then the second schedule starts and runs to completion as
|
|
383
|
+
* well. The outputs of both schedules are collected into an `Either` structure:
|
|
384
|
+
* - `Either.Left` contains the output of the second schedule.
|
|
385
|
+
* - `Either.Right` contains the output of the first schedule.
|
|
386
|
+
*
|
|
387
|
+
* This is useful when you need to switch from one schedule to another after the
|
|
388
|
+
* first one finishes, while still keeping track of which schedule produced each
|
|
389
|
+
* result.
|
|
390
|
+
*
|
|
391
|
+
* @see {@link andThen} If you need to merge the outputs of both schedules.
|
|
247
392
|
*
|
|
248
393
|
* @since 2.0.0
|
|
249
|
-
* @category
|
|
394
|
+
* @category Sequential Composition
|
|
250
395
|
*/
|
|
251
396
|
<Out2, In2, R2>(
|
|
252
397
|
that: Schedule<Out2, In2, R2>
|
|
253
398
|
): <Out, In, R>(self: Schedule<Out, In, R>) => Schedule<Either.Either<Out2, Out>, In & In2, R2 | R>
|
|
254
399
|
/**
|
|
255
|
-
*
|
|
256
|
-
*
|
|
400
|
+
* Runs two schedules sequentially, collecting results in an `Either`.
|
|
401
|
+
*
|
|
402
|
+
* **Details**
|
|
403
|
+
*
|
|
404
|
+
* This function combines two schedules in sequence. The first schedule runs to
|
|
405
|
+
* completion, and then the second schedule starts and runs to completion as
|
|
406
|
+
* well. The outputs of both schedules are collected into an `Either` structure:
|
|
407
|
+
* - `Either.Left` contains the output of the second schedule.
|
|
408
|
+
* - `Either.Right` contains the output of the first schedule.
|
|
409
|
+
*
|
|
410
|
+
* This is useful when you need to switch from one schedule to another after the
|
|
411
|
+
* first one finishes, while still keeping track of which schedule produced each
|
|
412
|
+
* result.
|
|
413
|
+
*
|
|
414
|
+
* @see {@link andThen} If you need to merge the outputs of both schedules.
|
|
257
415
|
*
|
|
258
416
|
* @since 2.0.0
|
|
259
|
-
* @category
|
|
417
|
+
* @category Sequential Composition
|
|
260
418
|
*/
|
|
261
419
|
<Out, In, R, Out2, In2, R2>(
|
|
262
420
|
self: Schedule<Out, In, R>,
|
|
@@ -265,60 +423,130 @@ export const andThenEither: {
|
|
|
265
423
|
} = internal.andThenEither
|
|
266
424
|
|
|
267
425
|
/**
|
|
268
|
-
*
|
|
426
|
+
* Transforms a schedule to always produce a constant output.
|
|
427
|
+
*
|
|
428
|
+
* **Details**
|
|
429
|
+
*
|
|
430
|
+
* This function modifies a given schedule so that instead of returning its
|
|
431
|
+
* computed outputs, it always returns a constant value.
|
|
432
|
+
*
|
|
433
|
+
* This is useful when you need a schedule for timing but don’t care about its
|
|
434
|
+
* actual output, or when you want to standardize results across different
|
|
435
|
+
* scheduling strategies.
|
|
269
436
|
*
|
|
270
437
|
* @since 2.0.0
|
|
271
|
-
* @category
|
|
438
|
+
* @category Mapping
|
|
272
439
|
*/
|
|
273
440
|
export const as: {
|
|
274
441
|
/**
|
|
275
|
-
*
|
|
442
|
+
* Transforms a schedule to always produce a constant output.
|
|
443
|
+
*
|
|
444
|
+
* **Details**
|
|
445
|
+
*
|
|
446
|
+
* This function modifies a given schedule so that instead of returning its
|
|
447
|
+
* computed outputs, it always returns a constant value.
|
|
448
|
+
*
|
|
449
|
+
* This is useful when you need a schedule for timing but don’t care about its
|
|
450
|
+
* actual output, or when you want to standardize results across different
|
|
451
|
+
* scheduling strategies.
|
|
276
452
|
*
|
|
277
453
|
* @since 2.0.0
|
|
278
|
-
* @category
|
|
454
|
+
* @category Mapping
|
|
279
455
|
*/
|
|
280
456
|
<Out2>(out: Out2): <Out, In, R>(self: Schedule<Out, In, R>) => Schedule<Out2, In, R>
|
|
281
457
|
/**
|
|
282
|
-
*
|
|
458
|
+
* Transforms a schedule to always produce a constant output.
|
|
459
|
+
*
|
|
460
|
+
* **Details**
|
|
461
|
+
*
|
|
462
|
+
* This function modifies a given schedule so that instead of returning its
|
|
463
|
+
* computed outputs, it always returns a constant value.
|
|
464
|
+
*
|
|
465
|
+
* This is useful when you need a schedule for timing but don’t care about its
|
|
466
|
+
* actual output, or when you want to standardize results across different
|
|
467
|
+
* scheduling strategies.
|
|
283
468
|
*
|
|
284
469
|
* @since 2.0.0
|
|
285
|
-
* @category
|
|
470
|
+
* @category Mapping
|
|
286
471
|
*/
|
|
287
472
|
<Out, In, R, Out2>(self: Schedule<Out, In, R>, out: Out2): Schedule<Out2, In, R>
|
|
288
473
|
} = internal.as
|
|
289
474
|
|
|
290
475
|
/**
|
|
291
|
-
*
|
|
476
|
+
* Transforms a schedule to always return `void` instead of its output.
|
|
477
|
+
*
|
|
478
|
+
* **Details**
|
|
479
|
+
*
|
|
480
|
+
* This function modifies a given schedule so that it no longer returns
|
|
481
|
+
* meaningful output—each execution produces `void`. This is useful when the
|
|
482
|
+
* schedule is used only for timing purposes and the actual output of the
|
|
483
|
+
* schedule is irrelevant.
|
|
484
|
+
*
|
|
485
|
+
* The schedule still determines when executions should occur, but the results
|
|
486
|
+
* are discarded.
|
|
292
487
|
*
|
|
293
488
|
* @since 2.0.0
|
|
294
|
-
* @category
|
|
489
|
+
* @category Mapping
|
|
295
490
|
*/
|
|
296
491
|
export const asVoid: <Out, In, R>(self: Schedule<Out, In, R>) => Schedule<void, In, R> = internal.asVoid
|
|
297
492
|
|
|
493
|
+
// TODO(4.0): rename to `zip`?
|
|
298
494
|
/**
|
|
299
|
-
*
|
|
300
|
-
*
|
|
495
|
+
* Combines two schedules, preserving both their inputs and outputs.
|
|
496
|
+
*
|
|
497
|
+
* **Details**
|
|
498
|
+
*
|
|
499
|
+
* This function merges two schedules so that both their input types and output
|
|
500
|
+
* types are retained. When executed, the resulting schedule will take inputs
|
|
501
|
+
* from both original schedules and produce a tuple containing both outputs.
|
|
502
|
+
*
|
|
503
|
+
* It recurs if either schedule wants to continue, using the shorter delay.
|
|
504
|
+
*
|
|
505
|
+
* This is useful when you want to track multiple schedules simultaneously,
|
|
506
|
+
* ensuring that both receive the same inputs and produce combined results.
|
|
301
507
|
*
|
|
302
508
|
* @since 2.0.0
|
|
303
|
-
* @category
|
|
509
|
+
* @category Zipping
|
|
304
510
|
*/
|
|
305
511
|
export const bothInOut: {
|
|
512
|
+
// TODO(4.0): rename to `zip`?
|
|
306
513
|
/**
|
|
307
|
-
*
|
|
308
|
-
*
|
|
514
|
+
* Combines two schedules, preserving both their inputs and outputs.
|
|
515
|
+
*
|
|
516
|
+
* **Details**
|
|
517
|
+
*
|
|
518
|
+
* This function merges two schedules so that both their input types and output
|
|
519
|
+
* types are retained. When executed, the resulting schedule will take inputs
|
|
520
|
+
* from both original schedules and produce a tuple containing both outputs.
|
|
521
|
+
*
|
|
522
|
+
* It recurs if either schedule wants to continue, using the shorter delay.
|
|
523
|
+
*
|
|
524
|
+
* This is useful when you want to track multiple schedules simultaneously,
|
|
525
|
+
* ensuring that both receive the same inputs and produce combined results.
|
|
309
526
|
*
|
|
310
527
|
* @since 2.0.0
|
|
311
|
-
* @category
|
|
528
|
+
* @category Zipping
|
|
312
529
|
*/
|
|
313
530
|
<Out2, In2, R2>(
|
|
314
531
|
that: Schedule<Out2, In2, R2>
|
|
315
532
|
): <Out, In, R>(self: Schedule<Out, In, R>) => Schedule<[Out, Out2], readonly [In, In2], R2 | R>
|
|
533
|
+
// TODO(4.0): rename to `zip`?
|
|
316
534
|
/**
|
|
317
|
-
*
|
|
318
|
-
*
|
|
535
|
+
* Combines two schedules, preserving both their inputs and outputs.
|
|
536
|
+
*
|
|
537
|
+
* **Details**
|
|
538
|
+
*
|
|
539
|
+
* This function merges two schedules so that both their input types and output
|
|
540
|
+
* types are retained. When executed, the resulting schedule will take inputs
|
|
541
|
+
* from both original schedules and produce a tuple containing both outputs.
|
|
542
|
+
*
|
|
543
|
+
* It recurs if either schedule wants to continue, using the shorter delay.
|
|
544
|
+
*
|
|
545
|
+
* This is useful when you want to track multiple schedules simultaneously,
|
|
546
|
+
* ensuring that both receive the same inputs and produce combined results.
|
|
319
547
|
*
|
|
320
548
|
* @since 2.0.0
|
|
321
|
-
* @category
|
|
549
|
+
* @category Zipping
|
|
322
550
|
*/
|
|
323
551
|
<Out, In, R, Out2, In2, R2>(
|
|
324
552
|
self: Schedule<Out, In, R>,
|
|
@@ -327,61 +555,118 @@ export const bothInOut: {
|
|
|
327
555
|
} = internal.bothInOut
|
|
328
556
|
|
|
329
557
|
/**
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
*
|
|
558
|
+
* Filters schedule executions based on a custom condition.
|
|
559
|
+
*
|
|
560
|
+
* **Details**
|
|
561
|
+
*
|
|
562
|
+
* This function modifies a schedule by applying a custom test function to each
|
|
563
|
+
* input-output pair. The test function determines whether the schedule should
|
|
564
|
+
* continue or stop. If the function returns `true`, the schedule proceeds as
|
|
565
|
+
* usual; if it returns `false`, the schedule terminates.
|
|
566
|
+
*
|
|
567
|
+
* This is useful for conditional retries, custom stop conditions, or
|
|
568
|
+
* dynamically controlling execution based on observed inputs and outputs.
|
|
569
|
+
*
|
|
570
|
+
* @see {@link checkEffect} If you need to use an effectful test function.
|
|
333
571
|
*
|
|
334
572
|
* @since 2.0.0
|
|
335
|
-
* @category
|
|
573
|
+
* @category Recurrence Conditions
|
|
336
574
|
*/
|
|
337
575
|
export const check: {
|
|
338
576
|
/**
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
577
|
+
* Filters schedule executions based on a custom condition.
|
|
578
|
+
*
|
|
579
|
+
* **Details**
|
|
580
|
+
*
|
|
581
|
+
* This function modifies a schedule by applying a custom test function to each
|
|
582
|
+
* input-output pair. The test function determines whether the schedule should
|
|
583
|
+
* continue or stop. If the function returns `true`, the schedule proceeds as
|
|
584
|
+
* usual; if it returns `false`, the schedule terminates.
|
|
585
|
+
*
|
|
586
|
+
* This is useful for conditional retries, custom stop conditions, or
|
|
587
|
+
* dynamically controlling execution based on observed inputs and outputs.
|
|
588
|
+
*
|
|
589
|
+
* @see {@link checkEffect} If you need to use an effectful test function.
|
|
342
590
|
*
|
|
343
591
|
* @since 2.0.0
|
|
344
|
-
* @category
|
|
592
|
+
* @category Recurrence Conditions
|
|
345
593
|
*/
|
|
346
594
|
<In, Out>(test: (input: In, output: Out) => boolean): <R>(self: Schedule<Out, In, R>) => Schedule<Out, In, R>
|
|
347
595
|
/**
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
596
|
+
* Filters schedule executions based on a custom condition.
|
|
597
|
+
*
|
|
598
|
+
* **Details**
|
|
599
|
+
*
|
|
600
|
+
* This function modifies a schedule by applying a custom test function to each
|
|
601
|
+
* input-output pair. The test function determines whether the schedule should
|
|
602
|
+
* continue or stop. If the function returns `true`, the schedule proceeds as
|
|
603
|
+
* usual; if it returns `false`, the schedule terminates.
|
|
604
|
+
*
|
|
605
|
+
* This is useful for conditional retries, custom stop conditions, or
|
|
606
|
+
* dynamically controlling execution based on observed inputs and outputs.
|
|
607
|
+
*
|
|
608
|
+
* @see {@link checkEffect} If you need to use an effectful test function.
|
|
351
609
|
*
|
|
352
610
|
* @since 2.0.0
|
|
353
|
-
* @category
|
|
611
|
+
* @category Recurrence Conditions
|
|
354
612
|
*/
|
|
355
613
|
<Out, In, R>(self: Schedule<Out, In, R>, test: (input: In, output: Out) => boolean): Schedule<Out, In, R>
|
|
356
614
|
} = internal.check
|
|
357
615
|
|
|
358
616
|
/**
|
|
359
|
-
*
|
|
360
|
-
*
|
|
361
|
-
*
|
|
617
|
+
* Conditionally filters schedule executions using an effectful function.
|
|
618
|
+
*
|
|
619
|
+
* **Details**
|
|
620
|
+
*
|
|
621
|
+
* This function modifies a schedule by applying a custom effectful test
|
|
622
|
+
* function to each input-output pair. The test function determines whether the
|
|
623
|
+
* schedule should continue (`true`) or stop (`false`).
|
|
624
|
+
*
|
|
625
|
+
* This is useful when the decision to continue depends on external factors such
|
|
626
|
+
* as database lookups, API calls, or other asynchronous computations.
|
|
627
|
+
*
|
|
628
|
+
* @see {@link check} If you need to use a pure test function.
|
|
362
629
|
*
|
|
363
630
|
* @since 2.0.0
|
|
364
|
-
* @category
|
|
631
|
+
* @category Recurrence Conditions
|
|
365
632
|
*/
|
|
366
633
|
export const checkEffect: {
|
|
367
634
|
/**
|
|
368
|
-
*
|
|
369
|
-
*
|
|
370
|
-
*
|
|
635
|
+
* Conditionally filters schedule executions using an effectful function.
|
|
636
|
+
*
|
|
637
|
+
* **Details**
|
|
638
|
+
*
|
|
639
|
+
* This function modifies a schedule by applying a custom effectful test
|
|
640
|
+
* function to each input-output pair. The test function determines whether the
|
|
641
|
+
* schedule should continue (`true`) or stop (`false`).
|
|
642
|
+
*
|
|
643
|
+
* This is useful when the decision to continue depends on external factors such
|
|
644
|
+
* as database lookups, API calls, or other asynchronous computations.
|
|
645
|
+
*
|
|
646
|
+
* @see {@link check} If you need to use a pure test function.
|
|
371
647
|
*
|
|
372
648
|
* @since 2.0.0
|
|
373
|
-
* @category
|
|
649
|
+
* @category Recurrence Conditions
|
|
374
650
|
*/
|
|
375
651
|
<In, Out, R2>(
|
|
376
652
|
test: (input: In, output: Out) => Effect.Effect<boolean, never, R2>
|
|
377
653
|
): <R>(self: Schedule<Out, In, R>) => Schedule<Out, In, R2 | R>
|
|
378
654
|
/**
|
|
379
|
-
*
|
|
380
|
-
*
|
|
381
|
-
*
|
|
655
|
+
* Conditionally filters schedule executions using an effectful function.
|
|
656
|
+
*
|
|
657
|
+
* **Details**
|
|
658
|
+
*
|
|
659
|
+
* This function modifies a schedule by applying a custom effectful test
|
|
660
|
+
* function to each input-output pair. The test function determines whether the
|
|
661
|
+
* schedule should continue (`true`) or stop (`false`).
|
|
662
|
+
*
|
|
663
|
+
* This is useful when the decision to continue depends on external factors such
|
|
664
|
+
* as database lookups, API calls, or other asynchronous computations.
|
|
665
|
+
*
|
|
666
|
+
* @see {@link check} If you need to use a pure test function.
|
|
382
667
|
*
|
|
383
668
|
* @since 2.0.0
|
|
384
|
-
* @category
|
|
669
|
+
* @category Recurrence Conditions
|
|
385
670
|
*/
|
|
386
671
|
<Out, In, R, R2>(
|
|
387
672
|
self: Schedule<Out, In, R>,
|
|
@@ -390,274 +675,560 @@ export const checkEffect: {
|
|
|
390
675
|
} = internal.checkEffect
|
|
391
676
|
|
|
392
677
|
/**
|
|
393
|
-
* A schedule that
|
|
678
|
+
* A schedule that collects all inputs into a `Chunk`.
|
|
679
|
+
*
|
|
680
|
+
* **Details**
|
|
681
|
+
*
|
|
682
|
+
* This function creates a schedule that never terminates and continuously
|
|
683
|
+
* collects every input it receives into a `Chunk`. Each time the schedule runs,
|
|
684
|
+
* it appends the new input to the collected list.
|
|
685
|
+
*
|
|
686
|
+
* This is useful when you need to track all received inputs over time, such as
|
|
687
|
+
* logging user actions, recording retry attempts, or accumulating data for
|
|
688
|
+
* later processing.
|
|
689
|
+
*
|
|
690
|
+
* @see {@link collectAllOutputs} If you need to collect outputs instead of
|
|
691
|
+
* inputs.
|
|
394
692
|
*
|
|
395
693
|
* @since 2.0.0
|
|
396
|
-
* @category
|
|
694
|
+
* @category Collecting
|
|
397
695
|
*/
|
|
398
696
|
export const collectAllInputs: <A>() => Schedule<Chunk.Chunk<A>, A> = internal.collectAllInputs
|
|
399
697
|
|
|
400
698
|
/**
|
|
401
|
-
*
|
|
699
|
+
* Collects all outputs of a schedule into a `Chunk`.
|
|
700
|
+
*
|
|
701
|
+
* **Details**
|
|
702
|
+
*
|
|
703
|
+
* This function modifies a given schedule so that instead of returning
|
|
704
|
+
* individual outputs, it accumulates them into a `Chunk`. The schedule
|
|
705
|
+
* continues to run, appending each output to the collected list.
|
|
706
|
+
*
|
|
707
|
+
* This is useful when you need to track all results over time, such as logging
|
|
708
|
+
* outputs, aggregating data, or keeping a history of previous values.
|
|
709
|
+
*
|
|
710
|
+
* @see {@link collectAllInputs} If you need to collect inputs instead of
|
|
711
|
+
* outputs.
|
|
402
712
|
*
|
|
403
713
|
* @since 2.0.0
|
|
404
|
-
* @category
|
|
714
|
+
* @category Collecting
|
|
405
715
|
*/
|
|
406
716
|
export const collectAllOutputs: <Out, In, R>(self: Schedule<Out, In, R>) => Schedule<Chunk.Chunk<Out>, In, R> =
|
|
407
717
|
internal.collectAllOutputs
|
|
408
718
|
|
|
409
719
|
/**
|
|
410
|
-
*
|
|
411
|
-
*
|
|
720
|
+
* Collects all inputs into a `Chunk` until a condition fails.
|
|
721
|
+
*
|
|
722
|
+
* **Details**
|
|
723
|
+
*
|
|
724
|
+
* This function creates a schedule that continuously collects inputs into a
|
|
725
|
+
* `Chunk` until the given predicate function `f` evaluates to `false`. Once the
|
|
726
|
+
* condition fails, the schedule stops.
|
|
412
727
|
*
|
|
413
728
|
* @since 2.0.0
|
|
414
|
-
* @category
|
|
729
|
+
* @category Collecting
|
|
415
730
|
*/
|
|
416
731
|
export const collectUntil: <A>(f: Predicate<A>) => Schedule<Chunk.Chunk<A>, A> = internal.collectUntil
|
|
417
732
|
|
|
418
733
|
/**
|
|
419
|
-
*
|
|
420
|
-
*
|
|
734
|
+
* Collects all inputs into a `Chunk` until an effectful condition fails.
|
|
735
|
+
*
|
|
736
|
+
* **Details**
|
|
737
|
+
*
|
|
738
|
+
* This function creates a schedule that continuously collects inputs into a
|
|
739
|
+
* `Chunk` until the given effectful predicate `f` returns `false`. The
|
|
740
|
+
* predicate runs as an effect, meaning it can involve asynchronous computations
|
|
741
|
+
* like API calls, database lookups, or randomness.
|
|
421
742
|
*
|
|
422
743
|
* @since 2.0.0
|
|
423
|
-
* @category
|
|
744
|
+
* @category Collecting
|
|
424
745
|
*/
|
|
425
746
|
export const collectUntilEffect: <A, R>(
|
|
426
747
|
f: (a: A) => Effect.Effect<boolean, never, R>
|
|
427
748
|
) => Schedule<Chunk.Chunk<A>, A, R> = internal.collectUntilEffect
|
|
428
749
|
|
|
429
750
|
/**
|
|
430
|
-
*
|
|
431
|
-
*
|
|
751
|
+
* Collects all inputs into a `Chunk` while a condition holds.
|
|
752
|
+
*
|
|
753
|
+
* **Details**
|
|
754
|
+
*
|
|
755
|
+
* This function creates a schedule that continuously collects inputs into a
|
|
756
|
+
* `Chunk` while the given predicate function `f` evaluates to `true`. As soon
|
|
757
|
+
* as the condition fails, the schedule stops.
|
|
432
758
|
*
|
|
433
759
|
* @since 2.0.0
|
|
434
|
-
* @category
|
|
760
|
+
* @category Collecting
|
|
435
761
|
*/
|
|
436
762
|
export const collectWhile: <A>(f: Predicate<A>) => Schedule<Chunk.Chunk<A>, A> = internal.collectWhile
|
|
437
763
|
|
|
438
764
|
/**
|
|
439
|
-
*
|
|
440
|
-
*
|
|
765
|
+
* Collects all inputs into a `Chunk` while an effectful condition holds.
|
|
766
|
+
*
|
|
767
|
+
* **Details**
|
|
768
|
+
*
|
|
769
|
+
* This function creates a schedule that continuously collects inputs into a
|
|
770
|
+
* `Chunk` while the given effectful predicate `f` returns `true`. The predicate
|
|
771
|
+
* returns an effect, meaning it can depend on external state, such as database
|
|
772
|
+
* queries, API responses, or real-time user conditions.
|
|
773
|
+
*
|
|
774
|
+
* As soon as the effectful condition returns `false`, the schedule stops. This
|
|
775
|
+
* is useful for dynamically controlled data collection, where stopping depends
|
|
776
|
+
* on an external or asynchronous factor.
|
|
441
777
|
*
|
|
442
|
-
* @category utils
|
|
443
778
|
* @since 2.0.0
|
|
779
|
+
* @category Collecting
|
|
444
780
|
*/
|
|
445
781
|
export const collectWhileEffect: <A, R>(
|
|
446
782
|
f: (a: A) => Effect.Effect<boolean, never, R>
|
|
447
783
|
) => Schedule<Chunk.Chunk<A>, A, R> = internal.collectWhileEffect
|
|
448
784
|
|
|
449
785
|
/**
|
|
450
|
-
*
|
|
451
|
-
*
|
|
452
|
-
*
|
|
453
|
-
*
|
|
786
|
+
* Chains two schedules, passing the output of the first as the input to the
|
|
787
|
+
* second, while selecting the shorter delay between them.
|
|
788
|
+
*
|
|
789
|
+
* **Details**
|
|
790
|
+
*
|
|
791
|
+
* This function composes two schedules so that the output of the first schedule
|
|
792
|
+
* becomes the input of the second schedule. The first schedule executes first,
|
|
793
|
+
* and once it produces a result, the second schedule receives that result and
|
|
794
|
+
* continues execution based on it.
|
|
795
|
+
*
|
|
796
|
+
* This is useful for building complex scheduling workflows where one schedule's
|
|
797
|
+
* behavior determines how the next schedule behaves.
|
|
454
798
|
*
|
|
455
799
|
* @since 2.0.0
|
|
456
|
-
* @category
|
|
800
|
+
* @category Composition
|
|
457
801
|
*/
|
|
458
802
|
export const compose: {
|
|
459
803
|
/**
|
|
460
|
-
*
|
|
461
|
-
*
|
|
462
|
-
*
|
|
463
|
-
*
|
|
804
|
+
* Chains two schedules, passing the output of the first as the input to the
|
|
805
|
+
* second, while selecting the shorter delay between them.
|
|
806
|
+
*
|
|
807
|
+
* **Details**
|
|
808
|
+
*
|
|
809
|
+
* This function composes two schedules so that the output of the first schedule
|
|
810
|
+
* becomes the input of the second schedule. The first schedule executes first,
|
|
811
|
+
* and once it produces a result, the second schedule receives that result and
|
|
812
|
+
* continues execution based on it.
|
|
813
|
+
*
|
|
814
|
+
* This is useful for building complex scheduling workflows where one schedule's
|
|
815
|
+
* behavior determines how the next schedule behaves.
|
|
464
816
|
*
|
|
465
817
|
* @since 2.0.0
|
|
466
|
-
* @category
|
|
818
|
+
* @category Composition
|
|
467
819
|
*/
|
|
468
820
|
<Out2, Out, R2>(that: Schedule<Out2, Out, R2>): <In, R>(self: Schedule<Out, In, R>) => Schedule<Out2, In, R2 | R>
|
|
469
821
|
/**
|
|
470
|
-
*
|
|
471
|
-
*
|
|
472
|
-
*
|
|
473
|
-
*
|
|
822
|
+
* Chains two schedules, passing the output of the first as the input to the
|
|
823
|
+
* second, while selecting the shorter delay between them.
|
|
824
|
+
*
|
|
825
|
+
* **Details**
|
|
826
|
+
*
|
|
827
|
+
* This function composes two schedules so that the output of the first schedule
|
|
828
|
+
* becomes the input of the second schedule. The first schedule executes first,
|
|
829
|
+
* and once it produces a result, the second schedule receives that result and
|
|
830
|
+
* continues execution based on it.
|
|
831
|
+
*
|
|
832
|
+
* This is useful for building complex scheduling workflows where one schedule's
|
|
833
|
+
* behavior determines how the next schedule behaves.
|
|
474
834
|
*
|
|
475
835
|
* @since 2.0.0
|
|
476
|
-
* @category
|
|
836
|
+
* @category Composition
|
|
477
837
|
*/
|
|
478
838
|
<Out, In, R, Out2, R2>(self: Schedule<Out, In, R>, that: Schedule<Out2, Out, R2>): Schedule<Out2, In, R | R2>
|
|
479
839
|
} = internal.compose
|
|
480
840
|
|
|
481
841
|
/**
|
|
482
|
-
*
|
|
483
|
-
*
|
|
842
|
+
* Transforms the input type of a schedule.
|
|
843
|
+
*
|
|
844
|
+
* **Details**
|
|
845
|
+
*
|
|
846
|
+
* This function modifies a given schedule by applying a transformation function
|
|
847
|
+
* to its inputs. Instead of directly receiving values of type `In`, the
|
|
848
|
+
* schedule will now accept values of type `In2`, which are converted to `In`
|
|
849
|
+
* using the provided mapping function `f`.
|
|
850
|
+
*
|
|
851
|
+
* This is useful when you have a schedule that expects a specific input type
|
|
852
|
+
* but you need to adapt it to work with a different type.
|
|
853
|
+
*
|
|
854
|
+
* @see {@link mapInputEffect} If you need to use an effectful transformation function.
|
|
484
855
|
*
|
|
485
856
|
* @since 2.0.0
|
|
486
|
-
* @category
|
|
857
|
+
* @category Mapping
|
|
487
858
|
*/
|
|
488
859
|
export const mapInput: {
|
|
489
860
|
/**
|
|
490
|
-
*
|
|
491
|
-
*
|
|
861
|
+
* Transforms the input type of a schedule.
|
|
862
|
+
*
|
|
863
|
+
* **Details**
|
|
864
|
+
*
|
|
865
|
+
* This function modifies a given schedule by applying a transformation function
|
|
866
|
+
* to its inputs. Instead of directly receiving values of type `In`, the
|
|
867
|
+
* schedule will now accept values of type `In2`, which are converted to `In`
|
|
868
|
+
* using the provided mapping function `f`.
|
|
869
|
+
*
|
|
870
|
+
* This is useful when you have a schedule that expects a specific input type
|
|
871
|
+
* but you need to adapt it to work with a different type.
|
|
872
|
+
*
|
|
873
|
+
* @see {@link mapInputEffect} If you need to use an effectful transformation function.
|
|
492
874
|
*
|
|
493
875
|
* @since 2.0.0
|
|
494
|
-
* @category
|
|
876
|
+
* @category Mapping
|
|
495
877
|
*/
|
|
496
878
|
<In, In2>(f: (in2: In2) => In): <Out, R>(self: Schedule<Out, In, R>) => Schedule<Out, In2, R>
|
|
497
879
|
/**
|
|
498
|
-
*
|
|
499
|
-
*
|
|
880
|
+
* Transforms the input type of a schedule.
|
|
881
|
+
*
|
|
882
|
+
* **Details**
|
|
883
|
+
*
|
|
884
|
+
* This function modifies a given schedule by applying a transformation function
|
|
885
|
+
* to its inputs. Instead of directly receiving values of type `In`, the
|
|
886
|
+
* schedule will now accept values of type `In2`, which are converted to `In`
|
|
887
|
+
* using the provided mapping function `f`.
|
|
888
|
+
*
|
|
889
|
+
* This is useful when you have a schedule that expects a specific input type
|
|
890
|
+
* but you need to adapt it to work with a different type.
|
|
891
|
+
*
|
|
892
|
+
* @see {@link mapInputEffect} If you need to use an effectful transformation function.
|
|
500
893
|
*
|
|
501
894
|
* @since 2.0.0
|
|
502
|
-
* @category
|
|
895
|
+
* @category Mapping
|
|
503
896
|
*/
|
|
504
897
|
<Out, In, R, In2>(self: Schedule<Out, In, R>, f: (in2: In2) => In): Schedule<Out, In2, R>
|
|
505
898
|
} = internal.mapInput
|
|
506
899
|
|
|
507
900
|
/**
|
|
508
|
-
* Transforms the
|
|
509
|
-
*
|
|
901
|
+
* Transforms the input type of a schedule using an effectful function.
|
|
902
|
+
*
|
|
903
|
+
* **Details**
|
|
904
|
+
*
|
|
905
|
+
* This function modifies a schedule by applying an effectful transformation to
|
|
906
|
+
* its inputs. Instead of directly receiving values of type `In`, the schedule
|
|
907
|
+
* will now accept values of type `In2`, which are converted to `In` via an
|
|
908
|
+
* effectful function `f`.
|
|
909
|
+
*
|
|
910
|
+
* This is useful when the input transformation involves external dependencies,
|
|
911
|
+
* such as API calls, database lookups, or other asynchronous computations.
|
|
912
|
+
*
|
|
913
|
+
* @see {@link mapInput} If you need to use a pure transformation function.
|
|
510
914
|
*
|
|
511
915
|
* @since 2.0.0
|
|
512
|
-
* @category
|
|
916
|
+
* @category Mapping
|
|
513
917
|
*/
|
|
514
|
-
export const
|
|
918
|
+
export const mapInputEffect: {
|
|
515
919
|
/**
|
|
516
|
-
* Transforms the
|
|
517
|
-
*
|
|
920
|
+
* Transforms the input type of a schedule using an effectful function.
|
|
921
|
+
*
|
|
922
|
+
* **Details**
|
|
923
|
+
*
|
|
924
|
+
* This function modifies a schedule by applying an effectful transformation to
|
|
925
|
+
* its inputs. Instead of directly receiving values of type `In`, the schedule
|
|
926
|
+
* will now accept values of type `In2`, which are converted to `In` via an
|
|
927
|
+
* effectful function `f`.
|
|
928
|
+
*
|
|
929
|
+
* This is useful when the input transformation involves external dependencies,
|
|
930
|
+
* such as API calls, database lookups, or other asynchronous computations.
|
|
931
|
+
*
|
|
932
|
+
* @see {@link mapInput} If you need to use a pure transformation function.
|
|
518
933
|
*
|
|
519
934
|
* @since 2.0.0
|
|
520
|
-
* @category
|
|
935
|
+
* @category Mapping
|
|
521
936
|
*/
|
|
522
|
-
<
|
|
523
|
-
f: (
|
|
524
|
-
): <Out,
|
|
937
|
+
<In2, In, R2>(
|
|
938
|
+
f: (in2: In2) => Effect.Effect<In, never, R2>
|
|
939
|
+
): <Out, R>(self: Schedule<Out, In, R>) => Schedule<Out, In2, R2 | R>
|
|
525
940
|
/**
|
|
526
|
-
* Transforms the
|
|
527
|
-
*
|
|
941
|
+
* Transforms the input type of a schedule using an effectful function.
|
|
942
|
+
*
|
|
943
|
+
* **Details**
|
|
944
|
+
*
|
|
945
|
+
* This function modifies a schedule by applying an effectful transformation to
|
|
946
|
+
* its inputs. Instead of directly receiving values of type `In`, the schedule
|
|
947
|
+
* will now accept values of type `In2`, which are converted to `In` via an
|
|
948
|
+
* effectful function `f`.
|
|
949
|
+
*
|
|
950
|
+
* This is useful when the input transformation involves external dependencies,
|
|
951
|
+
* such as API calls, database lookups, or other asynchronous computations.
|
|
952
|
+
*
|
|
953
|
+
* @see {@link mapInput} If you need to use a pure transformation function.
|
|
528
954
|
*
|
|
529
955
|
* @since 2.0.0
|
|
530
|
-
* @category
|
|
956
|
+
* @category Mapping
|
|
531
957
|
*/
|
|
532
|
-
<Out, In, R,
|
|
958
|
+
<Out, In, R, In2, R2>(
|
|
533
959
|
self: Schedule<Out, In, R>,
|
|
534
|
-
f: (
|
|
535
|
-
): Schedule<Out,
|
|
536
|
-
} = internal.
|
|
960
|
+
f: (in2: In2) => Effect.Effect<In, never, R2>
|
|
961
|
+
): Schedule<Out, In2, R | R2>
|
|
962
|
+
} = internal.mapInputEffect
|
|
537
963
|
|
|
538
964
|
/**
|
|
539
|
-
*
|
|
540
|
-
*
|
|
965
|
+
* Transforms the required context of a schedule.
|
|
966
|
+
*
|
|
967
|
+
* **Details**
|
|
968
|
+
*
|
|
969
|
+
* This function modifies a schedule by mapping its required context (`R`) into
|
|
970
|
+
* a new context (`R0`) using the provided function `f`.
|
|
971
|
+
*
|
|
972
|
+
* This is useful when you need to adapt a schedule to work with a different
|
|
973
|
+
* dependency environment without changing its core logic.
|
|
541
974
|
*
|
|
542
975
|
* @since 2.0.0
|
|
543
|
-
* @category
|
|
976
|
+
* @category Mapping
|
|
544
977
|
*/
|
|
545
|
-
export const
|
|
978
|
+
export const mapInputContext: {
|
|
546
979
|
/**
|
|
547
|
-
*
|
|
548
|
-
*
|
|
980
|
+
* Transforms the required context of a schedule.
|
|
981
|
+
*
|
|
982
|
+
* **Details**
|
|
983
|
+
*
|
|
984
|
+
* This function modifies a schedule by mapping its required context (`R`) into
|
|
985
|
+
* a new context (`R0`) using the provided function `f`.
|
|
986
|
+
*
|
|
987
|
+
* This is useful when you need to adapt a schedule to work with a different
|
|
988
|
+
* dependency environment without changing its core logic.
|
|
549
989
|
*
|
|
550
990
|
* @since 2.0.0
|
|
551
|
-
* @category
|
|
991
|
+
* @category Mapping
|
|
552
992
|
*/
|
|
553
|
-
<
|
|
554
|
-
f: (
|
|
555
|
-
): <Out,
|
|
993
|
+
<R0, R>(
|
|
994
|
+
f: (env0: Context.Context<R0>) => Context.Context<R>
|
|
995
|
+
): <Out, In>(self: Schedule<Out, In, R>) => Schedule<Out, In, R0>
|
|
556
996
|
/**
|
|
557
|
-
*
|
|
558
|
-
*
|
|
997
|
+
* Transforms the required context of a schedule.
|
|
998
|
+
*
|
|
999
|
+
* **Details**
|
|
1000
|
+
*
|
|
1001
|
+
* This function modifies a schedule by mapping its required context (`R`) into
|
|
1002
|
+
* a new context (`R0`) using the provided function `f`.
|
|
1003
|
+
*
|
|
1004
|
+
* This is useful when you need to adapt a schedule to work with a different
|
|
1005
|
+
* dependency environment without changing its core logic.
|
|
559
1006
|
*
|
|
560
1007
|
* @since 2.0.0
|
|
561
|
-
* @category
|
|
1008
|
+
* @category Mapping
|
|
562
1009
|
*/
|
|
563
|
-
<Out, In, R,
|
|
1010
|
+
<Out, In, R, R0>(
|
|
564
1011
|
self: Schedule<Out, In, R>,
|
|
565
|
-
f: (
|
|
566
|
-
): Schedule<Out,
|
|
567
|
-
} = internal.
|
|
1012
|
+
f: (env0: Context.Context<R0>) => Context.Context<R>
|
|
1013
|
+
): Schedule<Out, In, R0>
|
|
1014
|
+
} = internal.mapInputContext
|
|
568
1015
|
|
|
569
1016
|
/**
|
|
570
|
-
* A schedule that
|
|
1017
|
+
* A schedule that recurs indefinitely, counting the number of recurrences.
|
|
1018
|
+
*
|
|
1019
|
+
* **Details**
|
|
1020
|
+
*
|
|
1021
|
+
* This schedule never stops and simply counts how many times it has executed.
|
|
1022
|
+
* Each recurrence increases the count, starting from `0`.
|
|
1023
|
+
*
|
|
1024
|
+
* This is useful when tracking the number of attempts in retry policies,
|
|
1025
|
+
* measuring execution loops, or implementing infinite polling scenarios.
|
|
571
1026
|
*
|
|
572
1027
|
* @since 2.0.0
|
|
573
|
-
* @category
|
|
1028
|
+
* @category Constructors
|
|
574
1029
|
*/
|
|
575
1030
|
export const count: Schedule<number> = internal.count
|
|
576
1031
|
|
|
577
1032
|
/**
|
|
578
|
-
*
|
|
1033
|
+
* Creates a schedule that recurs based on a cron expression.
|
|
1034
|
+
*
|
|
1035
|
+
* **Details**
|
|
579
1036
|
*
|
|
580
|
-
*
|
|
1037
|
+
* This schedule automatically executes at intervals defined by a cron
|
|
1038
|
+
* expression. It triggers at the beginning of each matched interval and
|
|
1039
|
+
* produces timestamps representing the start and end of the cron window.
|
|
581
1040
|
*
|
|
582
|
-
*
|
|
1041
|
+
* The cron `expression` is validated lazily, meaning errors may only be
|
|
1042
|
+
* detected when the schedule is executed.
|
|
583
1043
|
*
|
|
584
1044
|
* @since 2.0.0
|
|
585
|
-
* @category
|
|
1045
|
+
* @category Cron
|
|
586
1046
|
*/
|
|
587
1047
|
export const cron: {
|
|
588
1048
|
/**
|
|
589
|
-
*
|
|
1049
|
+
* Creates a schedule that recurs based on a cron expression.
|
|
590
1050
|
*
|
|
591
|
-
*
|
|
1051
|
+
* **Details**
|
|
592
1052
|
*
|
|
593
|
-
*
|
|
1053
|
+
* This schedule automatically executes at intervals defined by a cron
|
|
1054
|
+
* expression. It triggers at the beginning of each matched interval and
|
|
1055
|
+
* produces timestamps representing the start and end of the cron window.
|
|
1056
|
+
*
|
|
1057
|
+
* The cron `expression` is validated lazily, meaning errors may only be
|
|
1058
|
+
* detected when the schedule is executed.
|
|
594
1059
|
*
|
|
595
1060
|
* @since 2.0.0
|
|
596
|
-
* @category
|
|
1061
|
+
* @category Cron
|
|
597
1062
|
*/
|
|
598
1063
|
(cron: Cron.Cron): Schedule<[number, number]>
|
|
599
1064
|
/**
|
|
600
|
-
*
|
|
1065
|
+
* Creates a schedule that recurs based on a cron expression.
|
|
1066
|
+
*
|
|
1067
|
+
* **Details**
|
|
601
1068
|
*
|
|
602
|
-
*
|
|
1069
|
+
* This schedule automatically executes at intervals defined by a cron
|
|
1070
|
+
* expression. It triggers at the beginning of each matched interval and
|
|
1071
|
+
* produces timestamps representing the start and end of the cron window.
|
|
603
1072
|
*
|
|
604
|
-
*
|
|
1073
|
+
* The cron `expression` is validated lazily, meaning errors may only be
|
|
1074
|
+
* detected when the schedule is executed.
|
|
605
1075
|
*
|
|
606
1076
|
* @since 2.0.0
|
|
607
|
-
* @category
|
|
1077
|
+
* @category Cron
|
|
608
1078
|
*/
|
|
609
1079
|
(expression: string, tz?: DateTime.TimeZone | string): Schedule<[number, number]>
|
|
610
1080
|
} = internal.cron
|
|
611
1081
|
|
|
612
1082
|
/**
|
|
613
|
-
* Cron-like schedule that recurs
|
|
614
|
-
*
|
|
1083
|
+
* Cron-like schedule that recurs at a specific second of each minute.
|
|
1084
|
+
*
|
|
1085
|
+
* **Details**
|
|
1086
|
+
*
|
|
1087
|
+
* This schedule triggers at the specified `second` of each minute,
|
|
1088
|
+
* starting at zero nanoseconds. It produces a count of executions
|
|
1089
|
+
* (0, 1, 2, ...). The `second` parameter is validated lazily, meaning
|
|
1090
|
+
* invalid values will only be caught at runtime.
|
|
1091
|
+
*
|
|
1092
|
+
* @since 2.0.0
|
|
1093
|
+
* @category Cron
|
|
1094
|
+
*/
|
|
1095
|
+
export const secondOfMinute: (second: number) => Schedule<number> = internal.secondOfMinute
|
|
1096
|
+
|
|
1097
|
+
/**
|
|
1098
|
+
* Creates a schedule that recurs every specified minute of each hour.
|
|
1099
|
+
*
|
|
1100
|
+
* **Details**
|
|
1101
|
+
*
|
|
1102
|
+
* This schedule triggers once per hour at the specified `minute`, starting
|
|
1103
|
+
* exactly at `minute:00` (zero seconds). The schedule produces a count of
|
|
1104
|
+
* executions (`0, 1, 2, ...`), representing how many times it has run.
|
|
1105
|
+
*
|
|
1106
|
+
* The `minute` parameter must be between `0` and `59`. It is validated lazily,
|
|
1107
|
+
* meaning an invalid value will cause errors only when the schedule is
|
|
1108
|
+
* executed.
|
|
1109
|
+
*
|
|
1110
|
+
* @since 2.0.0
|
|
1111
|
+
* @category Cron
|
|
1112
|
+
*/
|
|
1113
|
+
export const minuteOfHour: (minute: number) => Schedule<number> = internal.minuteOfHour
|
|
1114
|
+
|
|
1115
|
+
/**
|
|
1116
|
+
* Creates a schedule that recurs at a specific hour of each day.
|
|
1117
|
+
*
|
|
1118
|
+
* **Details**
|
|
1119
|
+
*
|
|
1120
|
+
* This schedule triggers once per day at the specified `hour`, starting at zero
|
|
1121
|
+
* minutes of that hour. The schedule produces a count of executions (`0, 1, 2,
|
|
1122
|
+
* ...`), indicating how many times it has been triggered.
|
|
1123
|
+
*
|
|
1124
|
+
* The `hour` parameter must be between `0` (midnight) and `23` (11 PM). It is
|
|
1125
|
+
* validated lazily, meaning an invalid value will cause errors only when the
|
|
1126
|
+
* schedule is executed.
|
|
1127
|
+
*
|
|
1128
|
+
* This is useful for scheduling daily recurring tasks at a fixed time, such as
|
|
1129
|
+
* running batch jobs or refreshing data.
|
|
1130
|
+
*
|
|
1131
|
+
* @since 2.0.0
|
|
1132
|
+
* @category Cron
|
|
1133
|
+
*/
|
|
1134
|
+
export const hourOfDay: (hour: number) => Schedule<number> = internal.hourOfDay
|
|
1135
|
+
|
|
1136
|
+
/**
|
|
1137
|
+
* Creates a schedule that recurs on a specific day of the month.
|
|
1138
|
+
*
|
|
1139
|
+
* **Details**
|
|
615
1140
|
*
|
|
616
|
-
*
|
|
1141
|
+
* This schedule triggers at midnight on the specified day of each month. It
|
|
1142
|
+
* will not execute in months that have fewer days than the given day. For
|
|
1143
|
+
* example, if the schedule is set to run on the 31st, it will not execute in
|
|
1144
|
+
* months with only 30 days.
|
|
617
1145
|
*
|
|
618
|
-
*
|
|
1146
|
+
* The schedule produces a count of executions, starting at 0 and incrementing
|
|
1147
|
+
* with each recurrence.
|
|
1148
|
+
*
|
|
1149
|
+
* The `day` parameter is validated lazily, meaning errors may only be detected
|
|
1150
|
+
* when the schedule is executed.
|
|
619
1151
|
*
|
|
620
1152
|
* @since 2.0.0
|
|
621
|
-
* @category
|
|
1153
|
+
* @category Cron
|
|
622
1154
|
*/
|
|
623
1155
|
export const dayOfMonth: (day: number) => Schedule<number> = internal.dayOfMonth
|
|
624
1156
|
|
|
625
1157
|
/**
|
|
626
|
-
*
|
|
627
|
-
*
|
|
1158
|
+
* Creates a schedule that recurs on a specific day of the week.
|
|
1159
|
+
*
|
|
1160
|
+
* **Details**
|
|
628
1161
|
*
|
|
629
|
-
*
|
|
630
|
-
*
|
|
1162
|
+
* This schedule triggers at midnight on the specified day of the week. The
|
|
1163
|
+
* `day` parameter follows the standard convention where `Monday = 1` and
|
|
1164
|
+
* `Sunday = 7`. The schedule produces a count of executions, starting at 0 and
|
|
1165
|
+
* incrementing with each recurrence.
|
|
1166
|
+
*
|
|
1167
|
+
* The `day` parameter is validated lazily, meaning errors may only be detected
|
|
1168
|
+
* when the schedule is executed.
|
|
631
1169
|
*
|
|
632
1170
|
* @since 2.0.0
|
|
633
|
-
* @category
|
|
1171
|
+
* @category Cron
|
|
634
1172
|
*/
|
|
635
1173
|
export const dayOfWeek: (day: number) => Schedule<number> = internal.dayOfWeek
|
|
636
1174
|
|
|
637
1175
|
/**
|
|
638
|
-
*
|
|
639
|
-
*
|
|
1176
|
+
* Modifies a schedule by adding a computed delay before each execution.
|
|
1177
|
+
*
|
|
1178
|
+
* **Details**
|
|
1179
|
+
*
|
|
1180
|
+
* This function adjusts an existing schedule by applying a transformation to
|
|
1181
|
+
* its delays. Instead of using the default interval, each delay is modified
|
|
1182
|
+
* using the provided function `f`, which takes the current delay and returns a
|
|
1183
|
+
* new delay.
|
|
1184
|
+
*
|
|
1185
|
+
* This is useful for dynamically adjusting wait times between executions, such
|
|
1186
|
+
* as introducing jitter, exponential backoff, or custom delay logic.
|
|
1187
|
+
*
|
|
1188
|
+
* @see {@link delayedEffect} If you need to compute the delay using an effectful function.
|
|
640
1189
|
*
|
|
641
1190
|
* @since 2.0.0
|
|
642
|
-
* @category
|
|
1191
|
+
* @category Timing & Delay
|
|
643
1192
|
*/
|
|
644
1193
|
export const delayed: {
|
|
645
1194
|
/**
|
|
646
|
-
*
|
|
647
|
-
*
|
|
1195
|
+
* Modifies a schedule by adding a computed delay before each execution.
|
|
1196
|
+
*
|
|
1197
|
+
* **Details**
|
|
1198
|
+
*
|
|
1199
|
+
* This function adjusts an existing schedule by applying a transformation to
|
|
1200
|
+
* its delays. Instead of using the default interval, each delay is modified
|
|
1201
|
+
* using the provided function `f`, which takes the current delay and returns a
|
|
1202
|
+
* new delay.
|
|
1203
|
+
*
|
|
1204
|
+
* This is useful for dynamically adjusting wait times between executions, such
|
|
1205
|
+
* as introducing jitter, exponential backoff, or custom delay logic.
|
|
1206
|
+
*
|
|
1207
|
+
* @see {@link delayedEffect} If you need to compute the delay using an effectful function.
|
|
648
1208
|
*
|
|
649
1209
|
* @since 2.0.0
|
|
650
|
-
* @category
|
|
1210
|
+
* @category Timing & Delay
|
|
651
1211
|
*/
|
|
652
1212
|
(
|
|
653
1213
|
f: (duration: Duration.Duration) => Duration.DurationInput
|
|
654
1214
|
): <Out, In, R>(self: Schedule<Out, In, R>) => Schedule<Out, In, R>
|
|
655
1215
|
/**
|
|
656
|
-
*
|
|
657
|
-
*
|
|
1216
|
+
* Modifies a schedule by adding a computed delay before each execution.
|
|
1217
|
+
*
|
|
1218
|
+
* **Details**
|
|
1219
|
+
*
|
|
1220
|
+
* This function adjusts an existing schedule by applying a transformation to
|
|
1221
|
+
* its delays. Instead of using the default interval, each delay is modified
|
|
1222
|
+
* using the provided function `f`, which takes the current delay and returns a
|
|
1223
|
+
* new delay.
|
|
1224
|
+
*
|
|
1225
|
+
* This is useful for dynamically adjusting wait times between executions, such
|
|
1226
|
+
* as introducing jitter, exponential backoff, or custom delay logic.
|
|
1227
|
+
*
|
|
1228
|
+
* @see {@link delayedEffect} If you need to compute the delay using an effectful function.
|
|
658
1229
|
*
|
|
659
1230
|
* @since 2.0.0
|
|
660
|
-
* @category
|
|
1231
|
+
* @category Timing & Delay
|
|
661
1232
|
*/
|
|
662
1233
|
<Out, In, R>(
|
|
663
1234
|
self: Schedule<Out, In, R>,
|
|
@@ -666,29 +1237,65 @@ export const delayed: {
|
|
|
666
1237
|
} = internal.delayed
|
|
667
1238
|
|
|
668
1239
|
/**
|
|
669
|
-
*
|
|
670
|
-
*
|
|
1240
|
+
* Modifies a schedule by adding an effectfully computed delay before each
|
|
1241
|
+
* execution.
|
|
1242
|
+
*
|
|
1243
|
+
* **Details**
|
|
1244
|
+
*
|
|
1245
|
+
* This function adjusts an existing schedule by introducing a delay that is
|
|
1246
|
+
* computed via an effect. Instead of using a fixed delay, each interval is
|
|
1247
|
+
* dynamically adjusted based on an effectful function `f`, which takes the
|
|
1248
|
+
* current delay and returns a new delay wrapped in an `Effect`.
|
|
1249
|
+
*
|
|
1250
|
+
* This is useful for adaptive scheduling where delays depend on external
|
|
1251
|
+
* factors, such as API calls, database queries, or dynamic system conditions.
|
|
1252
|
+
*
|
|
1253
|
+
* @see {@link delayed} If you need to compute the delay using a pure function.
|
|
671
1254
|
*
|
|
672
1255
|
* @since 2.0.0
|
|
673
|
-
* @category
|
|
1256
|
+
* @category Timing & Delay
|
|
674
1257
|
*/
|
|
675
1258
|
export const delayedEffect: {
|
|
676
1259
|
/**
|
|
677
|
-
*
|
|
678
|
-
*
|
|
1260
|
+
* Modifies a schedule by adding an effectfully computed delay before each
|
|
1261
|
+
* execution.
|
|
1262
|
+
*
|
|
1263
|
+
* **Details**
|
|
1264
|
+
*
|
|
1265
|
+
* This function adjusts an existing schedule by introducing a delay that is
|
|
1266
|
+
* computed via an effect. Instead of using a fixed delay, each interval is
|
|
1267
|
+
* dynamically adjusted based on an effectful function `f`, which takes the
|
|
1268
|
+
* current delay and returns a new delay wrapped in an `Effect`.
|
|
1269
|
+
*
|
|
1270
|
+
* This is useful for adaptive scheduling where delays depend on external
|
|
1271
|
+
* factors, such as API calls, database queries, or dynamic system conditions.
|
|
1272
|
+
*
|
|
1273
|
+
* @see {@link delayed} If you need to compute the delay using a pure function.
|
|
679
1274
|
*
|
|
680
1275
|
* @since 2.0.0
|
|
681
|
-
* @category
|
|
1276
|
+
* @category Timing & Delay
|
|
682
1277
|
*/
|
|
683
1278
|
<R2>(
|
|
684
1279
|
f: (duration: Duration.Duration) => Effect.Effect<Duration.DurationInput, never, R2>
|
|
685
1280
|
): <Out, In, R>(self: Schedule<Out, In, R>) => Schedule<Out, In, R2 | R>
|
|
686
1281
|
/**
|
|
687
|
-
*
|
|
688
|
-
*
|
|
1282
|
+
* Modifies a schedule by adding an effectfully computed delay before each
|
|
1283
|
+
* execution.
|
|
1284
|
+
*
|
|
1285
|
+
* **Details**
|
|
1286
|
+
*
|
|
1287
|
+
* This function adjusts an existing schedule by introducing a delay that is
|
|
1288
|
+
* computed via an effect. Instead of using a fixed delay, each interval is
|
|
1289
|
+
* dynamically adjusted based on an effectful function `f`, which takes the
|
|
1290
|
+
* current delay and returns a new delay wrapped in an `Effect`.
|
|
1291
|
+
*
|
|
1292
|
+
* This is useful for adaptive scheduling where delays depend on external
|
|
1293
|
+
* factors, such as API calls, database queries, or dynamic system conditions.
|
|
1294
|
+
*
|
|
1295
|
+
* @see {@link delayed} If you need to compute the delay using a pure function.
|
|
689
1296
|
*
|
|
690
1297
|
* @since 2.0.0
|
|
691
|
-
* @category
|
|
1298
|
+
* @category Timing & Delay
|
|
692
1299
|
*/
|
|
693
1300
|
<Out, In, R, R2>(
|
|
694
1301
|
self: Schedule<Out, In, R>,
|
|
@@ -697,45 +1304,82 @@ export const delayedEffect: {
|
|
|
697
1304
|
} = internal.delayedEffect
|
|
698
1305
|
|
|
699
1306
|
/**
|
|
700
|
-
*
|
|
701
|
-
*
|
|
1307
|
+
* Uses the delays produced by a schedule to further delay its intervals.
|
|
1308
|
+
*
|
|
1309
|
+
* **Details**
|
|
1310
|
+
*
|
|
1311
|
+
* This function modifies a schedule by using its own output delays to control
|
|
1312
|
+
* its execution timing. Instead of executing immediately at each interval, the
|
|
1313
|
+
* schedule will be delayed by the duration it produces.
|
|
702
1314
|
*
|
|
703
1315
|
* @since 2.0.0
|
|
704
|
-
* @category
|
|
1316
|
+
* @category Timing & Delay
|
|
705
1317
|
*/
|
|
706
1318
|
export const delayedSchedule: <In, R>(
|
|
707
1319
|
schedule: Schedule<Duration.Duration, In, R>
|
|
708
1320
|
) => Schedule<Duration.Duration, In, R> = internal.delayedSchedule
|
|
709
1321
|
|
|
710
1322
|
/**
|
|
711
|
-
*
|
|
1323
|
+
* Transforms a schedule to output the delay between each occurrence.
|
|
1324
|
+
*
|
|
1325
|
+
* **Details**
|
|
1326
|
+
*
|
|
1327
|
+
* This function modifies an existing schedule so that instead of producing its
|
|
1328
|
+
* original output, it now returns the delay between each scheduled execution.
|
|
712
1329
|
*
|
|
713
1330
|
* @since 2.0.0
|
|
714
|
-
* @category
|
|
1331
|
+
* @category Monitoring
|
|
715
1332
|
*/
|
|
716
1333
|
export const delays: <Out, In, R>(self: Schedule<Out, In, R>) => Schedule<Duration.Duration, In, R> = internal.delays
|
|
717
1334
|
|
|
718
1335
|
/**
|
|
719
|
-
*
|
|
1336
|
+
* Transforms both the input and output of a schedule.
|
|
1337
|
+
*
|
|
1338
|
+
* **Details**
|
|
1339
|
+
*
|
|
1340
|
+
* This function modifies an existing schedule by applying a transformation to
|
|
1341
|
+
* both its input values and its output values. The provided transformation
|
|
1342
|
+
* functions `onInput` and `onOutput` allow you to map the schedule to work with
|
|
1343
|
+
* a different input type while modifying its outputs as well.
|
|
1344
|
+
*
|
|
1345
|
+
* @see {@link mapBothEffect} If you need to use effectful transformation functions.
|
|
720
1346
|
*
|
|
721
1347
|
* @since 2.0.0
|
|
722
|
-
* @category
|
|
1348
|
+
* @category Mapping
|
|
723
1349
|
*/
|
|
724
1350
|
export const mapBoth: {
|
|
725
1351
|
/**
|
|
726
|
-
*
|
|
1352
|
+
* Transforms both the input and output of a schedule.
|
|
1353
|
+
*
|
|
1354
|
+
* **Details**
|
|
1355
|
+
*
|
|
1356
|
+
* This function modifies an existing schedule by applying a transformation to
|
|
1357
|
+
* both its input values and its output values. The provided transformation
|
|
1358
|
+
* functions `onInput` and `onOutput` allow you to map the schedule to work with
|
|
1359
|
+
* a different input type while modifying its outputs as well.
|
|
1360
|
+
*
|
|
1361
|
+
* @see {@link mapBothEffect} If you need to use effectful transformation functions.
|
|
727
1362
|
*
|
|
728
1363
|
* @since 2.0.0
|
|
729
|
-
* @category
|
|
1364
|
+
* @category Mapping
|
|
730
1365
|
*/
|
|
731
1366
|
<In2, In, Out, Out2>(
|
|
732
1367
|
options: { readonly onInput: (in2: In2) => In; readonly onOutput: (out: Out) => Out2 }
|
|
733
1368
|
): <R>(self: Schedule<Out, In, R>) => Schedule<Out2, In2, R>
|
|
734
1369
|
/**
|
|
735
|
-
*
|
|
1370
|
+
* Transforms both the input and output of a schedule.
|
|
1371
|
+
*
|
|
1372
|
+
* **Details**
|
|
1373
|
+
*
|
|
1374
|
+
* This function modifies an existing schedule by applying a transformation to
|
|
1375
|
+
* both its input values and its output values. The provided transformation
|
|
1376
|
+
* functions `onInput` and `onOutput` allow you to map the schedule to work with
|
|
1377
|
+
* a different input type while modifying its outputs as well.
|
|
1378
|
+
*
|
|
1379
|
+
* @see {@link mapBothEffect} If you need to use effectful transformation functions.
|
|
736
1380
|
*
|
|
737
1381
|
* @since 2.0.0
|
|
738
|
-
* @category
|
|
1382
|
+
* @category Mapping
|
|
739
1383
|
*/
|
|
740
1384
|
<Out, In, R, In2, Out2>(
|
|
741
1385
|
self: Schedule<Out, In, R>,
|
|
@@ -744,17 +1388,39 @@ export const mapBoth: {
|
|
|
744
1388
|
} = internal.mapBoth
|
|
745
1389
|
|
|
746
1390
|
/**
|
|
747
|
-
*
|
|
1391
|
+
* Transforms both the input and output of a schedule using effectful
|
|
1392
|
+
* computations.
|
|
1393
|
+
*
|
|
1394
|
+
* **Details**
|
|
1395
|
+
*
|
|
1396
|
+
* This function modifies an existing schedule by applying effectful
|
|
1397
|
+
* transformations to both its input values and its output values. The provided
|
|
1398
|
+
* effectful functions `onInput` and `onOutput` allow you to transform inputs
|
|
1399
|
+
* and outputs using computations that may involve additional logic, resource
|
|
1400
|
+
* access, or side effects.
|
|
1401
|
+
*
|
|
1402
|
+
* @see {@link mapBoth} If you need to use pure transformation functions.
|
|
748
1403
|
*
|
|
749
1404
|
* @since 2.0.0
|
|
750
|
-
* @category
|
|
1405
|
+
* @category Mapping
|
|
751
1406
|
*/
|
|
752
1407
|
export const mapBothEffect: {
|
|
753
1408
|
/**
|
|
754
|
-
*
|
|
1409
|
+
* Transforms both the input and output of a schedule using effectful
|
|
1410
|
+
* computations.
|
|
1411
|
+
*
|
|
1412
|
+
* **Details**
|
|
1413
|
+
*
|
|
1414
|
+
* This function modifies an existing schedule by applying effectful
|
|
1415
|
+
* transformations to both its input values and its output values. The provided
|
|
1416
|
+
* effectful functions `onInput` and `onOutput` allow you to transform inputs
|
|
1417
|
+
* and outputs using computations that may involve additional logic, resource
|
|
1418
|
+
* access, or side effects.
|
|
1419
|
+
*
|
|
1420
|
+
* @see {@link mapBoth} If you need to use pure transformation functions.
|
|
755
1421
|
*
|
|
756
1422
|
* @since 2.0.0
|
|
757
|
-
* @category
|
|
1423
|
+
* @category Mapping
|
|
758
1424
|
*/
|
|
759
1425
|
<In2, In, R2, Out, R3, Out2>(
|
|
760
1426
|
options: {
|
|
@@ -763,10 +1429,21 @@ export const mapBothEffect: {
|
|
|
763
1429
|
}
|
|
764
1430
|
): <R>(self: Schedule<Out, In, R>) => Schedule<Out2, In2, R2 | R3 | R>
|
|
765
1431
|
/**
|
|
766
|
-
*
|
|
1432
|
+
* Transforms both the input and output of a schedule using effectful
|
|
1433
|
+
* computations.
|
|
1434
|
+
*
|
|
1435
|
+
* **Details**
|
|
1436
|
+
*
|
|
1437
|
+
* This function modifies an existing schedule by applying effectful
|
|
1438
|
+
* transformations to both its input values and its output values. The provided
|
|
1439
|
+
* effectful functions `onInput` and `onOutput` allow you to transform inputs
|
|
1440
|
+
* and outputs using computations that may involve additional logic, resource
|
|
1441
|
+
* access, or side effects.
|
|
1442
|
+
*
|
|
1443
|
+
* @see {@link mapBoth} If you need to use pure transformation functions.
|
|
767
1444
|
*
|
|
768
1445
|
* @since 2.0.0
|
|
769
|
-
* @category
|
|
1446
|
+
* @category Mapping
|
|
770
1447
|
*/
|
|
771
1448
|
<Out, In, R, In2, R2, Out2, R3>(
|
|
772
1449
|
self: Schedule<Out, In, R>,
|
|
@@ -778,8 +1455,17 @@ export const mapBothEffect: {
|
|
|
778
1455
|
} = internal.mapBothEffect
|
|
779
1456
|
|
|
780
1457
|
/**
|
|
781
|
-
*
|
|
782
|
-
*
|
|
1458
|
+
* Creates a driver to manually control the execution of a schedule.
|
|
1459
|
+
*
|
|
1460
|
+
* **Details**
|
|
1461
|
+
*
|
|
1462
|
+
* This function returns a `ScheduleDriver`, which allows stepping through a
|
|
1463
|
+
* schedule manually while handling delays and sleeping appropriately. A driver
|
|
1464
|
+
* is useful when you need fine-grained control over how a schedule progresses,
|
|
1465
|
+
* rather than relying on automatic execution.
|
|
1466
|
+
*
|
|
1467
|
+
* The returned driver exposes methods for retrieving the current state,
|
|
1468
|
+
* executing the next step, and resetting the schedule when needed.
|
|
783
1469
|
*
|
|
784
1470
|
* @since 2.0.0
|
|
785
1471
|
* @category getter
|
|
@@ -788,39 +1474,39 @@ export const driver: <Out, In, R>(
|
|
|
788
1474
|
self: Schedule<Out, In, R>
|
|
789
1475
|
) => Effect.Effect<ScheduleDriver<Out, In, R>> = internal.driver
|
|
790
1476
|
|
|
1477
|
+
// TODO(4.0): remove?
|
|
791
1478
|
/**
|
|
792
|
-
*
|
|
793
|
-
* future.
|
|
1479
|
+
* Alias of {@link fromDelay}.
|
|
794
1480
|
*
|
|
795
1481
|
* @since 2.0.0
|
|
796
|
-
* @category
|
|
1482
|
+
* @category Constructors
|
|
797
1483
|
*/
|
|
798
1484
|
export const duration: (duration: Duration.DurationInput) => Schedule<Duration.Duration> = internal.duration
|
|
799
1485
|
|
|
1486
|
+
// TODO(4.0): remove?
|
|
800
1487
|
/**
|
|
801
|
-
*
|
|
802
|
-
* defined by both schedules.
|
|
1488
|
+
* Alias of {@link union}.
|
|
803
1489
|
*
|
|
804
1490
|
* @since 2.0.0
|
|
805
|
-
* @category
|
|
1491
|
+
* @category Alternatives
|
|
806
1492
|
*/
|
|
807
1493
|
export const either: {
|
|
1494
|
+
// TODO(4.0): remove?
|
|
808
1495
|
/**
|
|
809
|
-
*
|
|
810
|
-
* defined by both schedules.
|
|
1496
|
+
* Alias of {@link union}.
|
|
811
1497
|
*
|
|
812
1498
|
* @since 2.0.0
|
|
813
|
-
* @category
|
|
1499
|
+
* @category Alternatives
|
|
814
1500
|
*/
|
|
815
1501
|
<Out2, In2, R2>(
|
|
816
1502
|
that: Schedule<Out2, In2, R2>
|
|
817
1503
|
): <Out, In, R>(self: Schedule<Out, In, R>) => Schedule<[Out, Out2], In & In2, R2 | R>
|
|
1504
|
+
// TODO(4.0): remove?
|
|
818
1505
|
/**
|
|
819
|
-
*
|
|
820
|
-
* defined by both schedules.
|
|
1506
|
+
* Alias of {@link union}.
|
|
821
1507
|
*
|
|
822
1508
|
* @since 2.0.0
|
|
823
|
-
* @category
|
|
1509
|
+
* @category Alternatives
|
|
824
1510
|
*/
|
|
825
1511
|
<Out, In, R, Out2, In2, R2>(
|
|
826
1512
|
self: Schedule<Out, In, R>,
|
|
@@ -828,28 +1514,31 @@ export const either: {
|
|
|
828
1514
|
): Schedule<[Out, Out2], In & In2, R | R2>
|
|
829
1515
|
} = internal.either
|
|
830
1516
|
|
|
1517
|
+
// TODO(4.0): remove?
|
|
831
1518
|
/**
|
|
832
|
-
*
|
|
1519
|
+
* Alias of {@link unionWith}.
|
|
833
1520
|
*
|
|
834
1521
|
* @since 2.0.0
|
|
835
|
-
* @category
|
|
1522
|
+
* @category Alternatives
|
|
836
1523
|
*/
|
|
837
1524
|
export const eitherWith: {
|
|
1525
|
+
// TODO(4.0): remove?
|
|
838
1526
|
/**
|
|
839
|
-
*
|
|
1527
|
+
* Alias of {@link unionWith}.
|
|
840
1528
|
*
|
|
841
1529
|
* @since 2.0.0
|
|
842
|
-
* @category
|
|
1530
|
+
* @category Alternatives
|
|
843
1531
|
*/
|
|
844
1532
|
<Out2, In2, R2>(
|
|
845
1533
|
that: Schedule<Out2, In2, R2>,
|
|
846
1534
|
f: (x: Intervals.Intervals, y: Intervals.Intervals) => Intervals.Intervals
|
|
847
1535
|
): <Out, In, R>(self: Schedule<Out, In, R>) => Schedule<[Out, Out2], In & In2, R2 | R>
|
|
1536
|
+
// TODO(4.0): remove?
|
|
848
1537
|
/**
|
|
849
|
-
*
|
|
1538
|
+
* Alias of {@link unionWith}.
|
|
850
1539
|
*
|
|
851
1540
|
* @since 2.0.0
|
|
852
|
-
* @category
|
|
1541
|
+
* @category Alternatives
|
|
853
1542
|
*/
|
|
854
1543
|
<Out, In, R, Out2, In2, R2>(
|
|
855
1544
|
self: Schedule<Out, In, R>,
|
|
@@ -859,56 +1548,95 @@ export const eitherWith: {
|
|
|
859
1548
|
} = internal.eitherWith
|
|
860
1549
|
|
|
861
1550
|
/**
|
|
862
|
-
*
|
|
863
|
-
*
|
|
1551
|
+
* Creates a schedule that tracks the total elapsed duration since it started.
|
|
1552
|
+
*
|
|
1553
|
+
* **Details**
|
|
1554
|
+
*
|
|
1555
|
+
* This schedule executes continuously and returns the total time that has
|
|
1556
|
+
* passed since the first execution. The duration keeps increasing with each
|
|
1557
|
+
* step, providing a way to measure elapsed time.
|
|
1558
|
+
*
|
|
1559
|
+
* This is useful for tracking execution time, monitoring delays, or
|
|
1560
|
+
* implementing logic based on how long a process has been running.
|
|
864
1561
|
*
|
|
865
1562
|
* @since 2.0.0
|
|
866
|
-
* @category
|
|
1563
|
+
* @category Constructors
|
|
867
1564
|
*/
|
|
868
1565
|
export const elapsed: Schedule<Duration.Duration> = internal.elapsed
|
|
869
1566
|
|
|
870
1567
|
/**
|
|
871
|
-
*
|
|
872
|
-
*
|
|
873
|
-
*
|
|
874
|
-
*
|
|
875
|
-
*
|
|
1568
|
+
* Attaches a finalizer to a schedule that runs when the schedule completes.
|
|
1569
|
+
*
|
|
1570
|
+
* **Details**
|
|
1571
|
+
*
|
|
1572
|
+
* This function returns a new schedule that executes a given finalizer when the
|
|
1573
|
+
* schedule reaches completion. Unlike `Effect.ensuring`, this method does not
|
|
1574
|
+
* guarantee the finalizer will run in all cases. If the schedule never
|
|
1575
|
+
* initializes or is not driven to completion, the finalizer may not execute.
|
|
1576
|
+
* However, if the schedule decides not to continue, the finalizer will be
|
|
1577
|
+
* invoked.
|
|
1578
|
+
*
|
|
1579
|
+
* This is useful for cleaning up resources, logging, or executing other side
|
|
1580
|
+
* effects when a schedule completes.
|
|
876
1581
|
*
|
|
877
1582
|
* @since 2.0.0
|
|
878
|
-
* @category
|
|
1583
|
+
* @category Finalization
|
|
879
1584
|
*/
|
|
880
1585
|
export const ensuring: {
|
|
881
1586
|
/**
|
|
882
|
-
*
|
|
883
|
-
*
|
|
884
|
-
*
|
|
885
|
-
*
|
|
886
|
-
*
|
|
1587
|
+
* Attaches a finalizer to a schedule that runs when the schedule completes.
|
|
1588
|
+
*
|
|
1589
|
+
* **Details**
|
|
1590
|
+
*
|
|
1591
|
+
* This function returns a new schedule that executes a given finalizer when the
|
|
1592
|
+
* schedule reaches completion. Unlike `Effect.ensuring`, this method does not
|
|
1593
|
+
* guarantee the finalizer will run in all cases. If the schedule never
|
|
1594
|
+
* initializes or is not driven to completion, the finalizer may not execute.
|
|
1595
|
+
* However, if the schedule decides not to continue, the finalizer will be
|
|
1596
|
+
* invoked.
|
|
1597
|
+
*
|
|
1598
|
+
* This is useful for cleaning up resources, logging, or executing other side
|
|
1599
|
+
* effects when a schedule completes.
|
|
887
1600
|
*
|
|
888
1601
|
* @since 2.0.0
|
|
889
|
-
* @category
|
|
1602
|
+
* @category Finalization
|
|
890
1603
|
*/
|
|
891
1604
|
<X>(finalizer: Effect.Effect<X, never, never>): <Out, In, R>(self: Schedule<Out, In, R>) => Schedule<Out, In, R>
|
|
892
1605
|
/**
|
|
893
|
-
*
|
|
894
|
-
*
|
|
895
|
-
*
|
|
896
|
-
*
|
|
897
|
-
*
|
|
1606
|
+
* Attaches a finalizer to a schedule that runs when the schedule completes.
|
|
1607
|
+
*
|
|
1608
|
+
* **Details**
|
|
1609
|
+
*
|
|
1610
|
+
* This function returns a new schedule that executes a given finalizer when the
|
|
1611
|
+
* schedule reaches completion. Unlike `Effect.ensuring`, this method does not
|
|
1612
|
+
* guarantee the finalizer will run in all cases. If the schedule never
|
|
1613
|
+
* initializes or is not driven to completion, the finalizer may not execute.
|
|
1614
|
+
* However, if the schedule decides not to continue, the finalizer will be
|
|
1615
|
+
* invoked.
|
|
1616
|
+
*
|
|
1617
|
+
* This is useful for cleaning up resources, logging, or executing other side
|
|
1618
|
+
* effects when a schedule completes.
|
|
898
1619
|
*
|
|
899
1620
|
* @since 2.0.0
|
|
900
|
-
* @category
|
|
1621
|
+
* @category Finalization
|
|
901
1622
|
*/
|
|
902
1623
|
<Out, In, R, X>(self: Schedule<Out, In, R>, finalizer: Effect.Effect<X, never, never>): Schedule<Out, In, R>
|
|
903
1624
|
} = internal.ensuring
|
|
904
1625
|
|
|
905
1626
|
/**
|
|
906
|
-
*
|
|
907
|
-
*
|
|
908
|
-
*
|
|
1627
|
+
* Creates a schedule that recurs indefinitely with exponentially increasing
|
|
1628
|
+
* delays.
|
|
1629
|
+
*
|
|
1630
|
+
* **Details**
|
|
1631
|
+
*
|
|
1632
|
+
* This schedule starts with an initial delay of `base` and increases the delay
|
|
1633
|
+
* exponentially on each repetition using the formula `base * factor^n`, where
|
|
1634
|
+
* `n` is the number of times the schedule has executed so far. If no `factor`
|
|
1635
|
+
* is provided, it defaults to `2`, causing the delay to double after each
|
|
1636
|
+
* execution.
|
|
909
1637
|
*
|
|
910
1638
|
* @since 2.0.0
|
|
911
|
-
* @category
|
|
1639
|
+
* @category Constructors
|
|
912
1640
|
*/
|
|
913
1641
|
export const exponential: (
|
|
914
1642
|
base: Duration.DurationInput,
|
|
@@ -916,55 +1644,94 @@ export const exponential: (
|
|
|
916
1644
|
) => Schedule<Duration.Duration> = internal.exponential
|
|
917
1645
|
|
|
918
1646
|
/**
|
|
919
|
-
*
|
|
920
|
-
*
|
|
921
|
-
*
|
|
1647
|
+
* Creates a schedule that recurs indefinitely with Fibonacci-based increasing
|
|
1648
|
+
* delays.
|
|
1649
|
+
*
|
|
1650
|
+
* **Details**
|
|
1651
|
+
*
|
|
1652
|
+
* This schedule starts with an initial delay of `one` and increases subsequent
|
|
1653
|
+
* delays by summing the two previous delays, following the Fibonacci sequence.
|
|
1654
|
+
* The delay pattern follows: `one, one, one + one, (one + one) + one, ...`,
|
|
1655
|
+
* resulting in `1s, 1s, 2s, 3s, 5s, 8s, 13s, ...` if `one = 1s`.
|
|
1656
|
+
*
|
|
1657
|
+
* This is useful for progressive backoff strategies, where delays grow
|
|
1658
|
+
* naturally over time without increasing as aggressively as an exponential
|
|
1659
|
+
* schedule.
|
|
922
1660
|
*
|
|
923
1661
|
* @since 2.0.0
|
|
924
|
-
* @category
|
|
1662
|
+
* @category Constructors
|
|
925
1663
|
*/
|
|
926
1664
|
export const fibonacci: (one: Duration.DurationInput) => Schedule<Duration.Duration> = internal.fibonacci
|
|
927
1665
|
|
|
928
1666
|
/**
|
|
929
|
-
*
|
|
930
|
-
* repetitions of the schedule so far.
|
|
1667
|
+
* Creates a schedule that recurs at a fixed interval.
|
|
931
1668
|
*
|
|
932
|
-
*
|
|
933
|
-
*
|
|
1669
|
+
* **Details**
|
|
1670
|
+
*
|
|
1671
|
+
* This schedule executes at regular, evenly spaced intervals, returning the
|
|
1672
|
+
* number of times it has run so far. If the action being executed takes longer
|
|
1673
|
+
* than the interval, the next execution will happen immediately to prevent
|
|
1674
|
+
* "pile-ups," ensuring that the schedule remains consistent without overlapping
|
|
1675
|
+
* executions.
|
|
934
1676
|
*
|
|
935
1677
|
* ```
|
|
936
1678
|
* |-----interval-----|-----interval-----|-----interval-----|
|
|
937
1679
|
* |---------action--------||action|-----|action|-----------|
|
|
938
1680
|
* ```
|
|
939
1681
|
*
|
|
1682
|
+
* @see {@link spaced} If you need to run from the end of the last execution.
|
|
1683
|
+
*
|
|
940
1684
|
* @since 2.0.0
|
|
941
|
-
* @category
|
|
1685
|
+
* @category Constructors
|
|
942
1686
|
*/
|
|
943
1687
|
export const fixed: (interval: Duration.DurationInput) => Schedule<number> = internal.fixed
|
|
944
1688
|
|
|
945
1689
|
/**
|
|
946
|
-
*
|
|
1690
|
+
* Creates a schedule that recurs indefinitely, producing a count of
|
|
1691
|
+
* repetitions.
|
|
1692
|
+
*
|
|
1693
|
+
* **Details**
|
|
1694
|
+
*
|
|
1695
|
+
* This schedule runs indefinitely, returning an increasing count of executions
|
|
1696
|
+
* (`0, 1, 2, 3, ...`). Each step increments the count by one, allowing tracking
|
|
1697
|
+
* of how many times it has executed.
|
|
947
1698
|
*
|
|
948
1699
|
* @since 2.0.0
|
|
949
|
-
* @category
|
|
1700
|
+
* @category Constructors
|
|
950
1701
|
*/
|
|
951
1702
|
export const forever: Schedule<number> = internal.forever
|
|
952
1703
|
|
|
953
1704
|
/**
|
|
954
|
-
*
|
|
1705
|
+
* Creates a schedule that recurs once after a specified duration.
|
|
1706
|
+
*
|
|
1707
|
+
* **Details**
|
|
1708
|
+
*
|
|
1709
|
+
* This schedule executes a single time after waiting for the given duration.
|
|
1710
|
+
* Once it has executed, it does not repeat.
|
|
1711
|
+
*
|
|
1712
|
+
* @see {@link fromDelays} If you need to create a schedule with multiple delays.
|
|
955
1713
|
*
|
|
956
1714
|
* @since 2.0.0
|
|
957
|
-
* @category
|
|
1715
|
+
* @category Constructors
|
|
958
1716
|
*/
|
|
959
1717
|
export const fromDelay: (delay: Duration.DurationInput) => Schedule<Duration.Duration> = internal.fromDelay
|
|
960
1718
|
|
|
961
1719
|
/**
|
|
962
|
-
*
|
|
963
|
-
*
|
|
964
|
-
*
|
|
1720
|
+
* Creates a schedule that recurs once for each specified duration, applying the
|
|
1721
|
+
* given delays sequentially.
|
|
1722
|
+
*
|
|
1723
|
+
* **Details**
|
|
1724
|
+
*
|
|
1725
|
+
* This schedule executes multiple times, each time waiting for the
|
|
1726
|
+
* corresponding duration from the provided list of delays. The first execution
|
|
1727
|
+
* waits for `delay`, the next for the second value in `delays`, and so on. Once
|
|
1728
|
+
* all delays have been used, the schedule stops executing.
|
|
1729
|
+
*
|
|
1730
|
+
* This is useful for defining a custom delay sequence that does not follow a
|
|
1731
|
+
* fixed pattern like exponential or Fibonacci backoff.
|
|
965
1732
|
*
|
|
966
1733
|
* @since 2.0.0
|
|
967
|
-
* @category
|
|
1734
|
+
* @category Constructors
|
|
968
1735
|
*/
|
|
969
1736
|
export const fromDelays: (
|
|
970
1737
|
delay: Duration.DurationInput,
|
|
@@ -972,57 +1739,120 @@ export const fromDelays: (
|
|
|
972
1739
|
) => Schedule<Duration.Duration> = internal.fromDelays
|
|
973
1740
|
|
|
974
1741
|
/**
|
|
975
|
-
*
|
|
976
|
-
* function.
|
|
1742
|
+
* Creates a schedule that always recurs, transforming input values using the
|
|
1743
|
+
* specified function.
|
|
1744
|
+
*
|
|
1745
|
+
* **Details**
|
|
1746
|
+
*
|
|
1747
|
+
* This schedule continuously executes and applies the given function `f` to
|
|
1748
|
+
* each input value, producing a transformed output. The schedule itself does
|
|
1749
|
+
* not control delays or stopping conditions; it simply transforms the input
|
|
1750
|
+
* values as they are processed.
|
|
1751
|
+
*
|
|
1752
|
+
* This is useful when defining schedules that map inputs to outputs, allowing
|
|
1753
|
+
* dynamic transformations of incoming data.
|
|
977
1754
|
*
|
|
978
1755
|
* @since 2.0.0
|
|
979
|
-
* @category
|
|
1756
|
+
* @category Constructors
|
|
980
1757
|
*/
|
|
981
1758
|
export const fromFunction: <A, B>(f: (a: A) => B) => Schedule<B, A> = internal.fromFunction
|
|
982
1759
|
|
|
983
1760
|
/**
|
|
984
|
-
*
|
|
985
|
-
*
|
|
1761
|
+
* Creates a schedule that always recurs, passing inputs directly as outputs.
|
|
1762
|
+
*
|
|
1763
|
+
* **Details**
|
|
986
1764
|
*
|
|
987
|
-
*
|
|
1765
|
+
* This schedule runs indefinitely, returning each input value as its output
|
|
1766
|
+
* without modification. It effectively acts as a pass-through that simply
|
|
1767
|
+
* echoes its input values at each step.
|
|
988
1768
|
*
|
|
989
1769
|
* @since 2.0.0
|
|
990
|
-
* @category
|
|
1770
|
+
* @category Constructors
|
|
991
1771
|
*/
|
|
992
|
-
export const
|
|
1772
|
+
export const identity: <A>() => Schedule<A, A> = internal.identity
|
|
993
1773
|
|
|
994
1774
|
/**
|
|
995
|
-
*
|
|
1775
|
+
* Transforms a schedule to pass through its inputs as outputs.
|
|
1776
|
+
*
|
|
1777
|
+
* **Details**
|
|
1778
|
+
*
|
|
1779
|
+
* This function modifies an existing schedule so that it returns its input
|
|
1780
|
+
* values instead of its original output values. The schedule's timing remains
|
|
1781
|
+
* unchanged, but its outputs are replaced with whatever inputs it receives.
|
|
996
1782
|
*
|
|
997
1783
|
* @since 2.0.0
|
|
998
|
-
* @category constructors
|
|
999
1784
|
*/
|
|
1000
|
-
export const
|
|
1785
|
+
export const passthrough: <Out, In, R>(self: Schedule<Out, In, R>) => Schedule<In, In, R> = internal.passthrough
|
|
1001
1786
|
|
|
1002
1787
|
/**
|
|
1003
|
-
*
|
|
1004
|
-
*
|
|
1788
|
+
* Combines two schedules, continuing only if both schedules want to continue,
|
|
1789
|
+
* using the longer delay.
|
|
1790
|
+
*
|
|
1791
|
+
* **Details**
|
|
1792
|
+
*
|
|
1793
|
+
* This function takes two schedules and creates a new schedule that only
|
|
1794
|
+
* continues execution if both schedules allow it. The interval between
|
|
1795
|
+
* recurrences is determined by the longer delay between the two schedules.
|
|
1796
|
+
*
|
|
1797
|
+
* The output of the resulting schedule is a tuple containing the outputs of
|
|
1798
|
+
* both schedules. The input type is the intersection of both schedules' input
|
|
1799
|
+
* types.
|
|
1800
|
+
*
|
|
1801
|
+
* This is useful when coordinating multiple scheduling conditions where
|
|
1802
|
+
* execution should proceed only when both schedules permit it.
|
|
1803
|
+
*
|
|
1804
|
+
* @see {@link intersectWith} If you need to use a custom merge function.
|
|
1005
1805
|
*
|
|
1006
1806
|
* @since 2.0.0
|
|
1007
|
-
* @category
|
|
1807
|
+
* @category Composition
|
|
1008
1808
|
*/
|
|
1009
1809
|
export const intersect: {
|
|
1010
1810
|
/**
|
|
1011
|
-
*
|
|
1012
|
-
*
|
|
1811
|
+
* Combines two schedules, continuing only if both schedules want to continue,
|
|
1812
|
+
* using the longer delay.
|
|
1813
|
+
*
|
|
1814
|
+
* **Details**
|
|
1815
|
+
*
|
|
1816
|
+
* This function takes two schedules and creates a new schedule that only
|
|
1817
|
+
* continues execution if both schedules allow it. The interval between
|
|
1818
|
+
* recurrences is determined by the longer delay between the two schedules.
|
|
1819
|
+
*
|
|
1820
|
+
* The output of the resulting schedule is a tuple containing the outputs of
|
|
1821
|
+
* both schedules. The input type is the intersection of both schedules' input
|
|
1822
|
+
* types.
|
|
1823
|
+
*
|
|
1824
|
+
* This is useful when coordinating multiple scheduling conditions where
|
|
1825
|
+
* execution should proceed only when both schedules permit it.
|
|
1826
|
+
*
|
|
1827
|
+
* @see {@link intersectWith} If you need to use a custom merge function.
|
|
1013
1828
|
*
|
|
1014
1829
|
* @since 2.0.0
|
|
1015
|
-
* @category
|
|
1830
|
+
* @category Composition
|
|
1016
1831
|
*/
|
|
1017
1832
|
<Out2, In2, R2>(
|
|
1018
1833
|
that: Schedule<Out2, In2, R2>
|
|
1019
1834
|
): <Out, In, R>(self: Schedule<Out, In, R>) => Schedule<[Out, Out2], In & In2, R2 | R>
|
|
1020
1835
|
/**
|
|
1021
|
-
*
|
|
1022
|
-
*
|
|
1836
|
+
* Combines two schedules, continuing only if both schedules want to continue,
|
|
1837
|
+
* using the longer delay.
|
|
1838
|
+
*
|
|
1839
|
+
* **Details**
|
|
1840
|
+
*
|
|
1841
|
+
* This function takes two schedules and creates a new schedule that only
|
|
1842
|
+
* continues execution if both schedules allow it. The interval between
|
|
1843
|
+
* recurrences is determined by the longer delay between the two schedules.
|
|
1844
|
+
*
|
|
1845
|
+
* The output of the resulting schedule is a tuple containing the outputs of
|
|
1846
|
+
* both schedules. The input type is the intersection of both schedules' input
|
|
1847
|
+
* types.
|
|
1848
|
+
*
|
|
1849
|
+
* This is useful when coordinating multiple scheduling conditions where
|
|
1850
|
+
* execution should proceed only when both schedules permit it.
|
|
1851
|
+
*
|
|
1852
|
+
* @see {@link intersectWith} If you need to use a custom merge function.
|
|
1023
1853
|
*
|
|
1024
1854
|
* @since 2.0.0
|
|
1025
|
-
* @category
|
|
1855
|
+
* @category Composition
|
|
1026
1856
|
*/
|
|
1027
1857
|
<Out, In, R, Out2, In2, R2>(
|
|
1028
1858
|
self: Schedule<Out, In, R>,
|
|
@@ -1031,33 +1861,66 @@ export const intersect: {
|
|
|
1031
1861
|
} = internal.intersect
|
|
1032
1862
|
|
|
1033
1863
|
/**
|
|
1034
|
-
*
|
|
1035
|
-
*
|
|
1036
|
-
*
|
|
1864
|
+
* Combines two schedules, continuing only if both want to continue, merging
|
|
1865
|
+
* intervals using a custom function.
|
|
1866
|
+
*
|
|
1867
|
+
* **Details**
|
|
1868
|
+
*
|
|
1869
|
+
* This function takes two schedules and creates a new schedule that only
|
|
1870
|
+
* continues execution if both schedules allow it. Instead of automatically
|
|
1871
|
+
* using the longer delay (like {@link intersect}), this function applies a
|
|
1872
|
+
* user-provided merge function `f` to determine the next interval between
|
|
1873
|
+
* executions.
|
|
1874
|
+
*
|
|
1875
|
+
* The output of the resulting schedule is a tuple containing the outputs of
|
|
1876
|
+
* both schedules, and the input type is the intersection of both schedules'
|
|
1877
|
+
* input types.
|
|
1037
1878
|
*
|
|
1038
1879
|
* @since 2.0.0
|
|
1039
|
-
* @category
|
|
1880
|
+
* @category Composition
|
|
1040
1881
|
*/
|
|
1041
1882
|
export const intersectWith: {
|
|
1042
1883
|
/**
|
|
1043
|
-
*
|
|
1044
|
-
*
|
|
1045
|
-
*
|
|
1884
|
+
* Combines two schedules, continuing only if both want to continue, merging
|
|
1885
|
+
* intervals using a custom function.
|
|
1886
|
+
*
|
|
1887
|
+
* **Details**
|
|
1888
|
+
*
|
|
1889
|
+
* This function takes two schedules and creates a new schedule that only
|
|
1890
|
+
* continues execution if both schedules allow it. Instead of automatically
|
|
1891
|
+
* using the longer delay (like {@link intersect}), this function applies a
|
|
1892
|
+
* user-provided merge function `f` to determine the next interval between
|
|
1893
|
+
* executions.
|
|
1894
|
+
*
|
|
1895
|
+
* The output of the resulting schedule is a tuple containing the outputs of
|
|
1896
|
+
* both schedules, and the input type is the intersection of both schedules'
|
|
1897
|
+
* input types.
|
|
1046
1898
|
*
|
|
1047
1899
|
* @since 2.0.0
|
|
1048
|
-
* @category
|
|
1900
|
+
* @category Composition
|
|
1049
1901
|
*/
|
|
1050
1902
|
<Out2, In2, R2>(
|
|
1051
1903
|
that: Schedule<Out2, In2, R2>,
|
|
1052
1904
|
f: (x: Intervals.Intervals, y: Intervals.Intervals) => Intervals.Intervals
|
|
1053
1905
|
): <Out, In, R>(self: Schedule<Out, In, R>) => Schedule<[Out, Out2], In & In2, R2 | R>
|
|
1054
1906
|
/**
|
|
1055
|
-
*
|
|
1056
|
-
*
|
|
1057
|
-
*
|
|
1907
|
+
* Combines two schedules, continuing only if both want to continue, merging
|
|
1908
|
+
* intervals using a custom function.
|
|
1909
|
+
*
|
|
1910
|
+
* **Details**
|
|
1911
|
+
*
|
|
1912
|
+
* This function takes two schedules and creates a new schedule that only
|
|
1913
|
+
* continues execution if both schedules allow it. Instead of automatically
|
|
1914
|
+
* using the longer delay (like {@link intersect}), this function applies a
|
|
1915
|
+
* user-provided merge function `f` to determine the next interval between
|
|
1916
|
+
* executions.
|
|
1917
|
+
*
|
|
1918
|
+
* The output of the resulting schedule is a tuple containing the outputs of
|
|
1919
|
+
* both schedules, and the input type is the intersection of both schedules'
|
|
1920
|
+
* input types.
|
|
1058
1921
|
*
|
|
1059
1922
|
* @since 2.0.0
|
|
1060
|
-
* @category
|
|
1923
|
+
* @category Composition
|
|
1061
1924
|
*/
|
|
1062
1925
|
<Out, In, R, Out2, In2, R2>(
|
|
1063
1926
|
self: Schedule<Out, In, R>,
|
|
@@ -1067,52 +1930,93 @@ export const intersectWith: {
|
|
|
1067
1930
|
} = internal.intersectWith
|
|
1068
1931
|
|
|
1069
1932
|
/**
|
|
1070
|
-
* Returns a new schedule that randomly
|
|
1071
|
-
*
|
|
1933
|
+
* Returns a new schedule that randomly adjusts the interval size within a
|
|
1934
|
+
* range.
|
|
1935
|
+
*
|
|
1936
|
+
* **Details**
|
|
1072
1937
|
*
|
|
1073
|
-
*
|
|
1938
|
+
* This function modifies a schedule so that its delay between executions is
|
|
1939
|
+
* randomly varied within a range. By default, the delay is adjusted between
|
|
1940
|
+
* `80%` (`0.8 * interval`) and `120%` (`1.2 * interval`) of the original
|
|
1941
|
+
* interval size.
|
|
1074
1942
|
*
|
|
1075
|
-
*
|
|
1076
|
-
*
|
|
1943
|
+
* This is useful for adding randomness to repeated executions, reducing
|
|
1944
|
+
* contention in distributed systems, and avoiding synchronized execution
|
|
1945
|
+
* patterns that can cause bottlenecks.
|
|
1946
|
+
*
|
|
1947
|
+
* @see {@link jitteredWith} If you need to specify custom min/max values.
|
|
1077
1948
|
*
|
|
1078
1949
|
* @since 2.0.0
|
|
1079
|
-
* @category
|
|
1950
|
+
* @category Timing & Delay
|
|
1080
1951
|
*/
|
|
1081
1952
|
export const jittered: <Out, In, R>(self: Schedule<Out, In, R>) => Schedule<Out, In, R> = internal.jittered
|
|
1082
1953
|
|
|
1083
1954
|
/**
|
|
1084
|
-
* Returns a new schedule that randomly
|
|
1085
|
-
*
|
|
1955
|
+
* Returns a new schedule that randomly adjusts the interval size within a
|
|
1956
|
+
* user-defined range.
|
|
1957
|
+
*
|
|
1958
|
+
* **Details**
|
|
1959
|
+
*
|
|
1960
|
+
* This function modifies a schedule so that its delay between executions is
|
|
1961
|
+
* randomly varied within a specified range. Instead of using the default `0.8 -
|
|
1962
|
+
* 1.2` range like {@link jittered}, this function allows customizing the `min`
|
|
1963
|
+
* and `max` multipliers.
|
|
1086
1964
|
*
|
|
1087
|
-
* The
|
|
1088
|
-
*
|
|
1965
|
+
* The delay for each step will be adjusted within `min * original_interval` and
|
|
1966
|
+
* `max * original_interval`. If `min` and `max` are not provided, the defaults
|
|
1967
|
+
* are `0.8` and `1.2`, respectively.
|
|
1968
|
+
*
|
|
1969
|
+
* This is useful for introducing randomness into scheduling behavior while
|
|
1970
|
+
* having precise control over the jitter range.
|
|
1089
1971
|
*
|
|
1090
1972
|
* @since 2.0.0
|
|
1091
|
-
* @category
|
|
1973
|
+
* @category Timing & Delay
|
|
1092
1974
|
*/
|
|
1093
1975
|
export const jitteredWith: {
|
|
1094
1976
|
/**
|
|
1095
|
-
* Returns a new schedule that randomly
|
|
1096
|
-
*
|
|
1977
|
+
* Returns a new schedule that randomly adjusts the interval size within a
|
|
1978
|
+
* user-defined range.
|
|
1979
|
+
*
|
|
1980
|
+
* **Details**
|
|
1981
|
+
*
|
|
1982
|
+
* This function modifies a schedule so that its delay between executions is
|
|
1983
|
+
* randomly varied within a specified range. Instead of using the default `0.8 -
|
|
1984
|
+
* 1.2` range like {@link jittered}, this function allows customizing the `min`
|
|
1985
|
+
* and `max` multipliers.
|
|
1097
1986
|
*
|
|
1098
|
-
* The
|
|
1099
|
-
*
|
|
1987
|
+
* The delay for each step will be adjusted within `min * original_interval` and
|
|
1988
|
+
* `max * original_interval`. If `min` and `max` are not provided, the defaults
|
|
1989
|
+
* are `0.8` and `1.2`, respectively.
|
|
1990
|
+
*
|
|
1991
|
+
* This is useful for introducing randomness into scheduling behavior while
|
|
1992
|
+
* having precise control over the jitter range.
|
|
1100
1993
|
*
|
|
1101
1994
|
* @since 2.0.0
|
|
1102
|
-
* @category
|
|
1995
|
+
* @category Timing & Delay
|
|
1103
1996
|
*/
|
|
1104
1997
|
(
|
|
1105
1998
|
options: { min?: number | undefined; max?: number | undefined }
|
|
1106
1999
|
): <Out, In, R>(self: Schedule<Out, In, R>) => Schedule<Out, In, R>
|
|
1107
2000
|
/**
|
|
1108
|
-
* Returns a new schedule that randomly
|
|
1109
|
-
*
|
|
2001
|
+
* Returns a new schedule that randomly adjusts the interval size within a
|
|
2002
|
+
* user-defined range.
|
|
2003
|
+
*
|
|
2004
|
+
* **Details**
|
|
2005
|
+
*
|
|
2006
|
+
* This function modifies a schedule so that its delay between executions is
|
|
2007
|
+
* randomly varied within a specified range. Instead of using the default `0.8 -
|
|
2008
|
+
* 1.2` range like {@link jittered}, this function allows customizing the `min`
|
|
2009
|
+
* and `max` multipliers.
|
|
2010
|
+
*
|
|
2011
|
+
* The delay for each step will be adjusted within `min * original_interval` and
|
|
2012
|
+
* `max * original_interval`. If `min` and `max` are not provided, the defaults
|
|
2013
|
+
* are `0.8` and `1.2`, respectively.
|
|
1110
2014
|
*
|
|
1111
|
-
*
|
|
1112
|
-
*
|
|
2015
|
+
* This is useful for introducing randomness into scheduling behavior while
|
|
2016
|
+
* having precise control over the jitter range.
|
|
1113
2017
|
*
|
|
1114
2018
|
* @since 2.0.0
|
|
1115
|
-
* @category
|
|
2019
|
+
* @category Timing & Delay
|
|
1116
2020
|
*/
|
|
1117
2021
|
<Out, In, R>(
|
|
1118
2022
|
self: Schedule<Out, In, R>,
|
|
@@ -1121,65 +2025,151 @@ export const jitteredWith: {
|
|
|
1121
2025
|
} = internal.jitteredWith
|
|
1122
2026
|
|
|
1123
2027
|
/**
|
|
1124
|
-
*
|
|
1125
|
-
*
|
|
1126
|
-
*
|
|
2028
|
+
* Creates a schedule that recurs indefinitely, increasing the delay linearly.
|
|
2029
|
+
*
|
|
2030
|
+
* **Details**
|
|
2031
|
+
*
|
|
2032
|
+
* This schedule starts with an initial delay of `base` and increases the delay
|
|
2033
|
+
* on each recurrence in a linear fashion, following the formula:
|
|
2034
|
+
*
|
|
2035
|
+
* `delay = base * n`
|
|
2036
|
+
*
|
|
2037
|
+
* where `n` is the number of times the schedule has executed so far. This
|
|
2038
|
+
* results in increasing intervals between executions.
|
|
2039
|
+
*
|
|
2040
|
+
* This is useful for implementing linear backoff strategies where the wait time
|
|
2041
|
+
* between retries increases at a steady rate.
|
|
1127
2042
|
*
|
|
1128
2043
|
* @since 2.0.0
|
|
1129
|
-
* @category
|
|
2044
|
+
* @category Constructors
|
|
1130
2045
|
*/
|
|
1131
2046
|
export const linear: (base: Duration.DurationInput) => Schedule<Duration.Duration> = internal.linear
|
|
1132
2047
|
|
|
1133
2048
|
/**
|
|
1134
|
-
* Returns a new schedule that
|
|
1135
|
-
*
|
|
2049
|
+
* Returns a new schedule that transforms its output using the specified
|
|
2050
|
+
* function.
|
|
2051
|
+
*
|
|
2052
|
+
* **Details**
|
|
2053
|
+
*
|
|
2054
|
+
* This function modifies an existing schedule so that its outputs are
|
|
2055
|
+
* transformed by the provided function `f`. The timing and recurrence behavior
|
|
2056
|
+
* of the schedule remain unchanged, but the values it produces are mapped to
|
|
2057
|
+
* new values.
|
|
2058
|
+
*
|
|
2059
|
+
* This is useful when composing schedules where you need to adjust the output
|
|
2060
|
+
* format or apply additional processing.
|
|
2061
|
+
*
|
|
2062
|
+
* @see {@link mapEffect} If you need to use an effectful transformation
|
|
2063
|
+
* function.
|
|
1136
2064
|
*
|
|
1137
2065
|
* @since 2.0.0
|
|
1138
|
-
* @category
|
|
2066
|
+
* @category Mapping
|
|
1139
2067
|
*/
|
|
1140
2068
|
export const map: {
|
|
1141
2069
|
/**
|
|
1142
|
-
* Returns a new schedule that
|
|
1143
|
-
*
|
|
2070
|
+
* Returns a new schedule that transforms its output using the specified
|
|
2071
|
+
* function.
|
|
2072
|
+
*
|
|
2073
|
+
* **Details**
|
|
2074
|
+
*
|
|
2075
|
+
* This function modifies an existing schedule so that its outputs are
|
|
2076
|
+
* transformed by the provided function `f`. The timing and recurrence behavior
|
|
2077
|
+
* of the schedule remain unchanged, but the values it produces are mapped to
|
|
2078
|
+
* new values.
|
|
2079
|
+
*
|
|
2080
|
+
* This is useful when composing schedules where you need to adjust the output
|
|
2081
|
+
* format or apply additional processing.
|
|
2082
|
+
*
|
|
2083
|
+
* @see {@link mapEffect} If you need to use an effectful transformation
|
|
2084
|
+
* function.
|
|
1144
2085
|
*
|
|
1145
2086
|
* @since 2.0.0
|
|
1146
|
-
* @category
|
|
2087
|
+
* @category Mapping
|
|
1147
2088
|
*/
|
|
1148
2089
|
<Out, Out2>(f: (out: Out) => Out2): <In, R>(self: Schedule<Out, In, R>) => Schedule<Out2, In, R>
|
|
1149
2090
|
/**
|
|
1150
|
-
* Returns a new schedule that
|
|
1151
|
-
*
|
|
2091
|
+
* Returns a new schedule that transforms its output using the specified
|
|
2092
|
+
* function.
|
|
2093
|
+
*
|
|
2094
|
+
* **Details**
|
|
2095
|
+
*
|
|
2096
|
+
* This function modifies an existing schedule so that its outputs are
|
|
2097
|
+
* transformed by the provided function `f`. The timing and recurrence behavior
|
|
2098
|
+
* of the schedule remain unchanged, but the values it produces are mapped to
|
|
2099
|
+
* new values.
|
|
2100
|
+
*
|
|
2101
|
+
* This is useful when composing schedules where you need to adjust the output
|
|
2102
|
+
* format or apply additional processing.
|
|
2103
|
+
*
|
|
2104
|
+
* @see {@link mapEffect} If you need to use an effectful transformation
|
|
2105
|
+
* function.
|
|
1152
2106
|
*
|
|
1153
2107
|
* @since 2.0.0
|
|
1154
|
-
* @category
|
|
2108
|
+
* @category Mapping
|
|
1155
2109
|
*/
|
|
1156
2110
|
<Out, In, R, Out2>(self: Schedule<Out, In, R>, f: (out: Out) => Out2): Schedule<Out2, In, R>
|
|
1157
2111
|
} = internal.map
|
|
1158
2112
|
|
|
1159
2113
|
/**
|
|
1160
|
-
* Returns a new schedule that
|
|
1161
|
-
*
|
|
2114
|
+
* Returns a new schedule that applies an effectful transformation to its
|
|
2115
|
+
* output.
|
|
2116
|
+
*
|
|
2117
|
+
* **Details**
|
|
2118
|
+
*
|
|
2119
|
+
* This function modifies an existing schedule by applying an effectful function
|
|
2120
|
+
* `f` to its output values. The timing and recurrence behavior of the schedule
|
|
2121
|
+
* remain unchanged, but each output is mapped to a new value within an
|
|
2122
|
+
* `Effect`.
|
|
2123
|
+
*
|
|
2124
|
+
* This is useful when you need to perform side effects or asynchronous
|
|
2125
|
+
* transformations before passing the output forward.
|
|
2126
|
+
*
|
|
2127
|
+
* @see {@link map} If you need to use a pure transformation function.
|
|
1162
2128
|
*
|
|
1163
2129
|
* @since 2.0.0
|
|
1164
|
-
* @category
|
|
2130
|
+
* @category Mapping
|
|
1165
2131
|
*/
|
|
1166
2132
|
export const mapEffect: {
|
|
1167
2133
|
/**
|
|
1168
|
-
* Returns a new schedule that
|
|
1169
|
-
*
|
|
2134
|
+
* Returns a new schedule that applies an effectful transformation to its
|
|
2135
|
+
* output.
|
|
2136
|
+
*
|
|
2137
|
+
* **Details**
|
|
2138
|
+
*
|
|
2139
|
+
* This function modifies an existing schedule by applying an effectful function
|
|
2140
|
+
* `f` to its output values. The timing and recurrence behavior of the schedule
|
|
2141
|
+
* remain unchanged, but each output is mapped to a new value within an
|
|
2142
|
+
* `Effect`.
|
|
2143
|
+
*
|
|
2144
|
+
* This is useful when you need to perform side effects or asynchronous
|
|
2145
|
+
* transformations before passing the output forward.
|
|
2146
|
+
*
|
|
2147
|
+
* @see {@link map} If you need to use a pure transformation function.
|
|
1170
2148
|
*
|
|
1171
2149
|
* @since 2.0.0
|
|
1172
|
-
* @category
|
|
2150
|
+
* @category Mapping
|
|
1173
2151
|
*/
|
|
1174
2152
|
<Out, Out2, R2>(
|
|
1175
2153
|
f: (out: Out) => Effect.Effect<Out2, never, R2>
|
|
1176
2154
|
): <In, R>(self: Schedule<Out, In, R>) => Schedule<Out2, In, R2 | R>
|
|
1177
2155
|
/**
|
|
1178
|
-
* Returns a new schedule that
|
|
1179
|
-
*
|
|
2156
|
+
* Returns a new schedule that applies an effectful transformation to its
|
|
2157
|
+
* output.
|
|
2158
|
+
*
|
|
2159
|
+
* **Details**
|
|
2160
|
+
*
|
|
2161
|
+
* This function modifies an existing schedule by applying an effectful function
|
|
2162
|
+
* `f` to its output values. The timing and recurrence behavior of the schedule
|
|
2163
|
+
* remain unchanged, but each output is mapped to a new value within an
|
|
2164
|
+
* `Effect`.
|
|
2165
|
+
*
|
|
2166
|
+
* This is useful when you need to perform side effects or asynchronous
|
|
2167
|
+
* transformations before passing the output forward.
|
|
2168
|
+
*
|
|
2169
|
+
* @see {@link map} If you need to use a pure transformation function.
|
|
1180
2170
|
*
|
|
1181
2171
|
* @since 2.0.0
|
|
1182
|
-
* @category
|
|
2172
|
+
* @category Mapping
|
|
1183
2173
|
*/
|
|
1184
2174
|
<Out, In, R, Out2, R2>(
|
|
1185
2175
|
self: Schedule<Out, In, R>,
|
|
@@ -1188,41 +2178,56 @@ export const mapEffect: {
|
|
|
1188
2178
|
} = internal.mapEffect
|
|
1189
2179
|
|
|
1190
2180
|
/**
|
|
1191
|
-
*
|
|
1192
|
-
*
|
|
1193
|
-
* 2.
|
|
2181
|
+
* Returns a new schedule that modifies the delay between executions using a
|
|
2182
|
+
* custom function.
|
|
1194
2183
|
*
|
|
1195
|
-
*
|
|
2184
|
+
* **Details**
|
|
1196
2185
|
*
|
|
1197
|
-
*
|
|
1198
|
-
*
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
* Returns a new schedule that modifies the delay using the specified
|
|
1204
|
-
* function.
|
|
2186
|
+
* This function transforms an existing schedule by applying `f` to modify the
|
|
2187
|
+
* delay before each execution. The function receives both the schedule's output
|
|
2188
|
+
* (`out`) and the originally computed delay (`duration`), and returns a new
|
|
2189
|
+
* adjusted delay.
|
|
2190
|
+
*
|
|
2191
|
+
* @see {@link modifyDelayEffect} If you need to use an effectful function.
|
|
1205
2192
|
*
|
|
1206
2193
|
* @since 2.0.0
|
|
1207
|
-
* @category
|
|
2194
|
+
* @category Timing & Delay
|
|
1208
2195
|
*/
|
|
1209
2196
|
export const modifyDelay: {
|
|
1210
2197
|
/**
|
|
1211
|
-
* Returns a new schedule that modifies the delay using
|
|
1212
|
-
* function.
|
|
2198
|
+
* Returns a new schedule that modifies the delay between executions using a
|
|
2199
|
+
* custom function.
|
|
2200
|
+
*
|
|
2201
|
+
* **Details**
|
|
2202
|
+
*
|
|
2203
|
+
* This function transforms an existing schedule by applying `f` to modify the
|
|
2204
|
+
* delay before each execution. The function receives both the schedule's output
|
|
2205
|
+
* (`out`) and the originally computed delay (`duration`), and returns a new
|
|
2206
|
+
* adjusted delay.
|
|
2207
|
+
*
|
|
2208
|
+
* @see {@link modifyDelayEffect} If you need to use an effectful function.
|
|
1213
2209
|
*
|
|
1214
2210
|
* @since 2.0.0
|
|
1215
|
-
* @category
|
|
2211
|
+
* @category Timing & Delay
|
|
1216
2212
|
*/
|
|
1217
2213
|
<Out>(
|
|
1218
2214
|
f: (out: Out, duration: Duration.Duration) => Duration.DurationInput
|
|
1219
2215
|
): <In, R>(self: Schedule<Out, In, R>) => Schedule<Out, In, R>
|
|
1220
2216
|
/**
|
|
1221
|
-
* Returns a new schedule that modifies the delay using
|
|
1222
|
-
* function.
|
|
2217
|
+
* Returns a new schedule that modifies the delay between executions using a
|
|
2218
|
+
* custom function.
|
|
2219
|
+
*
|
|
2220
|
+
* **Details**
|
|
2221
|
+
*
|
|
2222
|
+
* This function transforms an existing schedule by applying `f` to modify the
|
|
2223
|
+
* delay before each execution. The function receives both the schedule's output
|
|
2224
|
+
* (`out`) and the originally computed delay (`duration`), and returns a new
|
|
2225
|
+
* adjusted delay.
|
|
2226
|
+
*
|
|
2227
|
+
* @see {@link modifyDelayEffect} If you need to use an effectful function.
|
|
1223
2228
|
*
|
|
1224
2229
|
* @since 2.0.0
|
|
1225
|
-
* @category
|
|
2230
|
+
* @category Timing & Delay
|
|
1226
2231
|
*/
|
|
1227
2232
|
<Out, In, R>(
|
|
1228
2233
|
self: Schedule<Out, In, R>,
|
|
@@ -1231,29 +2236,56 @@ export const modifyDelay: {
|
|
|
1231
2236
|
} = internal.modifyDelay
|
|
1232
2237
|
|
|
1233
2238
|
/**
|
|
1234
|
-
* Returns a new schedule that modifies the delay using
|
|
1235
|
-
*
|
|
2239
|
+
* Returns a new schedule that modifies the delay before execution using an
|
|
2240
|
+
* effectful function.
|
|
2241
|
+
*
|
|
2242
|
+
* **Details**
|
|
2243
|
+
*
|
|
2244
|
+
* This function takes an existing schedule and applies an effectful function
|
|
2245
|
+
* `f` to dynamically adjust the delay before each execution. The function
|
|
2246
|
+
* receives both the schedule's output (`out`) and the originally computed delay
|
|
2247
|
+
* (`duration`), returning a new adjusted delay wrapped in an `Effect`.
|
|
2248
|
+
*
|
|
2249
|
+
* @see {@link modifyDelay} If you need to use a pure function.
|
|
1236
2250
|
*
|
|
1237
2251
|
* @since 2.0.0
|
|
1238
|
-
* @category
|
|
2252
|
+
* @category Timing & Delay
|
|
1239
2253
|
*/
|
|
1240
2254
|
export const modifyDelayEffect: {
|
|
1241
2255
|
/**
|
|
1242
|
-
* Returns a new schedule that modifies the delay using
|
|
1243
|
-
*
|
|
2256
|
+
* Returns a new schedule that modifies the delay before execution using an
|
|
2257
|
+
* effectful function.
|
|
2258
|
+
*
|
|
2259
|
+
* **Details**
|
|
2260
|
+
*
|
|
2261
|
+
* This function takes an existing schedule and applies an effectful function
|
|
2262
|
+
* `f` to dynamically adjust the delay before each execution. The function
|
|
2263
|
+
* receives both the schedule's output (`out`) and the originally computed delay
|
|
2264
|
+
* (`duration`), returning a new adjusted delay wrapped in an `Effect`.
|
|
2265
|
+
*
|
|
2266
|
+
* @see {@link modifyDelay} If you need to use a pure function.
|
|
1244
2267
|
*
|
|
1245
2268
|
* @since 2.0.0
|
|
1246
|
-
* @category
|
|
2269
|
+
* @category Timing & Delay
|
|
1247
2270
|
*/
|
|
1248
2271
|
<Out, R2>(
|
|
1249
2272
|
f: (out: Out, duration: Duration.Duration) => Effect.Effect<Duration.DurationInput, never, R2>
|
|
1250
2273
|
): <In, R>(self: Schedule<Out, In, R>) => Schedule<Out, In, R2 | R>
|
|
1251
2274
|
/**
|
|
1252
|
-
* Returns a new schedule that modifies the delay using
|
|
1253
|
-
*
|
|
2275
|
+
* Returns a new schedule that modifies the delay before execution using an
|
|
2276
|
+
* effectful function.
|
|
2277
|
+
*
|
|
2278
|
+
* **Details**
|
|
2279
|
+
*
|
|
2280
|
+
* This function takes an existing schedule and applies an effectful function
|
|
2281
|
+
* `f` to dynamically adjust the delay before each execution. The function
|
|
2282
|
+
* receives both the schedule's output (`out`) and the originally computed delay
|
|
2283
|
+
* (`duration`), returning a new adjusted delay wrapped in an `Effect`.
|
|
2284
|
+
*
|
|
2285
|
+
* @see {@link modifyDelay} If you need to use a pure function.
|
|
1254
2286
|
*
|
|
1255
2287
|
* @since 2.0.0
|
|
1256
|
-
* @category
|
|
2288
|
+
* @category Timing & Delay
|
|
1257
2289
|
*/
|
|
1258
2290
|
<Out, In, R, R2>(
|
|
1259
2291
|
self: Schedule<Out, In, R>,
|
|
@@ -1262,32 +2294,50 @@ export const modifyDelayEffect: {
|
|
|
1262
2294
|
} = internal.modifyDelayEffect
|
|
1263
2295
|
|
|
1264
2296
|
/**
|
|
1265
|
-
* Returns a new schedule that
|
|
1266
|
-
*
|
|
1267
|
-
*
|
|
2297
|
+
* Returns a new schedule that executes an effect every time the schedule makes
|
|
2298
|
+
* a decision.
|
|
2299
|
+
*
|
|
2300
|
+
* **Details**
|
|
2301
|
+
*
|
|
2302
|
+
* This function enhances an existing schedule by running an effectful function
|
|
2303
|
+
* `f` whenever a scheduling decision is made. The function receives the current
|
|
2304
|
+
* schedule output (`out`) and the decision (`ScheduleDecision`), allowing
|
|
2305
|
+
* additional logic to be executed, such as logging, monitoring, or side
|
|
2306
|
+
* effects.
|
|
1268
2307
|
*
|
|
1269
2308
|
* @since 2.0.0
|
|
1270
|
-
* @category utils
|
|
1271
2309
|
*/
|
|
1272
2310
|
export const onDecision: {
|
|
1273
2311
|
/**
|
|
1274
|
-
* Returns a new schedule that
|
|
1275
|
-
*
|
|
1276
|
-
*
|
|
2312
|
+
* Returns a new schedule that executes an effect every time the schedule makes
|
|
2313
|
+
* a decision.
|
|
2314
|
+
*
|
|
2315
|
+
* **Details**
|
|
2316
|
+
*
|
|
2317
|
+
* This function enhances an existing schedule by running an effectful function
|
|
2318
|
+
* `f` whenever a scheduling decision is made. The function receives the current
|
|
2319
|
+
* schedule output (`out`) and the decision (`ScheduleDecision`), allowing
|
|
2320
|
+
* additional logic to be executed, such as logging, monitoring, or side
|
|
2321
|
+
* effects.
|
|
1277
2322
|
*
|
|
1278
2323
|
* @since 2.0.0
|
|
1279
|
-
* @category utils
|
|
1280
2324
|
*/
|
|
1281
2325
|
<Out, X, R2>(
|
|
1282
2326
|
f: (out: Out, decision: ScheduleDecision.ScheduleDecision) => Effect.Effect<X, never, R2>
|
|
1283
2327
|
): <In, R>(self: Schedule<Out, In, R>) => Schedule<Out, In, R2 | R>
|
|
1284
2328
|
/**
|
|
1285
|
-
* Returns a new schedule that
|
|
1286
|
-
*
|
|
1287
|
-
*
|
|
2329
|
+
* Returns a new schedule that executes an effect every time the schedule makes
|
|
2330
|
+
* a decision.
|
|
2331
|
+
*
|
|
2332
|
+
* **Details**
|
|
2333
|
+
*
|
|
2334
|
+
* This function enhances an existing schedule by running an effectful function
|
|
2335
|
+
* `f` whenever a scheduling decision is made. The function receives the current
|
|
2336
|
+
* schedule output (`out`) and the decision (`ScheduleDecision`), allowing
|
|
2337
|
+
* additional logic to be executed, such as logging, monitoring, or side
|
|
2338
|
+
* effects.
|
|
1288
2339
|
*
|
|
1289
2340
|
* @since 2.0.0
|
|
1290
|
-
* @category utils
|
|
1291
2341
|
*/
|
|
1292
2342
|
<Out, In, R, X, R2>(
|
|
1293
2343
|
self: Schedule<Out, In, R>,
|
|
@@ -1296,141 +2346,259 @@ export const onDecision: {
|
|
|
1296
2346
|
} = internal.onDecision
|
|
1297
2347
|
|
|
1298
2348
|
/**
|
|
1299
|
-
* A schedule that
|
|
2349
|
+
* A schedule that executes only once and then stops.
|
|
2350
|
+
*
|
|
2351
|
+
* **Details**
|
|
2352
|
+
*
|
|
2353
|
+
* This schedule triggers a single execution and then terminates. It does not
|
|
2354
|
+
* repeat or apply any additional logic.
|
|
1300
2355
|
*
|
|
1301
2356
|
* @since 2.0.0
|
|
1302
|
-
* @category
|
|
2357
|
+
* @category Constructors
|
|
1303
2358
|
*/
|
|
1304
2359
|
export const once: Schedule<void> = internal.once
|
|
1305
2360
|
|
|
1306
2361
|
/**
|
|
1307
|
-
* Returns a new schedule
|
|
2362
|
+
* Returns a new schedule with a provided context, eliminating the need for
|
|
2363
|
+
* external dependencies.
|
|
1308
2364
|
*
|
|
1309
|
-
*
|
|
1310
|
-
*
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
*
|
|
1316
|
-
*
|
|
2365
|
+
* **Details**
|
|
2366
|
+
*
|
|
2367
|
+
* This function supplies a required `context` to a schedule, allowing it to run
|
|
2368
|
+
* without requiring external dependencies. After calling this function, the
|
|
2369
|
+
* schedule can be used freely without needing to pass a context at execution
|
|
2370
|
+
* time.
|
|
2371
|
+
*
|
|
2372
|
+
* This is useful when working with schedules that rely on contextual
|
|
2373
|
+
* information, such as logging services, database connections, or configuration
|
|
2374
|
+
* settings.
|
|
1317
2375
|
*
|
|
1318
2376
|
* @since 2.0.0
|
|
1319
|
-
* @category
|
|
2377
|
+
* @category Context
|
|
1320
2378
|
*/
|
|
1321
2379
|
export const provideContext: {
|
|
1322
2380
|
/**
|
|
1323
|
-
* Returns a new schedule with
|
|
1324
|
-
*
|
|
2381
|
+
* Returns a new schedule with a provided context, eliminating the need for
|
|
2382
|
+
* external dependencies.
|
|
2383
|
+
*
|
|
2384
|
+
* **Details**
|
|
2385
|
+
*
|
|
2386
|
+
* This function supplies a required `context` to a schedule, allowing it to run
|
|
2387
|
+
* without requiring external dependencies. After calling this function, the
|
|
2388
|
+
* schedule can be used freely without needing to pass a context at execution
|
|
2389
|
+
* time.
|
|
2390
|
+
*
|
|
2391
|
+
* This is useful when working with schedules that rely on contextual
|
|
2392
|
+
* information, such as logging services, database connections, or configuration
|
|
2393
|
+
* settings.
|
|
1325
2394
|
*
|
|
1326
2395
|
* @since 2.0.0
|
|
1327
|
-
* @category
|
|
2396
|
+
* @category Context
|
|
1328
2397
|
*/
|
|
1329
2398
|
<R>(context: Context.Context<R>): <Out, In>(self: Schedule<Out, In, R>) => Schedule<Out, In, never>
|
|
1330
2399
|
/**
|
|
1331
|
-
* Returns a new schedule with
|
|
1332
|
-
*
|
|
2400
|
+
* Returns a new schedule with a provided context, eliminating the need for
|
|
2401
|
+
* external dependencies.
|
|
2402
|
+
*
|
|
2403
|
+
* **Details**
|
|
2404
|
+
*
|
|
2405
|
+
* This function supplies a required `context` to a schedule, allowing it to run
|
|
2406
|
+
* without requiring external dependencies. After calling this function, the
|
|
2407
|
+
* schedule can be used freely without needing to pass a context at execution
|
|
2408
|
+
* time.
|
|
2409
|
+
*
|
|
2410
|
+
* This is useful when working with schedules that rely on contextual
|
|
2411
|
+
* information, such as logging services, database connections, or configuration
|
|
2412
|
+
* settings.
|
|
1333
2413
|
*
|
|
1334
2414
|
* @since 2.0.0
|
|
1335
|
-
* @category
|
|
2415
|
+
* @category Context
|
|
1336
2416
|
*/
|
|
1337
2417
|
<Out, In, R>(self: Schedule<Out, In, R>, context: Context.Context<R>): Schedule<Out, In, never>
|
|
1338
2418
|
} = internal.provideContext
|
|
1339
2419
|
|
|
1340
2420
|
/**
|
|
1341
|
-
* Returns a new schedule with
|
|
1342
|
-
*
|
|
1343
|
-
*
|
|
2421
|
+
* Returns a new schedule with a single required service provided, eliminating
|
|
2422
|
+
* the need for external dependencies.
|
|
2423
|
+
*
|
|
2424
|
+
* **Details**
|
|
2425
|
+
*
|
|
2426
|
+
* This function supplies a single service dependency to a schedule, allowing it
|
|
2427
|
+
* to run without requiring that service externally. If a schedule depends on
|
|
2428
|
+
* multiple services, consider using `provideContext` instead.
|
|
2429
|
+
*
|
|
2430
|
+
* This is useful when working with schedules that require a specific service,
|
|
2431
|
+
* such as logging, metrics, or configuration retrieval.
|
|
1344
2432
|
*
|
|
1345
2433
|
* @since 2.0.0
|
|
1346
|
-
* @category
|
|
2434
|
+
* @category Context
|
|
1347
2435
|
*/
|
|
1348
2436
|
export const provideService: {
|
|
1349
2437
|
/**
|
|
1350
|
-
* Returns a new schedule with
|
|
1351
|
-
*
|
|
1352
|
-
*
|
|
2438
|
+
* Returns a new schedule with a single required service provided, eliminating
|
|
2439
|
+
* the need for external dependencies.
|
|
2440
|
+
*
|
|
2441
|
+
* **Details**
|
|
2442
|
+
*
|
|
2443
|
+
* This function supplies a single service dependency to a schedule, allowing it
|
|
2444
|
+
* to run without requiring that service externally. If a schedule depends on
|
|
2445
|
+
* multiple services, consider using `provideContext` instead.
|
|
2446
|
+
*
|
|
2447
|
+
* This is useful when working with schedules that require a specific service,
|
|
2448
|
+
* such as logging, metrics, or configuration retrieval.
|
|
1353
2449
|
*
|
|
1354
2450
|
* @since 2.0.0
|
|
1355
|
-
* @category
|
|
2451
|
+
* @category Context
|
|
1356
2452
|
*/
|
|
1357
|
-
<
|
|
1358
|
-
tag:
|
|
1359
|
-
service:
|
|
1360
|
-
): <Out, In, R>(self: Schedule<Out, In, R>) => Schedule<Out, In, Exclude<R,
|
|
2453
|
+
<I, S>(
|
|
2454
|
+
tag: Context.Tag<I, S>,
|
|
2455
|
+
service: Types.NoInfer<S>
|
|
2456
|
+
): <Out, In, R>(self: Schedule<Out, In, R>) => Schedule<Out, In, Exclude<R, I>>
|
|
1361
2457
|
/**
|
|
1362
|
-
* Returns a new schedule with
|
|
1363
|
-
*
|
|
1364
|
-
*
|
|
2458
|
+
* Returns a new schedule with a single required service provided, eliminating
|
|
2459
|
+
* the need for external dependencies.
|
|
2460
|
+
*
|
|
2461
|
+
* **Details**
|
|
2462
|
+
*
|
|
2463
|
+
* This function supplies a single service dependency to a schedule, allowing it
|
|
2464
|
+
* to run without requiring that service externally. If a schedule depends on
|
|
2465
|
+
* multiple services, consider using `provideContext` instead.
|
|
2466
|
+
*
|
|
2467
|
+
* This is useful when working with schedules that require a specific service,
|
|
2468
|
+
* such as logging, metrics, or configuration retrieval.
|
|
1365
2469
|
*
|
|
1366
2470
|
* @since 2.0.0
|
|
1367
|
-
* @category
|
|
2471
|
+
* @category Context
|
|
1368
2472
|
*/
|
|
1369
|
-
<Out, In, R,
|
|
2473
|
+
<Out, In, R, I, S>(
|
|
1370
2474
|
self: Schedule<Out, In, R>,
|
|
1371
|
-
tag:
|
|
1372
|
-
service:
|
|
1373
|
-
): Schedule<Out, In, Exclude<R,
|
|
2475
|
+
tag: Context.Tag<I, S>,
|
|
2476
|
+
service: Types.NoInfer<S>
|
|
2477
|
+
): Schedule<Out, In, Exclude<R, I>>
|
|
1374
2478
|
} = internal.provideService
|
|
1375
2479
|
|
|
1376
2480
|
/**
|
|
1377
|
-
* A schedule that recurs
|
|
2481
|
+
* A schedule that recurs until the given predicate evaluates to true.
|
|
2482
|
+
*
|
|
2483
|
+
* **Details**
|
|
2484
|
+
*
|
|
2485
|
+
* This schedule will continue executing as long as the provided predicate `f`
|
|
2486
|
+
* returns `false` for the input value. Once `f` evaluates to `true`, the
|
|
2487
|
+
* schedule stops recurring.
|
|
2488
|
+
*
|
|
2489
|
+
* This is useful for defining schedules that should stop when a certain
|
|
2490
|
+
* condition is met, such as detecting a success state, reaching a threshold, or
|
|
2491
|
+
* avoiding unnecessary retries.
|
|
2492
|
+
*
|
|
2493
|
+
* @see {@link recurUntilEffect} If you need to use an effectful predicate.
|
|
1378
2494
|
*
|
|
1379
2495
|
* @since 2.0.0
|
|
1380
|
-
* @category
|
|
2496
|
+
* @category Recurrence Conditions
|
|
1381
2497
|
*/
|
|
1382
2498
|
export const recurUntil: <A>(f: Predicate<A>) => Schedule<A, A> = internal.recurUntil
|
|
1383
2499
|
|
|
1384
2500
|
/**
|
|
1385
|
-
* A schedule that recurs
|
|
2501
|
+
* A schedule that recurs until the given effectful predicate evaluates to true.
|
|
2502
|
+
*
|
|
2503
|
+
* **Details**
|
|
2504
|
+
*
|
|
2505
|
+
* This schedule continues executing as long as the provided effectful predicate
|
|
2506
|
+
* `f` returns `false`. Once `f` evaluates to `true`, the schedule stops
|
|
2507
|
+
* recurring. Unlike {@link recurUntil}, this function allows the stopping
|
|
2508
|
+
* condition to be computed asynchronously or based on external dependencies.
|
|
2509
|
+
*
|
|
2510
|
+
* This is useful when the stopping condition depends on an effectful
|
|
2511
|
+
* computation, such as checking a database, making an API call, or retrieving
|
|
2512
|
+
* system state dynamically.
|
|
2513
|
+
*
|
|
2514
|
+
* @see {@link recurUntil} If you need to use a pure predicate.
|
|
1386
2515
|
*
|
|
1387
2516
|
* @since 2.0.0
|
|
1388
|
-
* @category
|
|
2517
|
+
* @category Recurrence Conditions
|
|
1389
2518
|
*/
|
|
1390
2519
|
export const recurUntilEffect: <A, R>(f: (a: A) => Effect.Effect<boolean, never, R>) => Schedule<A, A, R> =
|
|
1391
2520
|
internal.recurUntilEffect
|
|
1392
2521
|
|
|
1393
2522
|
/**
|
|
1394
|
-
* A schedule that recurs
|
|
1395
|
-
*
|
|
2523
|
+
* A schedule that recurs until the input value matches a partial function, then
|
|
2524
|
+
* maps the value.
|
|
2525
|
+
*
|
|
2526
|
+
* **Details**
|
|
2527
|
+
*
|
|
2528
|
+
* This schedule continues executing until the provided partial function `pf`
|
|
2529
|
+
* returns `Some(value)`. At that point, it stops and maps the resulting value
|
|
2530
|
+
* to an `Option<B>`. If `pf` returns `None`, the schedule continues.
|
|
2531
|
+
*
|
|
2532
|
+
* This is useful when defining schedules that should stop once a certain
|
|
2533
|
+
* condition is met and transform the final value before completion.
|
|
1396
2534
|
*
|
|
1397
2535
|
* @since 2.0.0
|
|
1398
|
-
* @category
|
|
2536
|
+
* @category Recurrence Conditions
|
|
1399
2537
|
*/
|
|
1400
2538
|
export const recurUntilOption: <A, B>(pf: (a: A) => Option.Option<B>) => Schedule<Option.Option<B>, A> =
|
|
1401
2539
|
internal.recurUntilOption
|
|
1402
2540
|
|
|
1403
2541
|
/**
|
|
1404
|
-
* A schedule that recurs
|
|
2542
|
+
* A schedule that recurs until the specified duration has elapsed.
|
|
2543
|
+
*
|
|
2544
|
+
* **Details**
|
|
2545
|
+
*
|
|
2546
|
+
* This schedule continues executing for the given `duration`, after which it
|
|
2547
|
+
* stops. The schedule outputs the elapsed time on each recurrence.
|
|
2548
|
+
*
|
|
2549
|
+
* This is useful for limiting the duration of retries, enforcing time-based
|
|
2550
|
+
* constraints, or ensuring that an operation does not run indefinitely.
|
|
1405
2551
|
*
|
|
1406
2552
|
* @since 2.0.0
|
|
1407
|
-
* @category
|
|
2553
|
+
* @category Recurrence Conditions
|
|
1408
2554
|
*/
|
|
1409
2555
|
export const recurUpTo: (duration: Duration.DurationInput) => Schedule<Duration.Duration> = internal.recurUpTo
|
|
1410
2556
|
|
|
1411
2557
|
/**
|
|
1412
|
-
* A schedule that recurs
|
|
2558
|
+
* A schedule that recurs as long as the given predicate evaluates to true.
|
|
2559
|
+
*
|
|
2560
|
+
* **Details*
|
|
2561
|
+
*
|
|
2562
|
+
* This schedule continues executing as long as the provided predicate `f`
|
|
2563
|
+
* returns `true` for the input value. Once `f` evaluates to `false`, the
|
|
2564
|
+
* schedule stops recurring.
|
|
2565
|
+
*
|
|
2566
|
+
* @see {@link recurWhileEffect} If you need to use an effectful predicate.
|
|
1413
2567
|
*
|
|
1414
2568
|
* @since 2.0.0
|
|
1415
|
-
* @category
|
|
2569
|
+
* @category Recurrence Conditions
|
|
1416
2570
|
*/
|
|
1417
2571
|
export const recurWhile: <A>(f: Predicate<A>) => Schedule<A, A> = internal.recurWhile
|
|
1418
2572
|
|
|
1419
2573
|
/**
|
|
1420
|
-
* A schedule that recurs
|
|
2574
|
+
* A schedule that recurs as long as the given effectful predicate evaluates to
|
|
1421
2575
|
* true.
|
|
1422
2576
|
*
|
|
2577
|
+
* **Details**
|
|
2578
|
+
*
|
|
2579
|
+
* This schedule continues executing as long as the provided effectful predicate
|
|
2580
|
+
* `f` returns `true`. Once `f` evaluates to `false`, the schedule stops
|
|
2581
|
+
* recurring. Unlike {@link recurWhile}, this function allows the condition to
|
|
2582
|
+
* be computed dynamically using an effectful computation.
|
|
2583
|
+
*
|
|
2584
|
+
* @see {@link recurWhile} If you need to use a pure predicate.
|
|
2585
|
+
*
|
|
1423
2586
|
* @since 2.0.0
|
|
1424
|
-
* @category
|
|
2587
|
+
* @category Recurrence Conditions
|
|
1425
2588
|
*/
|
|
1426
2589
|
export const recurWhileEffect: <A, R>(f: (a: A) => Effect.Effect<boolean, never, R>) => Schedule<A, A, R> =
|
|
1427
2590
|
internal.recurWhileEffect
|
|
1428
2591
|
|
|
1429
2592
|
/**
|
|
1430
|
-
* A schedule
|
|
1431
|
-
*
|
|
2593
|
+
* A schedule that recurs a fixed number of times before terminating.
|
|
2594
|
+
*
|
|
2595
|
+
* **Details**
|
|
1432
2596
|
*
|
|
1433
|
-
*
|
|
2597
|
+
* This schedule will continue executing until it has been stepped `n` times,
|
|
2598
|
+
* after which it will stop. The output of the schedule is the current count of
|
|
2599
|
+
* recurrences.
|
|
2600
|
+
*
|
|
2601
|
+
* @category Constructors
|
|
1434
2602
|
* @since 2.0.0
|
|
1435
2603
|
*/
|
|
1436
2604
|
export const recurs: (n: number) => Schedule<number> = internal.recurs
|
|
@@ -1438,22 +2606,55 @@ export const recurs: (n: number) => Schedule<number> = internal.recurs
|
|
|
1438
2606
|
/**
|
|
1439
2607
|
* Returns a new schedule that folds over the outputs of this one.
|
|
1440
2608
|
*
|
|
2609
|
+
* **Details**
|
|
2610
|
+
*
|
|
2611
|
+
* This schedule transforms the output by accumulating values over time using a
|
|
2612
|
+
* reducer function `f`. It starts with an initial value `zero` and updates it
|
|
2613
|
+
* each time the schedule produces an output.
|
|
2614
|
+
*
|
|
2615
|
+
* This is useful for tracking statistics, aggregating results, or summarizing
|
|
2616
|
+
* data across multiple executions.
|
|
2617
|
+
*
|
|
2618
|
+
* @see {@link reduceEffect} If you need to use an effectful reducer function.
|
|
2619
|
+
*
|
|
1441
2620
|
* @since 2.0.0
|
|
1442
|
-
* @category
|
|
2621
|
+
* @category Reducing
|
|
1443
2622
|
*/
|
|
1444
2623
|
export const reduce: {
|
|
1445
2624
|
/**
|
|
1446
2625
|
* Returns a new schedule that folds over the outputs of this one.
|
|
1447
2626
|
*
|
|
2627
|
+
* **Details**
|
|
2628
|
+
*
|
|
2629
|
+
* This schedule transforms the output by accumulating values over time using a
|
|
2630
|
+
* reducer function `f`. It starts with an initial value `zero` and updates it
|
|
2631
|
+
* each time the schedule produces an output.
|
|
2632
|
+
*
|
|
2633
|
+
* This is useful for tracking statistics, aggregating results, or summarizing
|
|
2634
|
+
* data across multiple executions.
|
|
2635
|
+
*
|
|
2636
|
+
* @see {@link reduceEffect} If you need to use an effectful reducer function.
|
|
2637
|
+
*
|
|
1448
2638
|
* @since 2.0.0
|
|
1449
|
-
* @category
|
|
2639
|
+
* @category Reducing
|
|
1450
2640
|
*/
|
|
1451
2641
|
<Out, Z>(zero: Z, f: (z: Z, out: Out) => Z): <In, R>(self: Schedule<Out, In, R>) => Schedule<Z, In, R>
|
|
1452
2642
|
/**
|
|
1453
2643
|
* Returns a new schedule that folds over the outputs of this one.
|
|
1454
2644
|
*
|
|
2645
|
+
* **Details**
|
|
2646
|
+
*
|
|
2647
|
+
* This schedule transforms the output by accumulating values over time using a
|
|
2648
|
+
* reducer function `f`. It starts with an initial value `zero` and updates it
|
|
2649
|
+
* each time the schedule produces an output.
|
|
2650
|
+
*
|
|
2651
|
+
* This is useful for tracking statistics, aggregating results, or summarizing
|
|
2652
|
+
* data across multiple executions.
|
|
2653
|
+
*
|
|
2654
|
+
* @see {@link reduceEffect} If you need to use an effectful reducer function.
|
|
2655
|
+
*
|
|
1455
2656
|
* @since 2.0.0
|
|
1456
|
-
* @category
|
|
2657
|
+
* @category Reducing
|
|
1457
2658
|
*/
|
|
1458
2659
|
<Out, In, R, Z>(self: Schedule<Out, In, R>, zero: Z, f: (z: Z, out: Out) => Z): Schedule<Z, In, R>
|
|
1459
2660
|
} = internal.reduce
|
|
@@ -1461,15 +2662,39 @@ export const reduce: {
|
|
|
1461
2662
|
/**
|
|
1462
2663
|
* Returns a new schedule that effectfully folds over the outputs of this one.
|
|
1463
2664
|
*
|
|
2665
|
+
* **Details**
|
|
2666
|
+
*
|
|
2667
|
+
* This schedule accumulates outputs over time using an effectful reducer
|
|
2668
|
+
* function `f`. It starts with an initial value `zero` and updates it
|
|
2669
|
+
* asynchronously or based on external dependencies.
|
|
2670
|
+
*
|
|
2671
|
+
* This is useful for asynchronous state tracking, logging, external metrics
|
|
2672
|
+
* aggregation, or any scenario where accumulation needs to involve an effectful
|
|
2673
|
+
* computation.
|
|
2674
|
+
*
|
|
2675
|
+
* @see {@link reduce} If you need to use a pure reducer function.
|
|
2676
|
+
*
|
|
1464
2677
|
* @since 2.0.0
|
|
1465
|
-
* @category
|
|
2678
|
+
* @category Reducing
|
|
1466
2679
|
*/
|
|
1467
2680
|
export const reduceEffect: {
|
|
1468
2681
|
/**
|
|
1469
2682
|
* Returns a new schedule that effectfully folds over the outputs of this one.
|
|
1470
2683
|
*
|
|
2684
|
+
* **Details**
|
|
2685
|
+
*
|
|
2686
|
+
* This schedule accumulates outputs over time using an effectful reducer
|
|
2687
|
+
* function `f`. It starts with an initial value `zero` and updates it
|
|
2688
|
+
* asynchronously or based on external dependencies.
|
|
2689
|
+
*
|
|
2690
|
+
* This is useful for asynchronous state tracking, logging, external metrics
|
|
2691
|
+
* aggregation, or any scenario where accumulation needs to involve an effectful
|
|
2692
|
+
* computation.
|
|
2693
|
+
*
|
|
2694
|
+
* @see {@link reduce} If you need to use a pure reducer function.
|
|
2695
|
+
*
|
|
1471
2696
|
* @since 2.0.0
|
|
1472
|
-
* @category
|
|
2697
|
+
* @category Reducing
|
|
1473
2698
|
*/
|
|
1474
2699
|
<Z, Out, R2>(
|
|
1475
2700
|
zero: Z,
|
|
@@ -1478,8 +2703,20 @@ export const reduceEffect: {
|
|
|
1478
2703
|
/**
|
|
1479
2704
|
* Returns a new schedule that effectfully folds over the outputs of this one.
|
|
1480
2705
|
*
|
|
2706
|
+
* **Details**
|
|
2707
|
+
*
|
|
2708
|
+
* This schedule accumulates outputs over time using an effectful reducer
|
|
2709
|
+
* function `f`. It starts with an initial value `zero` and updates it
|
|
2710
|
+
* asynchronously or based on external dependencies.
|
|
2711
|
+
*
|
|
2712
|
+
* This is useful for asynchronous state tracking, logging, external metrics
|
|
2713
|
+
* aggregation, or any scenario where accumulation needs to involve an effectful
|
|
2714
|
+
* computation.
|
|
2715
|
+
*
|
|
2716
|
+
* @see {@link reduce} If you need to use a pure reducer function.
|
|
2717
|
+
*
|
|
1481
2718
|
* @since 2.0.0
|
|
1482
|
-
* @category
|
|
2719
|
+
* @category Reducing
|
|
1483
2720
|
*/
|
|
1484
2721
|
<Out, In, R, Z, R2>(
|
|
1485
2722
|
self: Schedule<Out, In, R>,
|
|
@@ -1488,172 +2725,261 @@ export const reduceEffect: {
|
|
|
1488
2725
|
): Schedule<Z, In, R | R2>
|
|
1489
2726
|
} = internal.reduceEffect
|
|
1490
2727
|
|
|
2728
|
+
// TODO(4.0): remove?
|
|
1491
2729
|
/**
|
|
1492
|
-
*
|
|
1493
|
-
* state when this schedule is done.
|
|
2730
|
+
* Alias of {@link forever}.
|
|
1494
2731
|
*
|
|
1495
2732
|
* @since 2.0.0
|
|
1496
|
-
* @category
|
|
2733
|
+
* @category Constructors
|
|
1497
2734
|
*/
|
|
1498
2735
|
export const repeatForever: Schedule<number> = internal.forever
|
|
1499
2736
|
|
|
1500
2737
|
/**
|
|
1501
2738
|
* Returns a new schedule that outputs the number of repetitions of this one.
|
|
1502
2739
|
*
|
|
2740
|
+
* **Details**
|
|
2741
|
+
*
|
|
2742
|
+
* This schedule tracks how many times the given schedule has executed and
|
|
2743
|
+
* outputs the count instead of the original values. The first execution starts
|
|
2744
|
+
* at `0`, and the count increases with each recurrence.
|
|
2745
|
+
*
|
|
1503
2746
|
* @since 2.0.0
|
|
1504
|
-
* @category
|
|
2747
|
+
* @category Monitoring
|
|
1505
2748
|
*/
|
|
1506
2749
|
export const repetitions: <Out, In, R>(self: Schedule<Out, In, R>) => Schedule<number, In, R> = internal.repetitions
|
|
1507
2750
|
|
|
1508
2751
|
/**
|
|
1509
|
-
*
|
|
1510
|
-
*
|
|
2752
|
+
* Returns a new schedule that automatically resets to its initial state after a
|
|
2753
|
+
* period of inactivity defined by `duration`.
|
|
2754
|
+
*
|
|
2755
|
+
* **Details**
|
|
2756
|
+
*
|
|
2757
|
+
* This function modifies a schedule so that if no inputs are received for the
|
|
2758
|
+
* specified `duration`, the schedule resets as if it were new.
|
|
2759
|
+
*
|
|
2760
|
+
* @see {@link resetWhen} If you need to reset based on output values.
|
|
1511
2761
|
*
|
|
1512
2762
|
* @since 2.0.0
|
|
1513
|
-
* @category
|
|
2763
|
+
* @category State Management
|
|
1514
2764
|
*/
|
|
1515
2765
|
export const resetAfter: {
|
|
1516
2766
|
/**
|
|
1517
|
-
*
|
|
1518
|
-
*
|
|
2767
|
+
* Returns a new schedule that automatically resets to its initial state after a
|
|
2768
|
+
* period of inactivity defined by `duration`.
|
|
2769
|
+
*
|
|
2770
|
+
* **Details**
|
|
2771
|
+
*
|
|
2772
|
+
* This function modifies a schedule so that if no inputs are received for the
|
|
2773
|
+
* specified `duration`, the schedule resets as if it were new.
|
|
2774
|
+
*
|
|
2775
|
+
* @see {@link resetWhen} If you need to reset based on output values.
|
|
1519
2776
|
*
|
|
1520
2777
|
* @since 2.0.0
|
|
1521
|
-
* @category
|
|
2778
|
+
* @category State Management
|
|
1522
2779
|
*/
|
|
1523
2780
|
(duration: Duration.DurationInput): <Out, In, R>(self: Schedule<Out, In, R>) => Schedule<Out, In, R>
|
|
1524
2781
|
/**
|
|
1525
|
-
*
|
|
1526
|
-
*
|
|
2782
|
+
* Returns a new schedule that automatically resets to its initial state after a
|
|
2783
|
+
* period of inactivity defined by `duration`.
|
|
2784
|
+
*
|
|
2785
|
+
* **Details**
|
|
2786
|
+
*
|
|
2787
|
+
* This function modifies a schedule so that if no inputs are received for the
|
|
2788
|
+
* specified `duration`, the schedule resets as if it were new.
|
|
2789
|
+
*
|
|
2790
|
+
* @see {@link resetWhen} If you need to reset based on output values.
|
|
1527
2791
|
*
|
|
1528
2792
|
* @since 2.0.0
|
|
1529
|
-
* @category
|
|
2793
|
+
* @category State Management
|
|
1530
2794
|
*/
|
|
1531
2795
|
<Out, In, R>(self: Schedule<Out, In, R>, duration: Duration.DurationInput): Schedule<Out, In, R>
|
|
1532
2796
|
} = internal.resetAfter
|
|
1533
2797
|
|
|
1534
2798
|
/**
|
|
1535
2799
|
* Resets the schedule when the specified predicate on the schedule output
|
|
1536
|
-
* evaluates to true
|
|
2800
|
+
* evaluates to `true`.
|
|
2801
|
+
*
|
|
2802
|
+
* **Details**
|
|
2803
|
+
*
|
|
2804
|
+
* This function modifies a schedule so that it resets to its initial state
|
|
2805
|
+
* whenever the provided predicate `f` returns `true` for an output value.
|
|
2806
|
+
*
|
|
2807
|
+
* @see {@link resetAfter} If you need to reset based on inactivity.
|
|
1537
2808
|
*
|
|
1538
2809
|
* @since 2.0.0
|
|
1539
|
-
* @category
|
|
2810
|
+
* @category State Management
|
|
1540
2811
|
*/
|
|
1541
2812
|
export const resetWhen: {
|
|
1542
2813
|
/**
|
|
1543
2814
|
* Resets the schedule when the specified predicate on the schedule output
|
|
1544
|
-
* evaluates to true
|
|
2815
|
+
* evaluates to `true`.
|
|
2816
|
+
*
|
|
2817
|
+
* **Details**
|
|
2818
|
+
*
|
|
2819
|
+
* This function modifies a schedule so that it resets to its initial state
|
|
2820
|
+
* whenever the provided predicate `f` returns `true` for an output value.
|
|
2821
|
+
*
|
|
2822
|
+
* @see {@link resetAfter} If you need to reset based on inactivity.
|
|
1545
2823
|
*
|
|
1546
2824
|
* @since 2.0.0
|
|
1547
|
-
* @category
|
|
2825
|
+
* @category State Management
|
|
1548
2826
|
*/
|
|
1549
2827
|
<Out>(f: Predicate<Out>): <In, R>(self: Schedule<Out, In, R>) => Schedule<Out, In, R>
|
|
1550
2828
|
/**
|
|
1551
2829
|
* Resets the schedule when the specified predicate on the schedule output
|
|
1552
|
-
* evaluates to true
|
|
2830
|
+
* evaluates to `true`.
|
|
2831
|
+
*
|
|
2832
|
+
* **Details**
|
|
2833
|
+
*
|
|
2834
|
+
* This function modifies a schedule so that it resets to its initial state
|
|
2835
|
+
* whenever the provided predicate `f` returns `true` for an output value.
|
|
2836
|
+
*
|
|
2837
|
+
* @see {@link resetAfter} If you need to reset based on inactivity.
|
|
1553
2838
|
*
|
|
1554
2839
|
* @since 2.0.0
|
|
1555
|
-
* @category
|
|
2840
|
+
* @category State Management
|
|
1556
2841
|
*/
|
|
1557
2842
|
<Out, In, R>(self: Schedule<Out, In, R>, f: Predicate<Out>): Schedule<Out, In, R>
|
|
1558
2843
|
} = internal.resetWhen
|
|
1559
2844
|
|
|
1560
2845
|
/**
|
|
1561
|
-
* Runs a schedule using the provided inputs
|
|
2846
|
+
* Runs a schedule using the provided inputs and collects all outputs.
|
|
2847
|
+
*
|
|
2848
|
+
* **Details**
|
|
2849
|
+
*
|
|
2850
|
+
* This function executes a given schedule with a sequence of input values and
|
|
2851
|
+
* accumulates all outputs into a `Chunk`. The schedule starts execution at the
|
|
2852
|
+
* specified `now` timestamp and proceeds according to its defined behavior.
|
|
2853
|
+
*
|
|
2854
|
+
* This is useful for batch processing, simulating execution, or testing
|
|
2855
|
+
* schedules with predefined input sequences.
|
|
1562
2856
|
*
|
|
1563
2857
|
* @since 2.0.0
|
|
1564
|
-
* @category
|
|
2858
|
+
* @category Execution
|
|
1565
2859
|
*/
|
|
1566
2860
|
export const run: {
|
|
1567
2861
|
/**
|
|
1568
|
-
* Runs a schedule using the provided inputs
|
|
2862
|
+
* Runs a schedule using the provided inputs and collects all outputs.
|
|
2863
|
+
*
|
|
2864
|
+
* **Details**
|
|
2865
|
+
*
|
|
2866
|
+
* This function executes a given schedule with a sequence of input values and
|
|
2867
|
+
* accumulates all outputs into a `Chunk`. The schedule starts execution at the
|
|
2868
|
+
* specified `now` timestamp and proceeds according to its defined behavior.
|
|
2869
|
+
*
|
|
2870
|
+
* This is useful for batch processing, simulating execution, or testing
|
|
2871
|
+
* schedules with predefined input sequences.
|
|
1569
2872
|
*
|
|
1570
2873
|
* @since 2.0.0
|
|
1571
|
-
* @category
|
|
2874
|
+
* @category Execution
|
|
1572
2875
|
*/
|
|
1573
2876
|
<In>(
|
|
1574
2877
|
now: number,
|
|
1575
2878
|
input: Iterable<In>
|
|
1576
2879
|
): <Out, R>(self: Schedule<Out, In, R>) => Effect.Effect<Chunk.Chunk<Out>, never, R>
|
|
1577
2880
|
/**
|
|
1578
|
-
* Runs a schedule using the provided inputs
|
|
2881
|
+
* Runs a schedule using the provided inputs and collects all outputs.
|
|
2882
|
+
*
|
|
2883
|
+
* **Details**
|
|
2884
|
+
*
|
|
2885
|
+
* This function executes a given schedule with a sequence of input values and
|
|
2886
|
+
* accumulates all outputs into a `Chunk`. The schedule starts execution at the
|
|
2887
|
+
* specified `now` timestamp and proceeds according to its defined behavior.
|
|
2888
|
+
*
|
|
2889
|
+
* This is useful for batch processing, simulating execution, or testing
|
|
2890
|
+
* schedules with predefined input sequences.
|
|
1579
2891
|
*
|
|
1580
2892
|
* @since 2.0.0
|
|
1581
|
-
* @category
|
|
2893
|
+
* @category Execution
|
|
1582
2894
|
*/
|
|
1583
2895
|
<Out, In, R>(self: Schedule<Out, In, R>, now: number, input: Iterable<In>): Effect.Effect<Chunk.Chunk<Out>, never, R>
|
|
1584
2896
|
} = internal.run
|
|
1585
2897
|
|
|
1586
2898
|
/**
|
|
1587
|
-
*
|
|
1588
|
-
*
|
|
1589
|
-
* 1, 2.
|
|
2899
|
+
* Returns a schedule that recurs continuously, with each repetition
|
|
2900
|
+
* spaced by the specified `duration` from the last run.
|
|
1590
2901
|
*
|
|
1591
|
-
*
|
|
2902
|
+
* **Details**
|
|
1592
2903
|
*
|
|
1593
|
-
*
|
|
1594
|
-
*
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
/**
|
|
1599
|
-
* Returns a schedule that recurs continuously, each repetition spaced the
|
|
1600
|
-
* specified duration from the last run.
|
|
2904
|
+
* This schedule ensures that executions occur at a fixed interval,
|
|
2905
|
+
* maintaining a consistent delay between repetitions. The delay starts
|
|
2906
|
+
* from the end of the last execution, not from the schedule start time.
|
|
2907
|
+
*
|
|
2908
|
+
* @see {@link fixed} If you need to run at a fixed interval from the start.
|
|
1601
2909
|
*
|
|
1602
2910
|
* @since 2.0.0
|
|
1603
|
-
* @category
|
|
2911
|
+
* @category Constructors
|
|
1604
2912
|
*/
|
|
1605
2913
|
export const spaced: (duration: Duration.DurationInput) => Schedule<number> = internal.spaced
|
|
1606
2914
|
|
|
1607
2915
|
/**
|
|
1608
|
-
* A schedule that does not recur
|
|
2916
|
+
* A schedule that does not recur and stops immediately.
|
|
1609
2917
|
*
|
|
1610
2918
|
* @since 2.0.0
|
|
1611
|
-
* @category
|
|
2919
|
+
* @category Constructors
|
|
1612
2920
|
*/
|
|
1613
2921
|
export const stop: Schedule<void> = internal.stop
|
|
1614
2922
|
|
|
1615
2923
|
/**
|
|
1616
|
-
* Returns a schedule that
|
|
1617
|
-
* value.
|
|
2924
|
+
* Returns a schedule that recurs indefinitely, always producing the specified
|
|
2925
|
+
* constant value.
|
|
1618
2926
|
*
|
|
1619
2927
|
* @since 2.0.0
|
|
1620
|
-
* @category
|
|
2928
|
+
* @category Constructors
|
|
1621
2929
|
*/
|
|
1622
2930
|
export const succeed: <A>(value: A) => Schedule<A> = internal.succeed
|
|
1623
2931
|
|
|
1624
2932
|
/**
|
|
1625
|
-
* Returns a schedule that
|
|
1626
|
-
* value.
|
|
2933
|
+
* Returns a schedule that recurs indefinitely, evaluating the given function to
|
|
2934
|
+
* produce a constant value.
|
|
1627
2935
|
*
|
|
1628
|
-
* @category
|
|
2936
|
+
* @category Constructors
|
|
1629
2937
|
* @since 2.0.0
|
|
1630
2938
|
*/
|
|
1631
2939
|
export const sync: <A>(evaluate: LazyArg<A>) => Schedule<A> = internal.sync
|
|
1632
2940
|
|
|
1633
2941
|
/**
|
|
1634
|
-
* Returns a new schedule that
|
|
1635
|
-
*
|
|
2942
|
+
* Returns a new schedule that runs the given effectful function for each input
|
|
2943
|
+
* before continuing execution.
|
|
2944
|
+
*
|
|
2945
|
+
* **Details**
|
|
2946
|
+
*
|
|
2947
|
+
* This function allows side effects to be performed on each input processed by
|
|
2948
|
+
* the schedule. It does not modify the schedule’s behavior but ensures that the
|
|
2949
|
+
* provided function `f` runs before each step.
|
|
1636
2950
|
*
|
|
1637
2951
|
* @since 2.0.0
|
|
1638
|
-
* @category
|
|
2952
|
+
* @category Tapping
|
|
1639
2953
|
*/
|
|
1640
2954
|
export const tapInput: {
|
|
1641
2955
|
/**
|
|
1642
|
-
* Returns a new schedule that
|
|
1643
|
-
*
|
|
2956
|
+
* Returns a new schedule that runs the given effectful function for each input
|
|
2957
|
+
* before continuing execution.
|
|
2958
|
+
*
|
|
2959
|
+
* **Details**
|
|
2960
|
+
*
|
|
2961
|
+
* This function allows side effects to be performed on each input processed by
|
|
2962
|
+
* the schedule. It does not modify the schedule’s behavior but ensures that the
|
|
2963
|
+
* provided function `f` runs before each step.
|
|
1644
2964
|
*
|
|
1645
2965
|
* @since 2.0.0
|
|
1646
|
-
* @category
|
|
2966
|
+
* @category Tapping
|
|
1647
2967
|
*/
|
|
1648
2968
|
<In2, X, R2>(
|
|
1649
2969
|
f: (input: In2) => Effect.Effect<X, never, R2>
|
|
1650
2970
|
): <Out, In, R>(self: Schedule<Out, In, R>) => Schedule<Out, In & In2, R2 | R>
|
|
1651
2971
|
/**
|
|
1652
|
-
* Returns a new schedule that
|
|
1653
|
-
*
|
|
2972
|
+
* Returns a new schedule that runs the given effectful function for each input
|
|
2973
|
+
* before continuing execution.
|
|
2974
|
+
*
|
|
2975
|
+
* **Details**
|
|
2976
|
+
*
|
|
2977
|
+
* This function allows side effects to be performed on each input processed by
|
|
2978
|
+
* the schedule. It does not modify the schedule’s behavior but ensures that the
|
|
2979
|
+
* provided function `f` runs before each step.
|
|
1654
2980
|
*
|
|
1655
2981
|
* @since 2.0.0
|
|
1656
|
-
* @category
|
|
2982
|
+
* @category Tapping
|
|
1657
2983
|
*/
|
|
1658
2984
|
<Out, In, R, In2, X, R2>(
|
|
1659
2985
|
self: Schedule<Out, In, R>,
|
|
@@ -1662,69 +2988,138 @@ export const tapInput: {
|
|
|
1662
2988
|
} = internal.tapInput
|
|
1663
2989
|
|
|
1664
2990
|
/**
|
|
1665
|
-
* Returns a new schedule that
|
|
1666
|
-
*
|
|
2991
|
+
* Returns a new schedule that runs the given effectful function for each output
|
|
2992
|
+
* before continuing execution.
|
|
2993
|
+
*
|
|
2994
|
+
* **Details**
|
|
2995
|
+
*
|
|
2996
|
+
* This function allows side effects to be performed on each output produced by
|
|
2997
|
+
* the schedule. It does not modify the schedule’s behavior but ensures that the
|
|
2998
|
+
* provided function `f` runs after each step.
|
|
1667
2999
|
*
|
|
1668
3000
|
* @since 2.0.0
|
|
1669
|
-
* @category
|
|
3001
|
+
* @category Tapping
|
|
1670
3002
|
*/
|
|
1671
3003
|
export const tapOutput: {
|
|
1672
3004
|
/**
|
|
1673
|
-
* Returns a new schedule that
|
|
1674
|
-
*
|
|
3005
|
+
* Returns a new schedule that runs the given effectful function for each output
|
|
3006
|
+
* before continuing execution.
|
|
3007
|
+
*
|
|
3008
|
+
* **Details**
|
|
3009
|
+
*
|
|
3010
|
+
* This function allows side effects to be performed on each output produced by
|
|
3011
|
+
* the schedule. It does not modify the schedule’s behavior but ensures that the
|
|
3012
|
+
* provided function `f` runs after each step.
|
|
1675
3013
|
*
|
|
1676
3014
|
* @since 2.0.0
|
|
1677
|
-
* @category
|
|
3015
|
+
* @category Tapping
|
|
1678
3016
|
*/
|
|
1679
|
-
<
|
|
1680
|
-
f: (out:
|
|
3017
|
+
<X, R2, Out>(
|
|
3018
|
+
f: (out: Types.NoInfer<Out>) => Effect.Effect<X, never, R2>
|
|
1681
3019
|
): <In, R>(self: Schedule<Out, In, R>) => Schedule<Out, In, R2 | R>
|
|
1682
3020
|
/**
|
|
1683
|
-
* Returns a new schedule that
|
|
1684
|
-
*
|
|
3021
|
+
* Returns a new schedule that runs the given effectful function for each output
|
|
3022
|
+
* before continuing execution.
|
|
3023
|
+
*
|
|
3024
|
+
* **Details**
|
|
3025
|
+
*
|
|
3026
|
+
* This function allows side effects to be performed on each output produced by
|
|
3027
|
+
* the schedule. It does not modify the schedule’s behavior but ensures that the
|
|
3028
|
+
* provided function `f` runs after each step.
|
|
1685
3029
|
*
|
|
1686
3030
|
* @since 2.0.0
|
|
1687
|
-
* @category
|
|
3031
|
+
* @category Tapping
|
|
1688
3032
|
*/
|
|
1689
|
-
<Out, In, R,
|
|
3033
|
+
<Out, In, R, X, R2>(
|
|
1690
3034
|
self: Schedule<Out, In, R>,
|
|
1691
|
-
f: (out:
|
|
3035
|
+
f: (out: Out) => Effect.Effect<X, never, R2>
|
|
1692
3036
|
): Schedule<Out, In, R | R2>
|
|
1693
3037
|
} = internal.tapOutput
|
|
1694
3038
|
|
|
1695
3039
|
/**
|
|
1696
|
-
*
|
|
1697
|
-
*
|
|
3040
|
+
* Creates a schedule that repeatedly applies a function to transform a state
|
|
3041
|
+
* value, producing a sequence of values.
|
|
3042
|
+
*
|
|
3043
|
+
* **Details**
|
|
3044
|
+
*
|
|
3045
|
+
* This function starts with an `initial` value and applies `f` recursively to
|
|
3046
|
+
* generate the next state at each step. The schedule continues indefinitely,
|
|
3047
|
+
* producing a stream of values by unfolding the state over time.
|
|
1698
3048
|
*
|
|
1699
3049
|
* @since 2.0.0
|
|
1700
|
-
* @category
|
|
3050
|
+
* @category Constructors
|
|
1701
3051
|
*/
|
|
1702
3052
|
export const unfold: <A>(initial: A, f: (a: A) => A) => Schedule<A> = internal.unfold
|
|
1703
3053
|
|
|
1704
3054
|
/**
|
|
1705
|
-
*
|
|
1706
|
-
*
|
|
3055
|
+
* Combines two schedules, continuing execution as long as at least one of them
|
|
3056
|
+
* allows it, using the shorter delay.
|
|
3057
|
+
*
|
|
3058
|
+
* **Details**
|
|
3059
|
+
*
|
|
3060
|
+
* This function combines two schedules into a single schedule that executes in
|
|
3061
|
+
* parallel. If either schedule allows continuation, the merged schedule
|
|
3062
|
+
* continues. When both schedules produce delays, the schedule selects the
|
|
3063
|
+
* shorter delay to determine the next step.
|
|
3064
|
+
*
|
|
3065
|
+
* The output of the new schedule is a tuple containing the outputs of both
|
|
3066
|
+
* schedules. The input type is the intersection of both schedules' input types.
|
|
3067
|
+
*
|
|
3068
|
+
* This is useful for scenarios where multiple scheduling conditions should be
|
|
3069
|
+
* considered, ensuring execution proceeds if at least one schedule permits it.
|
|
3070
|
+
*
|
|
3071
|
+
* @see {@link unionWith} If you need to use a custom merge function.
|
|
1707
3072
|
*
|
|
1708
3073
|
* @since 2.0.0
|
|
1709
|
-
* @category
|
|
3074
|
+
* @category Composition
|
|
1710
3075
|
*/
|
|
1711
3076
|
export const union: {
|
|
1712
3077
|
/**
|
|
1713
|
-
*
|
|
1714
|
-
*
|
|
3078
|
+
* Combines two schedules, continuing execution as long as at least one of them
|
|
3079
|
+
* allows it, using the shorter delay.
|
|
3080
|
+
*
|
|
3081
|
+
* **Details**
|
|
3082
|
+
*
|
|
3083
|
+
* This function combines two schedules into a single schedule that executes in
|
|
3084
|
+
* parallel. If either schedule allows continuation, the merged schedule
|
|
3085
|
+
* continues. When both schedules produce delays, the schedule selects the
|
|
3086
|
+
* shorter delay to determine the next step.
|
|
3087
|
+
*
|
|
3088
|
+
* The output of the new schedule is a tuple containing the outputs of both
|
|
3089
|
+
* schedules. The input type is the intersection of both schedules' input types.
|
|
3090
|
+
*
|
|
3091
|
+
* This is useful for scenarios where multiple scheduling conditions should be
|
|
3092
|
+
* considered, ensuring execution proceeds if at least one schedule permits it.
|
|
3093
|
+
*
|
|
3094
|
+
* @see {@link unionWith} If you need to use a custom merge function.
|
|
1715
3095
|
*
|
|
1716
3096
|
* @since 2.0.0
|
|
1717
|
-
* @category
|
|
3097
|
+
* @category Composition
|
|
1718
3098
|
*/
|
|
1719
3099
|
<Out2, In2, R2>(
|
|
1720
3100
|
that: Schedule<Out2, In2, R2>
|
|
1721
3101
|
): <Out, In, R>(self: Schedule<Out, In, R>) => Schedule<[Out, Out2], In & In2, R2 | R>
|
|
1722
3102
|
/**
|
|
1723
|
-
*
|
|
1724
|
-
*
|
|
3103
|
+
* Combines two schedules, continuing execution as long as at least one of them
|
|
3104
|
+
* allows it, using the shorter delay.
|
|
3105
|
+
*
|
|
3106
|
+
* **Details**
|
|
3107
|
+
*
|
|
3108
|
+
* This function combines two schedules into a single schedule that executes in
|
|
3109
|
+
* parallel. If either schedule allows continuation, the merged schedule
|
|
3110
|
+
* continues. When both schedules produce delays, the schedule selects the
|
|
3111
|
+
* shorter delay to determine the next step.
|
|
3112
|
+
*
|
|
3113
|
+
* The output of the new schedule is a tuple containing the outputs of both
|
|
3114
|
+
* schedules. The input type is the intersection of both schedules' input types.
|
|
3115
|
+
*
|
|
3116
|
+
* This is useful for scenarios where multiple scheduling conditions should be
|
|
3117
|
+
* considered, ensuring execution proceeds if at least one schedule permits it.
|
|
3118
|
+
*
|
|
3119
|
+
* @see {@link unionWith} If you need to use a custom merge function.
|
|
1725
3120
|
*
|
|
1726
3121
|
* @since 2.0.0
|
|
1727
|
-
* @category
|
|
3122
|
+
* @category Composition
|
|
1728
3123
|
*/
|
|
1729
3124
|
<Out, In, R, Out2, In2, R2>(
|
|
1730
3125
|
self: Schedule<Out, In, R>,
|
|
@@ -1733,33 +3128,81 @@ export const union: {
|
|
|
1733
3128
|
} = internal.union
|
|
1734
3129
|
|
|
1735
3130
|
/**
|
|
1736
|
-
*
|
|
1737
|
-
*
|
|
1738
|
-
*
|
|
3131
|
+
* Combines two schedules, continuing execution as long as at least one of them
|
|
3132
|
+
* wants to continue, merging their intervals using a custom merge function.
|
|
3133
|
+
*
|
|
3134
|
+
* **Details**
|
|
3135
|
+
*
|
|
3136
|
+
* This function allows you to combine two schedules while defining how their
|
|
3137
|
+
* intervals should be merged. Unlike {@link union}, which simply selects the
|
|
3138
|
+
* shorter delay, this function lets you specify a custom merging strategy for
|
|
3139
|
+
* the schedules’ intervals.
|
|
3140
|
+
*
|
|
3141
|
+
* The merged schedule continues execution as long as at least one of the input
|
|
3142
|
+
* schedules allows it. The next interval is determined by applying the provided
|
|
3143
|
+
* merge function to the intervals of both schedules.
|
|
3144
|
+
*
|
|
3145
|
+
* The output of the resulting schedule is a tuple containing the outputs of
|
|
3146
|
+
* both schedules. The input type is the intersection of both schedules' input
|
|
3147
|
+
* types.
|
|
3148
|
+
*
|
|
3149
|
+
* @see {@link union} If you need to use the shorter delay.
|
|
1739
3150
|
*
|
|
1740
3151
|
* @since 2.0.0
|
|
1741
|
-
* @category
|
|
3152
|
+
* @category Composition
|
|
1742
3153
|
*/
|
|
1743
3154
|
export const unionWith: {
|
|
1744
3155
|
/**
|
|
1745
|
-
*
|
|
1746
|
-
*
|
|
1747
|
-
*
|
|
3156
|
+
* Combines two schedules, continuing execution as long as at least one of them
|
|
3157
|
+
* wants to continue, merging their intervals using a custom merge function.
|
|
3158
|
+
*
|
|
3159
|
+
* **Details**
|
|
3160
|
+
*
|
|
3161
|
+
* This function allows you to combine two schedules while defining how their
|
|
3162
|
+
* intervals should be merged. Unlike {@link union}, which simply selects the
|
|
3163
|
+
* shorter delay, this function lets you specify a custom merging strategy for
|
|
3164
|
+
* the schedules’ intervals.
|
|
3165
|
+
*
|
|
3166
|
+
* The merged schedule continues execution as long as at least one of the input
|
|
3167
|
+
* schedules allows it. The next interval is determined by applying the provided
|
|
3168
|
+
* merge function to the intervals of both schedules.
|
|
3169
|
+
*
|
|
3170
|
+
* The output of the resulting schedule is a tuple containing the outputs of
|
|
3171
|
+
* both schedules. The input type is the intersection of both schedules' input
|
|
3172
|
+
* types.
|
|
3173
|
+
*
|
|
3174
|
+
* @see {@link union} If you need to use the shorter delay.
|
|
1748
3175
|
*
|
|
1749
3176
|
* @since 2.0.0
|
|
1750
|
-
* @category
|
|
3177
|
+
* @category Composition
|
|
1751
3178
|
*/
|
|
1752
3179
|
<Out2, In2, R2>(
|
|
1753
3180
|
that: Schedule<Out2, In2, R2>,
|
|
1754
3181
|
f: (x: Intervals.Intervals, y: Intervals.Intervals) => Intervals.Intervals
|
|
1755
3182
|
): <Out, In, R>(self: Schedule<Out, In, R>) => Schedule<[Out, Out2], In & In2, R2 | R>
|
|
1756
3183
|
/**
|
|
1757
|
-
*
|
|
1758
|
-
*
|
|
1759
|
-
*
|
|
3184
|
+
* Combines two schedules, continuing execution as long as at least one of them
|
|
3185
|
+
* wants to continue, merging their intervals using a custom merge function.
|
|
3186
|
+
*
|
|
3187
|
+
* **Details**
|
|
3188
|
+
*
|
|
3189
|
+
* This function allows you to combine two schedules while defining how their
|
|
3190
|
+
* intervals should be merged. Unlike {@link union}, which simply selects the
|
|
3191
|
+
* shorter delay, this function lets you specify a custom merging strategy for
|
|
3192
|
+
* the schedules’ intervals.
|
|
3193
|
+
*
|
|
3194
|
+
* The merged schedule continues execution as long as at least one of the input
|
|
3195
|
+
* schedules allows it. The next interval is determined by applying the provided
|
|
3196
|
+
* merge function to the intervals of both schedules.
|
|
3197
|
+
*
|
|
3198
|
+
* The output of the resulting schedule is a tuple containing the outputs of
|
|
3199
|
+
* both schedules. The input type is the intersection of both schedules' input
|
|
3200
|
+
* types.
|
|
3201
|
+
*
|
|
3202
|
+
* @see {@link union} If you need to use the shorter delay.
|
|
1760
3203
|
*
|
|
1761
3204
|
* @since 2.0.0
|
|
1762
|
-
* @category
|
|
3205
|
+
* @category Composition
|
|
1763
3206
|
*/
|
|
1764
3207
|
<Out, In, R, Out2, In2, R2>(
|
|
1765
3208
|
self: Schedule<Out, In, R>,
|
|
@@ -1769,55 +3212,106 @@ export const unionWith: {
|
|
|
1769
3212
|
} = internal.unionWith
|
|
1770
3213
|
|
|
1771
3214
|
/**
|
|
1772
|
-
* Returns a new schedule that
|
|
1773
|
-
* input evaluates to true
|
|
3215
|
+
* Returns a new schedule that stops execution when the given predicate on the
|
|
3216
|
+
* input evaluates to `true`.
|
|
3217
|
+
*
|
|
3218
|
+
* **Details**
|
|
3219
|
+
*
|
|
3220
|
+
* This function modifies an existing schedule so that it continues executing
|
|
3221
|
+
* only while the provided predicate returns `false` for incoming inputs. Once
|
|
3222
|
+
* an input satisfies the condition, the schedule terminates immediately.
|
|
3223
|
+
*
|
|
3224
|
+
* @see {@link untilInputEffect} If you need to use an effectful predicate.
|
|
1774
3225
|
*
|
|
1775
3226
|
* @since 2.0.0
|
|
1776
|
-
* @category
|
|
3227
|
+
* @category Recurrence Conditions
|
|
1777
3228
|
*/
|
|
1778
3229
|
export const untilInput: {
|
|
1779
3230
|
/**
|
|
1780
|
-
* Returns a new schedule that
|
|
1781
|
-
* input evaluates to true
|
|
3231
|
+
* Returns a new schedule that stops execution when the given predicate on the
|
|
3232
|
+
* input evaluates to `true`.
|
|
3233
|
+
*
|
|
3234
|
+
* **Details**
|
|
3235
|
+
*
|
|
3236
|
+
* This function modifies an existing schedule so that it continues executing
|
|
3237
|
+
* only while the provided predicate returns `false` for incoming inputs. Once
|
|
3238
|
+
* an input satisfies the condition, the schedule terminates immediately.
|
|
3239
|
+
*
|
|
3240
|
+
* @see {@link untilInputEffect} If you need to use an effectful predicate.
|
|
1782
3241
|
*
|
|
1783
3242
|
* @since 2.0.0
|
|
1784
|
-
* @category
|
|
3243
|
+
* @category Recurrence Conditions
|
|
1785
3244
|
*/
|
|
1786
3245
|
<In>(f: Predicate<In>): <Out, R>(self: Schedule<Out, In, R>) => Schedule<Out, In, R>
|
|
1787
3246
|
/**
|
|
1788
|
-
* Returns a new schedule that
|
|
1789
|
-
* input evaluates to true
|
|
3247
|
+
* Returns a new schedule that stops execution when the given predicate on the
|
|
3248
|
+
* input evaluates to `true`.
|
|
3249
|
+
*
|
|
3250
|
+
* **Details**
|
|
3251
|
+
*
|
|
3252
|
+
* This function modifies an existing schedule so that it continues executing
|
|
3253
|
+
* only while the provided predicate returns `false` for incoming inputs. Once
|
|
3254
|
+
* an input satisfies the condition, the schedule terminates immediately.
|
|
3255
|
+
*
|
|
3256
|
+
* @see {@link untilInputEffect} If you need to use an effectful predicate.
|
|
1790
3257
|
*
|
|
1791
3258
|
* @since 2.0.0
|
|
1792
|
-
* @category
|
|
3259
|
+
* @category Recurrence Conditions
|
|
1793
3260
|
*/
|
|
1794
3261
|
<Out, In, R>(self: Schedule<Out, In, R>, f: Predicate<In>): Schedule<Out, In, R>
|
|
1795
3262
|
} = internal.untilInput
|
|
1796
3263
|
|
|
1797
3264
|
/**
|
|
1798
|
-
* Returns a new schedule that
|
|
1799
|
-
* predicate on the input evaluates to true
|
|
3265
|
+
* Returns a new schedule that stops execution when the given effectful
|
|
3266
|
+
* predicate on the input evaluates to `true`.
|
|
3267
|
+
*
|
|
3268
|
+
* **Details**
|
|
3269
|
+
*
|
|
3270
|
+
* This function modifies an existing schedule so that it continues executing
|
|
3271
|
+
* only while the provided effectful predicate returns `false` for incoming
|
|
3272
|
+
* inputs. The predicate is an `Effect`, meaning it can involve asynchronous
|
|
3273
|
+
* computations or dependency-based logic.
|
|
3274
|
+
*
|
|
3275
|
+
* @see {@link untilInput} If you need to use a pure predicate.
|
|
1800
3276
|
*
|
|
1801
3277
|
* @since 2.0.0
|
|
1802
|
-
* @category
|
|
3278
|
+
* @category Recurrence Conditions
|
|
1803
3279
|
*/
|
|
1804
3280
|
export const untilInputEffect: {
|
|
1805
3281
|
/**
|
|
1806
|
-
* Returns a new schedule that
|
|
1807
|
-
* predicate on the input evaluates to true
|
|
3282
|
+
* Returns a new schedule that stops execution when the given effectful
|
|
3283
|
+
* predicate on the input evaluates to `true`.
|
|
3284
|
+
*
|
|
3285
|
+
* **Details**
|
|
3286
|
+
*
|
|
3287
|
+
* This function modifies an existing schedule so that it continues executing
|
|
3288
|
+
* only while the provided effectful predicate returns `false` for incoming
|
|
3289
|
+
* inputs. The predicate is an `Effect`, meaning it can involve asynchronous
|
|
3290
|
+
* computations or dependency-based logic.
|
|
3291
|
+
*
|
|
3292
|
+
* @see {@link untilInput} If you need to use a pure predicate.
|
|
1808
3293
|
*
|
|
1809
3294
|
* @since 2.0.0
|
|
1810
|
-
* @category
|
|
3295
|
+
* @category Recurrence Conditions
|
|
1811
3296
|
*/
|
|
1812
3297
|
<In, R2>(
|
|
1813
3298
|
f: (input: In) => Effect.Effect<boolean, never, R2>
|
|
1814
3299
|
): <Out, R>(self: Schedule<Out, In, R>) => Schedule<Out, In, R2 | R>
|
|
1815
3300
|
/**
|
|
1816
|
-
* Returns a new schedule that
|
|
1817
|
-
* predicate on the input evaluates to true
|
|
3301
|
+
* Returns a new schedule that stops execution when the given effectful
|
|
3302
|
+
* predicate on the input evaluates to `true`.
|
|
3303
|
+
*
|
|
3304
|
+
* **Details**
|
|
3305
|
+
*
|
|
3306
|
+
* This function modifies an existing schedule so that it continues executing
|
|
3307
|
+
* only while the provided effectful predicate returns `false` for incoming
|
|
3308
|
+
* inputs. The predicate is an `Effect`, meaning it can involve asynchronous
|
|
3309
|
+
* computations or dependency-based logic.
|
|
3310
|
+
*
|
|
3311
|
+
* @see {@link untilInput} If you need to use a pure predicate.
|
|
1818
3312
|
*
|
|
1819
3313
|
* @since 2.0.0
|
|
1820
|
-
* @category
|
|
3314
|
+
* @category Recurrence Conditions
|
|
1821
3315
|
*/
|
|
1822
3316
|
<Out, In, R, R2>(
|
|
1823
3317
|
self: Schedule<Out, In, R>,
|
|
@@ -1826,55 +3320,112 @@ export const untilInputEffect: {
|
|
|
1826
3320
|
} = internal.untilInputEffect
|
|
1827
3321
|
|
|
1828
3322
|
/**
|
|
1829
|
-
* Returns a new schedule that
|
|
1830
|
-
* output evaluates to true
|
|
3323
|
+
* Returns a new schedule that stops execution when the given predicate on the
|
|
3324
|
+
* output evaluates to `true`.
|
|
3325
|
+
*
|
|
3326
|
+
* **Details**
|
|
3327
|
+
*
|
|
3328
|
+
* This function modifies an existing schedule so that it only continues
|
|
3329
|
+
* executing while the given predicate returns false for its output values. Once
|
|
3330
|
+
* the predicate evaluates to `true`, execution stops.
|
|
3331
|
+
*
|
|
3332
|
+
* The output of the resulting schedule remains the same, but its duration is
|
|
3333
|
+
* now constrained by a stopping condition based on its own output.
|
|
3334
|
+
*
|
|
3335
|
+
* @see {@link untilOutputEffect} If you need to use an effectful predicate.
|
|
1831
3336
|
*
|
|
1832
3337
|
* @since 2.0.0
|
|
1833
|
-
* @category
|
|
3338
|
+
* @category Recurrence Conditions
|
|
1834
3339
|
*/
|
|
1835
3340
|
export const untilOutput: {
|
|
1836
3341
|
/**
|
|
1837
|
-
* Returns a new schedule that
|
|
1838
|
-
* output evaluates to true
|
|
3342
|
+
* Returns a new schedule that stops execution when the given predicate on the
|
|
3343
|
+
* output evaluates to `true`.
|
|
3344
|
+
*
|
|
3345
|
+
* **Details**
|
|
3346
|
+
*
|
|
3347
|
+
* This function modifies an existing schedule so that it only continues
|
|
3348
|
+
* executing while the given predicate returns false for its output values. Once
|
|
3349
|
+
* the predicate evaluates to `true`, execution stops.
|
|
3350
|
+
*
|
|
3351
|
+
* The output of the resulting schedule remains the same, but its duration is
|
|
3352
|
+
* now constrained by a stopping condition based on its own output.
|
|
3353
|
+
*
|
|
3354
|
+
* @see {@link untilOutputEffect} If you need to use an effectful predicate.
|
|
1839
3355
|
*
|
|
1840
3356
|
* @since 2.0.0
|
|
1841
|
-
* @category
|
|
3357
|
+
* @category Recurrence Conditions
|
|
1842
3358
|
*/
|
|
1843
3359
|
<Out>(f: Predicate<Out>): <In, R>(self: Schedule<Out, In, R>) => Schedule<Out, In, R>
|
|
1844
3360
|
/**
|
|
1845
|
-
* Returns a new schedule that
|
|
1846
|
-
* output evaluates to true
|
|
3361
|
+
* Returns a new schedule that stops execution when the given predicate on the
|
|
3362
|
+
* output evaluates to `true`.
|
|
3363
|
+
*
|
|
3364
|
+
* **Details**
|
|
3365
|
+
*
|
|
3366
|
+
* This function modifies an existing schedule so that it only continues
|
|
3367
|
+
* executing while the given predicate returns false for its output values. Once
|
|
3368
|
+
* the predicate evaluates to `true`, execution stops.
|
|
3369
|
+
*
|
|
3370
|
+
* The output of the resulting schedule remains the same, but its duration is
|
|
3371
|
+
* now constrained by a stopping condition based on its own output.
|
|
3372
|
+
*
|
|
3373
|
+
* @see {@link untilOutputEffect} If you need to use an effectful predicate.
|
|
1847
3374
|
*
|
|
1848
3375
|
* @since 2.0.0
|
|
1849
|
-
* @category
|
|
3376
|
+
* @category Recurrence Conditions
|
|
1850
3377
|
*/
|
|
1851
3378
|
<Out, In, R>(self: Schedule<Out, In, R>, f: Predicate<Out>): Schedule<Out, In, R>
|
|
1852
3379
|
} = internal.untilOutput
|
|
1853
3380
|
|
|
1854
3381
|
/**
|
|
1855
|
-
* Returns a new schedule that
|
|
1856
|
-
* predicate on the output evaluates to true
|
|
3382
|
+
* Returns a new schedule that stops execution when the given effectful
|
|
3383
|
+
* predicate on the output evaluates to `true`.
|
|
3384
|
+
*
|
|
3385
|
+
* **Details**
|
|
3386
|
+
*
|
|
3387
|
+
* This function modifies an existing schedule so that it only continues
|
|
3388
|
+
* executing while the provided effectful predicate returns `false` for its
|
|
3389
|
+
* output values. Once the predicate returns `true`, execution stops.
|
|
3390
|
+
*
|
|
3391
|
+
* @see {@link untilOutput} If you need to use a pure predicate.
|
|
1857
3392
|
*
|
|
1858
3393
|
* @since 2.0.0
|
|
1859
|
-
* @category
|
|
3394
|
+
* @category Recurrence Conditions
|
|
1860
3395
|
*/
|
|
1861
3396
|
export const untilOutputEffect: {
|
|
1862
3397
|
/**
|
|
1863
|
-
* Returns a new schedule that
|
|
1864
|
-
* predicate on the output evaluates to true
|
|
3398
|
+
* Returns a new schedule that stops execution when the given effectful
|
|
3399
|
+
* predicate on the output evaluates to `true`.
|
|
3400
|
+
*
|
|
3401
|
+
* **Details**
|
|
3402
|
+
*
|
|
3403
|
+
* This function modifies an existing schedule so that it only continues
|
|
3404
|
+
* executing while the provided effectful predicate returns `false` for its
|
|
3405
|
+
* output values. Once the predicate returns `true`, execution stops.
|
|
3406
|
+
*
|
|
3407
|
+
* @see {@link untilOutput} If you need to use a pure predicate.
|
|
1865
3408
|
*
|
|
1866
3409
|
* @since 2.0.0
|
|
1867
|
-
* @category
|
|
3410
|
+
* @category Recurrence Conditions
|
|
1868
3411
|
*/
|
|
1869
3412
|
<Out, R2>(
|
|
1870
3413
|
f: (out: Out) => Effect.Effect<boolean, never, R2>
|
|
1871
3414
|
): <In, R>(self: Schedule<Out, In, R>) => Schedule<Out, In, R2 | R>
|
|
1872
3415
|
/**
|
|
1873
|
-
* Returns a new schedule that
|
|
1874
|
-
* predicate on the output evaluates to true
|
|
3416
|
+
* Returns a new schedule that stops execution when the given effectful
|
|
3417
|
+
* predicate on the output evaluates to `true`.
|
|
3418
|
+
*
|
|
3419
|
+
* **Details**
|
|
3420
|
+
*
|
|
3421
|
+
* This function modifies an existing schedule so that it only continues
|
|
3422
|
+
* executing while the provided effectful predicate returns `false` for its
|
|
3423
|
+
* output values. Once the predicate returns `true`, execution stops.
|
|
3424
|
+
*
|
|
3425
|
+
* @see {@link untilOutput} If you need to use a pure predicate.
|
|
1875
3426
|
*
|
|
1876
3427
|
* @since 2.0.0
|
|
1877
|
-
* @category
|
|
3428
|
+
* @category Recurrence Conditions
|
|
1878
3429
|
*/
|
|
1879
3430
|
<Out, In, R, R2>(
|
|
1880
3431
|
self: Schedule<Out, In, R>,
|
|
@@ -1883,78 +3434,144 @@ export const untilOutputEffect: {
|
|
|
1883
3434
|
} = internal.untilOutputEffect
|
|
1884
3435
|
|
|
1885
3436
|
/**
|
|
1886
|
-
*
|
|
3437
|
+
* Returns a new schedule that limits execution to a fixed duration.
|
|
3438
|
+
*
|
|
3439
|
+
* **Details**
|
|
3440
|
+
*
|
|
3441
|
+
* This function modifies an existing schedule to stop execution after a
|
|
3442
|
+
* specified duration has passed. The schedule continues as normal until the
|
|
3443
|
+
* duration is reached, at which point it stops automatically.
|
|
1887
3444
|
*
|
|
1888
3445
|
* @since 2.0.0
|
|
1889
|
-
* @category
|
|
3446
|
+
* @category Recurrence Conditions
|
|
1890
3447
|
*/
|
|
1891
3448
|
export const upTo: {
|
|
1892
3449
|
/**
|
|
1893
|
-
*
|
|
3450
|
+
* Returns a new schedule that limits execution to a fixed duration.
|
|
3451
|
+
*
|
|
3452
|
+
* **Details**
|
|
3453
|
+
*
|
|
3454
|
+
* This function modifies an existing schedule to stop execution after a
|
|
3455
|
+
* specified duration has passed. The schedule continues as normal until the
|
|
3456
|
+
* duration is reached, at which point it stops automatically.
|
|
1894
3457
|
*
|
|
1895
3458
|
* @since 2.0.0
|
|
1896
|
-
* @category
|
|
3459
|
+
* @category Recurrence Conditions
|
|
1897
3460
|
*/
|
|
1898
3461
|
(duration: Duration.DurationInput): <Out, In, R>(self: Schedule<Out, In, R>) => Schedule<Out, In, R>
|
|
1899
3462
|
/**
|
|
1900
|
-
*
|
|
3463
|
+
* Returns a new schedule that limits execution to a fixed duration.
|
|
3464
|
+
*
|
|
3465
|
+
* **Details**
|
|
3466
|
+
*
|
|
3467
|
+
* This function modifies an existing schedule to stop execution after a
|
|
3468
|
+
* specified duration has passed. The schedule continues as normal until the
|
|
3469
|
+
* duration is reached, at which point it stops automatically.
|
|
1901
3470
|
*
|
|
1902
3471
|
* @since 2.0.0
|
|
1903
|
-
* @category
|
|
3472
|
+
* @category Recurrence Conditions
|
|
1904
3473
|
*/
|
|
1905
3474
|
<Out, In, R>(self: Schedule<Out, In, R>, duration: Duration.DurationInput): Schedule<Out, In, R>
|
|
1906
3475
|
} = internal.upTo
|
|
1907
3476
|
|
|
1908
3477
|
/**
|
|
1909
|
-
* Returns a new schedule that continues
|
|
1910
|
-
* on the input
|
|
3478
|
+
* Returns a new schedule that continues execution as long as the given
|
|
3479
|
+
* predicate on the input is true.
|
|
3480
|
+
*
|
|
3481
|
+
* **Details**
|
|
3482
|
+
*
|
|
3483
|
+
* This function modifies an existing schedule so that it only continues
|
|
3484
|
+
* execution while a specified predicate holds true for its input. If the
|
|
3485
|
+
* predicate evaluates to `false` at any step, the schedule stops.
|
|
3486
|
+
*
|
|
3487
|
+
* @see {@link whileInputEffect} If you need to use an effectful predicate.
|
|
1911
3488
|
*
|
|
1912
3489
|
* @since 2.0.0
|
|
1913
|
-
* @category
|
|
3490
|
+
* @category Recurrence Conditions
|
|
1914
3491
|
*/
|
|
1915
3492
|
export const whileInput: {
|
|
1916
3493
|
/**
|
|
1917
|
-
* Returns a new schedule that continues
|
|
1918
|
-
* on the input
|
|
3494
|
+
* Returns a new schedule that continues execution as long as the given
|
|
3495
|
+
* predicate on the input is true.
|
|
3496
|
+
*
|
|
3497
|
+
* **Details**
|
|
3498
|
+
*
|
|
3499
|
+
* This function modifies an existing schedule so that it only continues
|
|
3500
|
+
* execution while a specified predicate holds true for its input. If the
|
|
3501
|
+
* predicate evaluates to `false` at any step, the schedule stops.
|
|
3502
|
+
*
|
|
3503
|
+
* @see {@link whileInputEffect} If you need to use an effectful predicate.
|
|
1919
3504
|
*
|
|
1920
3505
|
* @since 2.0.0
|
|
1921
|
-
* @category
|
|
3506
|
+
* @category Recurrence Conditions
|
|
1922
3507
|
*/
|
|
1923
3508
|
<In>(f: Predicate<In>): <Out, R>(self: Schedule<Out, In, R>) => Schedule<Out, In, R>
|
|
1924
3509
|
/**
|
|
1925
|
-
* Returns a new schedule that continues
|
|
1926
|
-
* on the input
|
|
3510
|
+
* Returns a new schedule that continues execution as long as the given
|
|
3511
|
+
* predicate on the input is true.
|
|
3512
|
+
*
|
|
3513
|
+
* **Details**
|
|
3514
|
+
*
|
|
3515
|
+
* This function modifies an existing schedule so that it only continues
|
|
3516
|
+
* execution while a specified predicate holds true for its input. If the
|
|
3517
|
+
* predicate evaluates to `false` at any step, the schedule stops.
|
|
3518
|
+
*
|
|
3519
|
+
* @see {@link whileInputEffect} If you need to use an effectful predicate.
|
|
1927
3520
|
*
|
|
1928
3521
|
* @since 2.0.0
|
|
1929
|
-
* @category
|
|
3522
|
+
* @category Recurrence Conditions
|
|
1930
3523
|
*/
|
|
1931
3524
|
<Out, In, R>(self: Schedule<Out, In, R>, f: Predicate<In>): Schedule<Out, In, R>
|
|
1932
3525
|
} = internal.whileInput
|
|
1933
3526
|
|
|
1934
3527
|
/**
|
|
1935
|
-
* Returns a new schedule that continues for as long as the
|
|
1936
|
-
* predicate on the input evaluates to true
|
|
3528
|
+
* Returns a new schedule that continues execution for as long as the given
|
|
3529
|
+
* effectful predicate on the input evaluates to `true`.
|
|
3530
|
+
*
|
|
3531
|
+
* **Details**
|
|
3532
|
+
*
|
|
3533
|
+
* This function modifies an existing schedule so that it only continues
|
|
3534
|
+
* execution while an effectful predicate holds true for its input. If the
|
|
3535
|
+
* predicate evaluates to `false` at any step, the schedule stops.
|
|
3536
|
+
*
|
|
3537
|
+
* @see {@link whileInput} If you need to use a pure predicate.
|
|
1937
3538
|
*
|
|
1938
3539
|
* @since 2.0.0
|
|
1939
|
-
* @category
|
|
3540
|
+
* @category Recurrence Conditions
|
|
1940
3541
|
*/
|
|
1941
3542
|
export const whileInputEffect: {
|
|
1942
3543
|
/**
|
|
1943
|
-
* Returns a new schedule that continues for as long as the
|
|
1944
|
-
* predicate on the input evaluates to true
|
|
3544
|
+
* Returns a new schedule that continues execution for as long as the given
|
|
3545
|
+
* effectful predicate on the input evaluates to `true`.
|
|
3546
|
+
*
|
|
3547
|
+
* **Details**
|
|
3548
|
+
*
|
|
3549
|
+
* This function modifies an existing schedule so that it only continues
|
|
3550
|
+
* execution while an effectful predicate holds true for its input. If the
|
|
3551
|
+
* predicate evaluates to `false` at any step, the schedule stops.
|
|
3552
|
+
*
|
|
3553
|
+
* @see {@link whileInput} If you need to use a pure predicate.
|
|
1945
3554
|
*
|
|
1946
3555
|
* @since 2.0.0
|
|
1947
|
-
* @category
|
|
3556
|
+
* @category Recurrence Conditions
|
|
1948
3557
|
*/
|
|
1949
3558
|
<In, R2>(
|
|
1950
3559
|
f: (input: In) => Effect.Effect<boolean, never, R2>
|
|
1951
3560
|
): <Out, R>(self: Schedule<Out, In, R>) => Schedule<Out, In, R2 | R>
|
|
1952
3561
|
/**
|
|
1953
|
-
* Returns a new schedule that continues for as long as the
|
|
1954
|
-
* predicate on the input evaluates to true
|
|
3562
|
+
* Returns a new schedule that continues execution for as long as the given
|
|
3563
|
+
* effectful predicate on the input evaluates to `true`.
|
|
3564
|
+
*
|
|
3565
|
+
* **Details**
|
|
3566
|
+
*
|
|
3567
|
+
* This function modifies an existing schedule so that it only continues
|
|
3568
|
+
* execution while an effectful predicate holds true for its input. If the
|
|
3569
|
+
* predicate evaluates to `false` at any step, the schedule stops.
|
|
3570
|
+
*
|
|
3571
|
+
* @see {@link whileInput} If you need to use a pure predicate.
|
|
1955
3572
|
*
|
|
1956
3573
|
* @since 2.0.0
|
|
1957
|
-
* @category
|
|
3574
|
+
* @category Recurrence Conditions
|
|
1958
3575
|
*/
|
|
1959
3576
|
<Out, In, R, R2>(
|
|
1960
3577
|
self: Schedule<Out, In, R>,
|
|
@@ -1963,55 +3580,103 @@ export const whileInputEffect: {
|
|
|
1963
3580
|
} = internal.whileInputEffect
|
|
1964
3581
|
|
|
1965
3582
|
/**
|
|
1966
|
-
* Returns a new schedule that continues for as long the
|
|
1967
|
-
* on the output evaluates to true
|
|
3583
|
+
* Returns a new schedule that continues execution for as long as the given
|
|
3584
|
+
* predicate on the output evaluates to `true`.
|
|
3585
|
+
*
|
|
3586
|
+
* **Details**
|
|
3587
|
+
*
|
|
3588
|
+
* This function modifies an existing schedule so that it only continues
|
|
3589
|
+
* execution while a provided condition holds true for its output. If the
|
|
3590
|
+
* predicate returns `false`, the schedule stops.
|
|
3591
|
+
*
|
|
3592
|
+
* @see {@link whileOutputEffect} If you need to use an effectful predicate.
|
|
1968
3593
|
*
|
|
1969
3594
|
* @since 2.0.0
|
|
1970
|
-
* @category
|
|
3595
|
+
* @category Recurrence Conditions
|
|
1971
3596
|
*/
|
|
1972
3597
|
export const whileOutput: {
|
|
1973
3598
|
/**
|
|
1974
|
-
* Returns a new schedule that continues for as long the
|
|
1975
|
-
* on the output evaluates to true
|
|
3599
|
+
* Returns a new schedule that continues execution for as long as the given
|
|
3600
|
+
* predicate on the output evaluates to `true`.
|
|
3601
|
+
*
|
|
3602
|
+
* **Details**
|
|
3603
|
+
*
|
|
3604
|
+
* This function modifies an existing schedule so that it only continues
|
|
3605
|
+
* execution while a provided condition holds true for its output. If the
|
|
3606
|
+
* predicate returns `false`, the schedule stops.
|
|
3607
|
+
*
|
|
3608
|
+
* @see {@link whileOutputEffect} If you need to use an effectful predicate.
|
|
1976
3609
|
*
|
|
1977
3610
|
* @since 2.0.0
|
|
1978
|
-
* @category
|
|
3611
|
+
* @category Recurrence Conditions
|
|
1979
3612
|
*/
|
|
1980
3613
|
<Out>(f: Predicate<Out>): <In, R>(self: Schedule<Out, In, R>) => Schedule<Out, In, R>
|
|
1981
3614
|
/**
|
|
1982
|
-
* Returns a new schedule that continues for as long the
|
|
1983
|
-
* on the output evaluates to true
|
|
3615
|
+
* Returns a new schedule that continues execution for as long as the given
|
|
3616
|
+
* predicate on the output evaluates to `true`.
|
|
3617
|
+
*
|
|
3618
|
+
* **Details**
|
|
3619
|
+
*
|
|
3620
|
+
* This function modifies an existing schedule so that it only continues
|
|
3621
|
+
* execution while a provided condition holds true for its output. If the
|
|
3622
|
+
* predicate returns `false`, the schedule stops.
|
|
3623
|
+
*
|
|
3624
|
+
* @see {@link whileOutputEffect} If you need to use an effectful predicate.
|
|
1984
3625
|
*
|
|
1985
3626
|
* @since 2.0.0
|
|
1986
|
-
* @category
|
|
3627
|
+
* @category Recurrence Conditions
|
|
1987
3628
|
*/
|
|
1988
3629
|
<Out, In, R>(self: Schedule<Out, In, R>, f: Predicate<Out>): Schedule<Out, In, R>
|
|
1989
3630
|
} = internal.whileOutput
|
|
1990
3631
|
|
|
1991
3632
|
/**
|
|
1992
|
-
* Returns a new schedule that continues for as long the
|
|
1993
|
-
* predicate on the output evaluates to true
|
|
3633
|
+
* Returns a new schedule that continues execution for as long as the given
|
|
3634
|
+
* effectful predicate on the output evaluates to `true`.
|
|
3635
|
+
*
|
|
3636
|
+
* **Details**
|
|
3637
|
+
*
|
|
3638
|
+
* This function modifies an existing schedule so that it only continues
|
|
3639
|
+
* execution while an effectful condition holds true for its output. If the
|
|
3640
|
+
* effectful predicate returns `false`, the schedule stops.
|
|
3641
|
+
*
|
|
3642
|
+
* @see {@link whileOutput} If you need to use a pure predicate.
|
|
1994
3643
|
*
|
|
1995
3644
|
* @since 2.0.0
|
|
1996
|
-
* @category
|
|
3645
|
+
* @category Recurrence Conditions
|
|
1997
3646
|
*/
|
|
1998
3647
|
export const whileOutputEffect: {
|
|
1999
3648
|
/**
|
|
2000
|
-
* Returns a new schedule that continues for as long the
|
|
2001
|
-
* predicate on the output evaluates to true
|
|
3649
|
+
* Returns a new schedule that continues execution for as long as the given
|
|
3650
|
+
* effectful predicate on the output evaluates to `true`.
|
|
3651
|
+
*
|
|
3652
|
+
* **Details**
|
|
3653
|
+
*
|
|
3654
|
+
* This function modifies an existing schedule so that it only continues
|
|
3655
|
+
* execution while an effectful condition holds true for its output. If the
|
|
3656
|
+
* effectful predicate returns `false`, the schedule stops.
|
|
3657
|
+
*
|
|
3658
|
+
* @see {@link whileOutput} If you need to use a pure predicate.
|
|
2002
3659
|
*
|
|
2003
3660
|
* @since 2.0.0
|
|
2004
|
-
* @category
|
|
3661
|
+
* @category Recurrence Conditions
|
|
2005
3662
|
*/
|
|
2006
3663
|
<Out, R2>(
|
|
2007
3664
|
f: (out: Out) => Effect.Effect<boolean, never, R2>
|
|
2008
3665
|
): <In, R>(self: Schedule<Out, In, R>) => Schedule<Out, In, R2 | R>
|
|
2009
3666
|
/**
|
|
2010
|
-
* Returns a new schedule that continues for as long the
|
|
2011
|
-
* predicate on the output evaluates to true
|
|
3667
|
+
* Returns a new schedule that continues execution for as long as the given
|
|
3668
|
+
* effectful predicate on the output evaluates to `true`.
|
|
3669
|
+
*
|
|
3670
|
+
* **Details**
|
|
3671
|
+
*
|
|
3672
|
+
* This function modifies an existing schedule so that it only continues
|
|
3673
|
+
* execution while an effectful condition holds true for its output. If the
|
|
3674
|
+
* effectful predicate returns `false`, the schedule stops.
|
|
3675
|
+
*
|
|
3676
|
+
* @see {@link whileOutput} If you need to use a pure predicate.
|
|
2012
3677
|
*
|
|
2013
3678
|
* @since 2.0.0
|
|
2014
|
-
* @category
|
|
3679
|
+
* @category Recurrence Conditions
|
|
2015
3680
|
*/
|
|
2016
3681
|
<Out, In, R, R2>(
|
|
2017
3682
|
self: Schedule<Out, In, R>,
|
|
@@ -2020,8 +3685,15 @@ export const whileOutputEffect: {
|
|
|
2020
3685
|
} = internal.whileOutputEffect
|
|
2021
3686
|
|
|
2022
3687
|
/**
|
|
2023
|
-
*
|
|
2024
|
-
*
|
|
3688
|
+
* Creates a schedule that divides time into fixed `interval`-long windows,
|
|
3689
|
+
* triggering execution at the start of each new window.
|
|
3690
|
+
*
|
|
3691
|
+
* **Details**
|
|
3692
|
+
*
|
|
3693
|
+
* This function produces a schedule that waits until the next time window
|
|
3694
|
+
* boundary before executing. Each window spans a fixed duration specified by
|
|
3695
|
+
* `interval`. If an action completes midway through a window, the schedule
|
|
3696
|
+
* waits until the next full window starts before proceeding.
|
|
2025
3697
|
*
|
|
2026
3698
|
* For example, `windowed(Duration.seconds(10))` would produce a schedule as
|
|
2027
3699
|
* follows:
|
|
@@ -2033,31 +3705,31 @@ export const whileOutputEffect: {
|
|
|
2033
3705
|
* ```
|
|
2034
3706
|
*
|
|
2035
3707
|
* @since 2.0.0
|
|
2036
|
-
* @category
|
|
3708
|
+
* @category Constructors
|
|
2037
3709
|
*/
|
|
2038
3710
|
export const windowed: (interval: Duration.DurationInput) => Schedule<number> = internal.windowed
|
|
2039
3711
|
|
|
2040
3712
|
/**
|
|
2041
|
-
* The same as
|
|
3713
|
+
* The same as {@link intersect} but ignores the right output.
|
|
2042
3714
|
*
|
|
2043
3715
|
* @since 2.0.0
|
|
2044
|
-
* @category
|
|
3716
|
+
* @category Composition
|
|
2045
3717
|
*/
|
|
2046
3718
|
export const zipLeft: {
|
|
2047
3719
|
/**
|
|
2048
|
-
* The same as
|
|
3720
|
+
* The same as {@link intersect} but ignores the right output.
|
|
2049
3721
|
*
|
|
2050
3722
|
* @since 2.0.0
|
|
2051
|
-
* @category
|
|
3723
|
+
* @category Composition
|
|
2052
3724
|
*/
|
|
2053
3725
|
<Out2, In2, R2>(
|
|
2054
3726
|
that: Schedule<Out2, In2, R2>
|
|
2055
3727
|
): <Out, In, R>(self: Schedule<Out, In, R>) => Schedule<Out, In & In2, R2 | R>
|
|
2056
3728
|
/**
|
|
2057
|
-
* The same as
|
|
3729
|
+
* The same as {@link intersect} but ignores the right output.
|
|
2058
3730
|
*
|
|
2059
3731
|
* @since 2.0.0
|
|
2060
|
-
* @category
|
|
3732
|
+
* @category Composition
|
|
2061
3733
|
*/
|
|
2062
3734
|
<Out, In, R, Out2, In2, R2>(
|
|
2063
3735
|
self: Schedule<Out, In, R>,
|
|
@@ -2066,26 +3738,26 @@ export const zipLeft: {
|
|
|
2066
3738
|
} = internal.zipLeft
|
|
2067
3739
|
|
|
2068
3740
|
/**
|
|
2069
|
-
* The same as
|
|
3741
|
+
* The same as {@link intersect} but ignores the left output.
|
|
2070
3742
|
*
|
|
2071
3743
|
* @since 2.0.0
|
|
2072
|
-
* @category
|
|
3744
|
+
* @category Composition
|
|
2073
3745
|
*/
|
|
2074
3746
|
export const zipRight: {
|
|
2075
3747
|
/**
|
|
2076
|
-
* The same as
|
|
3748
|
+
* The same as {@link intersect} but ignores the left output.
|
|
2077
3749
|
*
|
|
2078
3750
|
* @since 2.0.0
|
|
2079
|
-
* @category
|
|
3751
|
+
* @category Composition
|
|
2080
3752
|
*/
|
|
2081
3753
|
<Out2, In2, R2>(
|
|
2082
3754
|
that: Schedule<Out2, In2, R2>
|
|
2083
3755
|
): <Out, In, R>(self: Schedule<Out, In, R>) => Schedule<Out2, In & In2, R2 | R>
|
|
2084
3756
|
/**
|
|
2085
|
-
* The same as
|
|
3757
|
+
* The same as {@link intersect} but ignores the left output.
|
|
2086
3758
|
*
|
|
2087
3759
|
* @since 2.0.0
|
|
2088
|
-
* @category
|
|
3760
|
+
* @category Composition
|
|
2089
3761
|
*/
|
|
2090
3762
|
<Out, In, R, Out2, In2, R2>(
|
|
2091
3763
|
self: Schedule<Out, In, R>,
|
|
@@ -2094,27 +3766,27 @@ export const zipRight: {
|
|
|
2094
3766
|
} = internal.zipRight
|
|
2095
3767
|
|
|
2096
3768
|
/**
|
|
2097
|
-
* Equivalent to
|
|
3769
|
+
* Equivalent to {@link intersect} followed by {@link map}.
|
|
2098
3770
|
*
|
|
2099
3771
|
* @since 2.0.0
|
|
2100
|
-
* @category
|
|
3772
|
+
* @category Composition
|
|
2101
3773
|
*/
|
|
2102
3774
|
export const zipWith: {
|
|
2103
3775
|
/**
|
|
2104
|
-
* Equivalent to
|
|
3776
|
+
* Equivalent to {@link intersect} followed by {@link map}.
|
|
2105
3777
|
*
|
|
2106
3778
|
* @since 2.0.0
|
|
2107
|
-
* @category
|
|
3779
|
+
* @category Composition
|
|
2108
3780
|
*/
|
|
2109
3781
|
<Out2, In2, R2, Out, Out3>(
|
|
2110
3782
|
that: Schedule<Out2, In2, R2>,
|
|
2111
3783
|
f: (out: Out, out2: Out2) => Out3
|
|
2112
3784
|
): <In, R>(self: Schedule<Out, In, R>) => Schedule<Out3, In & In2, R2 | R>
|
|
2113
3785
|
/**
|
|
2114
|
-
* Equivalent to
|
|
3786
|
+
* Equivalent to {@link intersect} followed by {@link map}.
|
|
2115
3787
|
*
|
|
2116
3788
|
* @since 2.0.0
|
|
2117
|
-
* @category
|
|
3789
|
+
* @category Composition
|
|
2118
3790
|
*/
|
|
2119
3791
|
<Out, In, R, Out2, In2, R2, Out3>(
|
|
2120
3792
|
self: Schedule<Out, In, R>,
|