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/esm/DateTime.js
CHANGED
|
@@ -597,10 +597,10 @@ export const setPartsUtc = Internal.setPartsUtc;
|
|
|
597
597
|
// =============================================================================
|
|
598
598
|
// current time zone
|
|
599
599
|
// =============================================================================
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
600
|
+
/**
|
|
601
|
+
* @since 3.11.0
|
|
602
|
+
* @category current time zone
|
|
603
|
+
*/
|
|
604
604
|
export class CurrentTimeZone extends /*#__PURE__*/Context.Tag("effect/DateTime/CurrentTimeZone")() {}
|
|
605
605
|
/**
|
|
606
606
|
* Set the time zone of a `DateTime` to the current time zone, which is
|
package/dist/esm/DateTime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTime.js","names":["Context","Effect","dual","Internal","Layer","TypeId","TimeZoneTypeId","isDateTime","isTimeZone","isTimeZoneOffset","isTimeZoneNamed","isUtc","isZoned","Equivalence","Order","clamp","unsafeFromDate","unsafeMake","unsafeMakeZoned","makeZoned","make","makeZonedFromString","now","unsafeNow","setZone","setZoneOffset","zoneUnsafeMakeNamed","zoneMakeOffset","zoneMakeNamed","zoneMakeNamedEffect","zoneMakeLocal","zoneFromString","zoneToString","setZoneNamed","unsafeSetZoneNamed","distance","distanceDurationEither","distanceDuration","min","max","greaterThan","greaterThanOrEqualTo","lessThan","lessThanOrEqualTo","between","isFuture","unsafeIsFuture","isPast","unsafeIsPast","toDateUtc","toDate","zonedOffset","zonedOffsetIso","toEpochMillis","removeTime","toParts","toPartsUtc","getPartUtc","getPart","setParts","setPartsUtc","CurrentTimeZone","Tag","setZoneCurrent","self","map","zone","withCurrentZone","effect","provideService","withCurrentZoneLocal","provideServiceEffect","sync","withCurrentZoneOffset","offset","withCurrentZoneNamed","nowInCurrentZone","flatMap","mutate","mutateUtc","mapEpochMillis","withDate","withDateUtc","match","addDuration","subtractDuration","add","subtract","startOf","endOf","nearest","format","formatLocal","formatUtc","formatIntl","formatIso","formatIsoDate","formatIsoDateUtc","formatIsoOffset","formatIsoZoned","layerCurrentZone","succeed","layerCurrentZoneOffset","layerCurrentZoneNamed","zoneId","layerCurrentZoneLocal"],"sources":["../../src/DateTime.ts"],"sourcesContent":[null],"mappings":"AAIA,OAAO,KAAKA,OAAO,MAAM,cAAc;AAEvC,OAAO,KAAKC,MAAM,MAAM,aAAa;AAGrC,SAASC,IAAI,QAAsB,eAAe;AAElD,OAAO,KAAKC,QAAQ,MAAM,wBAAwB;AAClD,OAAO,KAAKC,KAAK,MAAM,YAAY;AAKnC;;;;AAIA,OAA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GAA4BnD,QAAQ,CAACmD,UAAU;AAEtE;AACA;AACA;AAEA;;;;;;;;AAQA,OAAO,MAAMC,OAAO,GAAkDpD,QAAQ,CAACoD,OAAO;AAEtF;;;;;;;;AAQA,OAAO,MAAMC,UAAU,GAAkDrD,QAAQ,CAACqD,UAAU;AAE5F;;;;;;;;;;;;;;;;AAgBA,OAAO,MAAMC,UAAU,GAmCnBtD,QAAQ,CAACsD,UAAU;AAEvB;;;;;;;;;;;;;;;;AAgBA,OAAO,MAAMC,OAAO,GAmChBvD,QAAQ,CAACuD,OAAO;AAEpB;;;;;;;;AAQA,OAAO,MAAMC,QAAQ,GAmBjBxD,QAAQ,CAACwD,QAAQ;AAErB;;;;;;AAMA,OAAO,MAAMC,WAAW,GAepBzD,QAAQ,CAACyD,WAAW;AAExB;AACA;AACA;AAEA
|
|
1
|
+
{"version":3,"file":"DateTime.js","names":["Context","Effect","dual","Internal","Layer","TypeId","TimeZoneTypeId","isDateTime","isTimeZone","isTimeZoneOffset","isTimeZoneNamed","isUtc","isZoned","Equivalence","Order","clamp","unsafeFromDate","unsafeMake","unsafeMakeZoned","makeZoned","make","makeZonedFromString","now","unsafeNow","setZone","setZoneOffset","zoneUnsafeMakeNamed","zoneMakeOffset","zoneMakeNamed","zoneMakeNamedEffect","zoneMakeLocal","zoneFromString","zoneToString","setZoneNamed","unsafeSetZoneNamed","distance","distanceDurationEither","distanceDuration","min","max","greaterThan","greaterThanOrEqualTo","lessThan","lessThanOrEqualTo","between","isFuture","unsafeIsFuture","isPast","unsafeIsPast","toDateUtc","toDate","zonedOffset","zonedOffsetIso","toEpochMillis","removeTime","toParts","toPartsUtc","getPartUtc","getPart","setParts","setPartsUtc","CurrentTimeZone","Tag","setZoneCurrent","self","map","zone","withCurrentZone","effect","provideService","withCurrentZoneLocal","provideServiceEffect","sync","withCurrentZoneOffset","offset","withCurrentZoneNamed","nowInCurrentZone","flatMap","mutate","mutateUtc","mapEpochMillis","withDate","withDateUtc","match","addDuration","subtractDuration","add","subtract","startOf","endOf","nearest","format","formatLocal","formatUtc","formatIntl","formatIso","formatIsoDate","formatIsoDateUtc","formatIsoOffset","formatIsoZoned","layerCurrentZone","succeed","layerCurrentZoneOffset","layerCurrentZoneNamed","zoneId","layerCurrentZoneLocal"],"sources":["../../src/DateTime.ts"],"sourcesContent":[null],"mappings":"AAIA,OAAO,KAAKA,OAAO,MAAM,cAAc;AAEvC,OAAO,KAAKC,MAAM,MAAM,aAAa;AAGrC,SAASC,IAAI,QAAsB,eAAe;AAElD,OAAO,KAAKC,QAAQ,MAAM,wBAAwB;AAClD,OAAO,KAAKC,KAAK,MAAM,YAAY;AAKnC;;;;AAIA,OAAO,MAAMC,MAAM,GAAkBF,QAAQ,CAACE,MAAM;AAoJpD;;;;AAIA,OAAO,MAAMC,cAAc,GAAkBH,QAAQ,CAACG,cAAc;AAgDpE;AACA;AACA;AAEA;;;;AAIA,OAAO,MAAMC,UAAU,GAAkCJ,QAAQ,CAACI,UAAU;AAE5E;;;;AAIA,OAAO,MAAMC,UAAU,GAAkCL,QAAQ,CAACK,UAAU;AAE5E;;;;AAIA,OAAO,MAAMC,gBAAgB,GAAyCN,QAAQ,CAACM,gBAAgB;AAE/F;;;;AAIA,OAAO,MAAMC,eAAe,GAAwCP,QAAQ,CAACO,eAAe;AAE5F;;;;AAIA,OAAO,MAAMC,KAAK,GAAoCR,QAAQ,CAACQ,KAAK;AAEpE;;;;AAIA,OAAO,MAAMC,OAAO,GAAsCT,QAAQ,CAACS,OAAO;AAE1E;AACA;AACA;AAEA;;;;AAIA,OAAO,MAAMC,WAAW,GAAsCV,QAAQ,CAACU,WAAW;AAElF;;;;AAIA,OAAO,MAAMC,KAAK,GAA0BX,QAAQ,CAACW,KAAK;AAE1D;;;AAGA,OAAO,MAAMC,KAAK,GASdZ,QAAQ,CAACY,KAAK;AAElB;AACA;AACA;AAEA;;;;;;;;AAQA,OAAO,MAAMC,cAAc,GAAwBb,QAAQ,CAACa,cAAc;AAE1E;;;;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,CAAC8F,gBAAgB;AAErF;;;;;;AAMA,OAAO,MAAMC,eAAe,GAA+B/F,QAAQ,CAAC+F,eAAe;AAEnF;;;;;;;;AAQA,OAAO,MAAMC,cAAc,GAA4BhG,QAAQ,CAACgG,cAAc;AAE9E;;;;;;AAMA,OAAO,MAAMC,gBAAgB,GAAIlC,IAAc,IAAmC9D,KAAK,CAACiG,OAAO,CAACxC,eAAe,EAAEK,IAAI,CAAC;AAEtH;;;;;;AAMA,OAAO,MAAMoC,sBAAsB,GAAI5B,MAAc,IACnDtE,KAAK,CAACiG,OAAO,CAACxC,eAAe,EAAE1D,QAAQ,CAACwB,cAAc,CAAC+C,MAAM,CAAC,CAAC;AAEjE;;;;;;AAMA,OAAO,MAAM6B,qBAAqB,GAChCC,MAAc,IAEdpG,KAAK,CAACgE,MAAM,CAACP,eAAe,EAAE1D,QAAQ,CAAC0B,mBAAmB,CAAC2E,MAAM,CAAC,CAAC;AAErE;;;;;;AAMA,OAAO,MAAMC,qBAAqB,gBAAiCrG,KAAK,CAACoE,IAAI,CAACX,eAAe,EAAE/B,aAAa,CAAC","ignoreList":[]}
|
package/dist/esm/Micro.js
CHANGED
|
@@ -95,7 +95,7 @@ class MicroCauseImpl extends globalThis.Error {
|
|
|
95
95
|
return this.stack;
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
class
|
|
98
|
+
class Fail extends MicroCauseImpl {
|
|
99
99
|
error;
|
|
100
100
|
constructor(error, traces = []) {
|
|
101
101
|
super("Fail", error, traces);
|
|
@@ -107,8 +107,8 @@ class FailImpl extends MicroCauseImpl {
|
|
|
107
107
|
* @experimental
|
|
108
108
|
* @category MicroCause
|
|
109
109
|
*/
|
|
110
|
-
export const causeFail = (error, traces = []) => new
|
|
111
|
-
class
|
|
110
|
+
export const causeFail = (error, traces = []) => new Fail(error, traces);
|
|
111
|
+
class Die extends MicroCauseImpl {
|
|
112
112
|
defect;
|
|
113
113
|
constructor(defect, traces = []) {
|
|
114
114
|
super("Die", defect, traces);
|
|
@@ -120,8 +120,8 @@ class DieImpl extends MicroCauseImpl {
|
|
|
120
120
|
* @experimental
|
|
121
121
|
* @category MicroCause
|
|
122
122
|
*/
|
|
123
|
-
export const causeDie = (defect, traces = []) => new
|
|
124
|
-
class
|
|
123
|
+
export const causeDie = (defect, traces = []) => new Die(defect, traces);
|
|
124
|
+
class Interrupt extends MicroCauseImpl {
|
|
125
125
|
constructor(traces = []) {
|
|
126
126
|
super("Interrupt", "interrupted", traces);
|
|
127
127
|
}
|
|
@@ -131,7 +131,7 @@ class InterruptImpl extends MicroCauseImpl {
|
|
|
131
131
|
* @experimental
|
|
132
132
|
* @category MicroCause
|
|
133
133
|
*/
|
|
134
|
-
export const causeInterrupt = (traces = []) => new
|
|
134
|
+
export const causeInterrupt = (traces = []) => new Interrupt(traces);
|
|
135
135
|
/**
|
|
136
136
|
* @since 3.4.6
|
|
137
137
|
* @experimental
|
|
@@ -173,22 +173,22 @@ export const causeWithTrace = /*#__PURE__*/dual(2, (self, trace) => {
|
|
|
173
173
|
}
|
|
174
174
|
});
|
|
175
175
|
// ----------------------------------------------------------------------------
|
|
176
|
-
//
|
|
176
|
+
// MicroFiber
|
|
177
177
|
// ----------------------------------------------------------------------------
|
|
178
178
|
/**
|
|
179
179
|
* @since 3.11.0
|
|
180
180
|
* @experimental
|
|
181
|
-
* @category
|
|
181
|
+
* @category MicroFiber
|
|
182
182
|
*/
|
|
183
|
-
export const
|
|
183
|
+
export const MicroFiberTypeId = /*#__PURE__*/Symbol.for("effect/Micro/MicroFiber");
|
|
184
184
|
const fiberVariance = {
|
|
185
185
|
_A: identity,
|
|
186
186
|
_E: identity
|
|
187
187
|
};
|
|
188
|
-
class
|
|
188
|
+
class MicroFiberImpl {
|
|
189
189
|
context;
|
|
190
190
|
interruptible;
|
|
191
|
-
[
|
|
191
|
+
[MicroFiberTypeId];
|
|
192
192
|
_stack = [];
|
|
193
193
|
_observers = [];
|
|
194
194
|
_exit;
|
|
@@ -197,7 +197,7 @@ class FiberImpl {
|
|
|
197
197
|
constructor(context, interruptible = true) {
|
|
198
198
|
this.context = context;
|
|
199
199
|
this.interruptible = interruptible;
|
|
200
|
-
this[
|
|
200
|
+
this[MicroFiberTypeId] = fiberVariance;
|
|
201
201
|
}
|
|
202
202
|
getRef(ref) {
|
|
203
203
|
return InternalContext.unsafeGetReference(this.context, ref);
|
|
@@ -276,7 +276,7 @@ class FiberImpl {
|
|
|
276
276
|
}
|
|
277
277
|
} catch (error) {
|
|
278
278
|
if (!hasProperty(current, evaluate)) {
|
|
279
|
-
return exitDie(`
|
|
279
|
+
return exitDie(`MicroFiber.runLoop: Not a valid effect: ${String(current)}`);
|
|
280
280
|
}
|
|
281
281
|
return exitDie(error);
|
|
282
282
|
}
|
|
@@ -314,13 +314,19 @@ const fiberInterruptChildren = fiber => {
|
|
|
314
314
|
/**
|
|
315
315
|
* @since 3.11.0
|
|
316
316
|
* @experimental
|
|
317
|
-
* @category
|
|
317
|
+
* @category MicroFiber
|
|
318
318
|
*/
|
|
319
319
|
export const fiberAwait = self => async(resume => sync(self.addObserver(exit => resume(succeed(exit)))));
|
|
320
|
+
/**
|
|
321
|
+
* @since 3.11.2
|
|
322
|
+
* @experimental
|
|
323
|
+
* @category MicroFiber
|
|
324
|
+
*/
|
|
325
|
+
export const fiberJoin = self => flatten(fiberAwait(self));
|
|
320
326
|
/**
|
|
321
327
|
* @since 3.11.0
|
|
322
328
|
* @experimental
|
|
323
|
-
* @category
|
|
329
|
+
* @category MicroFiber
|
|
324
330
|
*/
|
|
325
331
|
export const fiberInterrupt = self => suspend(() => {
|
|
326
332
|
self.unsafeInterrupt();
|
|
@@ -329,7 +335,7 @@ export const fiberInterrupt = self => suspend(() => {
|
|
|
329
335
|
/**
|
|
330
336
|
* @since 3.11.0
|
|
331
337
|
* @experimental
|
|
332
|
-
* @category
|
|
338
|
+
* @category MicroFiber
|
|
333
339
|
*/
|
|
334
340
|
export const fiberInterruptAll = fibers => suspend(() => {
|
|
335
341
|
for (const fiber of fibers) fiber.unsafeInterrupt();
|
|
@@ -376,7 +382,7 @@ const MicroProto = {
|
|
|
376
382
|
},
|
|
377
383
|
toJSON() {
|
|
378
384
|
return {
|
|
379
|
-
_id: "
|
|
385
|
+
_id: "Micro",
|
|
380
386
|
op: this[identifier],
|
|
381
387
|
...(args in this ? {
|
|
382
388
|
args: this[args]
|
|
@@ -419,7 +425,7 @@ const makeExit = options => {
|
|
|
419
425
|
},
|
|
420
426
|
toJSON() {
|
|
421
427
|
return {
|
|
422
|
-
_id: "
|
|
428
|
+
_id: "MicroExit",
|
|
423
429
|
_tag: options.op,
|
|
424
430
|
[options.prop]: this[args]
|
|
425
431
|
};
|
|
@@ -474,10 +480,10 @@ export const failCause = /*#__PURE__*/makeExit({
|
|
|
474
480
|
}
|
|
475
481
|
});
|
|
476
482
|
/**
|
|
477
|
-
* Creates a `Micro` effect that
|
|
483
|
+
* Creates a `Micro` effect that fails with the given error.
|
|
478
484
|
*
|
|
479
|
-
* This
|
|
480
|
-
* type level.
|
|
485
|
+
* This results in a `Fail` variant of the `MicroCause` type, where the error is
|
|
486
|
+
* tracked at the type level.
|
|
481
487
|
*
|
|
482
488
|
* @since 3.4.0
|
|
483
489
|
* @experimental
|
|
@@ -485,10 +491,10 @@ export const failCause = /*#__PURE__*/makeExit({
|
|
|
485
491
|
*/
|
|
486
492
|
export const fail = error => failCause(causeFail(error));
|
|
487
493
|
/**
|
|
488
|
-
* Creates a `Micro` effect that
|
|
494
|
+
* Creates a `Micro` effect that succeeds with a lazily evaluated value.
|
|
489
495
|
*
|
|
490
|
-
* If the evaluation of the value throws an error, the effect will fail with
|
|
491
|
-
* `
|
|
496
|
+
* If the evaluation of the value throws an error, the effect will fail with a
|
|
497
|
+
* `Die` variant of the `MicroCause` type.
|
|
492
498
|
*
|
|
493
499
|
* @since 3.4.0
|
|
494
500
|
* @experimental
|
|
@@ -546,7 +552,7 @@ export const yieldNowWith = /*#__PURE__*/makePrimitive({
|
|
|
546
552
|
*/
|
|
547
553
|
export const yieldNow = /*#__PURE__*/yieldNowWith(0);
|
|
548
554
|
/**
|
|
549
|
-
* Creates a `Micro` effect that will succeed with
|
|
555
|
+
* Creates a `Micro` effect that will succeed with the value wrapped in `Some`.
|
|
550
556
|
*
|
|
551
557
|
* @since 3.4.0
|
|
552
558
|
* @experimental
|
|
@@ -554,7 +560,7 @@ export const yieldNow = /*#__PURE__*/yieldNowWith(0);
|
|
|
554
560
|
*/
|
|
555
561
|
export const succeedSome = a => succeed(Option.some(a));
|
|
556
562
|
/**
|
|
557
|
-
* Creates a `Micro` effect that
|
|
563
|
+
* Creates a `Micro` effect that succeeds with `None`.
|
|
558
564
|
*
|
|
559
565
|
* @since 3.4.0
|
|
560
566
|
* @experimental
|
|
@@ -572,8 +578,8 @@ export const failCauseSync = evaluate => suspend(() => failCause(evaluate()));
|
|
|
572
578
|
/**
|
|
573
579
|
* Creates a `Micro` effect that will die with the specified error.
|
|
574
580
|
*
|
|
575
|
-
* This
|
|
576
|
-
* the type level.
|
|
581
|
+
* This results in a `Die` variant of the `MicroCause` type, where the error is
|
|
582
|
+
* not tracked at the type level.
|
|
577
583
|
*
|
|
578
584
|
* @since 3.4.0
|
|
579
585
|
* @experimental
|
|
@@ -583,8 +589,8 @@ export const die = defect => exitDie(defect);
|
|
|
583
589
|
/**
|
|
584
590
|
* Creates a `Micro` effect that will fail with the lazily evaluated error.
|
|
585
591
|
*
|
|
586
|
-
* This
|
|
587
|
-
* type level.
|
|
592
|
+
* This results in a `Fail` variant of the `MicroCause` type, where the error is
|
|
593
|
+
* tracked at the type level.
|
|
588
594
|
*
|
|
589
595
|
* @since 3.4.6
|
|
590
596
|
* @experimental
|
|
@@ -633,9 +639,6 @@ export {
|
|
|
633
639
|
* The `Micro` equivalent of a try / catch block, which allows you to map
|
|
634
640
|
* thrown errors to a specific error type.
|
|
635
641
|
*
|
|
636
|
-
* @since 3.4.0
|
|
637
|
-
* @experimental
|
|
638
|
-
* @category constructors
|
|
639
642
|
* @example
|
|
640
643
|
* ```ts
|
|
641
644
|
* import { Micro } from "effect"
|
|
@@ -645,11 +648,17 @@ export {
|
|
|
645
648
|
* catch: (cause) => new Error("caught", { cause })
|
|
646
649
|
* })
|
|
647
650
|
* ```
|
|
651
|
+
*
|
|
652
|
+
* @since 3.4.0
|
|
653
|
+
* @experimental
|
|
654
|
+
* @category constructors
|
|
648
655
|
*/
|
|
649
656
|
try_ as try };
|
|
650
657
|
/**
|
|
651
|
-
* Wrap a `Promise` into a `Micro` effect.
|
|
652
|
-
*
|
|
658
|
+
* Wrap a `Promise` into a `Micro` effect.
|
|
659
|
+
*
|
|
660
|
+
* Any errors will result in a `Die` variant of the `MicroCause` type, where the
|
|
661
|
+
* error is not tracked at the type level.
|
|
653
662
|
*
|
|
654
663
|
* @since 3.4.0
|
|
655
664
|
* @experimental
|
|
@@ -662,9 +671,6 @@ export const promise = evaluate => asyncOptions(function (resume, signal) {
|
|
|
662
671
|
* Wrap a `Promise` into a `Micro` effect. Any errors will be caught and
|
|
663
672
|
* converted into a specific error type.
|
|
664
673
|
*
|
|
665
|
-
* @since 3.4.0
|
|
666
|
-
* @experimental
|
|
667
|
-
* @category constructors
|
|
668
674
|
* @example
|
|
669
675
|
* ```ts
|
|
670
676
|
* import { Micro } from "effect"
|
|
@@ -674,6 +680,10 @@ export const promise = evaluate => asyncOptions(function (resume, signal) {
|
|
|
674
680
|
* catch: (cause) => new Error("caught", { cause })
|
|
675
681
|
* })
|
|
676
682
|
* ```
|
|
683
|
+
*
|
|
684
|
+
* @since 3.4.0
|
|
685
|
+
* @experimental
|
|
686
|
+
* @category constructors
|
|
677
687
|
*/
|
|
678
688
|
export const tryPromise = options => asyncOptions(function (resume, signal) {
|
|
679
689
|
try {
|
|
@@ -683,14 +693,14 @@ export const tryPromise = options => asyncOptions(function (resume, signal) {
|
|
|
683
693
|
}
|
|
684
694
|
}, options.try.length !== 0);
|
|
685
695
|
/**
|
|
686
|
-
* Create a `Micro` effect using the current `
|
|
696
|
+
* Create a `Micro` effect using the current `MicroFiber`.
|
|
687
697
|
*
|
|
688
698
|
* @since 3.4.0
|
|
689
699
|
* @experimental
|
|
690
700
|
* @category constructors
|
|
691
701
|
*/
|
|
692
|
-
export const
|
|
693
|
-
op: "
|
|
702
|
+
export const withMicroFiber = /*#__PURE__*/makePrimitive({
|
|
703
|
+
op: "WithMicroFiber",
|
|
694
704
|
eval(fiber) {
|
|
695
705
|
return this[args](fiber);
|
|
696
706
|
}
|
|
@@ -702,7 +712,7 @@ export const withFiber = /*#__PURE__*/makePrimitive({
|
|
|
702
712
|
* @experimental
|
|
703
713
|
* @category constructors
|
|
704
714
|
*/
|
|
705
|
-
export const yieldFlush = /*#__PURE__*/
|
|
715
|
+
export const yieldFlush = /*#__PURE__*/withMicroFiber(fiber => {
|
|
706
716
|
fiber.getRef(CurrentScheduler).flush();
|
|
707
717
|
return exitVoid;
|
|
708
718
|
});
|
|
@@ -806,7 +816,7 @@ const fromIterator = /*#__PURE__*/makePrimitive({
|
|
|
806
816
|
*/
|
|
807
817
|
export const as = /*#__PURE__*/dual(2, (self, value) => map(self, _ => value));
|
|
808
818
|
/**
|
|
809
|
-
* Wrap the success value of this `Micro` effect in
|
|
819
|
+
* Wrap the success value of this `Micro` effect in a `Some`.
|
|
810
820
|
*
|
|
811
821
|
* @since 3.4.0
|
|
812
822
|
* @experimental
|
|
@@ -825,11 +835,11 @@ export const flip = self => matchEffect(self, {
|
|
|
825
835
|
onSuccess: fail
|
|
826
836
|
});
|
|
827
837
|
/**
|
|
828
|
-
* A more flexible version of `flatMap
|
|
829
|
-
*
|
|
838
|
+
* A more flexible version of `flatMap` that combines `map` and `flatMap` into a
|
|
839
|
+
* single API.
|
|
830
840
|
*
|
|
831
|
-
* It also
|
|
832
|
-
*
|
|
841
|
+
* It also lets you directly pass a `Micro` effect, which will be executed after
|
|
842
|
+
* the current effect.
|
|
833
843
|
*
|
|
834
844
|
* @since 3.4.0
|
|
835
845
|
* @experimental
|
|
@@ -888,7 +898,7 @@ export const sandbox = self => catchAllCause(self, fail);
|
|
|
888
898
|
* @experimental
|
|
889
899
|
* @category sequencing
|
|
890
900
|
*/
|
|
891
|
-
export const raceAll = all =>
|
|
901
|
+
export const raceAll = all => withMicroFiber(parent => async(resume => {
|
|
892
902
|
const effects = Arr.fromIterable(all);
|
|
893
903
|
const len = effects.length;
|
|
894
904
|
let doneCount = 0;
|
|
@@ -921,13 +931,13 @@ export const raceAll = all => withFiber(parent => async(resume => {
|
|
|
921
931
|
/**
|
|
922
932
|
* Returns an effect that races all the specified effects,
|
|
923
933
|
* yielding the value of the first effect to succeed or fail. Losers of
|
|
924
|
-
* the race will be interrupted immediately
|
|
934
|
+
* the race will be interrupted immediately.
|
|
925
935
|
*
|
|
926
936
|
* @since 3.4.0
|
|
927
937
|
* @experimental
|
|
928
938
|
* @category sequencing
|
|
929
939
|
*/
|
|
930
|
-
export const raceAllFirst = all =>
|
|
940
|
+
export const raceAllFirst = all => withMicroFiber(parent => async(resume => {
|
|
931
941
|
let done = false;
|
|
932
942
|
const fibers = new Set();
|
|
933
943
|
const onExit = exit => {
|
|
@@ -947,7 +957,7 @@ export const raceAllFirst = all => withFiber(parent => async(resume => {
|
|
|
947
957
|
}));
|
|
948
958
|
/**
|
|
949
959
|
* Returns an effect that races two effects, yielding the value of the first
|
|
950
|
-
* effect to succeed. Losers of the race will be interrupted immediately
|
|
960
|
+
* effect to succeed. Losers of the race will be interrupted immediately.
|
|
951
961
|
*
|
|
952
962
|
* @since 3.4.0
|
|
953
963
|
* @experimental
|
|
@@ -956,7 +966,7 @@ export const raceAllFirst = all => withFiber(parent => async(resume => {
|
|
|
956
966
|
export const race = /*#__PURE__*/dual(2, (self, that) => raceAll([self, that]));
|
|
957
967
|
/**
|
|
958
968
|
* Returns an effect that races two effects, yielding the value of the first
|
|
959
|
-
* effect to succeed *or* fail. Losers of the race will be interrupted immediately
|
|
969
|
+
* effect to succeed *or* fail. Losers of the race will be interrupted immediately.
|
|
960
970
|
*
|
|
961
971
|
* @since 3.4.0
|
|
962
972
|
* @experimental
|
|
@@ -1147,7 +1157,7 @@ export class MicroSchedulerDefault {
|
|
|
1147
1157
|
* @experimental
|
|
1148
1158
|
* @category environment
|
|
1149
1159
|
*/
|
|
1150
|
-
export const service = tag =>
|
|
1160
|
+
export const service = tag => withMicroFiber(fiber => succeed(Context.unsafeGet(fiber.context, tag)));
|
|
1151
1161
|
/**
|
|
1152
1162
|
* Access the given `Context.Tag` from the environment, without tracking the
|
|
1153
1163
|
* dependency at the type level.
|
|
@@ -1159,7 +1169,7 @@ export const service = tag => withFiber(fiber => succeed(Context.unsafeGet(fiber
|
|
|
1159
1169
|
* @experimental
|
|
1160
1170
|
* @category environment
|
|
1161
1171
|
*/
|
|
1162
|
-
export const serviceOption = tag =>
|
|
1172
|
+
export const serviceOption = tag => withMicroFiber(fiber => succeed(Context.getOption(fiber.context, tag)));
|
|
1163
1173
|
/**
|
|
1164
1174
|
* Update the Context with the given mapping function.
|
|
1165
1175
|
*
|
|
@@ -1167,7 +1177,7 @@ export const serviceOption = tag => withFiber(fiber => succeed(Context.getOption
|
|
|
1167
1177
|
* @experimental
|
|
1168
1178
|
* @category environment
|
|
1169
1179
|
*/
|
|
1170
|
-
export const updateContext = /*#__PURE__*/dual(2, (self, f) =>
|
|
1180
|
+
export const updateContext = /*#__PURE__*/dual(2, (self, f) => withMicroFiber(fiber => {
|
|
1171
1181
|
const prev = fiber.context;
|
|
1172
1182
|
fiber.context = f(prev);
|
|
1173
1183
|
return onExit(self, () => {
|
|
@@ -1182,7 +1192,7 @@ export const updateContext = /*#__PURE__*/dual(2, (self, f) => withFiber(fiber =
|
|
|
1182
1192
|
* @experimental
|
|
1183
1193
|
* @category environment
|
|
1184
1194
|
*/
|
|
1185
|
-
export const updateService = /*#__PURE__*/dual(3, (self, tag, f) =>
|
|
1195
|
+
export const updateService = /*#__PURE__*/dual(3, (self, tag, f) => withMicroFiber(fiber => {
|
|
1186
1196
|
const prev = Context.unsafeGet(fiber.context, tag);
|
|
1187
1197
|
fiber.context = Context.add(fiber.context, tag, f(prev));
|
|
1188
1198
|
return onExit(self, () => {
|
|
@@ -1198,7 +1208,7 @@ export const updateService = /*#__PURE__*/dual(3, (self, tag, f) => withFiber(fi
|
|
|
1198
1208
|
* @category environment
|
|
1199
1209
|
*/
|
|
1200
1210
|
export const context = () => getContext;
|
|
1201
|
-
const getContext = /*#__PURE__*/
|
|
1211
|
+
const getContext = /*#__PURE__*/withMicroFiber(fiber => succeed(fiber.context));
|
|
1202
1212
|
/**
|
|
1203
1213
|
* Merge the given `Context` with the current context.
|
|
1204
1214
|
*
|
|
@@ -1255,10 +1265,8 @@ export class CurrentScheduler extends /*#__PURE__*/Context.Reference()("effect/M
|
|
|
1255
1265
|
* If you have a `Micro` that uses `concurrency: "inherit"`, you can use this
|
|
1256
1266
|
* api to control the concurrency of that `Micro` when it is run.
|
|
1257
1267
|
*
|
|
1258
|
-
* @since 3.4.0
|
|
1259
|
-
* @experimental
|
|
1260
|
-
* @category environment refs
|
|
1261
1268
|
* @example
|
|
1269
|
+
* ```ts
|
|
1262
1270
|
* import * as Micro from "effect/Micro"
|
|
1263
1271
|
*
|
|
1264
1272
|
* Micro.forEach([1, 2, 3], (n) => Micro.succeed(n), {
|
|
@@ -1266,6 +1274,11 @@ export class CurrentScheduler extends /*#__PURE__*/Context.Reference()("effect/M
|
|
|
1266
1274
|
* }).pipe(
|
|
1267
1275
|
* Micro.withConcurrency(2) // use a concurrency of 2
|
|
1268
1276
|
* )
|
|
1277
|
+
* ```
|
|
1278
|
+
*
|
|
1279
|
+
* @since 3.4.0
|
|
1280
|
+
* @experimental
|
|
1281
|
+
* @category environment refs
|
|
1269
1282
|
*/
|
|
1270
1283
|
export const withConcurrency = /*#__PURE__*/dual(2, (self, concurrency) => provideService(self, CurrentConcurrency, concurrency));
|
|
1271
1284
|
// ----------------------------------------------------------------------------
|
|
@@ -1509,7 +1522,7 @@ export const catchCauseIf = /*#__PURE__*/dual(3, (self, predicate, f) => catchAl
|
|
|
1509
1522
|
/**
|
|
1510
1523
|
* Catch the error of the given `Micro` effect, allowing you to recover from it.
|
|
1511
1524
|
*
|
|
1512
|
-
* It only catches expected
|
|
1525
|
+
* It only catches expected errors.
|
|
1513
1526
|
*
|
|
1514
1527
|
* @since 3.4.6
|
|
1515
1528
|
* @experimental
|
|
@@ -2014,7 +2027,7 @@ export const interrupt = /*#__PURE__*/failCause( /*#__PURE__*/causeInterrupt());
|
|
|
2014
2027
|
* @experimental
|
|
2015
2028
|
* @category flags
|
|
2016
2029
|
*/
|
|
2017
|
-
export const uninterruptible = self =>
|
|
2030
|
+
export const uninterruptible = self => withMicroFiber(fiber => {
|
|
2018
2031
|
if (!fiber.interruptible) return self;
|
|
2019
2032
|
fiber.interruptible = false;
|
|
2020
2033
|
fiber._stack.push(setInterruptible(true));
|
|
@@ -2037,7 +2050,7 @@ const setInterruptible = /*#__PURE__*/makePrimitive({
|
|
|
2037
2050
|
* @experimental
|
|
2038
2051
|
* @category flags
|
|
2039
2052
|
*/
|
|
2040
|
-
export const interruptible = self =>
|
|
2053
|
+
export const interruptible = self => withMicroFiber(fiber => {
|
|
2041
2054
|
if (fiber.interruptible) return self;
|
|
2042
2055
|
fiber.interruptible = true;
|
|
2043
2056
|
fiber._stack.push(setInterruptible(false));
|
|
@@ -2051,9 +2064,6 @@ export const interruptible = self => withFiber(fiber => {
|
|
|
2051
2064
|
* You can use the `restore` function to restore a `Micro` effect to the
|
|
2052
2065
|
* interruptibility state before the `uninterruptibleMask` was applied.
|
|
2053
2066
|
*
|
|
2054
|
-
* @since 3.4.0
|
|
2055
|
-
* @experimental
|
|
2056
|
-
* @category interruption
|
|
2057
2067
|
* @example
|
|
2058
2068
|
* ```ts
|
|
2059
2069
|
* import * as Micro from "effect/Micro"
|
|
@@ -2064,8 +2074,12 @@ export const interruptible = self => withFiber(fiber => {
|
|
|
2064
2074
|
* )
|
|
2065
2075
|
* )
|
|
2066
2076
|
* ```
|
|
2077
|
+
*
|
|
2078
|
+
* @since 3.4.0
|
|
2079
|
+
* @experimental
|
|
2080
|
+
* @category interruption
|
|
2067
2081
|
*/
|
|
2068
|
-
export const uninterruptibleMask = f =>
|
|
2082
|
+
export const uninterruptibleMask = f => withMicroFiber(fiber => {
|
|
2069
2083
|
if (!fiber.interruptible) return f(identity);
|
|
2070
2084
|
fiber.interruptible = false;
|
|
2071
2085
|
fiber._stack.push(setInterruptible(true));
|
|
@@ -2132,7 +2146,7 @@ export const whileLoop = /*#__PURE__*/makePrimitive({
|
|
|
2132
2146
|
* @experimental
|
|
2133
2147
|
* @category collecting & elements
|
|
2134
2148
|
*/
|
|
2135
|
-
export const forEach = (iterable, f, options) =>
|
|
2149
|
+
export const forEach = (iterable, f, options) => withMicroFiber(parent => {
|
|
2136
2150
|
const concurrencyOption = options?.concurrency === "inherit" ? parent.getRef(CurrentConcurrency) : options?.concurrency ?? 1;
|
|
2137
2151
|
const concurrency = concurrencyOption === "unbounded" ? Number.POSITIVE_INFINITY : Math.max(1, concurrencyOption);
|
|
2138
2152
|
const items = Arr.fromIterable(iterable);
|
|
@@ -2277,21 +2291,21 @@ let_ as let };
|
|
|
2277
2291
|
// fibers & forking
|
|
2278
2292
|
// ----------------------------------------------------------------------------
|
|
2279
2293
|
/**
|
|
2280
|
-
* Run the `Micro` effect in a new `
|
|
2294
|
+
* Run the `Micro` effect in a new `MicroFiber` that can be awaited, joined, or
|
|
2281
2295
|
* aborted.
|
|
2282
2296
|
*
|
|
2283
2297
|
* When the parent `Micro` finishes, this `Micro` will be aborted.
|
|
2284
2298
|
*
|
|
2285
2299
|
* @since 3.4.0
|
|
2286
2300
|
* @experimental
|
|
2287
|
-
* @category
|
|
2301
|
+
* @category fiber & forking
|
|
2288
2302
|
*/
|
|
2289
|
-
export const fork = self =>
|
|
2303
|
+
export const fork = self => withMicroFiber(fiber => {
|
|
2290
2304
|
fiberMiddleware.interruptChildren ??= fiberInterruptChildren;
|
|
2291
2305
|
return succeed(unsafeFork(fiber, self));
|
|
2292
2306
|
});
|
|
2293
2307
|
const unsafeFork = (parent, effect, immediate = false, daemon = false) => {
|
|
2294
|
-
const child = new
|
|
2308
|
+
const child = new MicroFiberImpl(parent.context, parent.interruptible);
|
|
2295
2309
|
if (!daemon) {
|
|
2296
2310
|
parent.children().add(child);
|
|
2297
2311
|
child.addObserver(() => parent.children().delete(child));
|
|
@@ -2304,51 +2318,48 @@ const unsafeFork = (parent, effect, immediate = false, daemon = false) => {
|
|
|
2304
2318
|
return child;
|
|
2305
2319
|
};
|
|
2306
2320
|
/**
|
|
2307
|
-
* Run the `Micro` effect in a new `
|
|
2321
|
+
* Run the `Micro` effect in a new `MicroFiber` that can be awaited, joined, or
|
|
2308
2322
|
* aborted.
|
|
2309
2323
|
*
|
|
2310
2324
|
* It will not be aborted when the parent `Micro` finishes.
|
|
2311
2325
|
*
|
|
2312
2326
|
* @since 3.4.0
|
|
2313
2327
|
* @experimental
|
|
2314
|
-
* @category
|
|
2328
|
+
* @category fiber & forking
|
|
2315
2329
|
*/
|
|
2316
|
-
export const forkDaemon = self =>
|
|
2330
|
+
export const forkDaemon = self => withMicroFiber(fiber => succeed(unsafeFork(fiber, self, false, true)));
|
|
2317
2331
|
/**
|
|
2318
|
-
* Run the `Micro` effect in a new `
|
|
2332
|
+
* Run the `Micro` effect in a new `MicroFiber` that can be awaited, joined, or
|
|
2319
2333
|
* aborted.
|
|
2320
2334
|
*
|
|
2321
2335
|
* The lifetime of the handle will be attached to the provided `MicroScope`.
|
|
2322
2336
|
*
|
|
2323
2337
|
* @since 3.4.0
|
|
2324
2338
|
* @experimental
|
|
2325
|
-
* @category
|
|
2339
|
+
* @category fiber & forking
|
|
2326
2340
|
*/
|
|
2327
2341
|
export const forkIn = /*#__PURE__*/dual(2, (self, scope) => uninterruptibleMask(restore => flatMap(scope.fork, scope => tap(restore(forkDaemon(onExit(self, exit => scope.close(exit)))), fiber => scope.addFinalizer(_ => fiberInterrupt(fiber))))));
|
|
2328
2342
|
/**
|
|
2329
|
-
* Run the `Micro` effect in a new `
|
|
2343
|
+
* Run the `Micro` effect in a new `MicroFiber` that can be awaited, joined, or
|
|
2330
2344
|
* aborted.
|
|
2331
2345
|
*
|
|
2332
2346
|
* The lifetime of the handle will be attached to the current `MicroScope`.
|
|
2333
2347
|
*
|
|
2334
2348
|
* @since 3.4.0
|
|
2335
2349
|
* @experimental
|
|
2336
|
-
* @category
|
|
2350
|
+
* @category fiber & forking
|
|
2337
2351
|
*/
|
|
2338
2352
|
export const forkScoped = self => flatMap(scope, scope => forkIn(self, scope));
|
|
2339
2353
|
// ----------------------------------------------------------------------------
|
|
2340
2354
|
// execution
|
|
2341
2355
|
// ----------------------------------------------------------------------------
|
|
2342
2356
|
/**
|
|
2343
|
-
* Execute the `Micro` effect and return a `
|
|
2357
|
+
* Execute the `Micro` effect and return a `MicroFiber` that can be awaited, joined,
|
|
2344
2358
|
* or aborted.
|
|
2345
2359
|
*
|
|
2346
2360
|
* You can listen for the result by adding an observer using the handle's
|
|
2347
2361
|
* `addObserver` method.
|
|
2348
2362
|
*
|
|
2349
|
-
* @since 3.4.0
|
|
2350
|
-
* @experimental
|
|
2351
|
-
* @category execution
|
|
2352
2363
|
* @example
|
|
2353
2364
|
* ```ts
|
|
2354
2365
|
* import * as Micro from "effect/Micro"
|
|
@@ -2362,9 +2373,13 @@ export const forkScoped = self => flatMap(scope, scope => forkIn(self, scope));
|
|
|
2362
2373
|
* console.log(exit)
|
|
2363
2374
|
* })
|
|
2364
2375
|
* ```
|
|
2376
|
+
*
|
|
2377
|
+
* @since 3.4.0
|
|
2378
|
+
* @experimental
|
|
2379
|
+
* @category execution
|
|
2365
2380
|
*/
|
|
2366
2381
|
export const runFork = (effect, options) => {
|
|
2367
|
-
const fiber = new
|
|
2382
|
+
const fiber = new MicroFiberImpl(CurrentScheduler.context(options?.scheduler ?? new MicroSchedulerDefault()));
|
|
2368
2383
|
fiber.evaluate(effect);
|
|
2369
2384
|
if (options?.signal) {
|
|
2370
2385
|
if (options.signal.aborted) {
|
|
@@ -2409,7 +2424,7 @@ export const runPromise = (effect, options) => runPromiseExit(effect, options).t
|
|
|
2409
2424
|
* Attempt to execute the `Micro` effect synchronously and return the `MicroExit`.
|
|
2410
2425
|
*
|
|
2411
2426
|
* If any asynchronous effects are encountered, the function will return a
|
|
2412
|
-
* `CauseDie` containing the `
|
|
2427
|
+
* `CauseDie` containing the `MicroFiber`.
|
|
2413
2428
|
*
|
|
2414
2429
|
* @since 3.4.6
|
|
2415
2430
|
* @experimental
|