effect 3.11.0 → 3.11.2
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/DateTime.js +4 -4
- package/dist/cjs/DateTime.js.map +1 -1
- package/dist/cjs/Micro.js +100 -85
- package/dist/cjs/Micro.js.map +1 -1
- package/dist/cjs/Stream.js +33 -10
- package/dist/cjs/Stream.js.map +1 -1
- package/dist/cjs/internal/pool.js +4 -2
- package/dist/cjs/internal/pool.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/dts/DateTime.d.ts +9 -0
- package/dist/dts/DateTime.d.ts.map +1 -1
- package/dist/dts/Micro.d.ts +148 -120
- package/dist/dts/Micro.d.ts.map +1 -1
- package/dist/dts/Stream.d.ts +131 -42
- package/dist/dts/Stream.d.ts.map +1 -1
- package/dist/esm/DateTime.js +4 -4
- package/dist/esm/DateTime.js.map +1 -1
- package/dist/esm/Micro.js +100 -85
- package/dist/esm/Micro.js.map +1 -1
- package/dist/esm/Stream.js +33 -10
- package/dist/esm/Stream.js.map +1 -1
- package/dist/esm/internal/pool.js +4 -2
- package/dist/esm/internal/pool.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/package.json +1 -1
- package/src/DateTime.ts +4 -5
- package/src/Micro.ts +201 -172
- package/src/Stream.ts +131 -42
- package/src/internal/pool.ts +4 -1
- package/src/internal/version.ts +1 -1
package/dist/dts/Micro.d.ts
CHANGED
|
@@ -132,7 +132,15 @@ export declare const MicroCauseTypeId: unique symbol;
|
|
|
132
132
|
*/
|
|
133
133
|
export type MicroCauseTypeId = typeof MicroCauseTypeId;
|
|
134
134
|
/**
|
|
135
|
-
* A
|
|
135
|
+
* A `MicroCause` is a data type that represents the different ways a `Micro` can fail.
|
|
136
|
+
*
|
|
137
|
+
* **Details**
|
|
138
|
+
*
|
|
139
|
+
* `MicroCause` comes in three forms:
|
|
140
|
+
*
|
|
141
|
+
* - `Die`: Indicates an unforeseen defect that wasn't planned for in the system's logic.
|
|
142
|
+
* - `Fail`: Covers anticipated errors that are recognized and typically handled within the application.
|
|
143
|
+
* - `Interrupt`: Signifies an operation that has been purposefully stopped.
|
|
136
144
|
*
|
|
137
145
|
* @since 3.4.6
|
|
138
146
|
* @experimental
|
|
@@ -255,22 +263,22 @@ export declare const causeWithTrace: {
|
|
|
255
263
|
/**
|
|
256
264
|
* @since 3.11.0
|
|
257
265
|
* @experimental
|
|
258
|
-
* @category
|
|
266
|
+
* @category MicroFiber
|
|
259
267
|
*/
|
|
260
|
-
export declare const
|
|
268
|
+
export declare const MicroFiberTypeId: unique symbol;
|
|
261
269
|
/**
|
|
262
270
|
* @since 3.11.0
|
|
263
271
|
* @experimental
|
|
264
|
-
* @category
|
|
272
|
+
* @category MicroFiber
|
|
265
273
|
*/
|
|
266
|
-
export type
|
|
274
|
+
export type MicroFiberTypeId = typeof MicroFiberTypeId;
|
|
267
275
|
/**
|
|
268
276
|
* @since 3.11.0
|
|
269
277
|
* @experimental
|
|
270
|
-
* @category
|
|
278
|
+
* @category MicroFiber
|
|
271
279
|
*/
|
|
272
|
-
export interface
|
|
273
|
-
readonly [
|
|
280
|
+
export interface MicroFiber<out A, out E = never> {
|
|
281
|
+
readonly [MicroFiberTypeId]: MicroFiber.Variance<A, E>;
|
|
274
282
|
readonly currentOpCount: number;
|
|
275
283
|
readonly getRef: <I, A>(ref: Context.Reference<I, A>) => A;
|
|
276
284
|
readonly context: Context.Context<never>;
|
|
@@ -281,27 +289,27 @@ export interface Fiber<out A, out E = never> {
|
|
|
281
289
|
/**
|
|
282
290
|
* @since 3.11.0
|
|
283
291
|
* @experimental
|
|
284
|
-
* @category
|
|
292
|
+
* @category MicroFiber
|
|
285
293
|
*/
|
|
286
|
-
export declare namespace
|
|
294
|
+
export declare namespace MicroFiber {
|
|
287
295
|
/**
|
|
288
296
|
* @since 3.11.0
|
|
289
297
|
* @experimental
|
|
290
|
-
* @category
|
|
298
|
+
* @category MicroFiber
|
|
291
299
|
*/
|
|
292
300
|
interface Variance<out A, out E = never> {
|
|
293
301
|
readonly _A: Covariant<A>;
|
|
294
302
|
readonly _E: Covariant<E>;
|
|
295
303
|
}
|
|
296
304
|
}
|
|
297
|
-
declare class
|
|
305
|
+
declare class MicroFiberImpl<in out A = any, in out E = any> implements MicroFiber<A, E> {
|
|
298
306
|
context: Context.Context<never>;
|
|
299
307
|
interruptible: boolean;
|
|
300
|
-
readonly [
|
|
308
|
+
readonly [MicroFiberTypeId]: MicroFiber.Variance<A, E>;
|
|
301
309
|
readonly _stack: Array<Primitive>;
|
|
302
310
|
readonly _observers: Array<(exit: MicroExit<A, E>) => void>;
|
|
303
311
|
_exit: MicroExit<A, E> | undefined;
|
|
304
|
-
_children: Set<
|
|
312
|
+
_children: Set<MicroFiberImpl<any, any>> | undefined;
|
|
305
313
|
currentOpCount: number;
|
|
306
314
|
constructor(context: Context.Context<never>, interruptible?: boolean);
|
|
307
315
|
getRef<I, A>(ref: Context.Reference<I, A>): A;
|
|
@@ -311,29 +319,35 @@ declare class FiberImpl<in out A = any, in out E = any> implements Fiber<A, E> {
|
|
|
311
319
|
unsafePoll(): MicroExit<A, E> | undefined;
|
|
312
320
|
evaluate(effect: Primitive): void;
|
|
313
321
|
runLoop(effect: Primitive): MicroExit<A, E> | Yield;
|
|
314
|
-
getCont<S extends successCont | failureCont>(symbol: S): (Primitive & Record<S, (value: any, fiber:
|
|
322
|
+
getCont<S extends successCont | failureCont>(symbol: S): (Primitive & Record<S, (value: any, fiber: MicroFiberImpl) => Primitive>) | undefined;
|
|
315
323
|
_yielded: MicroExit<any, any> | (() => void) | undefined;
|
|
316
324
|
yieldWith(value: MicroExit<any, any> | (() => void)): Yield;
|
|
317
|
-
children(): Set<
|
|
325
|
+
children(): Set<MicroFiber<any, any>>;
|
|
318
326
|
}
|
|
319
327
|
/**
|
|
320
328
|
* @since 3.11.0
|
|
321
329
|
* @experimental
|
|
322
|
-
* @category
|
|
330
|
+
* @category MicroFiber
|
|
331
|
+
*/
|
|
332
|
+
export declare const fiberAwait: <A, E>(self: MicroFiber<A, E>) => Micro<MicroExit<A, E>>;
|
|
333
|
+
/**
|
|
334
|
+
* @since 3.11.2
|
|
335
|
+
* @experimental
|
|
336
|
+
* @category MicroFiber
|
|
323
337
|
*/
|
|
324
|
-
export declare const
|
|
338
|
+
export declare const fiberJoin: <A, E>(self: MicroFiber<A, E>) => Micro<A, E>;
|
|
325
339
|
/**
|
|
326
340
|
* @since 3.11.0
|
|
327
341
|
* @experimental
|
|
328
|
-
* @category
|
|
342
|
+
* @category MicroFiber
|
|
329
343
|
*/
|
|
330
|
-
export declare const fiberInterrupt: <A, E>(self:
|
|
344
|
+
export declare const fiberInterrupt: <A, E>(self: MicroFiber<A, E>) => Micro<void>;
|
|
331
345
|
/**
|
|
332
346
|
* @since 3.11.0
|
|
333
347
|
* @experimental
|
|
334
|
-
* @category
|
|
348
|
+
* @category MicroFiber
|
|
335
349
|
*/
|
|
336
|
-
export declare const fiberInterruptAll: <A extends Iterable<
|
|
350
|
+
export declare const fiberInterruptAll: <A extends Iterable<MicroFiber<any, any>>>(fibers: A) => Micro<void>;
|
|
337
351
|
declare const identifier: unique symbol;
|
|
338
352
|
type identifier = typeof identifier;
|
|
339
353
|
declare const evaluate: unique symbol;
|
|
@@ -348,10 +362,10 @@ declare const Yield: unique symbol;
|
|
|
348
362
|
type Yield = typeof Yield;
|
|
349
363
|
interface Primitive {
|
|
350
364
|
readonly [identifier]: string;
|
|
351
|
-
readonly [successCont]: ((value: unknown, fiber:
|
|
352
|
-
readonly [failureCont]: ((cause: MicroCause<unknown>, fiber:
|
|
353
|
-
readonly [ensureCont]: ((fiber:
|
|
354
|
-
[evaluate](fiber:
|
|
365
|
+
readonly [successCont]: ((value: unknown, fiber: MicroFiberImpl) => Primitive | Yield) | undefined;
|
|
366
|
+
readonly [failureCont]: ((cause: MicroCause<unknown>, fiber: MicroFiberImpl) => Primitive | Yield) | undefined;
|
|
367
|
+
readonly [ensureCont]: ((fiber: MicroFiberImpl) => ((value: unknown, fiber: MicroFiberImpl) => Primitive | Yield) | undefined) | undefined;
|
|
368
|
+
[evaluate](fiber: MicroFiberImpl): Primitive | Yield;
|
|
355
369
|
}
|
|
356
370
|
/**
|
|
357
371
|
* Creates a `Micro` effect that will succeed with the specified constant value.
|
|
@@ -370,10 +384,10 @@ export declare const succeed: <A>(value: A) => Micro<A>;
|
|
|
370
384
|
*/
|
|
371
385
|
export declare const failCause: <E>(cause: MicroCause<E>) => Micro<never, E>;
|
|
372
386
|
/**
|
|
373
|
-
* Creates a `Micro` effect that
|
|
387
|
+
* Creates a `Micro` effect that fails with the given error.
|
|
374
388
|
*
|
|
375
|
-
* This
|
|
376
|
-
* type level.
|
|
389
|
+
* This results in a `Fail` variant of the `MicroCause` type, where the error is
|
|
390
|
+
* tracked at the type level.
|
|
377
391
|
*
|
|
378
392
|
* @since 3.4.0
|
|
379
393
|
* @experimental
|
|
@@ -381,10 +395,10 @@ export declare const failCause: <E>(cause: MicroCause<E>) => Micro<never, E>;
|
|
|
381
395
|
*/
|
|
382
396
|
export declare const fail: <E>(error: E) => Micro<never, E>;
|
|
383
397
|
/**
|
|
384
|
-
* Creates a `Micro` effect that
|
|
398
|
+
* Creates a `Micro` effect that succeeds with a lazily evaluated value.
|
|
385
399
|
*
|
|
386
|
-
* If the evaluation of the value throws an error, the effect will fail with
|
|
387
|
-
* `
|
|
400
|
+
* If the evaluation of the value throws an error, the effect will fail with a
|
|
401
|
+
* `Die` variant of the `MicroCause` type.
|
|
388
402
|
*
|
|
389
403
|
* @since 3.4.0
|
|
390
404
|
* @experimental
|
|
@@ -418,7 +432,7 @@ export declare const yieldNowWith: (priority?: number) => Micro<void>;
|
|
|
418
432
|
*/
|
|
419
433
|
export declare const yieldNow: Micro<void>;
|
|
420
434
|
/**
|
|
421
|
-
* Creates a `Micro` effect that will succeed with
|
|
435
|
+
* Creates a `Micro` effect that will succeed with the value wrapped in `Some`.
|
|
422
436
|
*
|
|
423
437
|
* @since 3.4.0
|
|
424
438
|
* @experimental
|
|
@@ -426,7 +440,7 @@ export declare const yieldNow: Micro<void>;
|
|
|
426
440
|
*/
|
|
427
441
|
export declare const succeedSome: <A>(a: A) => Micro<Option.Option<A>>;
|
|
428
442
|
/**
|
|
429
|
-
* Creates a `Micro` effect that
|
|
443
|
+
* Creates a `Micro` effect that succeeds with `None`.
|
|
430
444
|
*
|
|
431
445
|
* @since 3.4.0
|
|
432
446
|
* @experimental
|
|
@@ -444,8 +458,8 @@ export declare const failCauseSync: <E>(evaluate: LazyArg<MicroCause<E>>) => Mic
|
|
|
444
458
|
/**
|
|
445
459
|
* Creates a `Micro` effect that will die with the specified error.
|
|
446
460
|
*
|
|
447
|
-
* This
|
|
448
|
-
* the type level.
|
|
461
|
+
* This results in a `Die` variant of the `MicroCause` type, where the error is
|
|
462
|
+
* not tracked at the type level.
|
|
449
463
|
*
|
|
450
464
|
* @since 3.4.0
|
|
451
465
|
* @experimental
|
|
@@ -455,8 +469,8 @@ export declare const die: (defect: unknown) => Micro<never>;
|
|
|
455
469
|
/**
|
|
456
470
|
* Creates a `Micro` effect that will fail with the lazily evaluated error.
|
|
457
471
|
*
|
|
458
|
-
* This
|
|
459
|
-
* type level.
|
|
472
|
+
* This results in a `Fail` variant of the `MicroCause` type, where the error is
|
|
473
|
+
* tracked at the type level.
|
|
460
474
|
*
|
|
461
475
|
* @since 3.4.6
|
|
462
476
|
* @experimental
|
|
@@ -502,9 +516,6 @@ export {
|
|
|
502
516
|
* The `Micro` equivalent of a try / catch block, which allows you to map
|
|
503
517
|
* thrown errors to a specific error type.
|
|
504
518
|
*
|
|
505
|
-
* @since 3.4.0
|
|
506
|
-
* @experimental
|
|
507
|
-
* @category constructors
|
|
508
519
|
* @example
|
|
509
520
|
* ```ts
|
|
510
521
|
* import { Micro } from "effect"
|
|
@@ -514,11 +525,17 @@ export {
|
|
|
514
525
|
* catch: (cause) => new Error("caught", { cause })
|
|
515
526
|
* })
|
|
516
527
|
* ```
|
|
528
|
+
*
|
|
529
|
+
* @since 3.4.0
|
|
530
|
+
* @experimental
|
|
531
|
+
* @category constructors
|
|
517
532
|
*/
|
|
518
533
|
try_ as try };
|
|
519
534
|
/**
|
|
520
|
-
* Wrap a `Promise` into a `Micro` effect.
|
|
521
|
-
*
|
|
535
|
+
* Wrap a `Promise` into a `Micro` effect.
|
|
536
|
+
*
|
|
537
|
+
* Any errors will result in a `Die` variant of the `MicroCause` type, where the
|
|
538
|
+
* error is not tracked at the type level.
|
|
522
539
|
*
|
|
523
540
|
* @since 3.4.0
|
|
524
541
|
* @experimental
|
|
@@ -529,9 +546,6 @@ export declare const promise: <A>(evaluate: (signal: AbortSignal) => PromiseLike
|
|
|
529
546
|
* Wrap a `Promise` into a `Micro` effect. Any errors will be caught and
|
|
530
547
|
* converted into a specific error type.
|
|
531
548
|
*
|
|
532
|
-
* @since 3.4.0
|
|
533
|
-
* @experimental
|
|
534
|
-
* @category constructors
|
|
535
549
|
* @example
|
|
536
550
|
* ```ts
|
|
537
551
|
* import { Micro } from "effect"
|
|
@@ -541,19 +555,23 @@ export declare const promise: <A>(evaluate: (signal: AbortSignal) => PromiseLike
|
|
|
541
555
|
* catch: (cause) => new Error("caught", { cause })
|
|
542
556
|
* })
|
|
543
557
|
* ```
|
|
558
|
+
*
|
|
559
|
+
* @since 3.4.0
|
|
560
|
+
* @experimental
|
|
561
|
+
* @category constructors
|
|
544
562
|
*/
|
|
545
563
|
export declare const tryPromise: <A, E>(options: {
|
|
546
564
|
readonly try: (signal: AbortSignal) => PromiseLike<A>;
|
|
547
565
|
readonly catch: (error: unknown) => E;
|
|
548
566
|
}) => Micro<A, E>;
|
|
549
567
|
/**
|
|
550
|
-
* Create a `Micro` effect using the current `
|
|
568
|
+
* Create a `Micro` effect using the current `MicroFiber`.
|
|
551
569
|
*
|
|
552
570
|
* @since 3.4.0
|
|
553
571
|
* @experimental
|
|
554
572
|
* @category constructors
|
|
555
573
|
*/
|
|
556
|
-
export declare const
|
|
574
|
+
export declare const withMicroFiber: <A, E = never, R = never>(evaluate: (fiber: MicroFiberImpl<A, E>) => Micro<A, E, R>) => Micro<A, E, R>;
|
|
557
575
|
/**
|
|
558
576
|
* Flush any yielded effects that are waiting to be executed.
|
|
559
577
|
*
|
|
@@ -618,7 +636,7 @@ export declare const as: {
|
|
|
618
636
|
<A, E, R, B>(self: Micro<A, E, R>, value: B): Micro<B, E, R>;
|
|
619
637
|
};
|
|
620
638
|
/**
|
|
621
|
-
* Wrap the success value of this `Micro` effect in
|
|
639
|
+
* Wrap the success value of this `Micro` effect in a `Some`.
|
|
622
640
|
*
|
|
623
641
|
* @since 3.4.0
|
|
624
642
|
* @experimental
|
|
@@ -634,11 +652,11 @@ export declare const asSome: <A, E, R>(self: Micro<A, E, R>) => Micro<Option.Opt
|
|
|
634
652
|
*/
|
|
635
653
|
export declare const flip: <A, E, R>(self: Micro<A, E, R>) => Micro<E, A, R>;
|
|
636
654
|
/**
|
|
637
|
-
* A more flexible version of `flatMap
|
|
638
|
-
*
|
|
655
|
+
* A more flexible version of `flatMap` that combines `map` and `flatMap` into a
|
|
656
|
+
* single API.
|
|
639
657
|
*
|
|
640
|
-
* It also
|
|
641
|
-
*
|
|
658
|
+
* It also lets you directly pass a `Micro` effect, which will be executed after
|
|
659
|
+
* the current effect.
|
|
642
660
|
*
|
|
643
661
|
* @since 3.4.0
|
|
644
662
|
* @experimental
|
|
@@ -646,11 +664,11 @@ export declare const flip: <A, E, R>(self: Micro<A, E, R>) => Micro<E, A, R>;
|
|
|
646
664
|
*/
|
|
647
665
|
export declare const andThen: {
|
|
648
666
|
/**
|
|
649
|
-
* A more flexible version of `flatMap
|
|
650
|
-
*
|
|
667
|
+
* A more flexible version of `flatMap` that combines `map` and `flatMap` into a
|
|
668
|
+
* single API.
|
|
651
669
|
*
|
|
652
|
-
* It also
|
|
653
|
-
*
|
|
670
|
+
* It also lets you directly pass a `Micro` effect, which will be executed after
|
|
671
|
+
* the current effect.
|
|
654
672
|
*
|
|
655
673
|
* @since 3.4.0
|
|
656
674
|
* @experimental
|
|
@@ -658,11 +676,11 @@ export declare const andThen: {
|
|
|
658
676
|
*/
|
|
659
677
|
<A, X>(f: (a: A) => X): <E, R>(self: Micro<A, E, R>) => [X] extends [Micro<infer A1, infer E1, infer R1>] ? Micro<A1, E | E1, R | R1> : Micro<X, E, R>;
|
|
660
678
|
/**
|
|
661
|
-
* A more flexible version of `flatMap
|
|
662
|
-
*
|
|
679
|
+
* A more flexible version of `flatMap` that combines `map` and `flatMap` into a
|
|
680
|
+
* single API.
|
|
663
681
|
*
|
|
664
|
-
* It also
|
|
665
|
-
*
|
|
682
|
+
* It also lets you directly pass a `Micro` effect, which will be executed after
|
|
683
|
+
* the current effect.
|
|
666
684
|
*
|
|
667
685
|
* @since 3.4.0
|
|
668
686
|
* @experimental
|
|
@@ -670,11 +688,11 @@ export declare const andThen: {
|
|
|
670
688
|
*/
|
|
671
689
|
<X>(f: NotFunction<X>): <A, E, R>(self: Micro<A, E, R>) => [X] extends [Micro<infer A1, infer E1, infer R1>] ? Micro<A1, E | E1, R | R1> : Micro<X, E, R>;
|
|
672
690
|
/**
|
|
673
|
-
* A more flexible version of `flatMap
|
|
674
|
-
*
|
|
691
|
+
* A more flexible version of `flatMap` that combines `map` and `flatMap` into a
|
|
692
|
+
* single API.
|
|
675
693
|
*
|
|
676
|
-
* It also
|
|
677
|
-
*
|
|
694
|
+
* It also lets you directly pass a `Micro` effect, which will be executed after
|
|
695
|
+
* the current effect.
|
|
678
696
|
*
|
|
679
697
|
* @since 3.4.0
|
|
680
698
|
* @experimental
|
|
@@ -682,11 +700,11 @@ export declare const andThen: {
|
|
|
682
700
|
*/
|
|
683
701
|
<A, E, R, X>(self: Micro<A, E, R>, f: (a: A) => X): [X] extends [Micro<infer A1, infer E1, infer R1>] ? Micro<A1, E | E1, R | R1> : Micro<X, E, R>;
|
|
684
702
|
/**
|
|
685
|
-
* A more flexible version of `flatMap
|
|
686
|
-
*
|
|
703
|
+
* A more flexible version of `flatMap` that combines `map` and `flatMap` into a
|
|
704
|
+
* single API.
|
|
687
705
|
*
|
|
688
|
-
* It also
|
|
689
|
-
*
|
|
706
|
+
* It also lets you directly pass a `Micro` effect, which will be executed after
|
|
707
|
+
* the current effect.
|
|
690
708
|
*
|
|
691
709
|
* @since 3.4.0
|
|
692
710
|
* @experimental
|
|
@@ -782,7 +800,7 @@ export declare const raceAll: <Eff extends Micro<any, any, any>>(all: Iterable<E
|
|
|
782
800
|
/**
|
|
783
801
|
* Returns an effect that races all the specified effects,
|
|
784
802
|
* yielding the value of the first effect to succeed or fail. Losers of
|
|
785
|
-
* the race will be interrupted immediately
|
|
803
|
+
* the race will be interrupted immediately.
|
|
786
804
|
*
|
|
787
805
|
* @since 3.4.0
|
|
788
806
|
* @experimental
|
|
@@ -791,7 +809,7 @@ export declare const raceAll: <Eff extends Micro<any, any, any>>(all: Iterable<E
|
|
|
791
809
|
export declare const raceAllFirst: <Eff extends Micro<any, any, any>>(all: Iterable<Eff>) => Micro<Micro.Success<Eff>, Micro.Error<Eff>, Micro.Context<Eff>>;
|
|
792
810
|
/**
|
|
793
811
|
* Returns an effect that races two effects, yielding the value of the first
|
|
794
|
-
* effect to succeed. Losers of the race will be interrupted immediately
|
|
812
|
+
* effect to succeed. Losers of the race will be interrupted immediately.
|
|
795
813
|
*
|
|
796
814
|
* @since 3.4.0
|
|
797
815
|
* @experimental
|
|
@@ -800,7 +818,7 @@ export declare const raceAllFirst: <Eff extends Micro<any, any, any>>(all: Itera
|
|
|
800
818
|
export declare const race: {
|
|
801
819
|
/**
|
|
802
820
|
* Returns an effect that races two effects, yielding the value of the first
|
|
803
|
-
* effect to succeed. Losers of the race will be interrupted immediately
|
|
821
|
+
* effect to succeed. Losers of the race will be interrupted immediately.
|
|
804
822
|
*
|
|
805
823
|
* @since 3.4.0
|
|
806
824
|
* @experimental
|
|
@@ -809,7 +827,7 @@ export declare const race: {
|
|
|
809
827
|
<A2, E2, R2>(that: Micro<A2, E2, R2>): <A, E, R>(self: Micro<A, E, R>) => Micro<A | A2, E | E2, R | R2>;
|
|
810
828
|
/**
|
|
811
829
|
* Returns an effect that races two effects, yielding the value of the first
|
|
812
|
-
* effect to succeed. Losers of the race will be interrupted immediately
|
|
830
|
+
* effect to succeed. Losers of the race will be interrupted immediately.
|
|
813
831
|
*
|
|
814
832
|
* @since 3.4.0
|
|
815
833
|
* @experimental
|
|
@@ -819,7 +837,7 @@ export declare const race: {
|
|
|
819
837
|
};
|
|
820
838
|
/**
|
|
821
839
|
* Returns an effect that races two effects, yielding the value of the first
|
|
822
|
-
* effect to succeed *or* fail. Losers of the race will be interrupted immediately
|
|
840
|
+
* effect to succeed *or* fail. Losers of the race will be interrupted immediately.
|
|
823
841
|
*
|
|
824
842
|
* @since 3.4.0
|
|
825
843
|
* @experimental
|
|
@@ -828,7 +846,7 @@ export declare const race: {
|
|
|
828
846
|
export declare const raceFirst: {
|
|
829
847
|
/**
|
|
830
848
|
* Returns an effect that races two effects, yielding the value of the first
|
|
831
|
-
* effect to succeed *or* fail. Losers of the race will be interrupted immediately
|
|
849
|
+
* effect to succeed *or* fail. Losers of the race will be interrupted immediately.
|
|
832
850
|
*
|
|
833
851
|
* @since 3.4.0
|
|
834
852
|
* @experimental
|
|
@@ -837,7 +855,7 @@ export declare const raceFirst: {
|
|
|
837
855
|
<A2, E2, R2>(that: Micro<A2, E2, R2>): <A, E, R>(self: Micro<A, E, R>) => Micro<A | A2, E | E2, R | R2>;
|
|
838
856
|
/**
|
|
839
857
|
* Returns an effect that races two effects, yielding the value of the first
|
|
840
|
-
* effect to succeed *or* fail. Losers of the race will be interrupted immediately
|
|
858
|
+
* effect to succeed *or* fail. Losers of the race will be interrupted immediately.
|
|
841
859
|
*
|
|
842
860
|
* @since 3.4.0
|
|
843
861
|
* @experimental
|
|
@@ -910,10 +928,9 @@ export declare const map: {
|
|
|
910
928
|
<A, E, R, B>(self: Micro<A, E, R>, f: (a: A) => B): Micro<B, E, R>;
|
|
911
929
|
};
|
|
912
930
|
/**
|
|
913
|
-
* The MicroExit type is
|
|
914
|
-
*
|
|
915
|
-
*
|
|
916
|
-
* It uses the `Either` data type to represent the success and failure cases.
|
|
931
|
+
* The `MicroExit` type is used to represent the result of a `Micro` computation. It
|
|
932
|
+
* can either be successful, containing a value of type `A`, or it can fail,
|
|
933
|
+
* containing an error of type `E` wrapped in a `MicroCause`.
|
|
917
934
|
*
|
|
918
935
|
* @since 3.4.6
|
|
919
936
|
* @experimental
|
|
@@ -1044,7 +1061,7 @@ export declare const exitVoidAll: <I extends Iterable<MicroExit<any, any>>>(exit
|
|
|
1044
1061
|
*/
|
|
1045
1062
|
export interface MicroScheduler {
|
|
1046
1063
|
readonly scheduleTask: (task: () => void, priority: number) => void;
|
|
1047
|
-
readonly shouldYield: (fiber:
|
|
1064
|
+
readonly shouldYield: (fiber: MicroFiber<unknown, unknown>) => boolean;
|
|
1048
1065
|
readonly flush: () => void;
|
|
1049
1066
|
}
|
|
1050
1067
|
/**
|
|
@@ -1070,7 +1087,7 @@ export declare class MicroSchedulerDefault implements MicroScheduler {
|
|
|
1070
1087
|
/**
|
|
1071
1088
|
* @since 3.5.9
|
|
1072
1089
|
*/
|
|
1073
|
-
shouldYield(fiber:
|
|
1090
|
+
shouldYield(fiber: MicroFiber<unknown, unknown>): boolean;
|
|
1074
1091
|
/**
|
|
1075
1092
|
* @since 3.5.9
|
|
1076
1093
|
*/
|
|
@@ -1293,10 +1310,8 @@ export declare class CurrentScheduler extends CurrentScheduler_base {
|
|
|
1293
1310
|
* If you have a `Micro` that uses `concurrency: "inherit"`, you can use this
|
|
1294
1311
|
* api to control the concurrency of that `Micro` when it is run.
|
|
1295
1312
|
*
|
|
1296
|
-
* @since 3.4.0
|
|
1297
|
-
* @experimental
|
|
1298
|
-
* @category environment refs
|
|
1299
1313
|
* @example
|
|
1314
|
+
* ```ts
|
|
1300
1315
|
* import * as Micro from "effect/Micro"
|
|
1301
1316
|
*
|
|
1302
1317
|
* Micro.forEach([1, 2, 3], (n) => Micro.succeed(n), {
|
|
@@ -1304,16 +1319,19 @@ export declare class CurrentScheduler extends CurrentScheduler_base {
|
|
|
1304
1319
|
* }).pipe(
|
|
1305
1320
|
* Micro.withConcurrency(2) // use a concurrency of 2
|
|
1306
1321
|
* )
|
|
1322
|
+
* ```
|
|
1323
|
+
*
|
|
1324
|
+
* @since 3.4.0
|
|
1325
|
+
* @experimental
|
|
1326
|
+
* @category environment refs
|
|
1307
1327
|
*/
|
|
1308
1328
|
export declare const withConcurrency: {
|
|
1309
1329
|
/**
|
|
1310
1330
|
* If you have a `Micro` that uses `concurrency: "inherit"`, you can use this
|
|
1311
1331
|
* api to control the concurrency of that `Micro` when it is run.
|
|
1312
1332
|
*
|
|
1313
|
-
* @since 3.4.0
|
|
1314
|
-
* @experimental
|
|
1315
|
-
* @category environment refs
|
|
1316
1333
|
* @example
|
|
1334
|
+
* ```ts
|
|
1317
1335
|
* import * as Micro from "effect/Micro"
|
|
1318
1336
|
*
|
|
1319
1337
|
* Micro.forEach([1, 2, 3], (n) => Micro.succeed(n), {
|
|
@@ -1321,16 +1339,19 @@ export declare const withConcurrency: {
|
|
|
1321
1339
|
* }).pipe(
|
|
1322
1340
|
* Micro.withConcurrency(2) // use a concurrency of 2
|
|
1323
1341
|
* )
|
|
1342
|
+
* ```
|
|
1343
|
+
*
|
|
1344
|
+
* @since 3.4.0
|
|
1345
|
+
* @experimental
|
|
1346
|
+
* @category environment refs
|
|
1324
1347
|
*/
|
|
1325
1348
|
(concurrency: "unbounded" | number): <A, E, R>(self: Micro<A, E, R>) => Micro<A, E, R>;
|
|
1326
1349
|
/**
|
|
1327
1350
|
* If you have a `Micro` that uses `concurrency: "inherit"`, you can use this
|
|
1328
1351
|
* api to control the concurrency of that `Micro` when it is run.
|
|
1329
1352
|
*
|
|
1330
|
-
* @since 3.4.0
|
|
1331
|
-
* @experimental
|
|
1332
|
-
* @category environment refs
|
|
1333
1353
|
* @example
|
|
1354
|
+
* ```ts
|
|
1334
1355
|
* import * as Micro from "effect/Micro"
|
|
1335
1356
|
*
|
|
1336
1357
|
* Micro.forEach([1, 2, 3], (n) => Micro.succeed(n), {
|
|
@@ -1338,6 +1359,11 @@ export declare const withConcurrency: {
|
|
|
1338
1359
|
* }).pipe(
|
|
1339
1360
|
* Micro.withConcurrency(2) // use a concurrency of 2
|
|
1340
1361
|
* )
|
|
1362
|
+
* ```
|
|
1363
|
+
*
|
|
1364
|
+
* @since 3.4.0
|
|
1365
|
+
* @experimental
|
|
1366
|
+
* @category environment refs
|
|
1341
1367
|
*/
|
|
1342
1368
|
<A, E, R>(self: Micro<A, E, R>, concurrency: "unbounded" | number): Micro<A, E, R>;
|
|
1343
1369
|
};
|
|
@@ -1974,7 +2000,7 @@ export declare const catchCauseIf: {
|
|
|
1974
2000
|
/**
|
|
1975
2001
|
* Catch the error of the given `Micro` effect, allowing you to recover from it.
|
|
1976
2002
|
*
|
|
1977
|
-
* It only catches expected
|
|
2003
|
+
* It only catches expected errors.
|
|
1978
2004
|
*
|
|
1979
2005
|
* @since 3.4.6
|
|
1980
2006
|
* @experimental
|
|
@@ -1984,7 +2010,7 @@ export declare const catchAll: {
|
|
|
1984
2010
|
/**
|
|
1985
2011
|
* Catch the error of the given `Micro` effect, allowing you to recover from it.
|
|
1986
2012
|
*
|
|
1987
|
-
* It only catches expected
|
|
2013
|
+
* It only catches expected errors.
|
|
1988
2014
|
*
|
|
1989
2015
|
* @since 3.4.6
|
|
1990
2016
|
* @experimental
|
|
@@ -1994,7 +2020,7 @@ export declare const catchAll: {
|
|
|
1994
2020
|
/**
|
|
1995
2021
|
* Catch the error of the given `Micro` effect, allowing you to recover from it.
|
|
1996
2022
|
*
|
|
1997
|
-
* It only catches expected
|
|
2023
|
+
* It only catches expected errors.
|
|
1998
2024
|
*
|
|
1999
2025
|
* @since 3.4.6
|
|
2000
2026
|
* @experimental
|
|
@@ -2965,9 +2991,6 @@ export declare const interruptible: <A, E, R>(self: Micro<A, E, R>) => Micro<A,
|
|
|
2965
2991
|
* You can use the `restore` function to restore a `Micro` effect to the
|
|
2966
2992
|
* interruptibility state before the `uninterruptibleMask` was applied.
|
|
2967
2993
|
*
|
|
2968
|
-
* @since 3.4.0
|
|
2969
|
-
* @experimental
|
|
2970
|
-
* @category interruption
|
|
2971
2994
|
* @example
|
|
2972
2995
|
* ```ts
|
|
2973
2996
|
* import * as Micro from "effect/Micro"
|
|
@@ -2978,6 +3001,10 @@ export declare const interruptible: <A, E, R>(self: Micro<A, E, R>) => Micro<A,
|
|
|
2978
3001
|
* )
|
|
2979
3002
|
* )
|
|
2980
3003
|
* ```
|
|
3004
|
+
*
|
|
3005
|
+
* @since 3.4.0
|
|
3006
|
+
* @experimental
|
|
3007
|
+
* @category interruption
|
|
2981
3008
|
*/
|
|
2982
3009
|
export declare const uninterruptibleMask: <A, E, R>(f: (restore: <A_1, E_1, R_1>(effect: Micro<A_1, E_1, R_1>) => Micro<A_1, E_1, R_1>) => Micro<A, E, R>) => Micro<A, E, R>;
|
|
2983
3010
|
/**
|
|
@@ -3210,82 +3237,79 @@ export {
|
|
|
3210
3237
|
*/
|
|
3211
3238
|
let_ as let };
|
|
3212
3239
|
/**
|
|
3213
|
-
* Run the `Micro` effect in a new `
|
|
3240
|
+
* Run the `Micro` effect in a new `MicroFiber` that can be awaited, joined, or
|
|
3214
3241
|
* aborted.
|
|
3215
3242
|
*
|
|
3216
3243
|
* When the parent `Micro` finishes, this `Micro` will be aborted.
|
|
3217
3244
|
*
|
|
3218
3245
|
* @since 3.4.0
|
|
3219
3246
|
* @experimental
|
|
3220
|
-
* @category
|
|
3247
|
+
* @category fiber & forking
|
|
3221
3248
|
*/
|
|
3222
|
-
export declare const fork: <A, E, R>(self: Micro<A, E, R>) => Micro<
|
|
3249
|
+
export declare const fork: <A, E, R>(self: Micro<A, E, R>) => Micro<MicroFiber<A, E>, never, R>;
|
|
3223
3250
|
/**
|
|
3224
|
-
* Run the `Micro` effect in a new `
|
|
3251
|
+
* Run the `Micro` effect in a new `MicroFiber` that can be awaited, joined, or
|
|
3225
3252
|
* aborted.
|
|
3226
3253
|
*
|
|
3227
3254
|
* It will not be aborted when the parent `Micro` finishes.
|
|
3228
3255
|
*
|
|
3229
3256
|
* @since 3.4.0
|
|
3230
3257
|
* @experimental
|
|
3231
|
-
* @category
|
|
3258
|
+
* @category fiber & forking
|
|
3232
3259
|
*/
|
|
3233
|
-
export declare const forkDaemon: <A, E, R>(self: Micro<A, E, R>) => Micro<
|
|
3260
|
+
export declare const forkDaemon: <A, E, R>(self: Micro<A, E, R>) => Micro<MicroFiber<A, E>, never, R>;
|
|
3234
3261
|
/**
|
|
3235
|
-
* Run the `Micro` effect in a new `
|
|
3262
|
+
* Run the `Micro` effect in a new `MicroFiber` that can be awaited, joined, or
|
|
3236
3263
|
* aborted.
|
|
3237
3264
|
*
|
|
3238
3265
|
* The lifetime of the handle will be attached to the provided `MicroScope`.
|
|
3239
3266
|
*
|
|
3240
3267
|
* @since 3.4.0
|
|
3241
3268
|
* @experimental
|
|
3242
|
-
* @category
|
|
3269
|
+
* @category fiber & forking
|
|
3243
3270
|
*/
|
|
3244
3271
|
export declare const forkIn: {
|
|
3245
3272
|
/**
|
|
3246
|
-
* Run the `Micro` effect in a new `
|
|
3273
|
+
* Run the `Micro` effect in a new `MicroFiber` that can be awaited, joined, or
|
|
3247
3274
|
* aborted.
|
|
3248
3275
|
*
|
|
3249
3276
|
* The lifetime of the handle will be attached to the provided `MicroScope`.
|
|
3250
3277
|
*
|
|
3251
3278
|
* @since 3.4.0
|
|
3252
3279
|
* @experimental
|
|
3253
|
-
* @category
|
|
3280
|
+
* @category fiber & forking
|
|
3254
3281
|
*/
|
|
3255
|
-
(scope: MicroScope): <A, E, R>(self: Micro<A, E, R>) => Micro<
|
|
3282
|
+
(scope: MicroScope): <A, E, R>(self: Micro<A, E, R>) => Micro<MicroFiber<A, E>, never, R>;
|
|
3256
3283
|
/**
|
|
3257
|
-
* Run the `Micro` effect in a new `
|
|
3284
|
+
* Run the `Micro` effect in a new `MicroFiber` that can be awaited, joined, or
|
|
3258
3285
|
* aborted.
|
|
3259
3286
|
*
|
|
3260
3287
|
* The lifetime of the handle will be attached to the provided `MicroScope`.
|
|
3261
3288
|
*
|
|
3262
3289
|
* @since 3.4.0
|
|
3263
3290
|
* @experimental
|
|
3264
|
-
* @category
|
|
3291
|
+
* @category fiber & forking
|
|
3265
3292
|
*/
|
|
3266
|
-
<A, E, R>(self: Micro<A, E, R>, scope: MicroScope): Micro<
|
|
3293
|
+
<A, E, R>(self: Micro<A, E, R>, scope: MicroScope): Micro<MicroFiber<A, E>, never, R>;
|
|
3267
3294
|
};
|
|
3268
3295
|
/**
|
|
3269
|
-
* Run the `Micro` effect in a new `
|
|
3296
|
+
* Run the `Micro` effect in a new `MicroFiber` that can be awaited, joined, or
|
|
3270
3297
|
* aborted.
|
|
3271
3298
|
*
|
|
3272
3299
|
* The lifetime of the handle will be attached to the current `MicroScope`.
|
|
3273
3300
|
*
|
|
3274
3301
|
* @since 3.4.0
|
|
3275
3302
|
* @experimental
|
|
3276
|
-
* @category
|
|
3303
|
+
* @category fiber & forking
|
|
3277
3304
|
*/
|
|
3278
|
-
export declare const forkScoped: <A, E, R>(self: Micro<A, E, R>) => Micro<
|
|
3305
|
+
export declare const forkScoped: <A, E, R>(self: Micro<A, E, R>) => Micro<MicroFiber<A, E>, never, R | MicroScope>;
|
|
3279
3306
|
/**
|
|
3280
|
-
* Execute the `Micro` effect and return a `
|
|
3307
|
+
* Execute the `Micro` effect and return a `MicroFiber` that can be awaited, joined,
|
|
3281
3308
|
* or aborted.
|
|
3282
3309
|
*
|
|
3283
3310
|
* You can listen for the result by adding an observer using the handle's
|
|
3284
3311
|
* `addObserver` method.
|
|
3285
3312
|
*
|
|
3286
|
-
* @since 3.4.0
|
|
3287
|
-
* @experimental
|
|
3288
|
-
* @category execution
|
|
3289
3313
|
* @example
|
|
3290
3314
|
* ```ts
|
|
3291
3315
|
* import * as Micro from "effect/Micro"
|
|
@@ -3299,11 +3323,15 @@ export declare const forkScoped: <A, E, R>(self: Micro<A, E, R>) => Micro<Fiber<
|
|
|
3299
3323
|
* console.log(exit)
|
|
3300
3324
|
* })
|
|
3301
3325
|
* ```
|
|
3326
|
+
*
|
|
3327
|
+
* @since 3.4.0
|
|
3328
|
+
* @experimental
|
|
3329
|
+
* @category execution
|
|
3302
3330
|
*/
|
|
3303
3331
|
export declare const runFork: <A, E>(effect: Micro<A, E>, options?: {
|
|
3304
3332
|
readonly signal?: AbortSignal | undefined;
|
|
3305
3333
|
readonly scheduler?: MicroScheduler | undefined;
|
|
3306
|
-
} | undefined) =>
|
|
3334
|
+
} | undefined) => MicroFiberImpl<A, E>;
|
|
3307
3335
|
/**
|
|
3308
3336
|
* Execute the `Micro` effect and return a `Promise` that resolves with the
|
|
3309
3337
|
* `MicroExit` of the computation.
|
|
@@ -3332,7 +3360,7 @@ export declare const runPromise: <A, E>(effect: Micro<A, E>, options?: {
|
|
|
3332
3360
|
* Attempt to execute the `Micro` effect synchronously and return the `MicroExit`.
|
|
3333
3361
|
*
|
|
3334
3362
|
* If any asynchronous effects are encountered, the function will return a
|
|
3335
|
-
* `CauseDie` containing the `
|
|
3363
|
+
* `CauseDie` containing the `MicroFiber`.
|
|
3336
3364
|
*
|
|
3337
3365
|
* @since 3.4.6
|
|
3338
3366
|
* @experimental
|