effect 3.6.8 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Array.js +1 -1
- package/dist/cjs/Array.js.map +1 -1
- package/dist/cjs/Config.js +8 -1
- package/dist/cjs/Config.js.map +1 -1
- package/dist/cjs/Context.js +9 -1
- package/dist/cjs/Context.js.map +1 -1
- package/dist/cjs/Effect.js +26 -4
- package/dist/cjs/Effect.js.map +1 -1
- package/dist/cjs/Fiber.js.map +1 -1
- package/dist/cjs/FiberHandle.js +20 -8
- package/dist/cjs/FiberHandle.js.map +1 -1
- package/dist/cjs/FiberMap.js +22 -11
- package/dist/cjs/FiberMap.js.map +1 -1
- package/dist/cjs/FiberSet.js +23 -9
- package/dist/cjs/FiberSet.js.map +1 -1
- package/dist/cjs/Micro.js +9 -2
- package/dist/cjs/Micro.js.map +1 -1
- package/dist/cjs/Stream.js +30 -2
- package/dist/cjs/Stream.js.map +1 -1
- package/dist/cjs/internal/config.js +7 -1
- package/dist/cjs/internal/config.js.map +1 -1
- package/dist/cjs/internal/context.js +8 -1
- package/dist/cjs/internal/context.js.map +1 -1
- package/dist/cjs/internal/effect/circular.js +3 -1
- package/dist/cjs/internal/effect/circular.js.map +1 -1
- package/dist/cjs/internal/fiberRuntime.js +23 -15
- package/dist/cjs/internal/fiberRuntime.js.map +1 -1
- package/dist/cjs/internal/stream.js +6 -3
- package/dist/cjs/internal/stream.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/dts/Array.d.ts +9 -9
- package/dist/dts/Array.d.ts.map +1 -1
- package/dist/dts/Config.d.ts +7 -0
- package/dist/dts/Config.d.ts.map +1 -1
- package/dist/dts/Context.d.ts +12 -0
- package/dist/dts/Context.d.ts.map +1 -1
- package/dist/dts/Effect.d.ts +84 -4
- package/dist/dts/Effect.d.ts.map +1 -1
- package/dist/dts/Fiber.d.ts +5 -1
- package/dist/dts/Fiber.d.ts.map +1 -1
- package/dist/dts/FiberHandle.d.ts +7 -0
- package/dist/dts/FiberHandle.d.ts.map +1 -1
- package/dist/dts/FiberMap.d.ts +7 -0
- package/dist/dts/FiberMap.d.ts.map +1 -1
- package/dist/dts/FiberSet.d.ts +17 -5
- package/dist/dts/FiberSet.d.ts.map +1 -1
- package/dist/dts/Micro.d.ts +6 -0
- package/dist/dts/Micro.d.ts.map +1 -1
- package/dist/dts/Stream.d.ts +30 -0
- package/dist/dts/Stream.d.ts.map +1 -1
- package/dist/dts/internal/stream.d.ts +0 -1
- package/dist/dts/internal/stream.d.ts.map +1 -1
- package/dist/esm/Array.js +1 -1
- package/dist/esm/Array.js.map +1 -1
- package/dist/esm/Config.js +7 -0
- package/dist/esm/Config.js.map +1 -1
- package/dist/esm/Context.js +8 -0
- package/dist/esm/Context.js.map +1 -1
- package/dist/esm/Effect.js +22 -0
- package/dist/esm/Effect.js.map +1 -1
- package/dist/esm/Fiber.js.map +1 -1
- package/dist/esm/FiberHandle.js +20 -8
- package/dist/esm/FiberHandle.js.map +1 -1
- package/dist/esm/FiberMap.js +22 -11
- package/dist/esm/FiberMap.js.map +1 -1
- package/dist/esm/FiberSet.js +23 -9
- package/dist/esm/FiberSet.js.map +1 -1
- package/dist/esm/Micro.js +7 -1
- package/dist/esm/Micro.js.map +1 -1
- package/dist/esm/Stream.js +27 -0
- package/dist/esm/Stream.js.map +1 -1
- package/dist/esm/internal/config.js +5 -0
- package/dist/esm/internal/config.js.map +1 -1
- package/dist/esm/internal/context.js +7 -0
- package/dist/esm/internal/context.js.map +1 -1
- package/dist/esm/internal/effect/circular.js +2 -0
- package/dist/esm/internal/effect/circular.js.map +1 -1
- package/dist/esm/internal/fiberRuntime.js +20 -13
- package/dist/esm/internal/fiberRuntime.js.map +1 -1
- package/dist/esm/internal/stream.js +3 -0
- package/dist/esm/internal/stream.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/package.json +1 -1
- package/src/Array.ts +39 -9
- package/src/Config.ts +8 -0
- package/src/Context.ts +13 -0
- package/src/Effect.ts +172 -19
- package/src/Fiber.ts +8 -1
- package/src/FiberHandle.ts +46 -10
- package/src/FiberMap.ts +48 -13
- package/src/FiberSet.ts +65 -24
- package/src/Micro.ts +8 -1
- package/src/Stream.ts +36 -0
- package/src/internal/config.ts +10 -0
- package/src/internal/context.ts +12 -0
- package/src/internal/effect/circular.ts +91 -0
- package/src/internal/fiberRuntime.ts +101 -30
- package/src/internal/stream.ts +18 -0
- package/src/internal/version.ts +1 -1
package/package.json
CHANGED
package/src/Array.ts
CHANGED
|
@@ -1049,14 +1049,23 @@ export const insertAt: {
|
|
|
1049
1049
|
* import { Array } from "effect"
|
|
1050
1050
|
*
|
|
1051
1051
|
* const letters = ['a', 'b', 'c', 'd']
|
|
1052
|
-
* const result = Array.replace(1, 'z')
|
|
1052
|
+
* const result = Array.replace(letters, 1, 'z')
|
|
1053
1053
|
* assert.deepStrictEqual(result, ['a', 'z', 'c', 'd'])
|
|
1054
1054
|
*
|
|
1055
1055
|
* @since 2.0.0
|
|
1056
1056
|
*/
|
|
1057
1057
|
export const replace: {
|
|
1058
|
-
<B>(
|
|
1059
|
-
|
|
1058
|
+
<B>(
|
|
1059
|
+
i: number,
|
|
1060
|
+
b: B
|
|
1061
|
+
): <A, S extends Iterable<A> = Iterable<A>>(
|
|
1062
|
+
self: S
|
|
1063
|
+
) => ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>
|
|
1064
|
+
<A, B, S extends Iterable<A> = Iterable<A>>(
|
|
1065
|
+
self: S,
|
|
1066
|
+
i: number,
|
|
1067
|
+
b: B
|
|
1068
|
+
): ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>
|
|
1060
1069
|
} = dual(3, <A, B>(self: Iterable<A>, i: number, b: B): Array<A | B> => modify(self, i, () => b))
|
|
1061
1070
|
|
|
1062
1071
|
/**
|
|
@@ -1072,8 +1081,15 @@ export const replace: {
|
|
|
1072
1081
|
* @since 2.0.0
|
|
1073
1082
|
*/
|
|
1074
1083
|
export const replaceOption: {
|
|
1075
|
-
<B>(
|
|
1076
|
-
|
|
1084
|
+
<B>(
|
|
1085
|
+
i: number,
|
|
1086
|
+
b: B
|
|
1087
|
+
): <A, S extends Iterable<A> = Iterable<A>>(self: S) => Option<ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>>
|
|
1088
|
+
<A, B, S extends Iterable<A> = Iterable<A>>(
|
|
1089
|
+
self: S,
|
|
1090
|
+
i: number,
|
|
1091
|
+
b: B
|
|
1092
|
+
): Option<ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>>
|
|
1077
1093
|
} = dual(
|
|
1078
1094
|
3,
|
|
1079
1095
|
<A, B>(self: Iterable<A>, i: number, b: B): Option<Array<A | B>> => modifyOption(self, i, () => b)
|
|
@@ -1093,8 +1109,15 @@ export const replaceOption: {
|
|
|
1093
1109
|
* @since 2.0.0
|
|
1094
1110
|
*/
|
|
1095
1111
|
export const modify: {
|
|
1096
|
-
<A, B
|
|
1097
|
-
|
|
1112
|
+
<A, B, S extends Iterable<A> = Iterable<A>>(
|
|
1113
|
+
i: number,
|
|
1114
|
+
f: (a: ReadonlyArray.Infer<S>) => B
|
|
1115
|
+
): (self: S) => ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>
|
|
1116
|
+
<A, B, S extends Iterable<A> = Iterable<A>>(
|
|
1117
|
+
self: S,
|
|
1118
|
+
i: number,
|
|
1119
|
+
f: (a: ReadonlyArray.Infer<S>) => B
|
|
1120
|
+
): ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>
|
|
1098
1121
|
} = dual(
|
|
1099
1122
|
3,
|
|
1100
1123
|
<A, B>(self: Iterable<A>, i: number, f: (a: A) => B): Array<A | B> =>
|
|
@@ -1118,8 +1141,15 @@ export const modify: {
|
|
|
1118
1141
|
* @since 2.0.0
|
|
1119
1142
|
*/
|
|
1120
1143
|
export const modifyOption: {
|
|
1121
|
-
<A, B
|
|
1122
|
-
|
|
1144
|
+
<A, B, S extends Iterable<A> = Iterable<A>>(
|
|
1145
|
+
i: number,
|
|
1146
|
+
f: (a: ReadonlyArray.Infer<S>) => B
|
|
1147
|
+
): (self: S) => Option<ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>>
|
|
1148
|
+
<A, B, S extends Iterable<A> = Iterable<A>>(
|
|
1149
|
+
self: S,
|
|
1150
|
+
i: number,
|
|
1151
|
+
f: (a: ReadonlyArray.Infer<S>) => B
|
|
1152
|
+
): Option<ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>>
|
|
1123
1153
|
} = dual(3, <A, B>(self: Iterable<A>, i: number, f: (a: A) => B): Option<Array<A | B>> => {
|
|
1124
1154
|
const out = Array.from(self)
|
|
1125
1155
|
if (isOutOfBound(i, out)) {
|
package/src/Config.ts
CHANGED
|
@@ -367,6 +367,14 @@ export const hashSet: <A>(config: Config<A>, name?: string) => Config<HashSet.Ha
|
|
|
367
367
|
*/
|
|
368
368
|
export const string: (name?: string) => Config<string> = internal.string
|
|
369
369
|
|
|
370
|
+
/**
|
|
371
|
+
* Constructs a config for a non-empty string value.
|
|
372
|
+
*
|
|
373
|
+
* @since 3.7.0
|
|
374
|
+
* @category constructors
|
|
375
|
+
*/
|
|
376
|
+
export const nonEmptyString: (name?: string) => Config<string> = internal.nonEmptyString
|
|
377
|
+
|
|
370
378
|
/**
|
|
371
379
|
* Constructs a config which contains the specified value.
|
|
372
380
|
*
|
package/src/Context.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* @since 2.0.0
|
|
9
9
|
*/
|
|
10
10
|
import type { Equal } from "./Equal.js"
|
|
11
|
+
import type { LazyArg } from "./Function.js"
|
|
11
12
|
import type { Inspectable } from "./Inspectable.js"
|
|
12
13
|
import * as internal from "./internal/context.js"
|
|
13
14
|
import type { Option } from "./Option.js"
|
|
@@ -263,6 +264,18 @@ export const get: {
|
|
|
263
264
|
<Services, T extends ValidTagsById<Services>>(self: Context<Services>, tag: T): Tag.Service<T>
|
|
264
265
|
} = internal.get
|
|
265
266
|
|
|
267
|
+
/**
|
|
268
|
+
* Get a service from the context that corresponds to the given tag, or
|
|
269
|
+
* use the fallback value.
|
|
270
|
+
*
|
|
271
|
+
* @since 3.7.0
|
|
272
|
+
* @category getters
|
|
273
|
+
*/
|
|
274
|
+
export const getOrElse: {
|
|
275
|
+
<S, I, B>(tag: Tag<I, S>, orElse: LazyArg<B>): <Services>(self: Context<Services>) => S | B
|
|
276
|
+
<Services, S, I, B>(self: Context<Services>, tag: Tag<I, S>, orElse: LazyArg<B>): S | B
|
|
277
|
+
} = internal.getOrElse
|
|
278
|
+
|
|
266
279
|
/**
|
|
267
280
|
* Get a service from the context that corresponds to the given tag.
|
|
268
281
|
* This function is unsafe because if the tag is not present in the context, a runtime error will be thrown.
|
package/src/Effect.ts
CHANGED
|
@@ -484,6 +484,7 @@ export const all: <
|
|
|
484
484
|
readonly batching?: boolean | "inherit" | undefined
|
|
485
485
|
readonly discard?: boolean | undefined
|
|
486
486
|
readonly mode?: "default" | "validate" | "either" | undefined
|
|
487
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
487
488
|
}
|
|
488
489
|
>(arg: Arg, options?: O) => All.Return<Arg, O> = fiberRuntime.all
|
|
489
490
|
|
|
@@ -503,6 +504,7 @@ export const allWith: <
|
|
|
503
504
|
readonly batching?: boolean | "inherit" | undefined
|
|
504
505
|
readonly discard?: boolean | undefined
|
|
505
506
|
readonly mode?: "default" | "validate" | "either" | undefined
|
|
507
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
506
508
|
}
|
|
507
509
|
>(
|
|
508
510
|
options?: O
|
|
@@ -602,6 +604,7 @@ export declare namespace All {
|
|
|
602
604
|
readonly batching?: boolean | "inherit" | undefined
|
|
603
605
|
readonly discard?: boolean | undefined
|
|
604
606
|
readonly mode?: "default" | "validate" | "either" | undefined
|
|
607
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
605
608
|
}
|
|
606
609
|
> = [Arg] extends [ReadonlyArray<EffectAny>] ? ReturnTuple<Arg, IsDiscard<O>, ExtractMode<O>>
|
|
607
610
|
: [Arg] extends [Iterable<EffectAny>] ? ReturnIterable<Arg, IsDiscard<O>, ExtractMode<O>>
|
|
@@ -622,6 +625,7 @@ export const allSuccesses: <X extends Effect<any, any, any>>(
|
|
|
622
625
|
| {
|
|
623
626
|
readonly concurrency?: Concurrency | undefined
|
|
624
627
|
readonly batching?: boolean | "inherit" | undefined
|
|
628
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
625
629
|
}
|
|
626
630
|
| undefined
|
|
627
631
|
) => Effect<Array<Effect.Success<X>>, never, Effect.Context<X>> = fiberRuntime.allSuccesses
|
|
@@ -678,6 +682,7 @@ export const exists: {
|
|
|
678
682
|
| {
|
|
679
683
|
readonly concurrency?: Concurrency | undefined
|
|
680
684
|
readonly batching?: boolean | "inherit" | undefined
|
|
685
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
681
686
|
}
|
|
682
687
|
| undefined
|
|
683
688
|
): (elements: Iterable<A>) => Effect<boolean, E, R>
|
|
@@ -688,6 +693,7 @@ export const exists: {
|
|
|
688
693
|
| {
|
|
689
694
|
readonly concurrency?: Concurrency | undefined
|
|
690
695
|
readonly batching?: boolean | "inherit" | undefined
|
|
696
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
691
697
|
}
|
|
692
698
|
| undefined
|
|
693
699
|
): Effect<boolean, E, R>
|
|
@@ -706,6 +712,7 @@ export const filter: {
|
|
|
706
712
|
readonly concurrency?: Concurrency | undefined
|
|
707
713
|
readonly batching?: boolean | "inherit" | undefined
|
|
708
714
|
readonly negate?: boolean | undefined
|
|
715
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
709
716
|
} | undefined
|
|
710
717
|
): (elements: Iterable<A>) => Effect<Array<A>, E, R>
|
|
711
718
|
<A, E, R>(
|
|
@@ -715,6 +722,7 @@ export const filter: {
|
|
|
715
722
|
readonly concurrency?: Concurrency | undefined
|
|
716
723
|
readonly batching?: boolean | "inherit" | undefined
|
|
717
724
|
readonly negate?: boolean | undefined
|
|
725
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
718
726
|
} | undefined
|
|
719
727
|
): Effect<Array<A>, E, R>
|
|
720
728
|
} = fiberRuntime.filter
|
|
@@ -784,6 +792,7 @@ export const forEach: {
|
|
|
784
792
|
readonly concurrency?: Concurrency | undefined
|
|
785
793
|
readonly batching?: boolean | "inherit" | undefined
|
|
786
794
|
readonly discard?: false | undefined
|
|
795
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
787
796
|
} | undefined
|
|
788
797
|
): (
|
|
789
798
|
self: S
|
|
@@ -794,6 +803,7 @@ export const forEach: {
|
|
|
794
803
|
readonly concurrency?: Concurrency | undefined
|
|
795
804
|
readonly batching?: boolean | "inherit" | undefined
|
|
796
805
|
readonly discard: true
|
|
806
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
797
807
|
}
|
|
798
808
|
): (self: Iterable<A>) => Effect<void, E, R>
|
|
799
809
|
<B, E, R, S extends Iterable<any>>(
|
|
@@ -803,6 +813,7 @@ export const forEach: {
|
|
|
803
813
|
readonly concurrency?: Concurrency | undefined
|
|
804
814
|
readonly batching?: boolean | "inherit" | undefined
|
|
805
815
|
readonly discard?: false | undefined
|
|
816
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
806
817
|
} | undefined
|
|
807
818
|
): Effect<RA.ReadonlyArray.With<S, B>, E, R>
|
|
808
819
|
<A, B, E, R>(
|
|
@@ -812,6 +823,7 @@ export const forEach: {
|
|
|
812
823
|
readonly concurrency?: Concurrency | undefined
|
|
813
824
|
readonly batching?: boolean | "inherit" | undefined
|
|
814
825
|
readonly discard: true
|
|
826
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
815
827
|
}
|
|
816
828
|
): Effect<void, E, R>
|
|
817
829
|
} = fiberRuntime.forEach as any
|
|
@@ -838,7 +850,11 @@ export const mergeAll: {
|
|
|
838
850
|
zero: Z,
|
|
839
851
|
f: (z: Z, a: Effect.Success<Eff>, i: number) => Z,
|
|
840
852
|
options?:
|
|
841
|
-
| {
|
|
853
|
+
| {
|
|
854
|
+
readonly concurrency?: Concurrency | undefined
|
|
855
|
+
readonly batching?: boolean | "inherit" | undefined
|
|
856
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
857
|
+
}
|
|
842
858
|
| undefined
|
|
843
859
|
): (elements: Iterable<Eff>) => Effect<Z, Effect.Error<Eff>, Effect.Context<Eff>>
|
|
844
860
|
<Eff extends Effect<any, any, any>, Z>(
|
|
@@ -846,7 +862,11 @@ export const mergeAll: {
|
|
|
846
862
|
zero: Z,
|
|
847
863
|
f: (z: Z, a: Effect.Success<Eff>, i: number) => Z,
|
|
848
864
|
options?:
|
|
849
|
-
| {
|
|
865
|
+
| {
|
|
866
|
+
readonly concurrency?: Concurrency | undefined
|
|
867
|
+
readonly batching?: boolean | "inherit" | undefined
|
|
868
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
869
|
+
}
|
|
850
870
|
| undefined
|
|
851
871
|
): Effect<Z, Effect.Error<Eff>, Effect.Context<Eff>>
|
|
852
872
|
} = fiberRuntime.mergeAll
|
|
@@ -862,14 +882,22 @@ export const partition: {
|
|
|
862
882
|
<A, B, E, R>(
|
|
863
883
|
f: (a: A, i: number) => Effect<B, E, R>,
|
|
864
884
|
options?:
|
|
865
|
-
| {
|
|
885
|
+
| {
|
|
886
|
+
readonly concurrency?: Concurrency | undefined
|
|
887
|
+
readonly batching?: boolean | "inherit" | undefined
|
|
888
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
889
|
+
}
|
|
866
890
|
| undefined
|
|
867
891
|
): (elements: Iterable<A>) => Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
|
|
868
892
|
<A, B, E, R>(
|
|
869
893
|
elements: Iterable<A>,
|
|
870
894
|
f: (a: A, i: number) => Effect<B, E, R>,
|
|
871
895
|
options?:
|
|
872
|
-
| {
|
|
896
|
+
| {
|
|
897
|
+
readonly concurrency?: Concurrency | undefined
|
|
898
|
+
readonly batching?: boolean | "inherit" | undefined
|
|
899
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
900
|
+
}
|
|
873
901
|
| undefined
|
|
874
902
|
): Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
|
|
875
903
|
} = fiberRuntime.partition
|
|
@@ -897,7 +925,11 @@ export const reduceEffect: {
|
|
|
897
925
|
zero: Effect<Z, E, R>,
|
|
898
926
|
f: (acc: NoInfer<Z>, a: Effect.Success<Eff>, i: number) => Z,
|
|
899
927
|
options?:
|
|
900
|
-
| {
|
|
928
|
+
| {
|
|
929
|
+
readonly concurrency?: Concurrency | undefined
|
|
930
|
+
readonly batching?: boolean | "inherit" | undefined
|
|
931
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
932
|
+
}
|
|
901
933
|
| undefined
|
|
902
934
|
): (elements: Iterable<Eff>) => Effect<Z, E | Effect.Error<Eff>, R | Effect.Context<Eff>>
|
|
903
935
|
<Eff extends Effect<any, any, any>, Z, E, R>(
|
|
@@ -905,7 +937,11 @@ export const reduceEffect: {
|
|
|
905
937
|
zero: Effect<Z, E, R>,
|
|
906
938
|
f: (acc: NoInfer<Z>, a: Effect.Success<Eff>, i: number) => Z,
|
|
907
939
|
options?:
|
|
908
|
-
| {
|
|
940
|
+
| {
|
|
941
|
+
readonly concurrency?: Concurrency | undefined
|
|
942
|
+
readonly batching?: boolean | "inherit" | undefined
|
|
943
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
944
|
+
}
|
|
909
945
|
| undefined
|
|
910
946
|
): Effect<Z, E | Effect.Error<Eff>, R | Effect.Context<Eff>>
|
|
911
947
|
} = fiberRuntime.reduceEffect
|
|
@@ -965,6 +1001,7 @@ export const replicateEffect: {
|
|
|
965
1001
|
readonly concurrency?: Concurrency | undefined
|
|
966
1002
|
readonly batching?: boolean | "inherit" | undefined
|
|
967
1003
|
readonly discard?: false | undefined
|
|
1004
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
968
1005
|
}
|
|
969
1006
|
): <A, E, R>(self: Effect<A, E, R>) => Effect<Array<A>, E, R>
|
|
970
1007
|
(
|
|
@@ -973,6 +1010,7 @@ export const replicateEffect: {
|
|
|
973
1010
|
readonly concurrency?: Concurrency | undefined
|
|
974
1011
|
readonly batching?: boolean | "inherit" | undefined
|
|
975
1012
|
readonly discard: true
|
|
1013
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
976
1014
|
}
|
|
977
1015
|
): <A, E, R>(self: Effect<A, E, R>) => Effect<void, E, R>
|
|
978
1016
|
<A, E, R>(
|
|
@@ -982,6 +1020,7 @@ export const replicateEffect: {
|
|
|
982
1020
|
readonly concurrency?: Concurrency | undefined
|
|
983
1021
|
readonly batching?: boolean | "inherit" | undefined
|
|
984
1022
|
readonly discard?: false | undefined
|
|
1023
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
985
1024
|
}
|
|
986
1025
|
): Effect<Array<A>, E, R>
|
|
987
1026
|
<A, E, R>(
|
|
@@ -991,6 +1030,7 @@ export const replicateEffect: {
|
|
|
991
1030
|
readonly concurrency?: Concurrency | undefined
|
|
992
1031
|
readonly batching?: boolean | "inherit" | undefined
|
|
993
1032
|
readonly discard: true
|
|
1033
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
994
1034
|
}
|
|
995
1035
|
): Effect<void, E, R>
|
|
996
1036
|
} = fiberRuntime.replicateEffect
|
|
@@ -1044,6 +1084,7 @@ export const validateAll: {
|
|
|
1044
1084
|
readonly concurrency?: Concurrency | undefined
|
|
1045
1085
|
readonly batching?: boolean | "inherit" | undefined
|
|
1046
1086
|
readonly discard?: false | undefined
|
|
1087
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
1047
1088
|
} | undefined
|
|
1048
1089
|
): (elements: Iterable<A>) => Effect<Array<B>, Array<E>, R>
|
|
1049
1090
|
<A, B, E, R>(
|
|
@@ -1052,6 +1093,7 @@ export const validateAll: {
|
|
|
1052
1093
|
readonly concurrency?: Concurrency | undefined
|
|
1053
1094
|
readonly batching?: boolean | "inherit" | undefined
|
|
1054
1095
|
readonly discard: true
|
|
1096
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
1055
1097
|
}
|
|
1056
1098
|
): (elements: Iterable<A>) => Effect<void, Array<E>, R>
|
|
1057
1099
|
<A, B, E, R>(
|
|
@@ -1061,6 +1103,7 @@ export const validateAll: {
|
|
|
1061
1103
|
readonly concurrency?: Concurrency | undefined
|
|
1062
1104
|
readonly batching?: boolean | "inherit" | undefined
|
|
1063
1105
|
readonly discard?: false | undefined
|
|
1106
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
1064
1107
|
} | undefined
|
|
1065
1108
|
): Effect<Array<B>, Array<E>, R>
|
|
1066
1109
|
<A, B, E, R>(
|
|
@@ -1070,6 +1113,7 @@ export const validateAll: {
|
|
|
1070
1113
|
readonly concurrency?: Concurrency | undefined
|
|
1071
1114
|
readonly batching?: boolean | "inherit" | undefined
|
|
1072
1115
|
readonly discard: true
|
|
1116
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
1073
1117
|
}
|
|
1074
1118
|
): Effect<void, Array<E>, R>
|
|
1075
1119
|
} = fiberRuntime.validateAll
|
|
@@ -1098,14 +1142,22 @@ export const validateFirst: {
|
|
|
1098
1142
|
<A, B, E, R>(
|
|
1099
1143
|
f: (a: A, i: number) => Effect<B, E, R>,
|
|
1100
1144
|
options?:
|
|
1101
|
-
| {
|
|
1145
|
+
| {
|
|
1146
|
+
readonly concurrency?: Concurrency | undefined
|
|
1147
|
+
readonly batching?: boolean | "inherit" | undefined
|
|
1148
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
1149
|
+
}
|
|
1102
1150
|
| undefined
|
|
1103
1151
|
): (elements: Iterable<A>) => Effect<B, Array<E>, R>
|
|
1104
1152
|
<A, B, E, R>(
|
|
1105
1153
|
elements: Iterable<A>,
|
|
1106
1154
|
f: (a: A, i: number) => Effect<B, E, R>,
|
|
1107
1155
|
options?:
|
|
1108
|
-
| {
|
|
1156
|
+
| {
|
|
1157
|
+
readonly concurrency?: Concurrency | undefined
|
|
1158
|
+
readonly batching?: boolean | "inherit" | undefined
|
|
1159
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
1160
|
+
}
|
|
1109
1161
|
| undefined
|
|
1110
1162
|
): Effect<B, Array<E>, R>
|
|
1111
1163
|
} = fiberRuntime.validateFirst
|
|
@@ -3488,6 +3540,78 @@ export const bind: {
|
|
|
3488
3540
|
): Effect<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }, E1 | E2, R1 | R2>
|
|
3489
3541
|
} = effect.bind
|
|
3490
3542
|
|
|
3543
|
+
/**
|
|
3544
|
+
* `bindAll` combines `Effect.all` with `Effect.bind`. It is useful
|
|
3545
|
+
* when you want to concurrently run multiple effects and then combine their
|
|
3546
|
+
* results in a Do notation pipeline.
|
|
3547
|
+
*
|
|
3548
|
+
* @example
|
|
3549
|
+
* import { Effect, Either, pipe } from "effect"
|
|
3550
|
+
*
|
|
3551
|
+
* const result = pipe(
|
|
3552
|
+
* Effect.Do,
|
|
3553
|
+
* Effect.bind("x", () => Effect.succeed(2)),
|
|
3554
|
+
* Effect.bindAll(({ x }) => ({
|
|
3555
|
+
* a: Effect.succeed(x),
|
|
3556
|
+
* b: Effect.fail("oops"),
|
|
3557
|
+
* }), { concurrency: 2, mode: "either" })
|
|
3558
|
+
* )
|
|
3559
|
+
* assert.deepStrictEqual(Effect.runSync(result), { x: 2, a: Either.right(2), b: Either.left("oops") })
|
|
3560
|
+
*
|
|
3561
|
+
* @category do notation
|
|
3562
|
+
* @since 3.7.0
|
|
3563
|
+
*/
|
|
3564
|
+
export const bindAll: {
|
|
3565
|
+
<
|
|
3566
|
+
A extends object,
|
|
3567
|
+
X extends Record<string, Effect<any, any, any>>,
|
|
3568
|
+
O extends {
|
|
3569
|
+
readonly concurrency?: Concurrency | undefined
|
|
3570
|
+
readonly batching?: boolean | "inherit" | undefined
|
|
3571
|
+
readonly mode?: "default" | "validate" | "either" | undefined
|
|
3572
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
3573
|
+
}
|
|
3574
|
+
>(
|
|
3575
|
+
f: (a: A) => [Extract<keyof X, keyof A>] extends [never] ? X : `Duplicate keys`,
|
|
3576
|
+
options?: undefined | O
|
|
3577
|
+
): <E1, R1>(
|
|
3578
|
+
self: Effect<A, E1, R1>
|
|
3579
|
+
) => [All.ReturnObject<X, false, All.ExtractMode<O>>] extends [Effect<infer Success, infer Error, infer Context>]
|
|
3580
|
+
? Effect<
|
|
3581
|
+
{ [K in keyof A | keyof Success]: K extends keyof A ? A[K] : K extends keyof Success ? Success[K] : never },
|
|
3582
|
+
E1 | Error,
|
|
3583
|
+
R1 | Context
|
|
3584
|
+
>
|
|
3585
|
+
: never
|
|
3586
|
+
<
|
|
3587
|
+
A extends object,
|
|
3588
|
+
X extends Record<string, Effect<any, any, any>>,
|
|
3589
|
+
O extends {
|
|
3590
|
+
readonly concurrency?: Concurrency | undefined
|
|
3591
|
+
readonly batching?: boolean | "inherit" | undefined
|
|
3592
|
+
readonly mode?: "default" | "validate" | "either" | undefined
|
|
3593
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
3594
|
+
},
|
|
3595
|
+
E1,
|
|
3596
|
+
R1
|
|
3597
|
+
>(
|
|
3598
|
+
self: Effect<A, E1, R1>,
|
|
3599
|
+
f: (a: A) => [Extract<keyof X, keyof A>] extends [never] ? X : `Duplicate keys`,
|
|
3600
|
+
options?: undefined | {
|
|
3601
|
+
readonly concurrency?: Concurrency | undefined
|
|
3602
|
+
readonly batching?: boolean | "inherit" | undefined
|
|
3603
|
+
readonly mode?: "default" | "validate" | "either" | undefined
|
|
3604
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
3605
|
+
}
|
|
3606
|
+
): [All.ReturnObject<X, false, All.ExtractMode<O>>] extends [Effect<infer Success, infer Error, infer Context>]
|
|
3607
|
+
? Effect<
|
|
3608
|
+
{ [K in keyof A | keyof Success]: K extends keyof A ? A[K] : K extends keyof Success ? Success[K] : never },
|
|
3609
|
+
E1 | Error,
|
|
3610
|
+
R1 | Context
|
|
3611
|
+
>
|
|
3612
|
+
: never
|
|
3613
|
+
} = circular.bindAll
|
|
3614
|
+
|
|
3491
3615
|
/**
|
|
3492
3616
|
* The "do simulation" in Effect allows you to write code in a more declarative style, similar to the "do notation" in other programming languages. It provides a way to define variables and perform operations on them using functions like `bind` and `let`.
|
|
3493
3617
|
*
|
|
@@ -5347,19 +5471,20 @@ export const validate: {
|
|
|
5347
5471
|
<B, E1, R1>(
|
|
5348
5472
|
that: Effect<B, E1, R1>,
|
|
5349
5473
|
options?: {
|
|
5350
|
-
/**
|
|
5351
|
-
* @since 2.0.0
|
|
5352
|
-
* @category supervision & fibers
|
|
5353
|
-
*/
|
|
5354
5474
|
readonly concurrent?: boolean | undefined
|
|
5355
5475
|
readonly batching?: boolean | "inherit" | undefined
|
|
5476
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
5356
5477
|
} | undefined
|
|
5357
5478
|
): <A, E, R>(self: Effect<A, E, R>) => Effect<[A, B], E1 | E, R1 | R>
|
|
5358
5479
|
<A, E, R, B, E1, R1>(
|
|
5359
5480
|
self: Effect<A, E, R>,
|
|
5360
5481
|
that: Effect<B, E1, R1>,
|
|
5361
5482
|
options?:
|
|
5362
|
-
| {
|
|
5483
|
+
| {
|
|
5484
|
+
readonly concurrent?: boolean | undefined
|
|
5485
|
+
readonly batching?: boolean | "inherit" | undefined
|
|
5486
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
5487
|
+
}
|
|
5363
5488
|
| undefined
|
|
5364
5489
|
): Effect<[A, B], E | E1, R | R1>
|
|
5365
5490
|
} = fiberRuntime.validate
|
|
@@ -5376,7 +5501,11 @@ export const validateWith: {
|
|
|
5376
5501
|
that: Effect<B, E1, R1>,
|
|
5377
5502
|
f: (a: A, b: B) => C,
|
|
5378
5503
|
options?:
|
|
5379
|
-
| {
|
|
5504
|
+
| {
|
|
5505
|
+
readonly concurrent?: boolean | undefined
|
|
5506
|
+
readonly batching?: boolean | "inherit" | undefined
|
|
5507
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
5508
|
+
}
|
|
5380
5509
|
| undefined
|
|
5381
5510
|
): <E, R>(self: Effect<A, E, R>) => Effect<C, E1 | E, R1 | R>
|
|
5382
5511
|
<A, E, R, B, E1, R1, C>(
|
|
@@ -5384,7 +5513,11 @@ export const validateWith: {
|
|
|
5384
5513
|
that: Effect<B, E1, R1>,
|
|
5385
5514
|
f: (a: A, b: B) => C,
|
|
5386
5515
|
options?:
|
|
5387
|
-
| {
|
|
5516
|
+
| {
|
|
5517
|
+
readonly concurrent?: boolean | undefined
|
|
5518
|
+
readonly batching?: boolean | "inherit" | undefined
|
|
5519
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
5520
|
+
}
|
|
5388
5521
|
| undefined
|
|
5389
5522
|
): Effect<C, E | E1, R | R1>
|
|
5390
5523
|
} = fiberRuntime.validateWith
|
|
@@ -5446,14 +5579,22 @@ export const zip: {
|
|
|
5446
5579
|
<A2, E2, R2>(
|
|
5447
5580
|
that: Effect<A2, E2, R2>,
|
|
5448
5581
|
options?:
|
|
5449
|
-
| {
|
|
5582
|
+
| {
|
|
5583
|
+
readonly concurrent?: boolean | undefined
|
|
5584
|
+
readonly batching?: boolean | "inherit" | undefined
|
|
5585
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
5586
|
+
}
|
|
5450
5587
|
| undefined
|
|
5451
5588
|
): <A, E, R>(self: Effect<A, E, R>) => Effect<[A, A2], E2 | E, R2 | R>
|
|
5452
5589
|
<A, E, R, A2, E2, R2>(
|
|
5453
5590
|
self: Effect<A, E, R>,
|
|
5454
5591
|
that: Effect<A2, E2, R2>,
|
|
5455
5592
|
options?:
|
|
5456
|
-
| {
|
|
5593
|
+
| {
|
|
5594
|
+
readonly concurrent?: boolean | undefined
|
|
5595
|
+
readonly batching?: boolean | "inherit" | undefined
|
|
5596
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
5597
|
+
}
|
|
5457
5598
|
| undefined
|
|
5458
5599
|
): Effect<[A, A2], E | E2, R | R2>
|
|
5459
5600
|
} = fiberRuntime.zipOptions
|
|
@@ -5482,14 +5623,22 @@ export const zipLeft: {
|
|
|
5482
5623
|
<A2, E2, R2>(
|
|
5483
5624
|
that: Effect<A2, E2, R2>,
|
|
5484
5625
|
options?:
|
|
5485
|
-
| {
|
|
5626
|
+
| {
|
|
5627
|
+
readonly concurrent?: boolean | undefined
|
|
5628
|
+
readonly batching?: boolean | "inherit" | undefined
|
|
5629
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
5630
|
+
}
|
|
5486
5631
|
| undefined
|
|
5487
5632
|
): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E2 | E, R2 | R>
|
|
5488
5633
|
<A, E, R, A2, E2, R2>(
|
|
5489
5634
|
self: Effect<A, E, R>,
|
|
5490
5635
|
that: Effect<A2, E2, R2>,
|
|
5491
5636
|
options?:
|
|
5492
|
-
| {
|
|
5637
|
+
| {
|
|
5638
|
+
readonly concurrent?: boolean | undefined
|
|
5639
|
+
readonly batching?: boolean | "inherit" | undefined
|
|
5640
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
5641
|
+
}
|
|
5493
5642
|
| undefined
|
|
5494
5643
|
): Effect<A, E | E2, R | R2>
|
|
5495
5644
|
} = fiberRuntime.zipLeftOptions
|
|
@@ -5520,6 +5669,7 @@ export const zipRight: {
|
|
|
5520
5669
|
options?: {
|
|
5521
5670
|
readonly concurrent?: boolean | undefined
|
|
5522
5671
|
readonly batching?: boolean | "inherit" | undefined
|
|
5672
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
5523
5673
|
}
|
|
5524
5674
|
): <A, E, R>(self: Effect<A, E, R>) => Effect<A2, E2 | E, R2 | R>
|
|
5525
5675
|
<A, E, R, A2, E2, R2>(
|
|
@@ -5528,6 +5678,7 @@ export const zipRight: {
|
|
|
5528
5678
|
options?: {
|
|
5529
5679
|
readonly concurrent?: boolean | undefined
|
|
5530
5680
|
readonly batching?: boolean | "inherit" | undefined
|
|
5681
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
5531
5682
|
}
|
|
5532
5683
|
): Effect<A2, E2 | E, R2 | R>
|
|
5533
5684
|
} = fiberRuntime.zipRightOptions
|
|
@@ -5572,6 +5723,7 @@ export const zipWith: {
|
|
|
5572
5723
|
options?: {
|
|
5573
5724
|
readonly concurrent?: boolean | undefined
|
|
5574
5725
|
readonly batching?: boolean | "inherit" | undefined
|
|
5726
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
5575
5727
|
}
|
|
5576
5728
|
): <E, R>(self: Effect<A, E, R>) => Effect<B, E2 | E, R2 | R>
|
|
5577
5729
|
<A, E, R, A2, E2, R2, B>(
|
|
@@ -5581,6 +5733,7 @@ export const zipWith: {
|
|
|
5581
5733
|
options?: {
|
|
5582
5734
|
readonly concurrent?: boolean | undefined
|
|
5583
5735
|
readonly batching?: boolean | "inherit" | undefined
|
|
5736
|
+
readonly concurrentFinalizers?: boolean | undefined
|
|
5584
5737
|
}
|
|
5585
5738
|
): Effect<B, E2 | E, R2 | R>
|
|
5586
5739
|
} = fiberRuntime.zipWithOptions
|
package/src/Fiber.ts
CHANGED
|
@@ -275,7 +275,14 @@ export {
|
|
|
275
275
|
* @since 2.0.0
|
|
276
276
|
* @category destructors
|
|
277
277
|
*/
|
|
278
|
-
export const awaitAll:
|
|
278
|
+
export const awaitAll: <const T extends Iterable<Fiber<any, any>>>(
|
|
279
|
+
fibers: T
|
|
280
|
+
) => Effect.Effect<
|
|
281
|
+
[T] extends [ReadonlyArray<infer U>]
|
|
282
|
+
? number extends T["length"] ? Array<U extends Fiber<infer A, infer E> ? Exit.Exit<A, E> : never>
|
|
283
|
+
: { -readonly [K in keyof T]: T[K] extends Fiber<infer A, infer E> ? Exit.Exit<A, E> : never }
|
|
284
|
+
: Array<T extends Iterable<infer U> ? U extends Fiber<infer A, infer E> ? Exit.Exit<A, E> : never : never>
|
|
285
|
+
> = fiberRuntime.fiberAwaitAll
|
|
279
286
|
|
|
280
287
|
/**
|
|
281
288
|
* Retrieves the immediate children of the fiber.
|