effect 3.4.5 → 3.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Micro.js +481 -425
- package/dist/cjs/Micro.js.map +1 -1
- package/dist/cjs/internal/channel.js +5 -2
- package/dist/cjs/internal/channel.js.map +1 -1
- package/dist/cjs/internal/core-effect.js +14 -11
- package/dist/cjs/internal/core-effect.js.map +1 -1
- package/dist/cjs/internal/fiberRuntime.js +4 -9
- package/dist/cjs/internal/fiberRuntime.js.map +1 -1
- package/dist/cjs/internal/pubsub.js +13 -2
- package/dist/cjs/internal/pubsub.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/dts/Match.d.ts +14 -14
- package/dist/dts/Match.d.ts.map +1 -1
- package/dist/dts/Micro.d.ts +344 -260
- package/dist/dts/Micro.d.ts.map +1 -1
- package/dist/dts/internal/core-effect.d.ts.map +1 -1
- package/dist/esm/Micro.js +456 -402
- package/dist/esm/Micro.js.map +1 -1
- package/dist/esm/internal/channel.js +5 -2
- package/dist/esm/internal/channel.js.map +1 -1
- package/dist/esm/internal/core-effect.js +11 -9
- package/dist/esm/internal/core-effect.js.map +1 -1
- package/dist/esm/internal/fiberRuntime.js +4 -9
- package/dist/esm/internal/fiberRuntime.js.map +1 -1
- package/dist/esm/internal/pubsub.js +13 -2
- package/dist/esm/internal/pubsub.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/package.json +1 -1
- package/src/Match.ts +16 -16
- package/src/Micro.ts +715 -603
- package/src/internal/channel.ts +17 -19
- package/src/internal/core-effect.ts +14 -10
- package/src/internal/fiberRuntime.ts +4 -10
- package/src/internal/pubsub.ts +13 -2
- package/src/internal/version.ts +1 -1
package/dist/dts/Micro.d.ts
CHANGED
|
@@ -53,7 +53,7 @@ export type runSymbol = typeof runSymbol;
|
|
|
53
53
|
*/
|
|
54
54
|
export interface Micro<out A, out E = never, out R = never> extends Effect<A, E, R> {
|
|
55
55
|
readonly [TypeId]: Micro.Variance<A, E, R>;
|
|
56
|
-
readonly [runSymbol]: (env: Env<any>,
|
|
56
|
+
readonly [runSymbol]: (env: Env<any>, onExit: (exit: MicroExit<A, E>) => void) => void;
|
|
57
57
|
[Unify.typeSymbol]?: unknown;
|
|
58
58
|
[Unify.unifySymbol]?: MicroUnify<this>;
|
|
59
59
|
[Unify.ignoreSymbol]?: MicroUnifyIgnore;
|
|
@@ -127,194 +127,218 @@ export interface MicroIterator<T extends Micro<any, any, any>> {
|
|
|
127
127
|
next(...args: ReadonlyArray<any>): IteratorResult<YieldWrap<T>, Micro.Success<T>>;
|
|
128
128
|
}
|
|
129
129
|
/**
|
|
130
|
-
* @since 3.4.
|
|
130
|
+
* @since 3.4.6
|
|
131
131
|
* @experimental
|
|
132
|
-
* @category
|
|
132
|
+
* @category MicroCause
|
|
133
133
|
*/
|
|
134
|
-
export declare const
|
|
134
|
+
export declare const MicroCauseTypeId: unique symbol;
|
|
135
135
|
/**
|
|
136
|
-
* @since 3.4.
|
|
136
|
+
* @since 3.4.6
|
|
137
137
|
* @experimental
|
|
138
|
-
* @category
|
|
138
|
+
* @category MicroCause
|
|
139
139
|
*/
|
|
140
|
-
export type
|
|
140
|
+
export type MicroCauseTypeId = typeof MicroCauseTypeId;
|
|
141
141
|
/**
|
|
142
|
-
* A Micro
|
|
142
|
+
* A Micro Cause is a data type that represents the different ways a Micro can fail.
|
|
143
143
|
*
|
|
144
|
-
* @since 3.4.
|
|
144
|
+
* @since 3.4.6
|
|
145
145
|
* @experimental
|
|
146
|
-
* @category
|
|
146
|
+
* @category MicroCause
|
|
147
147
|
*/
|
|
148
|
-
export type
|
|
148
|
+
export type MicroCause<E> = MicroCause.Die | MicroCause.Fail<E> | MicroCause.Interrupt;
|
|
149
149
|
/**
|
|
150
|
-
* @since 3.4.
|
|
150
|
+
* @since 3.4.6
|
|
151
151
|
* @experimental
|
|
152
|
-
* @category
|
|
152
|
+
* @category MicroCause
|
|
153
153
|
*/
|
|
154
|
-
export declare namespace
|
|
154
|
+
export declare namespace MicroCause {
|
|
155
|
+
/**
|
|
156
|
+
* @since 3.4.6
|
|
157
|
+
* @experimental
|
|
158
|
+
*/
|
|
159
|
+
type Error<T> = T extends MicroCause.Fail<infer E> ? E : never;
|
|
155
160
|
/**
|
|
156
161
|
* @since 3.4.0
|
|
157
162
|
* @experimental
|
|
158
163
|
*/
|
|
159
164
|
interface Proto<Tag extends string, E> extends Pipeable, globalThis.Error {
|
|
160
|
-
readonly [
|
|
165
|
+
readonly [MicroCauseTypeId]: {
|
|
161
166
|
_E: Covariant<E>;
|
|
162
167
|
};
|
|
163
168
|
readonly _tag: Tag;
|
|
164
169
|
readonly traces: ReadonlyArray<string>;
|
|
165
170
|
}
|
|
166
171
|
/**
|
|
167
|
-
* @since 3.4.
|
|
172
|
+
* @since 3.4.6
|
|
168
173
|
* @experimental
|
|
169
|
-
* @category
|
|
174
|
+
* @category MicroCause
|
|
170
175
|
*/
|
|
171
|
-
interface
|
|
176
|
+
interface Die extends Proto<"Die", never> {
|
|
172
177
|
readonly defect: unknown;
|
|
173
178
|
}
|
|
174
179
|
/**
|
|
175
|
-
* @since 3.4.
|
|
180
|
+
* @since 3.4.6
|
|
176
181
|
* @experimental
|
|
177
|
-
* @category
|
|
182
|
+
* @category MicroCause
|
|
178
183
|
*/
|
|
179
|
-
interface
|
|
184
|
+
interface Fail<E> extends Proto<"Fail", E> {
|
|
180
185
|
readonly error: E;
|
|
181
186
|
}
|
|
182
187
|
/**
|
|
183
|
-
* @since 3.4.
|
|
188
|
+
* @since 3.4.6
|
|
184
189
|
* @experimental
|
|
185
|
-
* @category
|
|
190
|
+
* @category MicroCause
|
|
186
191
|
*/
|
|
187
|
-
interface
|
|
192
|
+
interface Interrupt extends Proto<"Interrupt", never> {
|
|
188
193
|
}
|
|
189
194
|
}
|
|
190
195
|
/**
|
|
191
|
-
* @since 3.4.
|
|
196
|
+
* @since 3.4.6
|
|
192
197
|
* @experimental
|
|
193
|
-
* @category
|
|
198
|
+
* @category MicroCause
|
|
194
199
|
*/
|
|
195
|
-
export declare const
|
|
200
|
+
export declare const causeFail: <E>(error: E, traces?: ReadonlyArray<string>) => MicroCause<E>;
|
|
196
201
|
/**
|
|
197
|
-
* @since 3.4.
|
|
202
|
+
* @since 3.4.6
|
|
198
203
|
* @experimental
|
|
199
|
-
* @category
|
|
204
|
+
* @category MicroCause
|
|
200
205
|
*/
|
|
201
|
-
export declare const
|
|
206
|
+
export declare const causeDie: (defect: unknown, traces?: ReadonlyArray<string>) => MicroCause<never>;
|
|
202
207
|
/**
|
|
203
|
-
* @since 3.4.
|
|
208
|
+
* @since 3.4.6
|
|
204
209
|
* @experimental
|
|
205
|
-
* @category
|
|
210
|
+
* @category MicroCause
|
|
206
211
|
*/
|
|
207
|
-
export declare const
|
|
212
|
+
export declare const causeInterrupt: (traces?: ReadonlyArray<string>) => MicroCause<never>;
|
|
208
213
|
/**
|
|
209
|
-
* @since 3.4.
|
|
214
|
+
* @since 3.4.6
|
|
210
215
|
* @experimental
|
|
211
|
-
* @category
|
|
216
|
+
* @category MicroCause
|
|
212
217
|
*/
|
|
213
|
-
export declare const
|
|
218
|
+
export declare const causeIsFail: <E>(self: MicroCause<E>) => self is MicroCause.Fail<E>;
|
|
214
219
|
/**
|
|
215
|
-
* @since 3.4.
|
|
220
|
+
* @since 3.4.6
|
|
216
221
|
* @experimental
|
|
217
|
-
* @category
|
|
222
|
+
* @category MicroCause
|
|
218
223
|
*/
|
|
219
|
-
export declare const
|
|
224
|
+
export declare const causeIsDie: <E>(self: MicroCause<E>) => self is MicroCause.Die;
|
|
220
225
|
/**
|
|
221
|
-
* @since 3.4.
|
|
226
|
+
* @since 3.4.6
|
|
222
227
|
* @experimental
|
|
223
|
-
* @category
|
|
228
|
+
* @category MicroCause
|
|
224
229
|
*/
|
|
225
|
-
export declare const
|
|
230
|
+
export declare const causeIsInterrupt: <E>(self: MicroCause<E>) => self is MicroCause.Interrupt;
|
|
226
231
|
/**
|
|
227
|
-
* @since 3.4.
|
|
232
|
+
* @since 3.4.6
|
|
228
233
|
* @experimental
|
|
229
|
-
* @category
|
|
234
|
+
* @category MicroCause
|
|
230
235
|
*/
|
|
231
|
-
export declare const
|
|
236
|
+
export declare const causeSquash: <E>(self: MicroCause<E>) => unknown;
|
|
232
237
|
/**
|
|
233
|
-
* @since 3.4.
|
|
238
|
+
* @since 3.4.6
|
|
234
239
|
* @experimental
|
|
235
|
-
* @category
|
|
240
|
+
* @category MicroCause
|
|
236
241
|
*/
|
|
237
|
-
export declare const
|
|
238
|
-
(trace: string): <E>(self:
|
|
239
|
-
<E>(self:
|
|
242
|
+
export declare const causeWithTrace: {
|
|
243
|
+
(trace: string): <E>(self: MicroCause<E>) => MicroCause<E>;
|
|
244
|
+
<E>(self: MicroCause<E>, trace: string): MicroCause<E>;
|
|
240
245
|
};
|
|
241
246
|
/**
|
|
242
|
-
*
|
|
247
|
+
* @since 3.4.6
|
|
248
|
+
* @experimental
|
|
249
|
+
* @category MicroExit
|
|
250
|
+
*/
|
|
251
|
+
export declare namespace MicroExit {
|
|
252
|
+
/**
|
|
253
|
+
* @since 3.4.6
|
|
254
|
+
* @experimental
|
|
255
|
+
* @category MicroExit
|
|
256
|
+
*/
|
|
257
|
+
type Success<A, E = never> = Either.Right<MicroCause<E>, A>;
|
|
258
|
+
/**
|
|
259
|
+
* @since 3.4.6
|
|
260
|
+
* @experimental
|
|
261
|
+
* @category MicroExit
|
|
262
|
+
*/
|
|
263
|
+
type Failure<A, E = never> = Either.Left<MicroCause<E>, A>;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* The MicroExit type is a data type that represents the result of a Micro
|
|
243
267
|
* computation.
|
|
244
268
|
*
|
|
245
269
|
* It uses the `Either` data type to represent the success and failure cases.
|
|
246
270
|
*
|
|
247
|
-
* @since 3.4.
|
|
271
|
+
* @since 3.4.6
|
|
248
272
|
* @experimental
|
|
249
|
-
* @category
|
|
273
|
+
* @category MicroExit
|
|
250
274
|
*/
|
|
251
|
-
export type
|
|
275
|
+
export type MicroExit<A, E = never> = MicroExit.Success<A, E> | MicroExit.Failure<A, E>;
|
|
252
276
|
/**
|
|
253
|
-
* @since 3.4.
|
|
277
|
+
* @since 3.4.6
|
|
254
278
|
* @experimental
|
|
255
|
-
* @category
|
|
279
|
+
* @category MicroExit
|
|
256
280
|
*/
|
|
257
|
-
export declare const
|
|
281
|
+
export declare const exitInterrupt: MicroExit<never>;
|
|
258
282
|
/**
|
|
259
|
-
* @since 3.4.
|
|
283
|
+
* @since 3.4.6
|
|
260
284
|
* @experimental
|
|
261
|
-
* @category
|
|
285
|
+
* @category MicroExit
|
|
262
286
|
*/
|
|
263
|
-
export declare const
|
|
287
|
+
export declare const exitSucceed: <A>(a: A) => MicroExit<A, never>;
|
|
264
288
|
/**
|
|
265
|
-
* @since 3.4.
|
|
289
|
+
* @since 3.4.6
|
|
266
290
|
* @experimental
|
|
267
|
-
* @category
|
|
291
|
+
* @category MicroExit
|
|
268
292
|
*/
|
|
269
|
-
export declare const
|
|
293
|
+
export declare const exitFail: <E>(e: E) => MicroExit<never, E>;
|
|
270
294
|
/**
|
|
271
|
-
* @since 3.4.
|
|
295
|
+
* @since 3.4.6
|
|
272
296
|
* @experimental
|
|
273
|
-
* @category
|
|
297
|
+
* @category MicroExit
|
|
274
298
|
*/
|
|
275
|
-
export declare const
|
|
299
|
+
export declare const exitDie: (defect: unknown) => MicroExit<never>;
|
|
276
300
|
/**
|
|
277
|
-
* @since 3.4.
|
|
301
|
+
* @since 3.4.6
|
|
278
302
|
* @experimental
|
|
279
|
-
* @category
|
|
303
|
+
* @category MicroExit
|
|
280
304
|
*/
|
|
281
|
-
export declare const
|
|
305
|
+
export declare const exitFailCause: <E>(cause: MicroCause<E>) => MicroExit<never, E>;
|
|
282
306
|
/**
|
|
283
|
-
* @since 3.4.
|
|
307
|
+
* @since 3.4.6
|
|
284
308
|
* @experimental
|
|
285
|
-
* @category
|
|
309
|
+
* @category MicroExit
|
|
286
310
|
*/
|
|
287
|
-
export declare const
|
|
311
|
+
export declare const exitIsSuccess: <A, E>(self: MicroExit<A, E>) => self is MicroExit.Success<A, E>;
|
|
288
312
|
/**
|
|
289
|
-
* @since 3.4.
|
|
313
|
+
* @since 3.4.6
|
|
290
314
|
* @experimental
|
|
291
|
-
* @category
|
|
315
|
+
* @category MicroExit
|
|
292
316
|
*/
|
|
293
|
-
export declare const
|
|
317
|
+
export declare const exitIsFailure: <A, E>(self: MicroExit<A, E>) => self is MicroExit.Failure<A, E>;
|
|
294
318
|
/**
|
|
295
|
-
* @since 3.4.
|
|
319
|
+
* @since 3.4.6
|
|
296
320
|
* @experimental
|
|
297
|
-
* @category
|
|
321
|
+
* @category MicroExit
|
|
298
322
|
*/
|
|
299
|
-
export declare const
|
|
323
|
+
export declare const exitIsInterrupt: <A, E>(self: MicroExit<A, E>) => self is Either.Left<MicroCause.Interrupt, A>;
|
|
300
324
|
/**
|
|
301
|
-
* @since 3.4.
|
|
325
|
+
* @since 3.4.6
|
|
302
326
|
* @experimental
|
|
303
|
-
* @category
|
|
327
|
+
* @category MicroExit
|
|
304
328
|
*/
|
|
305
|
-
export declare const
|
|
329
|
+
export declare const exitIsFail: <A, E>(self: MicroExit<A, E>) => self is Either.Left<MicroCause.Fail<E>, A>;
|
|
306
330
|
/**
|
|
307
|
-
* @since 3.4.
|
|
331
|
+
* @since 3.4.6
|
|
308
332
|
* @experimental
|
|
309
|
-
* @category
|
|
333
|
+
* @category MicroExit
|
|
310
334
|
*/
|
|
311
|
-
export declare const
|
|
335
|
+
export declare const exitIsDie: <A, E>(self: MicroExit<A, E>) => self is Either.Left<MicroCause.Die, A>;
|
|
312
336
|
/**
|
|
313
|
-
* @since 3.4.
|
|
337
|
+
* @since 3.4.6
|
|
314
338
|
* @experimental
|
|
315
|
-
* @category
|
|
339
|
+
* @category MicroExit
|
|
316
340
|
*/
|
|
317
|
-
export declare const
|
|
341
|
+
export declare const exitVoid: MicroExit<void>;
|
|
318
342
|
/**
|
|
319
343
|
* @since 3.4.0
|
|
320
344
|
* @experimental
|
|
@@ -472,11 +496,11 @@ export declare const provideService: {
|
|
|
472
496
|
* Create a service using the provided `Micro` effect, and add it to the
|
|
473
497
|
* current context.
|
|
474
498
|
*
|
|
475
|
-
* @since 3.4.
|
|
499
|
+
* @since 3.4.6
|
|
476
500
|
* @experimental
|
|
477
501
|
* @category environment
|
|
478
502
|
*/
|
|
479
|
-
export declare const
|
|
503
|
+
export declare const provideServiceEffect: {
|
|
480
504
|
<I, S, E2, R2>(tag: Context.Tag<I, S>, acquire: Micro<S, E2, R2>): <A, E, R>(self: Micro<A, E, R>) => Micro<A, E | E2, Exclude<R, I> | R2>;
|
|
481
505
|
<A, E, R, I, S, E2, R2>(self: Micro<A, E, R>, tag: Context.Tag<I, S>, acquire: Micro<S, E2, R2>): Micro<A, E | E2, Exclude<R, I> | R2>;
|
|
482
506
|
};
|
|
@@ -545,23 +569,23 @@ export declare const withConcurrency: {
|
|
|
545
569
|
* @experimental
|
|
546
570
|
* @category constructors
|
|
547
571
|
*/
|
|
548
|
-
export declare const make: <A, E
|
|
572
|
+
export declare const make: <R, A, E>(run: (env: Env<R>, onExit: (exit: MicroExit<A, E>) => void) => void) => Micro<A, E, R>;
|
|
549
573
|
/**
|
|
550
|
-
* Converts a `
|
|
574
|
+
* Converts a `MicroExit` into a `Micro` effect.
|
|
551
575
|
*
|
|
552
|
-
* @since 3.4.
|
|
576
|
+
* @since 3.4.6
|
|
553
577
|
* @experimental
|
|
554
578
|
* @category constructors
|
|
555
579
|
*/
|
|
556
|
-
export declare const
|
|
580
|
+
export declare const fromExit: <A, E>(self: MicroExit<A, E>) => Micro<A, E>;
|
|
557
581
|
/**
|
|
558
|
-
* Converts a lazy `
|
|
582
|
+
* Converts a lazy `MicroExit` into a `Micro` effect.
|
|
559
583
|
*
|
|
560
|
-
* @since 3.4.
|
|
584
|
+
* @since 3.4.6
|
|
561
585
|
* @experimental
|
|
562
586
|
* @category constructors
|
|
563
587
|
*/
|
|
564
|
-
export declare const
|
|
588
|
+
export declare const fromExitSync: <A, E>(self: LazyArg<MicroExit<A, E>>) => Micro<A, E>;
|
|
565
589
|
/**
|
|
566
590
|
* Creates a `Micro` effect that will succeed with the specified constant value.
|
|
567
591
|
*
|
|
@@ -589,7 +613,7 @@ export declare const succeedNone: Micro<Option.Option<never>>;
|
|
|
589
613
|
/**
|
|
590
614
|
* Creates a `Micro` effect that will fail with the specified error.
|
|
591
615
|
*
|
|
592
|
-
* This will result in a `
|
|
616
|
+
* This will result in a `CauseFail`, where the error is tracked at the
|
|
593
617
|
* type level.
|
|
594
618
|
*
|
|
595
619
|
* @since 3.4.0
|
|
@@ -600,7 +624,7 @@ export declare const fail: <E>(e: E) => Micro<never, E>;
|
|
|
600
624
|
/**
|
|
601
625
|
* Creates a `Micro` effect that will fail with the lazily evaluated error.
|
|
602
626
|
*
|
|
603
|
-
* This will result in a `
|
|
627
|
+
* This will result in a `CauseFail`, where the error is tracked at the
|
|
604
628
|
* type level.
|
|
605
629
|
*
|
|
606
630
|
* @since 3.4.0
|
|
@@ -611,7 +635,7 @@ export declare const failSync: <E>(e: LazyArg<E>) => Micro<never, E>;
|
|
|
611
635
|
/**
|
|
612
636
|
* Creates a `Micro` effect that will die with the specified error.
|
|
613
637
|
*
|
|
614
|
-
* This will result in a `
|
|
638
|
+
* This will result in a `CauseDie`, where the error is not tracked at
|
|
615
639
|
* the type level.
|
|
616
640
|
*
|
|
617
641
|
* @since 3.4.0
|
|
@@ -620,26 +644,26 @@ export declare const failSync: <E>(e: LazyArg<E>) => Micro<never, E>;
|
|
|
620
644
|
*/
|
|
621
645
|
export declare const die: (defect: unknown) => Micro<never>;
|
|
622
646
|
/**
|
|
623
|
-
* Creates a `Micro` effect that will fail with the specified `
|
|
647
|
+
* Creates a `Micro` effect that will fail with the specified `MicroCause`.
|
|
624
648
|
*
|
|
625
|
-
* @since 3.4.
|
|
649
|
+
* @since 3.4.6
|
|
626
650
|
* @experimental
|
|
627
651
|
* @category constructors
|
|
628
652
|
*/
|
|
629
|
-
export declare const
|
|
653
|
+
export declare const failCause: <E>(cause: MicroCause<E>) => Micro<never, E>;
|
|
630
654
|
/**
|
|
631
|
-
* Creates a `Micro` effect that will fail with the lazily evaluated `
|
|
655
|
+
* Creates a `Micro` effect that will fail with the lazily evaluated `MicroCause`.
|
|
632
656
|
*
|
|
633
|
-
* @since 3.4.
|
|
657
|
+
* @since 3.4.6
|
|
634
658
|
* @experimental
|
|
635
659
|
* @category constructors
|
|
636
660
|
*/
|
|
637
|
-
export declare const
|
|
661
|
+
export declare const failCauseSync: <E>(cause: LazyArg<MicroCause<E>>) => Micro<never, E>;
|
|
638
662
|
/**
|
|
639
663
|
* Creates a `Micro` effect that will succeed with the lazily evaluated value.
|
|
640
664
|
*
|
|
641
665
|
* If the evaluation of the value throws an error, the effect will fail with
|
|
642
|
-
* `
|
|
666
|
+
* `CauseDie`.
|
|
643
667
|
*
|
|
644
668
|
* @since 3.4.0
|
|
645
669
|
* @experimental
|
|
@@ -719,7 +743,7 @@ export {
|
|
|
719
743
|
try_ as try };
|
|
720
744
|
/**
|
|
721
745
|
* Wrap a `Promise` into a `Micro` effect. Any errors will result in a
|
|
722
|
-
* `
|
|
746
|
+
* `CauseDie`.
|
|
723
747
|
*
|
|
724
748
|
* @since 3.4.0
|
|
725
749
|
* @experimental
|
|
@@ -878,21 +902,21 @@ export declare const tap: {
|
|
|
878
902
|
*/
|
|
879
903
|
export declare const asVoid: <A, E, R>(self: Micro<A, E, R>) => Micro<void, E, R>;
|
|
880
904
|
/**
|
|
881
|
-
* Access the `
|
|
905
|
+
* Access the `MicroExit` of the given `Micro` effect.
|
|
882
906
|
*
|
|
883
|
-
* @since 3.4.
|
|
907
|
+
* @since 3.4.6
|
|
884
908
|
* @experimental
|
|
885
909
|
* @category mapping & sequencing
|
|
886
910
|
*/
|
|
887
|
-
export declare const
|
|
911
|
+
export declare const exit: <A, E, R>(self: Micro<A, E, R>) => Micro<MicroExit<A, E>, never, R>;
|
|
888
912
|
/**
|
|
889
|
-
* Replace the error type of the given `Micro` with the full `
|
|
913
|
+
* Replace the error type of the given `Micro` with the full `MicroCause` object.
|
|
890
914
|
*
|
|
891
915
|
* @since 3.4.0
|
|
892
916
|
* @experimental
|
|
893
917
|
* @category mapping & sequencing
|
|
894
918
|
*/
|
|
895
|
-
export declare const sandbox: <A, E, R>(self: Micro<A, E, R>) => Micro<A,
|
|
919
|
+
export declare const sandbox: <A, E, R>(self: Micro<A, E, R>) => Micro<A, MicroCause<E>, R>;
|
|
896
920
|
/**
|
|
897
921
|
* Returns an effect that races all the specified effects,
|
|
898
922
|
* yielding the value of the first effect to succeed with a value. Losers of
|
|
@@ -972,7 +996,7 @@ export declare const zipWith: {
|
|
|
972
996
|
};
|
|
973
997
|
/**
|
|
974
998
|
* Filter the specified effect with the provided function, failing with specified
|
|
975
|
-
* `
|
|
999
|
+
* `MicroCause` if the predicate fails.
|
|
976
1000
|
*
|
|
977
1001
|
* In addition to the filtering capabilities discussed earlier, you have the option to further
|
|
978
1002
|
* refine and narrow down the type of the success channel by providing a
|
|
@@ -981,11 +1005,11 @@ export declare const zipWith: {
|
|
|
981
1005
|
* @experimental
|
|
982
1006
|
* @category filtering & conditionals
|
|
983
1007
|
*/
|
|
984
|
-
export declare const
|
|
985
|
-
<A, B extends A, E2>(refinement: Refinement<A, B>, orFailWith: (a: NoInfer<A>) =>
|
|
986
|
-
<A, E2>(predicate: Predicate<NoInfer<A>>, orFailWith: (a: NoInfer<A>) =>
|
|
987
|
-
<A, E, R, B extends A, E2>(self: Micro<A, E, R>, refinement: Refinement<A, B>, orFailWith: (a: A) =>
|
|
988
|
-
<A, E, R, E2>(self: Micro<A, E, R>, predicate: Predicate<A>, orFailWith: (a: A) =>
|
|
1008
|
+
export declare const filterOrFailCause: {
|
|
1009
|
+
<A, B extends A, E2>(refinement: Refinement<A, B>, orFailWith: (a: NoInfer<A>) => MicroCause<E2>): <E, R>(self: Micro<A, E, R>) => Micro<B, E2 | E, R>;
|
|
1010
|
+
<A, E2>(predicate: Predicate<NoInfer<A>>, orFailWith: (a: NoInfer<A>) => MicroCause<E2>): <E, R>(self: Micro<A, E, R>) => Micro<A, E2 | E, R>;
|
|
1011
|
+
<A, E, R, B extends A, E2>(self: Micro<A, E, R>, refinement: Refinement<A, B>, orFailWith: (a: A) => MicroCause<E2>): Micro<B, E | E2, R>;
|
|
1012
|
+
<A, E, R, E2>(self: Micro<A, E, R>, predicate: Predicate<A>, orFailWith: (a: A) => MicroCause<E2>): Micro<A, E | E2, R>;
|
|
989
1013
|
};
|
|
990
1014
|
/**
|
|
991
1015
|
* Filter the specified effect with the provided function, failing with specified
|
|
@@ -1019,22 +1043,22 @@ export declare const when: {
|
|
|
1019
1043
|
* Repeat the given `Micro` using the provided options.
|
|
1020
1044
|
*
|
|
1021
1045
|
* The `while` predicate will be checked after each iteration, and can use the
|
|
1022
|
-
* fall `
|
|
1046
|
+
* fall `MicroExit` of the effect to determine if the repetition should continue.
|
|
1023
1047
|
*
|
|
1024
|
-
* @since 3.4.
|
|
1048
|
+
* @since 3.4.6
|
|
1025
1049
|
* @experimental
|
|
1026
1050
|
* @category repetition
|
|
1027
1051
|
*/
|
|
1028
|
-
export declare const
|
|
1052
|
+
export declare const repeatExit: {
|
|
1029
1053
|
<A, E>(options: {
|
|
1030
|
-
while: Predicate<
|
|
1054
|
+
while: Predicate<MicroExit<A, E>>;
|
|
1031
1055
|
times?: number | undefined;
|
|
1032
|
-
|
|
1056
|
+
schedule?: MicroSchedule | undefined;
|
|
1033
1057
|
}): <R>(self: Micro<A, E, R>) => Micro<A, E, R>;
|
|
1034
1058
|
<A, E, R>(self: Micro<A, E, R>, options: {
|
|
1035
|
-
while: Predicate<
|
|
1059
|
+
while: Predicate<MicroExit<A, E>>;
|
|
1036
1060
|
times?: number | undefined;
|
|
1037
|
-
|
|
1061
|
+
schedule?: MicroSchedule | undefined;
|
|
1038
1062
|
}): Micro<A, E, R>;
|
|
1039
1063
|
};
|
|
1040
1064
|
/**
|
|
@@ -1049,12 +1073,12 @@ export declare const repeat: {
|
|
|
1049
1073
|
<A, E>(options?: {
|
|
1050
1074
|
while?: Predicate<A> | undefined;
|
|
1051
1075
|
times?: number | undefined;
|
|
1052
|
-
|
|
1076
|
+
schedule?: MicroSchedule | undefined;
|
|
1053
1077
|
} | undefined): <R>(self: Micro<A, E, R>) => Micro<A, E, R>;
|
|
1054
1078
|
<A, E, R>(self: Micro<A, E, R>, options?: {
|
|
1055
1079
|
while?: Predicate<A> | undefined;
|
|
1056
1080
|
times?: number | undefined;
|
|
1057
|
-
|
|
1081
|
+
schedule?: MicroSchedule | undefined;
|
|
1058
1082
|
} | undefined): Micro<A, E, R>;
|
|
1059
1083
|
};
|
|
1060
1084
|
/**
|
|
@@ -1066,164 +1090,197 @@ export declare const repeat: {
|
|
|
1066
1090
|
*/
|
|
1067
1091
|
export declare const forever: <A, E, R>(self: Micro<A, E, R>) => Micro<never, E, R>;
|
|
1068
1092
|
/**
|
|
1069
|
-
*
|
|
1070
|
-
* repeats.
|
|
1093
|
+
* The `MicroSchedule` type represents a function that can be used to calculate
|
|
1094
|
+
* the delay between repeats.
|
|
1071
1095
|
*
|
|
1072
|
-
* The function takes the current attempt number and the elapsed time since
|
|
1073
|
-
*
|
|
1074
|
-
*
|
|
1096
|
+
* The function takes the current attempt number and the elapsed time since the
|
|
1097
|
+
* first attempt, and returns the delay for the next attempt. If the function
|
|
1098
|
+
* returns `None`, the repetition will stop.
|
|
1075
1099
|
*
|
|
1076
|
-
* @since 3.4.
|
|
1100
|
+
* @since 3.4.6
|
|
1077
1101
|
* @experimental
|
|
1078
|
-
* @category
|
|
1102
|
+
* @category scheduling
|
|
1079
1103
|
*/
|
|
1080
|
-
export type
|
|
1104
|
+
export type MicroSchedule = (attempt: number, elapsed: number) => Option.Option<number>;
|
|
1081
1105
|
/**
|
|
1082
|
-
* Create a `
|
|
1106
|
+
* Create a `MicroSchedule` that will stop repeating after the specified number
|
|
1107
|
+
* of attempts.
|
|
1083
1108
|
*
|
|
1084
|
-
* @since 3.4.
|
|
1109
|
+
* @since 3.4.6
|
|
1085
1110
|
* @experimental
|
|
1086
|
-
* @category
|
|
1111
|
+
* @category scheduling
|
|
1087
1112
|
*/
|
|
1088
|
-
export declare const
|
|
1113
|
+
export declare const scheduleRecurs: (n: number) => MicroSchedule;
|
|
1089
1114
|
/**
|
|
1090
|
-
* Create a `
|
|
1115
|
+
* Create a `MicroSchedule` that will generate a constant delay.
|
|
1091
1116
|
*
|
|
1092
|
-
* @since 3.4.
|
|
1117
|
+
* @since 3.4.6
|
|
1093
1118
|
* @experimental
|
|
1094
|
-
* @category
|
|
1119
|
+
* @category scheduling
|
|
1095
1120
|
*/
|
|
1096
|
-
export declare const
|
|
1121
|
+
export declare const scheduleSpaced: (millis: number) => MicroSchedule;
|
|
1097
1122
|
/**
|
|
1098
|
-
*
|
|
1123
|
+
* Create a `MicroSchedule` that will generate a delay with an exponential backoff.
|
|
1124
|
+
*
|
|
1125
|
+
* @since 3.4.6
|
|
1126
|
+
* @experimental
|
|
1127
|
+
* @category scheduling
|
|
1128
|
+
*/
|
|
1129
|
+
export declare const scheduleExponential: (baseMillis: number, factor?: number) => MicroSchedule;
|
|
1130
|
+
/**
|
|
1131
|
+
* Returns a new `MicroSchedule` with an added calculated delay to each delay
|
|
1132
|
+
* returned by this schedule.
|
|
1133
|
+
*
|
|
1134
|
+
* @since 3.4.6
|
|
1135
|
+
* @experimental
|
|
1136
|
+
* @category scheduling
|
|
1137
|
+
*/
|
|
1138
|
+
export declare const scheduleAddDelay: {
|
|
1139
|
+
(f: () => number): (self: MicroSchedule) => MicroSchedule;
|
|
1140
|
+
(self: MicroSchedule, f: () => number): MicroSchedule;
|
|
1141
|
+
};
|
|
1142
|
+
/**
|
|
1143
|
+
* Transform a `MicroSchedule` to one that will have a delay that will never exceed
|
|
1099
1144
|
* the specified maximum.
|
|
1100
1145
|
*
|
|
1101
|
-
* @since 3.4.
|
|
1146
|
+
* @since 3.4.6
|
|
1102
1147
|
* @experimental
|
|
1103
|
-
* @category
|
|
1148
|
+
* @category scheduling
|
|
1104
1149
|
*/
|
|
1105
|
-
export declare const
|
|
1106
|
-
(max: number): (self:
|
|
1107
|
-
(self:
|
|
1150
|
+
export declare const scheduleWithMaxDelay: {
|
|
1151
|
+
(max: number): (self: MicroSchedule) => MicroSchedule;
|
|
1152
|
+
(self: MicroSchedule, max: number): MicroSchedule;
|
|
1108
1153
|
};
|
|
1109
1154
|
/**
|
|
1110
|
-
* Transform a `
|
|
1155
|
+
* Transform a `MicroSchedule` to one that will stop repeating after the specified
|
|
1111
1156
|
* amount of time.
|
|
1112
1157
|
*
|
|
1113
|
-
* @since 3.4.
|
|
1158
|
+
* @since 3.4.6
|
|
1114
1159
|
* @experimental
|
|
1115
|
-
* @category
|
|
1160
|
+
* @category scheduling
|
|
1116
1161
|
*/
|
|
1117
|
-
export declare const
|
|
1118
|
-
(max: number): (self:
|
|
1119
|
-
(self:
|
|
1162
|
+
export declare const scheduleWithMaxElapsed: {
|
|
1163
|
+
(max: number): (self: MicroSchedule) => MicroSchedule;
|
|
1164
|
+
(self: MicroSchedule, max: number): MicroSchedule;
|
|
1120
1165
|
};
|
|
1121
1166
|
/**
|
|
1122
|
-
*
|
|
1123
|
-
*
|
|
1167
|
+
* Combines two `MicroSchedule`s, by recurring if either schedule wants to
|
|
1168
|
+
* recur, using the minimum of the two durations between recurrences.
|
|
1124
1169
|
*
|
|
1125
|
-
* @since 3.4.
|
|
1170
|
+
* @since 3.4.6
|
|
1126
1171
|
* @experimental
|
|
1127
|
-
* @category
|
|
1172
|
+
* @category scheduling
|
|
1128
1173
|
*/
|
|
1129
|
-
export declare const
|
|
1130
|
-
(
|
|
1131
|
-
(self:
|
|
1174
|
+
export declare const scheduleUnion: {
|
|
1175
|
+
(that: MicroSchedule): (self: MicroSchedule) => MicroSchedule;
|
|
1176
|
+
(self: MicroSchedule, that: MicroSchedule): MicroSchedule;
|
|
1132
1177
|
};
|
|
1133
1178
|
/**
|
|
1134
|
-
*
|
|
1135
|
-
*
|
|
1179
|
+
* Combines two `MicroSchedule`s, by recurring only if both schedules want to
|
|
1180
|
+
* recur, using the maximum of the two durations between recurrences.
|
|
1136
1181
|
*
|
|
1137
|
-
* @since 3.4.
|
|
1182
|
+
* @since 3.4.6
|
|
1183
|
+
* @experimental
|
|
1184
|
+
* @category scheduling
|
|
1185
|
+
*/
|
|
1186
|
+
export declare const scheduleIntersect: {
|
|
1187
|
+
(that: MicroSchedule): (self: MicroSchedule) => MicroSchedule;
|
|
1188
|
+
(self: MicroSchedule, that: MicroSchedule): MicroSchedule;
|
|
1189
|
+
};
|
|
1190
|
+
/**
|
|
1191
|
+
* Catch the full `MicroCause` object of the given `Micro` effect, allowing you to
|
|
1192
|
+
* recover from any kind of cause.
|
|
1193
|
+
*
|
|
1194
|
+
* @since 3.4.6
|
|
1138
1195
|
* @experimental
|
|
1139
1196
|
* @category error handling
|
|
1140
1197
|
*/
|
|
1141
|
-
export declare const
|
|
1142
|
-
<E, B, E2, R2>(f: (
|
|
1143
|
-
<A, E, R, B, E2, R2>(self: Micro<A, E, R>, f: (
|
|
1198
|
+
export declare const catchAllCause: {
|
|
1199
|
+
<E, B, E2, R2>(f: (cause: NoInfer<MicroCause<E>>) => Micro<B, E2, R2>): <A, R>(self: Micro<A, E, R>) => Micro<A | B, E2, R | R2>;
|
|
1200
|
+
<A, E, R, B, E2, R2>(self: Micro<A, E, R>, f: (cause: NoInfer<MicroCause<E>>) => Micro<B, E2, R2>): Micro<A | B, E2, R | R2>;
|
|
1144
1201
|
};
|
|
1145
1202
|
/**
|
|
1146
|
-
* Selectively catch a `
|
|
1203
|
+
* Selectively catch a `MicroCause` object of the given `Micro` effect,
|
|
1147
1204
|
* using the provided predicate to determine if the failure should be caught.
|
|
1148
1205
|
*
|
|
1149
|
-
* @since 3.4.
|
|
1206
|
+
* @since 3.4.6
|
|
1150
1207
|
* @experimental
|
|
1151
1208
|
* @category error handling
|
|
1152
1209
|
*/
|
|
1153
|
-
export declare const
|
|
1154
|
-
<E, B, E2, R2, EB extends
|
|
1155
|
-
<E, B, E2, R2>(predicate: Predicate<
|
|
1156
|
-
<A, E, R, B, E2, R2, EB extends
|
|
1157
|
-
<A, E, R, B, E2, R2>(self: Micro<A, E, R>, predicate: Predicate<
|
|
1210
|
+
export declare const catchCauseIf: {
|
|
1211
|
+
<E, B, E2, R2, EB extends MicroCause<E>>(refinement: Refinement<MicroCause<E>, EB>, f: (cause: EB) => Micro<B, E2, R2>): <A, R>(self: Micro<A, E, R>) => Micro<A | B, Exclude<E, MicroCause.Error<EB>> | E2, R | R2>;
|
|
1212
|
+
<E, B, E2, R2>(predicate: Predicate<MicroCause<NoInfer<E>>>, f: (cause: NoInfer<MicroCause<E>>) => Micro<B, E2, R2>): <A, R>(self: Micro<A, E, R>) => Micro<A | B, E | E2, R | R2>;
|
|
1213
|
+
<A, E, R, B, E2, R2, EB extends MicroCause<E>>(self: Micro<A, E, R>, refinement: Refinement<MicroCause<E>, EB>, f: (cause: EB) => Micro<B, E2, R2>): Micro<A | B, Exclude<E, MicroCause.Error<EB>> | E2, R | R2>;
|
|
1214
|
+
<A, E, R, B, E2, R2>(self: Micro<A, E, R>, predicate: Predicate<MicroCause<NoInfer<E>>>, f: (cause: NoInfer<MicroCause<E>>) => Micro<B, E2, R2>): Micro<A | B, E | E2, R | R2>;
|
|
1158
1215
|
};
|
|
1159
1216
|
/**
|
|
1160
1217
|
* Catch the error of the given `Micro` effect, allowing you to recover from it.
|
|
1161
1218
|
*
|
|
1162
|
-
* It only catches expected (`
|
|
1219
|
+
* It only catches expected (`MicroCause.Fail`) errors.
|
|
1163
1220
|
*
|
|
1164
|
-
* @since 3.4.
|
|
1221
|
+
* @since 3.4.6
|
|
1165
1222
|
* @experimental
|
|
1166
1223
|
* @category error handling
|
|
1167
1224
|
*/
|
|
1168
|
-
export declare const
|
|
1225
|
+
export declare const catchAll: {
|
|
1169
1226
|
<E, B, E2, R2>(f: (e: NoInfer<E>) => Micro<B, E2, R2>): <A, R>(self: Micro<A, E, R>) => Micro<A | B, E2, R | R2>;
|
|
1170
1227
|
<A, E, R, B, E2, R2>(self: Micro<A, E, R>, f: (e: NoInfer<E>) => Micro<B, E2, R2>): Micro<A | B, E2, R | R2>;
|
|
1171
1228
|
};
|
|
1172
1229
|
/**
|
|
1173
1230
|
* Catch any unexpected errors of the given `Micro` effect, allowing you to recover from them.
|
|
1174
1231
|
*
|
|
1175
|
-
* @since 3.4.
|
|
1232
|
+
* @since 3.4.6
|
|
1176
1233
|
* @experimental
|
|
1177
1234
|
* @category error handling
|
|
1178
1235
|
*/
|
|
1179
|
-
export declare const
|
|
1236
|
+
export declare const catchAllDefect: {
|
|
1180
1237
|
<E, B, E2, R2>(f: (defect: unknown) => Micro<B, E2, R2>): <A, R>(self: Micro<A, E, R>) => Micro<A | B, E | E2, R | R2>;
|
|
1181
1238
|
<A, E, R, B, E2, R2>(self: Micro<A, E, R>, f: (defect: unknown) => Micro<B, E2, R2>): Micro<A | B, E | E2, R | R2>;
|
|
1182
1239
|
};
|
|
1183
1240
|
/**
|
|
1184
|
-
* Perform a side effect using the full `
|
|
1241
|
+
* Perform a side effect using the full `MicroCause` object of the given `Micro`.
|
|
1185
1242
|
*
|
|
1186
|
-
* @since 3.4.
|
|
1243
|
+
* @since 3.4.6
|
|
1187
1244
|
* @experimental
|
|
1188
1245
|
* @category error handling
|
|
1189
1246
|
*/
|
|
1190
|
-
export declare const
|
|
1191
|
-
<E, B, E2, R2>(f: (
|
|
1192
|
-
<A, E, R, B, E2, R2>(self: Micro<A, E, R>, f: (
|
|
1247
|
+
export declare const tapErrorCause: {
|
|
1248
|
+
<E, B, E2, R2>(f: (cause: NoInfer<MicroCause<E>>) => Micro<B, E2, R2>): <A, R>(self: Micro<A, E, R>) => Micro<A, E | E2, R | R2>;
|
|
1249
|
+
<A, E, R, B, E2, R2>(self: Micro<A, E, R>, f: (cause: NoInfer<MicroCause<E>>) => Micro<B, E2, R2>): Micro<A, E | E2, R | R2>;
|
|
1193
1250
|
};
|
|
1194
1251
|
/**
|
|
1195
|
-
* Perform a side effect using if a `
|
|
1252
|
+
* Perform a side effect using if a `MicroCause` object matches the specified
|
|
1196
1253
|
* predicate.
|
|
1197
1254
|
*
|
|
1198
1255
|
* @since 3.4.0
|
|
1199
1256
|
* @experimental
|
|
1200
1257
|
* @category error handling
|
|
1201
1258
|
*/
|
|
1202
|
-
export declare const
|
|
1203
|
-
<E, B, E2, R2, EB extends
|
|
1204
|
-
<E, B, E2, R2>(predicate: (
|
|
1205
|
-
<A, E, R, B, E2, R2, EB extends
|
|
1206
|
-
<A, E, R, B, E2, R2>(self: Micro<A, E, R>, predicate: (
|
|
1259
|
+
export declare const tapErrorCauseIf: {
|
|
1260
|
+
<E, B, E2, R2, EB extends MicroCause<E>>(refinement: Refinement<MicroCause<E>, EB>, f: (a: EB) => Micro<B, E2, R2>): <A, R>(self: Micro<A, E, R>) => Micro<A, E | E2, R | R2>;
|
|
1261
|
+
<E, B, E2, R2>(predicate: (cause: NoInfer<MicroCause<E>>) => boolean, f: (a: NoInfer<MicroCause<E>>) => Micro<B, E2, R2>): <A, R>(self: Micro<A, E, R>) => Micro<A, E | E2, R | R2>;
|
|
1262
|
+
<A, E, R, B, E2, R2, EB extends MicroCause<E>>(self: Micro<A, E, R>, refinement: Refinement<MicroCause<E>, EB>, f: (a: EB) => Micro<B, E2, R2>): Micro<A, E | E2, R | R2>;
|
|
1263
|
+
<A, E, R, B, E2, R2>(self: Micro<A, E, R>, predicate: (cause: NoInfer<MicroCause<E>>) => boolean, f: (a: NoInfer<MicroCause<E>>) => Micro<B, E2, R2>): Micro<A, E | E2, R | R2>;
|
|
1207
1264
|
};
|
|
1208
1265
|
/**
|
|
1209
1266
|
* Perform a side effect from expected errors of the given `Micro`.
|
|
1210
1267
|
*
|
|
1211
|
-
* @since 3.4.
|
|
1268
|
+
* @since 3.4.6
|
|
1212
1269
|
* @experimental
|
|
1213
1270
|
* @category error handling
|
|
1214
1271
|
*/
|
|
1215
|
-
export declare const
|
|
1216
|
-
<E, B, E2, R2>(f: (
|
|
1217
|
-
<A, E, R, B, E2, R2>(self: Micro<A, E, R>, f: (
|
|
1272
|
+
export declare const tapError: {
|
|
1273
|
+
<E, B, E2, R2>(f: (e: NoInfer<E>) => Micro<B, E2, R2>): <A, R>(self: Micro<A, E, R>) => Micro<A, E | E2, R | R2>;
|
|
1274
|
+
<A, E, R, B, E2, R2>(self: Micro<A, E, R>, f: (e: NoInfer<E>) => Micro<B, E2, R2>): Micro<A, E | E2, R | R2>;
|
|
1218
1275
|
};
|
|
1219
1276
|
/**
|
|
1220
1277
|
* Perform a side effect from unexpected errors of the given `Micro`.
|
|
1221
1278
|
*
|
|
1222
|
-
* @since 3.4.
|
|
1279
|
+
* @since 3.4.6
|
|
1223
1280
|
* @experimental
|
|
1224
1281
|
* @category error handling
|
|
1225
1282
|
*/
|
|
1226
|
-
export declare const
|
|
1283
|
+
export declare const tapDefect: {
|
|
1227
1284
|
<E, B, E2, R2>(f: (defect: unknown) => Micro<B, E2, R2>): <A, R>(self: Micro<A, E, R>) => Micro<A, E | E2, R | R2>;
|
|
1228
1285
|
<A, E, R, B, E2, R2>(self: Micro<A, E, R>, f: (defect: unknown) => Micro<B, E2, R2>): Micro<A, E | E2, R | R2>;
|
|
1229
1286
|
};
|
|
@@ -1264,15 +1321,15 @@ export declare const catchTag: {
|
|
|
1264
1321
|
}>, R | R1>;
|
|
1265
1322
|
};
|
|
1266
1323
|
/**
|
|
1267
|
-
* Transform the full `
|
|
1324
|
+
* Transform the full `MicroCause` object of the given `Micro` effect.
|
|
1268
1325
|
*
|
|
1269
|
-
* @since 3.4.
|
|
1326
|
+
* @since 3.4.6
|
|
1270
1327
|
* @experimental
|
|
1271
1328
|
* @category error handling
|
|
1272
1329
|
*/
|
|
1273
|
-
export declare const
|
|
1274
|
-
<E, E2>(f: (
|
|
1275
|
-
<A, E, R, E2>(self: Micro<A, E, R>, f: (
|
|
1330
|
+
export declare const mapErrorCause: {
|
|
1331
|
+
<E, E2>(f: (e: MicroCause<E>) => MicroCause<E2>): <A, R>(self: Micro<A, E, R>) => Micro<A, E2, R>;
|
|
1332
|
+
<A, E, R, E2>(self: Micro<A, E, R>, f: (e: MicroCause<E>) => MicroCause<E2>): Micro<A, E2, R>;
|
|
1276
1333
|
};
|
|
1277
1334
|
/**
|
|
1278
1335
|
* Transform any expected errors of the given `Micro` effect.
|
|
@@ -1282,8 +1339,8 @@ export declare const mapFailure: {
|
|
|
1282
1339
|
* @category error handling
|
|
1283
1340
|
*/
|
|
1284
1341
|
export declare const mapError: {
|
|
1285
|
-
<E, E2>(f: (
|
|
1286
|
-
<A, E, R, E2>(self: Micro<A, E, R>, f: (
|
|
1342
|
+
<E, E2>(f: (e: E) => E2): <A, R>(self: Micro<A, E, R>) => Micro<A, E2, R>;
|
|
1343
|
+
<A, E, R, E2>(self: Micro<A, E, R>, f: (e: E) => E2): Micro<A, E2, R>;
|
|
1287
1344
|
};
|
|
1288
1345
|
/**
|
|
1289
1346
|
* Elevate any expected errors of the given `Micro` effect to unexpected errors,
|
|
@@ -1352,17 +1409,17 @@ export declare const retry: {
|
|
|
1352
1409
|
<A, E>(options?: {
|
|
1353
1410
|
while?: Predicate<E> | undefined;
|
|
1354
1411
|
times?: number | undefined;
|
|
1355
|
-
|
|
1412
|
+
schedule?: MicroSchedule | undefined;
|
|
1356
1413
|
} | undefined): <R>(self: Micro<A, E, R>) => Micro<A, E, R>;
|
|
1357
1414
|
<A, E, R>(self: Micro<A, E, R>, options?: {
|
|
1358
1415
|
while?: Predicate<E> | undefined;
|
|
1359
1416
|
times?: number | undefined;
|
|
1360
|
-
|
|
1417
|
+
schedule?: MicroSchedule | undefined;
|
|
1361
1418
|
} | undefined): Micro<A, E, R>;
|
|
1362
1419
|
};
|
|
1363
1420
|
/**
|
|
1364
1421
|
* Add a stack trace to any failures that occur in the effect. The trace will be
|
|
1365
|
-
* added to the `traces` field of the `
|
|
1422
|
+
* added to the `traces` field of the `MicroCause` object.
|
|
1366
1423
|
*
|
|
1367
1424
|
* @since 3.4.0
|
|
1368
1425
|
* @experimental
|
|
@@ -1373,41 +1430,41 @@ export declare const withTrace: {
|
|
|
1373
1430
|
<A, E, R>(self: Micro<A, E, R>, name: string): Micro<A, E, R>;
|
|
1374
1431
|
};
|
|
1375
1432
|
/**
|
|
1376
|
-
* @since 3.4.
|
|
1433
|
+
* @since 3.4.6
|
|
1377
1434
|
* @experimental
|
|
1378
1435
|
* @category pattern matching
|
|
1379
1436
|
*/
|
|
1380
|
-
export declare const
|
|
1437
|
+
export declare const matchCauseEffect: {
|
|
1381
1438
|
<E, A2, E2, R2, A, A3, E3, R3>(options: {
|
|
1382
|
-
readonly onFailure: (
|
|
1439
|
+
readonly onFailure: (cause: MicroCause<E>) => Micro<A2, E2, R2>;
|
|
1383
1440
|
readonly onSuccess: (a: A) => Micro<A3, E3, R3>;
|
|
1384
1441
|
}): <R>(self: Micro<A, E, R>) => Micro<A2 | A3, E2 | E3, R2 | R3 | R>;
|
|
1385
1442
|
<A, E, R, A2, E2, R2, A3, E3, R3>(self: Micro<A, E, R>, options: {
|
|
1386
|
-
readonly onFailure: (
|
|
1443
|
+
readonly onFailure: (cause: MicroCause<E>) => Micro<A2, E2, R2>;
|
|
1387
1444
|
readonly onSuccess: (a: A) => Micro<A3, E3, R3>;
|
|
1388
1445
|
}): Micro<A2 | A3, E2 | E3, R2 | R3 | R>;
|
|
1389
1446
|
};
|
|
1390
1447
|
/**
|
|
1391
|
-
* @since 3.4.
|
|
1448
|
+
* @since 3.4.6
|
|
1392
1449
|
* @experimental
|
|
1393
1450
|
* @category pattern matching
|
|
1394
1451
|
*/
|
|
1395
|
-
export declare const
|
|
1452
|
+
export declare const matchCause: {
|
|
1396
1453
|
<E, A2, A, A3>(options: {
|
|
1397
|
-
readonly onFailure: (
|
|
1454
|
+
readonly onFailure: (cause: MicroCause<E>) => A2;
|
|
1398
1455
|
readonly onSuccess: (a: A) => A3;
|
|
1399
1456
|
}): <R>(self: Micro<A, E, R>) => Micro<A2 | A3, never, R>;
|
|
1400
1457
|
<A, E, R, A2, A3>(self: Micro<A, E, R>, options: {
|
|
1401
|
-
readonly onFailure: (
|
|
1458
|
+
readonly onFailure: (cause: MicroCause<E>) => A2;
|
|
1402
1459
|
readonly onSuccess: (a: A) => A3;
|
|
1403
1460
|
}): Micro<A2 | A3, never, R>;
|
|
1404
1461
|
};
|
|
1405
1462
|
/**
|
|
1406
|
-
* @since 3.4.
|
|
1463
|
+
* @since 3.4.6
|
|
1407
1464
|
* @experimental
|
|
1408
1465
|
* @category pattern matching
|
|
1409
1466
|
*/
|
|
1410
|
-
export declare const
|
|
1467
|
+
export declare const matchEffect: {
|
|
1411
1468
|
<E, A2, E2, R2, A, A3, E3, R3>(options: {
|
|
1412
1469
|
readonly onFailure: (e: E) => Micro<A2, E2, R2>;
|
|
1413
1470
|
readonly onSuccess: (a: A) => Micro<A3, E3, R3>;
|
|
@@ -1472,6 +1529,21 @@ export declare const timeoutOrElse: {
|
|
|
1472
1529
|
readonly onTimeout: LazyArg<Micro<A2, E2, R2>>;
|
|
1473
1530
|
}): Micro<A | A2, E | E2, R | R2>;
|
|
1474
1531
|
};
|
|
1532
|
+
/**
|
|
1533
|
+
* Returns an effect that will timeout this effect, that will fail with a
|
|
1534
|
+
* `TimeoutException` if the timeout elapses before the effect has produced a
|
|
1535
|
+
* value.
|
|
1536
|
+
*
|
|
1537
|
+
* If the timeout elapses, the running effect will be safely interrupted.
|
|
1538
|
+
*
|
|
1539
|
+
* @since 3.4.0
|
|
1540
|
+
* @experimental
|
|
1541
|
+
* @category delays & timeouts
|
|
1542
|
+
*/
|
|
1543
|
+
export declare const timeout: {
|
|
1544
|
+
(millis: number): <A, E, R>(self: Micro<A, E, R>) => Micro<A, E | TimeoutException, R>;
|
|
1545
|
+
<A, E, R>(self: Micro<A, E, R>, millis: number): Micro<A, E | TimeoutException, R>;
|
|
1546
|
+
};
|
|
1475
1547
|
/**
|
|
1476
1548
|
* Returns an effect that will timeout this effect, succeeding with a `None`
|
|
1477
1549
|
* if the timeout elapses before the effect has produced a value; and `Some` of
|
|
@@ -1483,7 +1555,7 @@ export declare const timeoutOrElse: {
|
|
|
1483
1555
|
* @experimental
|
|
1484
1556
|
* @category delays & timeouts
|
|
1485
1557
|
*/
|
|
1486
|
-
export declare const
|
|
1558
|
+
export declare const timeoutOption: {
|
|
1487
1559
|
(millis: number): <A, E, R>(self: Micro<A, E, R>) => Micro<Option.Option<A>, E, R>;
|
|
1488
1560
|
<A, E, R>(self: Micro<A, E, R>, millis: number): Micro<Option.Option<A>, E, R>;
|
|
1489
1561
|
};
|
|
@@ -1506,7 +1578,7 @@ export type MicroScopeTypeId = typeof MicroScopeTypeId;
|
|
|
1506
1578
|
*/
|
|
1507
1579
|
export interface MicroScope {
|
|
1508
1580
|
readonly [MicroScopeTypeId]: MicroScopeTypeId;
|
|
1509
|
-
readonly addFinalizer: (finalizer: (
|
|
1581
|
+
readonly addFinalizer: (finalizer: (exit: MicroExit<unknown, unknown>) => Micro<void>) => Micro<void>;
|
|
1510
1582
|
readonly fork: Micro<MicroScope.Closeable>;
|
|
1511
1583
|
}
|
|
1512
1584
|
/**
|
|
@@ -1521,7 +1593,7 @@ export declare namespace MicroScope {
|
|
|
1521
1593
|
* @category resources & finalization
|
|
1522
1594
|
*/
|
|
1523
1595
|
interface Closeable extends MicroScope {
|
|
1524
|
-
readonly close: (
|
|
1596
|
+
readonly close: (exit: MicroExit<any, any>) => Micro<void>;
|
|
1525
1597
|
}
|
|
1526
1598
|
}
|
|
1527
1599
|
/**
|
|
@@ -1578,7 +1650,7 @@ export declare const scoped: <A, E, R>(self: Micro<A, E, R>) => Micro<A, E, Excl
|
|
|
1578
1650
|
* @experimental
|
|
1579
1651
|
* @category resources & finalization
|
|
1580
1652
|
*/
|
|
1581
|
-
export declare const acquireRelease: <A, E, R>(acquire: Micro<A, E, R>, release: (a: A,
|
|
1653
|
+
export declare const acquireRelease: <A, E, R>(acquire: Micro<A, E, R>, release: (a: A, exit: MicroExit<unknown, unknown>) => Micro<void>) => Micro<A, E, R | MicroScope>;
|
|
1582
1654
|
/**
|
|
1583
1655
|
* Add a finalizer to the current `MicroScope`.
|
|
1584
1656
|
*
|
|
@@ -1586,32 +1658,32 @@ export declare const acquireRelease: <A, E, R>(acquire: Micro<A, E, R>, release:
|
|
|
1586
1658
|
* @experimental
|
|
1587
1659
|
* @category resources & finalization
|
|
1588
1660
|
*/
|
|
1589
|
-
export declare const addFinalizer: (finalizer: (
|
|
1661
|
+
export declare const addFinalizer: (finalizer: (exit: MicroExit<unknown, unknown>) => Micro<void>) => Micro<void, never, MicroScope>;
|
|
1590
1662
|
/**
|
|
1591
1663
|
* When the `Micro` effect is completed, run the given finalizer effect with the
|
|
1592
|
-
* `
|
|
1664
|
+
* `MicroExit` of the executed effect.
|
|
1593
1665
|
*
|
|
1594
|
-
* @since 3.4.
|
|
1666
|
+
* @since 3.4.6
|
|
1595
1667
|
* @experimental
|
|
1596
1668
|
* @category resources & finalization
|
|
1597
1669
|
*/
|
|
1598
|
-
export declare const
|
|
1599
|
-
<A, E, XE, XR>(f: (
|
|
1600
|
-
<A, E, R, XE, XR>(self: Micro<A, E, R>, f: (
|
|
1670
|
+
export declare const onExit: {
|
|
1671
|
+
<A, E, XE, XR>(f: (exit: MicroExit<A, E>) => Micro<void, XE, XR>): <R>(self: Micro<A, E, R>) => Micro<A, E | XE, R | XR>;
|
|
1672
|
+
<A, E, R, XE, XR>(self: Micro<A, E, R>, f: (exit: MicroExit<A, E>) => Micro<void, XE, XR>): Micro<A, E | XE, R | XR>;
|
|
1601
1673
|
};
|
|
1602
1674
|
/**
|
|
1603
1675
|
* When the `Micro` effect is completed, run the given finalizer effect if it
|
|
1604
1676
|
* matches the specified predicate.
|
|
1605
1677
|
*
|
|
1606
|
-
* @since 3.4.
|
|
1678
|
+
* @since 3.4.6
|
|
1607
1679
|
* @experimental
|
|
1608
1680
|
* @category resources & finalization
|
|
1609
1681
|
*/
|
|
1610
|
-
export declare const
|
|
1611
|
-
<A, E, XE, XR, B extends
|
|
1612
|
-
<A, E, XE, XR>(predicate: Predicate<
|
|
1613
|
-
<A, E, R, XE, XR, B extends
|
|
1614
|
-
<A, E, R, XE, XR>(self: Micro<A, E, R>, predicate: Predicate<
|
|
1682
|
+
export declare const onExitIf: {
|
|
1683
|
+
<A, E, XE, XR, B extends MicroExit<A, E>>(refinement: Refinement<MicroExit<A, E>, B>, f: (exit: B) => Micro<void, XE, XR>): <R>(self: Micro<A, E, R>) => Micro<A, E | XE, R | XR>;
|
|
1684
|
+
<A, E, XE, XR>(predicate: Predicate<MicroExit<NoInfer<A>, NoInfer<E>>>, f: (exit: MicroExit<NoInfer<A>, NoInfer<E>>) => Micro<void, XE, XR>): <R>(self: Micro<A, E, R>) => Micro<A, E | XE, R | XR>;
|
|
1685
|
+
<A, E, R, XE, XR, B extends MicroExit<A, E>>(self: Micro<A, E, R>, refinement: Refinement<MicroExit<A, E>, B>, f: (exit: B) => Micro<void, XE, XR>): Micro<A, E | XE, R | XR>;
|
|
1686
|
+
<A, E, R, XE, XR>(self: Micro<A, E, R>, predicate: Predicate<MicroExit<NoInfer<A>, NoInfer<E>>>, f: (exit: MicroExit<NoInfer<A>, NoInfer<E>>) => Micro<void, XE, XR>): Micro<A, E | XE, R | XR>;
|
|
1615
1687
|
};
|
|
1616
1688
|
/**
|
|
1617
1689
|
* Regardless of the result of the this `Micro` effect, run the finalizer effect.
|
|
@@ -1626,24 +1698,24 @@ export declare const ensuring: {
|
|
|
1626
1698
|
};
|
|
1627
1699
|
/**
|
|
1628
1700
|
* When the `Micro` effect fails, run the given finalizer effect with the
|
|
1629
|
-
* `
|
|
1701
|
+
* `MicroCause` of the executed effect.
|
|
1630
1702
|
*
|
|
1631
|
-
* @since 3.4.
|
|
1703
|
+
* @since 3.4.6
|
|
1632
1704
|
* @experimental
|
|
1633
1705
|
* @category resources & finalization
|
|
1634
1706
|
*/
|
|
1635
|
-
export declare const
|
|
1636
|
-
<A, E, XE, XR>(f: (
|
|
1637
|
-
<A, E, R, XE, XR>(self: Micro<A, E, R>, f: (
|
|
1707
|
+
export declare const onError: {
|
|
1708
|
+
<A, E, XE, XR>(f: (cause: MicroCause<NoInfer<E>>) => Micro<void, XE, XR>): <R>(self: Micro<A, E, R>) => Micro<A, E | XE, R | XR>;
|
|
1709
|
+
<A, E, R, XE, XR>(self: Micro<A, E, R>, f: (cause: MicroCause<NoInfer<E>>) => Micro<void, XE, XR>): Micro<A, E | XE, R | XR>;
|
|
1638
1710
|
};
|
|
1639
1711
|
/**
|
|
1640
1712
|
* If this `Micro` effect is aborted, run the finalizer effect.
|
|
1641
1713
|
*
|
|
1642
|
-
* @since 3.4.
|
|
1714
|
+
* @since 3.4.6
|
|
1643
1715
|
* @experimental
|
|
1644
1716
|
* @category resources & finalization
|
|
1645
1717
|
*/
|
|
1646
|
-
export declare const
|
|
1718
|
+
export declare const onInterrupt: {
|
|
1647
1719
|
<XE, XR>(finalizer: Micro<void, XE, XR>): <A, E, R>(self: Micro<A, E, R>) => Micro<A, E | XE, R | XR>;
|
|
1648
1720
|
<A, E, R, XE, XR>(self: Micro<A, E, R>, finalizer: Micro<void, XE, XR>): Micro<A, E | XE, R | XR>;
|
|
1649
1721
|
};
|
|
@@ -1655,15 +1727,15 @@ export declare const onAbort: {
|
|
|
1655
1727
|
* @experimental
|
|
1656
1728
|
* @category resources & finalization
|
|
1657
1729
|
*/
|
|
1658
|
-
export declare const acquireUseRelease: <Resource, E, R, A, E2, R2, E3, R3>(acquire: Micro<Resource, E, R>, use: (a: Resource) => Micro<A, E2, R2>, release: (a: Resource,
|
|
1730
|
+
export declare const acquireUseRelease: <Resource, E, R, A, E2, R2, E3, R3>(acquire: Micro<Resource, E, R>, use: (a: Resource) => Micro<A, E2, R2>, release: (a: Resource, exit: MicroExit<A, E2>) => Micro<void, E3, R3>) => Micro<A, E | E2 | E3, R | R2 | R3>;
|
|
1659
1731
|
/**
|
|
1660
1732
|
* Abort the current `Micro` effect.
|
|
1661
1733
|
*
|
|
1662
|
-
* @since 3.4.
|
|
1734
|
+
* @since 3.4.6
|
|
1663
1735
|
* @experimental
|
|
1664
1736
|
* @category interruption
|
|
1665
1737
|
*/
|
|
1666
|
-
export declare const
|
|
1738
|
+
export declare const interrupt: Micro<never>;
|
|
1667
1739
|
/**
|
|
1668
1740
|
* Wrap the given `Micro` effect in an uninterruptible region, preventing the
|
|
1669
1741
|
* effect from being aborted.
|
|
@@ -1886,13 +1958,13 @@ export type HandleTypeId = typeof HandleTypeId;
|
|
|
1886
1958
|
*/
|
|
1887
1959
|
export interface Handle<A, E = never> {
|
|
1888
1960
|
readonly [HandleTypeId]: HandleTypeId;
|
|
1889
|
-
readonly await: Micro<
|
|
1961
|
+
readonly await: Micro<MicroExit<A, E>>;
|
|
1890
1962
|
readonly join: Micro<A, E>;
|
|
1891
|
-
readonly
|
|
1892
|
-
readonly
|
|
1893
|
-
readonly addObserver: (observer: (
|
|
1894
|
-
readonly removeObserver: (observer: (
|
|
1895
|
-
readonly unsafePoll: () =>
|
|
1963
|
+
readonly interrupt: Micro<MicroExit<A, E>>;
|
|
1964
|
+
readonly unsafeInterrupt: () => void;
|
|
1965
|
+
readonly addObserver: (observer: (exit: MicroExit<A, E>) => void) => void;
|
|
1966
|
+
readonly removeObserver: (observer: (exit: MicroExit<A, E>) => void) => void;
|
|
1967
|
+
readonly unsafePoll: () => MicroExit<A, E> | null;
|
|
1896
1968
|
}
|
|
1897
1969
|
/**
|
|
1898
1970
|
* @since 3.4.0
|
|
@@ -1965,8 +2037,8 @@ export declare const forkScoped: <A, E, R>(self: Micro<A, E, R>) => Micro<Handle
|
|
|
1965
2037
|
* Micro.runFork
|
|
1966
2038
|
* )
|
|
1967
2039
|
*
|
|
1968
|
-
* handle.addObserver((
|
|
1969
|
-
* console.log(
|
|
2040
|
+
* handle.addObserver((exit) => {
|
|
2041
|
+
* console.log(exit)
|
|
1970
2042
|
* })
|
|
1971
2043
|
*/
|
|
1972
2044
|
export declare const runFork: <A, E>(effect: Micro<A, E>, options?: {
|
|
@@ -1974,15 +2046,15 @@ export declare const runFork: <A, E>(effect: Micro<A, E>, options?: {
|
|
|
1974
2046
|
} | undefined) => Handle<A, E>;
|
|
1975
2047
|
/**
|
|
1976
2048
|
* Execute the `Micro` effect and return a `Promise` that resolves with the
|
|
1977
|
-
* `
|
|
2049
|
+
* `MicroExit` of the computation.
|
|
1978
2050
|
*
|
|
1979
|
-
* @since 3.4.
|
|
2051
|
+
* @since 3.4.6
|
|
1980
2052
|
* @experimental
|
|
1981
2053
|
* @category execution
|
|
1982
2054
|
*/
|
|
1983
|
-
export declare const
|
|
2055
|
+
export declare const runPromiseExit: <A, E>(effect: Micro<A, E>, options?: {
|
|
1984
2056
|
readonly signal?: AbortSignal | undefined;
|
|
1985
|
-
} | undefined) => Promise<
|
|
2057
|
+
} | undefined) => Promise<MicroExit<A, E>>;
|
|
1986
2058
|
/**
|
|
1987
2059
|
* Execute the `Micro` effect and return a `Promise` that resolves with the
|
|
1988
2060
|
* successful value of the computation.
|
|
@@ -1995,16 +2067,16 @@ export declare const runPromise: <A, E>(effect: Micro<A, E>, options?: {
|
|
|
1995
2067
|
readonly signal?: AbortSignal | undefined;
|
|
1996
2068
|
} | undefined) => Promise<A>;
|
|
1997
2069
|
/**
|
|
1998
|
-
* Attempt to execute the `Micro` effect synchronously and return the `
|
|
2070
|
+
* Attempt to execute the `Micro` effect synchronously and return the `MicroExit`.
|
|
1999
2071
|
*
|
|
2000
2072
|
* If any asynchronous effects are encountered, the function will return a
|
|
2001
|
-
*
|
|
2073
|
+
* `CauseDie` containing the `Handle`.
|
|
2002
2074
|
*
|
|
2003
|
-
* @since 3.4.
|
|
2075
|
+
* @since 3.4.6
|
|
2004
2076
|
* @experimental
|
|
2005
2077
|
* @category execution
|
|
2006
2078
|
*/
|
|
2007
|
-
export declare const
|
|
2079
|
+
export declare const runSyncExit: <A, E>(effect: Micro<A, E>) => MicroExit<A, E>;
|
|
2008
2080
|
/**
|
|
2009
2081
|
* Attempt to execute the `Micro` effect synchronously and return the success
|
|
2010
2082
|
* value.
|
|
@@ -2025,7 +2097,7 @@ export interface YieldableError extends Pipeable, Inspectable, Readonly<Error> {
|
|
|
2025
2097
|
readonly [SinkTypeId]: Sink.VarianceStruct<never, unknown, never, this, never>;
|
|
2026
2098
|
readonly [ChannelTypeId]: Channel.VarianceStruct<never, unknown, this, unknown, never, unknown, never>;
|
|
2027
2099
|
readonly [TypeId]: Micro.Variance<never, this, never>;
|
|
2028
|
-
readonly [runSymbol]: (env: Env<any>,
|
|
2100
|
+
readonly [runSymbol]: (env: Env<any>, onExit: (exit: MicroExit<never, this>) => void) => void;
|
|
2029
2101
|
[Symbol.iterator](): MicroIterator<Micro<never, this, never>>;
|
|
2030
2102
|
}
|
|
2031
2103
|
/**
|
|
@@ -2059,4 +2131,16 @@ export declare class NoSuchElementException extends NoSuchElementException_base<
|
|
|
2059
2131
|
message?: string | undefined;
|
|
2060
2132
|
}> {
|
|
2061
2133
|
}
|
|
2134
|
+
declare const TimeoutException_base: new <A extends Record<string, any> = {}>(args: Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => YieldableError & {
|
|
2135
|
+
readonly _tag: "TimeoutException";
|
|
2136
|
+
} & Readonly<A>;
|
|
2137
|
+
/**
|
|
2138
|
+
* Represents a checked exception which occurs when a timeout occurs.
|
|
2139
|
+
*
|
|
2140
|
+
* @since 3.4.4
|
|
2141
|
+
* @experimental
|
|
2142
|
+
* @category errors
|
|
2143
|
+
*/
|
|
2144
|
+
export declare class TimeoutException extends TimeoutException_base {
|
|
2145
|
+
}
|
|
2062
2146
|
//# sourceMappingURL=Micro.d.ts.map
|