effect 4.0.0-beta.17 → 4.0.0-beta.19
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/Array.d.ts +127 -299
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +102 -62
- package/dist/Array.js.map +1 -1
- package/dist/Cache.d.ts.map +1 -1
- package/dist/Cache.js +5 -4
- package/dist/Cache.js.map +1 -1
- package/dist/Channel.d.ts +97 -11
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +72 -29
- package/dist/Channel.js.map +1 -1
- package/dist/Chunk.d.ts +54 -247
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +36 -67
- package/dist/Chunk.js.map +1 -1
- package/dist/Effect.d.ts +337 -437
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +118 -134
- package/dist/Effect.js.map +1 -1
- package/dist/Filter.d.ts +0 -33
- package/dist/Filter.d.ts.map +1 -1
- package/dist/Filter.js +0 -13
- package/dist/Filter.js.map +1 -1
- package/dist/HashMap.d.ts +15 -14
- package/dist/HashMap.d.ts.map +1 -1
- package/dist/HashMap.js +4 -4
- package/dist/HashMap.js.map +1 -1
- package/dist/Iterable.d.ts +40 -39
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +94 -22
- package/dist/Iterable.js.map +1 -1
- package/dist/Option.d.ts +22 -15
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js +14 -7
- package/dist/Option.js.map +1 -1
- package/dist/Pull.d.ts.map +1 -1
- package/dist/Pull.js +1 -1
- package/dist/Pull.js.map +1 -1
- package/dist/Record.d.ts +24 -120
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js +21 -41
- package/dist/Record.js.map +1 -1
- package/dist/Sink.d.ts +11 -11
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js +53 -6
- package/dist/Sink.js.map +1 -1
- package/dist/Stream.d.ts +198 -386
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +103 -59
- package/dist/Stream.js.map +1 -1
- package/dist/Trie.d.ts +18 -17
- package/dist/Trie.d.ts.map +1 -1
- package/dist/Trie.js +5 -5
- package/dist/Trie.js.map +1 -1
- package/dist/TxChunk.d.ts +37 -37
- package/dist/TxChunk.d.ts.map +1 -1
- package/dist/TxChunk.js +3 -3
- package/dist/TxChunk.js.map +1 -1
- package/dist/TxDeferred.d.ts +328 -0
- package/dist/TxDeferred.d.ts.map +1 -0
- package/dist/TxDeferred.js +196 -0
- package/dist/TxDeferred.js.map +1 -0
- package/dist/TxHashMap.d.ts +84 -83
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js +24 -24
- package/dist/TxHashMap.js.map +1 -1
- package/dist/TxHashSet.d.ts +35 -35
- package/dist/TxHashSet.d.ts.map +1 -1
- package/dist/TxHashSet.js +14 -14
- package/dist/TxHashSet.js.map +1 -1
- package/dist/TxPriorityQueue.d.ts +609 -0
- package/dist/TxPriorityQueue.d.ts.map +1 -0
- package/dist/TxPriorityQueue.js +415 -0
- package/dist/TxPriorityQueue.js.map +1 -0
- package/dist/TxPubSub.d.ts +585 -0
- package/dist/TxPubSub.d.ts.map +1 -0
- package/dist/TxPubSub.js +521 -0
- package/dist/TxPubSub.js.map +1 -0
- package/dist/TxQueue.d.ts +32 -32
- package/dist/TxQueue.d.ts.map +1 -1
- package/dist/TxQueue.js +26 -26
- package/dist/TxQueue.js.map +1 -1
- package/dist/TxReentrantLock.d.ts +523 -0
- package/dist/TxReentrantLock.d.ts.map +1 -0
- package/dist/TxReentrantLock.js +504 -0
- package/dist/TxReentrantLock.js.map +1 -0
- package/dist/TxRef.d.ts +34 -34
- package/dist/TxRef.d.ts.map +1 -1
- package/dist/TxRef.js +21 -14
- package/dist/TxRef.js.map +1 -1
- package/dist/TxSemaphore.d.ts +8 -8
- package/dist/TxSemaphore.d.ts.map +1 -1
- package/dist/TxSemaphore.js +7 -7
- package/dist/TxSemaphore.js.map +1 -1
- package/dist/TxSubscriptionRef.d.ts +508 -0
- package/dist/TxSubscriptionRef.d.ts.map +1 -0
- package/dist/TxSubscriptionRef.js +293 -0
- package/dist/TxSubscriptionRef.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/effect.js +99 -42
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/hashMap.js +3 -2
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/trie.js +5 -4
- package/dist/internal/trie.js.map +1 -1
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +0 -9
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +1 -1
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +1 -1
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cluster/K8sHttpClient.js +4 -4
- package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
- package/dist/unstable/cluster/Sharding.js +1 -1
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/encoding/Sse.js +1 -1
- package/dist/unstable/encoding/Sse.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +1 -2
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +3 -3
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/package.json +1 -1
- package/src/Array.ts +190 -342
- package/src/Cache.ts +6 -5
- package/src/Channel.ts +506 -102
- package/src/Chunk.ts +81 -268
- package/src/Effect.ts +437 -518
- package/src/Filter.ts +0 -57
- package/src/HashMap.ts +15 -14
- package/src/Iterable.ts +105 -50
- package/src/Option.ts +30 -20
- package/src/Pull.ts +1 -1
- package/src/Record.ts +43 -152
- package/src/Sink.ts +75 -23
- package/src/Stream.ts +442 -502
- package/src/Trie.ts +18 -17
- package/src/TxChunk.ts +72 -53
- package/src/TxDeferred.ts +394 -0
- package/src/TxHashMap.ts +332 -285
- package/src/TxHashSet.ts +111 -116
- package/src/TxPriorityQueue.ts +767 -0
- package/src/TxPubSub.ts +789 -0
- package/src/TxQueue.ts +241 -251
- package/src/TxReentrantLock.ts +753 -0
- package/src/TxRef.ts +50 -38
- package/src/TxSemaphore.ts +29 -32
- package/src/TxSubscriptionRef.ts +639 -0
- package/src/index.ts +45 -0
- package/src/internal/effect.ts +368 -163
- package/src/internal/hashMap.ts +7 -5
- package/src/internal/trie.ts +16 -9
- package/src/unstable/ai/Tool.ts +0 -9
- package/src/unstable/cli/Command.ts +6 -4
- package/src/unstable/cluster/K8sHttpClient.ts +4 -4
- package/src/unstable/cluster/Sharding.ts +1 -1
- package/src/unstable/encoding/Sse.ts +1 -1
- package/src/unstable/rpc/RpcServer.ts +1 -7
- package/src/unstable/socket/Socket.ts +9 -11
package/dist/Stream.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import * as Duration from "./Duration.ts";
|
|
|
8
8
|
import * as Effect from "./Effect.ts";
|
|
9
9
|
import * as ExecutionPlan from "./ExecutionPlan.ts";
|
|
10
10
|
import * as Exit from "./Exit.ts";
|
|
11
|
-
import * as Filter from "./Filter.ts";
|
|
11
|
+
import type * as Filter from "./Filter.ts";
|
|
12
12
|
import type { LazyArg } from "./Function.ts";
|
|
13
13
|
import type { TypeLambda } from "./HKT.ts";
|
|
14
14
|
import type * as Layer from "./Layer.ts";
|
|
@@ -4775,7 +4775,7 @@ export declare const filter: {
|
|
|
4775
4775
|
* @since 2.0.0
|
|
4776
4776
|
* @category Filtering
|
|
4777
4777
|
*/
|
|
4778
|
-
<A
|
|
4778
|
+
<A>(predicate: Predicate<NoInfer<A>>): <E, R>(self: Stream<A, E, R>) => Stream<A, E, R>;
|
|
4779
4779
|
/**
|
|
4780
4780
|
* Filters a stream to the elements that satisfy a predicate.
|
|
4781
4781
|
*
|
|
@@ -4821,20 +4821,38 @@ export declare const filter: {
|
|
|
4821
4821
|
* @since 2.0.0
|
|
4822
4822
|
* @category Filtering
|
|
4823
4823
|
*/
|
|
4824
|
-
<A, E, R
|
|
4824
|
+
<A, E, R>(self: Stream<A, E, R>, predicate: Predicate<A>): Stream<A, E, R>;
|
|
4825
4825
|
};
|
|
4826
4826
|
/**
|
|
4827
|
-
*
|
|
4827
|
+
* Filters and maps stream elements in one pass using a `Filter`.
|
|
4828
|
+
*
|
|
4829
|
+
* @since 4.0.0
|
|
4830
|
+
* @category Filtering
|
|
4831
|
+
*/
|
|
4832
|
+
export declare const filterMap: {
|
|
4833
|
+
/**
|
|
4834
|
+
* Filters and maps stream elements in one pass using a `Filter`.
|
|
4835
|
+
*
|
|
4836
|
+
* @since 4.0.0
|
|
4837
|
+
* @category Filtering
|
|
4838
|
+
*/
|
|
4839
|
+
<A, B, X>(filter: Filter.Filter<NoInfer<A>, B, X>): <E, R>(self: Stream<A, E, R>) => Stream<B, E, R>;
|
|
4840
|
+
/**
|
|
4841
|
+
* Filters and maps stream elements in one pass using a `Filter`.
|
|
4842
|
+
*
|
|
4843
|
+
* @since 4.0.0
|
|
4844
|
+
* @category Filtering
|
|
4845
|
+
*/
|
|
4846
|
+
<A, E, R, B, X>(self: Stream<A, E, R>, filter: Filter.Filter<A, B, X>): Stream<B, E, R>;
|
|
4847
|
+
};
|
|
4848
|
+
/**
|
|
4849
|
+
* Effectfully filters elements in a single pass.
|
|
4828
4850
|
*
|
|
4829
4851
|
* @example
|
|
4830
4852
|
* ```ts
|
|
4831
|
-
* import { Console, Effect,
|
|
4832
|
-
*
|
|
4833
|
-
* const filter = Filter.makeEffect((n: number) =>
|
|
4834
|
-
* Effect.succeed(n > 2 ? Result.succeed(n + 1) : Result.fail(n))
|
|
4835
|
-
* )
|
|
4853
|
+
* import { Console, Effect, Stream } from "effect"
|
|
4836
4854
|
*
|
|
4837
|
-
* const stream = Stream.make(1, 2, 3, 4).pipe(Stream.filterEffect(
|
|
4855
|
+
* const stream = Stream.make(1, 2, 3, 4).pipe(Stream.filterEffect((n) => Effect.succeed(n > 2)))
|
|
4838
4856
|
*
|
|
4839
4857
|
* const program = Effect.gen(function*() {
|
|
4840
4858
|
* const result = yield* Stream.runCollect(stream)
|
|
@@ -4842,7 +4860,7 @@ export declare const filter: {
|
|
|
4842
4860
|
* })
|
|
4843
4861
|
*
|
|
4844
4862
|
* Effect.runPromise(program)
|
|
4845
|
-
* // Output: [
|
|
4863
|
+
* // Output: [ 3, 4 ]
|
|
4846
4864
|
* ```
|
|
4847
4865
|
*
|
|
4848
4866
|
* @since 2.0.0
|
|
@@ -4850,17 +4868,13 @@ export declare const filter: {
|
|
|
4850
4868
|
*/
|
|
4851
4869
|
export declare const filterEffect: {
|
|
4852
4870
|
/**
|
|
4853
|
-
* Effectfully filters
|
|
4871
|
+
* Effectfully filters elements in a single pass.
|
|
4854
4872
|
*
|
|
4855
4873
|
* @example
|
|
4856
4874
|
* ```ts
|
|
4857
|
-
* import { Console, Effect,
|
|
4858
|
-
*
|
|
4859
|
-
* const filter = Filter.makeEffect((n: number) =>
|
|
4860
|
-
* Effect.succeed(n > 2 ? Result.succeed(n + 1) : Result.fail(n))
|
|
4861
|
-
* )
|
|
4875
|
+
* import { Console, Effect, Stream } from "effect"
|
|
4862
4876
|
*
|
|
4863
|
-
* const stream = Stream.make(1, 2, 3, 4).pipe(Stream.filterEffect(
|
|
4877
|
+
* const stream = Stream.make(1, 2, 3, 4).pipe(Stream.filterEffect((n) => Effect.succeed(n > 2)))
|
|
4864
4878
|
*
|
|
4865
4879
|
* const program = Effect.gen(function*() {
|
|
4866
4880
|
* const result = yield* Stream.runCollect(stream)
|
|
@@ -4868,25 +4882,21 @@ export declare const filterEffect: {
|
|
|
4868
4882
|
* })
|
|
4869
4883
|
*
|
|
4870
4884
|
* Effect.runPromise(program)
|
|
4871
|
-
* // Output: [
|
|
4885
|
+
* // Output: [ 3, 4 ]
|
|
4872
4886
|
* ```
|
|
4873
4887
|
*
|
|
4874
4888
|
* @since 2.0.0
|
|
4875
4889
|
* @category Filtering
|
|
4876
4890
|
*/
|
|
4877
|
-
<A,
|
|
4891
|
+
<A, EX, RX>(predicate: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, EX, RX>): <E, R>(self: Stream<A, E, R>) => Stream<A, E | EX, R | RX>;
|
|
4878
4892
|
/**
|
|
4879
|
-
* Effectfully filters
|
|
4893
|
+
* Effectfully filters elements in a single pass.
|
|
4880
4894
|
*
|
|
4881
4895
|
* @example
|
|
4882
4896
|
* ```ts
|
|
4883
|
-
* import { Console, Effect,
|
|
4884
|
-
*
|
|
4885
|
-
* const filter = Filter.makeEffect((n: number) =>
|
|
4886
|
-
* Effect.succeed(n > 2 ? Result.succeed(n + 1) : Result.fail(n))
|
|
4887
|
-
* )
|
|
4897
|
+
* import { Console, Effect, Stream } from "effect"
|
|
4888
4898
|
*
|
|
4889
|
-
* const stream = Stream.make(1, 2, 3, 4).pipe(Stream.filterEffect(
|
|
4899
|
+
* const stream = Stream.make(1, 2, 3, 4).pipe(Stream.filterEffect((n) => Effect.succeed(n > 2)))
|
|
4890
4900
|
*
|
|
4891
4901
|
* const program = Effect.gen(function*() {
|
|
4892
4902
|
* const result = yield* Stream.runCollect(stream)
|
|
@@ -4894,28 +4904,48 @@ export declare const filterEffect: {
|
|
|
4894
4904
|
* })
|
|
4895
4905
|
*
|
|
4896
4906
|
* Effect.runPromise(program)
|
|
4897
|
-
* // Output: [
|
|
4907
|
+
* // Output: [ 3, 4 ]
|
|
4898
4908
|
* ```
|
|
4899
4909
|
*
|
|
4900
4910
|
* @since 2.0.0
|
|
4901
4911
|
* @category Filtering
|
|
4902
4912
|
*/
|
|
4913
|
+
<A, E, R, EX, RX>(self: Stream<A, E, R>, predicate: (a: NoInfer<A>, i: number) => Effect.Effect<boolean, EX, RX>): Stream<A, E | EX, R | RX>;
|
|
4914
|
+
};
|
|
4915
|
+
/**
|
|
4916
|
+
* Effectfully filters and maps elements in a single pass.
|
|
4917
|
+
*
|
|
4918
|
+
* @since 4.0.0
|
|
4919
|
+
* @category Filtering
|
|
4920
|
+
*/
|
|
4921
|
+
export declare const filterMapEffect: {
|
|
4922
|
+
/**
|
|
4923
|
+
* Effectfully filters and maps elements in a single pass.
|
|
4924
|
+
*
|
|
4925
|
+
* @since 4.0.0
|
|
4926
|
+
* @category Filtering
|
|
4927
|
+
*/
|
|
4928
|
+
<A, B, X, EX, RX>(filter: Filter.FilterEffect<NoInfer<A>, B, X, EX, RX>): <E, R>(self: Stream<A, E, R>) => Stream<B, E | EX, R | RX>;
|
|
4929
|
+
/**
|
|
4930
|
+
* Effectfully filters and maps elements in a single pass.
|
|
4931
|
+
*
|
|
4932
|
+
* @since 4.0.0
|
|
4933
|
+
* @category Filtering
|
|
4934
|
+
*/
|
|
4903
4935
|
<A, E, R, B, X, EX, RX>(self: Stream<A, E, R>, filter: Filter.FilterEffect<A, B, X, EX, RX>): Stream<B, E | EX, R | RX>;
|
|
4904
4936
|
};
|
|
4905
4937
|
/**
|
|
4906
|
-
* Partitions a stream using a Filter and exposes passing and failing values as queues.
|
|
4938
|
+
* Partitions a stream using a `Filter` and exposes passing and failing values as queues.
|
|
4907
4939
|
*
|
|
4908
4940
|
* Each queue fails with the stream error or `Cause.Done` when the source ends.
|
|
4909
4941
|
*
|
|
4910
4942
|
* @example
|
|
4911
4943
|
* ```ts
|
|
4912
|
-
* import { Console, Effect,
|
|
4944
|
+
* import { Console, Effect, Result, Stream } from "effect"
|
|
4913
4945
|
*
|
|
4914
4946
|
* const program = Effect.gen(function*() {
|
|
4915
4947
|
* const [passes, fails] = yield* Stream.make(1, 2, 3, 4).pipe(
|
|
4916
|
-
* Stream.partitionQueue(
|
|
4917
|
-
* Filter.make((n) => (n % 2 === 0 ? Result.succeed(n) : Result.fail(n)))
|
|
4918
|
-
* )
|
|
4948
|
+
* Stream.partitionQueue((n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
|
|
4919
4949
|
* )
|
|
4920
4950
|
*
|
|
4921
4951
|
* const passValues = yield* Stream.fromQueue(passes).pipe(Stream.runCollect)
|
|
@@ -4935,56 +4965,17 @@ export declare const filterEffect: {
|
|
|
4935
4965
|
*/
|
|
4936
4966
|
export declare const partitionQueue: {
|
|
4937
4967
|
/**
|
|
4938
|
-
* Partitions a stream using a Filter and exposes passing and failing values as queues.
|
|
4968
|
+
* Partitions a stream using a `Filter` and exposes passing and failing values as queues.
|
|
4939
4969
|
*
|
|
4940
4970
|
* Each queue fails with the stream error or `Cause.Done` when the source ends.
|
|
4941
4971
|
*
|
|
4942
4972
|
* @example
|
|
4943
4973
|
* ```ts
|
|
4944
|
-
* import { Console, Effect,
|
|
4945
|
-
*
|
|
4946
|
-
* const program = Effect.gen(function*() {
|
|
4947
|
-
* const [passes, fails] = yield* Stream.make(1, 2, 3, 4).pipe(
|
|
4948
|
-
* Stream.partitionQueue(
|
|
4949
|
-
* Filter.make((n) => (n % 2 === 0 ? Result.succeed(n) : Result.fail(n)))
|
|
4950
|
-
* )
|
|
4951
|
-
* )
|
|
4952
|
-
*
|
|
4953
|
-
* const passValues = yield* Stream.fromQueue(passes).pipe(Stream.runCollect)
|
|
4954
|
-
* const failValues = yield* Stream.fromQueue(fails).pipe(Stream.runCollect)
|
|
4955
|
-
*
|
|
4956
|
-
* yield* Console.log(passValues)
|
|
4957
|
-
* // Output: [ 2, 4 ]
|
|
4958
|
-
* yield* Console.log(failValues)
|
|
4959
|
-
* // Output: [ 1, 3 ]
|
|
4960
|
-
* })
|
|
4961
|
-
*
|
|
4962
|
-
* Effect.runPromise(Effect.scoped(program))
|
|
4963
|
-
* ```
|
|
4964
|
-
*
|
|
4965
|
-
* @since 4.0.0
|
|
4966
|
-
* @category Filtering
|
|
4967
|
-
*/
|
|
4968
|
-
<A, B extends A>(refinement: Refinement<NoInfer<A>, B>, options?: {
|
|
4969
|
-
readonly capacity?: number | "unbounded" | undefined;
|
|
4970
|
-
}): <E, R>(self: Stream<A, E, R>) => Effect.Effect<[
|
|
4971
|
-
passes: Queue.Dequeue<B, E | Cause.Done>,
|
|
4972
|
-
fails: Queue.Dequeue<Exclude<A, B>, E | Cause.Done>
|
|
4973
|
-
], never, R | Scope.Scope>;
|
|
4974
|
-
/**
|
|
4975
|
-
* Partitions a stream using a Filter and exposes passing and failing values as queues.
|
|
4976
|
-
*
|
|
4977
|
-
* Each queue fails with the stream error or `Cause.Done` when the source ends.
|
|
4978
|
-
*
|
|
4979
|
-
* @example
|
|
4980
|
-
* ```ts
|
|
4981
|
-
* import { Console, Effect, Filter, Result, Stream } from "effect"
|
|
4974
|
+
* import { Console, Effect, Result, Stream } from "effect"
|
|
4982
4975
|
*
|
|
4983
4976
|
* const program = Effect.gen(function*() {
|
|
4984
4977
|
* const [passes, fails] = yield* Stream.make(1, 2, 3, 4).pipe(
|
|
4985
|
-
* Stream.partitionQueue(
|
|
4986
|
-
* Filter.make((n) => (n % 2 === 0 ? Result.succeed(n) : Result.fail(n)))
|
|
4987
|
-
* )
|
|
4978
|
+
* Stream.partitionQueue((n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
|
|
4988
4979
|
* )
|
|
4989
4980
|
*
|
|
4990
4981
|
* const passValues = yield* Stream.fromQueue(passes).pipe(Stream.runCollect)
|
|
@@ -5002,63 +4993,24 @@ export declare const partitionQueue: {
|
|
|
5002
4993
|
* @since 4.0.0
|
|
5003
4994
|
* @category Filtering
|
|
5004
4995
|
*/
|
|
5005
|
-
<A,
|
|
4996
|
+
<A, Pass, Fail>(filter: Filter.Filter<NoInfer<A>, Pass, Fail>, options?: {
|
|
5006
4997
|
readonly capacity?: number | "unbounded" | undefined;
|
|
5007
4998
|
}): <E, R>(self: Stream<A, E, R>) => Effect.Effect<[
|
|
5008
|
-
passes: Queue.Dequeue<
|
|
5009
|
-
fails: Queue.Dequeue<
|
|
4999
|
+
passes: Queue.Dequeue<Pass, E | Cause.Done>,
|
|
5000
|
+
fails: Queue.Dequeue<Fail, E | Cause.Done>
|
|
5010
5001
|
], never, R | Scope.Scope>;
|
|
5011
5002
|
/**
|
|
5012
|
-
* Partitions a stream using a Filter and exposes passing and failing values as queues.
|
|
5003
|
+
* Partitions a stream using a `Filter` and exposes passing and failing values as queues.
|
|
5013
5004
|
*
|
|
5014
5005
|
* Each queue fails with the stream error or `Cause.Done` when the source ends.
|
|
5015
5006
|
*
|
|
5016
5007
|
* @example
|
|
5017
5008
|
* ```ts
|
|
5018
|
-
* import { Console, Effect,
|
|
5019
|
-
*
|
|
5020
|
-
* const program = Effect.gen(function*() {
|
|
5021
|
-
* const [passes, fails] = yield* Stream.make(1, 2, 3, 4).pipe(
|
|
5022
|
-
* Stream.partitionQueue(
|
|
5023
|
-
* Filter.make((n) => (n % 2 === 0 ? Result.succeed(n) : Result.fail(n)))
|
|
5024
|
-
* )
|
|
5025
|
-
* )
|
|
5026
|
-
*
|
|
5027
|
-
* const passValues = yield* Stream.fromQueue(passes).pipe(Stream.runCollect)
|
|
5028
|
-
* const failValues = yield* Stream.fromQueue(fails).pipe(Stream.runCollect)
|
|
5029
|
-
*
|
|
5030
|
-
* yield* Console.log(passValues)
|
|
5031
|
-
* // Output: [ 2, 4 ]
|
|
5032
|
-
* yield* Console.log(failValues)
|
|
5033
|
-
* // Output: [ 1, 3 ]
|
|
5034
|
-
* })
|
|
5035
|
-
*
|
|
5036
|
-
* Effect.runPromise(Effect.scoped(program))
|
|
5037
|
-
* ```
|
|
5038
|
-
*
|
|
5039
|
-
* @since 4.0.0
|
|
5040
|
-
* @category Filtering
|
|
5041
|
-
*/
|
|
5042
|
-
<A, E, R, B extends A>(self: Stream<A, E, R>, refinement: Refinement<A, B>, options?: {
|
|
5043
|
-
readonly capacity?: number | "unbounded" | undefined;
|
|
5044
|
-
}): Effect.Effect<[
|
|
5045
|
-
passes: Queue.Dequeue<B, E | Cause.Done>,
|
|
5046
|
-
fails: Queue.Dequeue<Exclude<A, B>, E | Cause.Done>
|
|
5047
|
-
], never, R | Scope.Scope>;
|
|
5048
|
-
/**
|
|
5049
|
-
* Partitions a stream using a Filter and exposes passing and failing values as queues.
|
|
5050
|
-
*
|
|
5051
|
-
* Each queue fails with the stream error or `Cause.Done` when the source ends.
|
|
5052
|
-
*
|
|
5053
|
-
* @example
|
|
5054
|
-
* ```ts
|
|
5055
|
-
* import { Console, Effect, Filter, Result, Stream } from "effect"
|
|
5009
|
+
* import { Console, Effect, Result, Stream } from "effect"
|
|
5056
5010
|
*
|
|
5057
5011
|
* const program = Effect.gen(function*() {
|
|
5058
5012
|
* const [passes, fails] = yield* Stream.make(1, 2, 3, 4).pipe(
|
|
5059
|
-
* Stream.partitionQueue(
|
|
5060
|
-
* Filter.make((n) => (n % 2 === 0 ? Result.succeed(n) : Result.fail(n)))
|
|
5061
|
-
* )
|
|
5013
|
+
* Stream.partitionQueue((n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
|
|
5062
5014
|
* )
|
|
5063
5015
|
*
|
|
5064
5016
|
* const passValues = yield* Stream.fromQueue(passes).pipe(Stream.runCollect)
|
|
@@ -5076,119 +5028,49 @@ export declare const partitionQueue: {
|
|
|
5076
5028
|
* @since 4.0.0
|
|
5077
5029
|
* @category Filtering
|
|
5078
5030
|
*/
|
|
5079
|
-
<A, E, R,
|
|
5031
|
+
<A, E, R, Pass, Fail>(self: Stream<A, E, R>, filter: Filter.Filter<NoInfer<A>, Pass, Fail>, options?: {
|
|
5080
5032
|
readonly capacity?: number | "unbounded" | undefined;
|
|
5081
5033
|
}): Effect.Effect<[
|
|
5082
|
-
passes: Queue.Dequeue<
|
|
5083
|
-
fails: Queue.Dequeue<
|
|
5034
|
+
passes: Queue.Dequeue<Pass, E | Cause.Done>,
|
|
5035
|
+
fails: Queue.Dequeue<Fail, E | Cause.Done>
|
|
5084
5036
|
], never, R | Scope.Scope>;
|
|
5085
5037
|
};
|
|
5086
5038
|
/**
|
|
5087
|
-
* Splits a stream using an effectful
|
|
5039
|
+
* Splits a stream using an effectful `Filter`, producing pass and fail streams.
|
|
5088
5040
|
*
|
|
5089
5041
|
* @since 4.0.0
|
|
5090
5042
|
* @category Filtering
|
|
5091
|
-
*
|
|
5092
|
-
* @example
|
|
5093
|
-
* ```ts
|
|
5094
|
-
* import { Console, Effect, Result, Stream } from "effect"
|
|
5095
|
-
*
|
|
5096
|
-
* const program = Effect.scoped(
|
|
5097
|
-
* Effect.gen(function*() {
|
|
5098
|
-
* const [evens, odds] = yield* Stream.make(1, 2, 3, 4).pipe(
|
|
5099
|
-
* Stream.partitionEffect((n) =>
|
|
5100
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
|
|
5101
|
-
* )
|
|
5102
|
-
* )
|
|
5103
|
-
* const result = yield* Effect.all({
|
|
5104
|
-
* evens: Stream.runCollect(evens),
|
|
5105
|
-
* odds: Stream.runCollect(odds)
|
|
5106
|
-
* })
|
|
5107
|
-
* yield* Console.log(result)
|
|
5108
|
-
* })
|
|
5109
|
-
* )
|
|
5110
|
-
*
|
|
5111
|
-
* Effect.runPromise(program)
|
|
5112
|
-
* // Output: { evens: [ 2, 4 ], odds: [ 1, 3 ] }
|
|
5113
|
-
* ```
|
|
5114
5043
|
*/
|
|
5115
5044
|
export declare const partitionEffect: {
|
|
5116
5045
|
/**
|
|
5117
|
-
* Splits a stream using an effectful
|
|
5046
|
+
* Splits a stream using an effectful `Filter`, producing pass and fail streams.
|
|
5118
5047
|
*
|
|
5119
5048
|
* @since 4.0.0
|
|
5120
5049
|
* @category Filtering
|
|
5121
|
-
*
|
|
5122
|
-
* @example
|
|
5123
|
-
* ```ts
|
|
5124
|
-
* import { Console, Effect, Result, Stream } from "effect"
|
|
5125
|
-
*
|
|
5126
|
-
* const program = Effect.scoped(
|
|
5127
|
-
* Effect.gen(function*() {
|
|
5128
|
-
* const [evens, odds] = yield* Stream.make(1, 2, 3, 4).pipe(
|
|
5129
|
-
* Stream.partitionEffect((n) =>
|
|
5130
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
|
|
5131
|
-
* )
|
|
5132
|
-
* )
|
|
5133
|
-
* const result = yield* Effect.all({
|
|
5134
|
-
* evens: Stream.runCollect(evens),
|
|
5135
|
-
* odds: Stream.runCollect(odds)
|
|
5136
|
-
* })
|
|
5137
|
-
* yield* Console.log(result)
|
|
5138
|
-
* })
|
|
5139
|
-
* )
|
|
5140
|
-
*
|
|
5141
|
-
* Effect.runPromise(program)
|
|
5142
|
-
* // Output: { evens: [ 2, 4 ], odds: [ 1, 3 ] }
|
|
5143
|
-
* ```
|
|
5144
5050
|
*/
|
|
5145
|
-
<A,
|
|
5051
|
+
<A, Pass, Fail, EX, RX>(filter: Filter.FilterEffect<NoInfer<A>, Pass, Fail, EX, RX>, options?: {
|
|
5146
5052
|
readonly capacity?: number | "unbounded" | undefined;
|
|
5147
5053
|
readonly concurrency?: number | "unbounded" | undefined;
|
|
5148
5054
|
}): <E, R>(self: Stream<A, E, R>) => Effect.Effect<[
|
|
5149
|
-
passes: Stream<
|
|
5150
|
-
fails: Stream<
|
|
5055
|
+
passes: Stream<Pass, E | EX>,
|
|
5056
|
+
fails: Stream<Fail, E | EX>
|
|
5151
5057
|
], never, R | RX | Scope.Scope>;
|
|
5152
5058
|
/**
|
|
5153
|
-
* Splits a stream using an effectful
|
|
5059
|
+
* Splits a stream using an effectful `Filter`, producing pass and fail streams.
|
|
5154
5060
|
*
|
|
5155
5061
|
* @since 4.0.0
|
|
5156
5062
|
* @category Filtering
|
|
5157
|
-
*
|
|
5158
|
-
* @example
|
|
5159
|
-
* ```ts
|
|
5160
|
-
* import { Console, Effect, Result, Stream } from "effect"
|
|
5161
|
-
*
|
|
5162
|
-
* const program = Effect.scoped(
|
|
5163
|
-
* Effect.gen(function*() {
|
|
5164
|
-
* const [evens, odds] = yield* Stream.make(1, 2, 3, 4).pipe(
|
|
5165
|
-
* Stream.partitionEffect((n) =>
|
|
5166
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
|
|
5167
|
-
* )
|
|
5168
|
-
* )
|
|
5169
|
-
* const result = yield* Effect.all({
|
|
5170
|
-
* evens: Stream.runCollect(evens),
|
|
5171
|
-
* odds: Stream.runCollect(odds)
|
|
5172
|
-
* })
|
|
5173
|
-
* yield* Console.log(result)
|
|
5174
|
-
* })
|
|
5175
|
-
* )
|
|
5176
|
-
*
|
|
5177
|
-
* Effect.runPromise(program)
|
|
5178
|
-
* // Output: { evens: [ 2, 4 ], odds: [ 1, 3 ] }
|
|
5179
|
-
* ```
|
|
5180
5063
|
*/
|
|
5181
|
-
<A, E, R,
|
|
5064
|
+
<A, E, R, Pass, Fail, EX, RX>(self: Stream<A, E, R>, filter: Filter.FilterEffect<NoInfer<A>, Pass, Fail, EX, RX>, options?: {
|
|
5182
5065
|
readonly capacity?: number | "unbounded" | undefined;
|
|
5183
5066
|
readonly concurrency?: number | "unbounded" | undefined;
|
|
5184
5067
|
}): Effect.Effect<[
|
|
5185
|
-
passes: Stream<
|
|
5186
|
-
fails: Stream<
|
|
5068
|
+
passes: Stream<Pass, E | EX>,
|
|
5069
|
+
fails: Stream<Fail, E | EX>
|
|
5187
5070
|
], never, R | RX | Scope.Scope>;
|
|
5188
5071
|
};
|
|
5189
5072
|
/**
|
|
5190
|
-
* Splits a stream into excluded and satisfying substreams using a
|
|
5191
|
-
* refinement, or Filter.
|
|
5073
|
+
* Splits a stream into excluded and satisfying substreams using a `Filter`.
|
|
5192
5074
|
*
|
|
5193
5075
|
* The faster stream may advance up to `bufferSize` elements ahead of the slower
|
|
5194
5076
|
* one.
|
|
@@ -5198,12 +5080,12 @@ export declare const partitionEffect: {
|
|
|
5198
5080
|
*
|
|
5199
5081
|
* @example
|
|
5200
5082
|
* ```ts
|
|
5201
|
-
* import { Console, Effect, Stream } from "effect"
|
|
5083
|
+
* import { Console, Effect, Result, Stream } from "effect"
|
|
5202
5084
|
*
|
|
5203
5085
|
* const program = Effect.gen(function*() {
|
|
5204
5086
|
* const [excluded, satisfying] = yield* Stream.partition(
|
|
5205
5087
|
* Stream.make(1, 2, 3, 4),
|
|
5206
|
-
* (n) => n % 2 === 0
|
|
5088
|
+
* (n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n)
|
|
5207
5089
|
* )
|
|
5208
5090
|
* const left = yield* Stream.runCollect(excluded)
|
|
5209
5091
|
* const right = yield* Stream.runCollect(satisfying)
|
|
@@ -5216,8 +5098,7 @@ export declare const partitionEffect: {
|
|
|
5216
5098
|
*/
|
|
5217
5099
|
export declare const partition: {
|
|
5218
5100
|
/**
|
|
5219
|
-
* Splits a stream into excluded and satisfying substreams using a
|
|
5220
|
-
* refinement, or Filter.
|
|
5101
|
+
* Splits a stream into excluded and satisfying substreams using a `Filter`.
|
|
5221
5102
|
*
|
|
5222
5103
|
* The faster stream may advance up to `bufferSize` elements ahead of the slower
|
|
5223
5104
|
* one.
|
|
@@ -5227,46 +5108,12 @@ export declare const partition: {
|
|
|
5227
5108
|
*
|
|
5228
5109
|
* @example
|
|
5229
5110
|
* ```ts
|
|
5230
|
-
* import { Console, Effect, Stream } from "effect"
|
|
5231
|
-
*
|
|
5232
|
-
* const program = Effect.gen(function*() {
|
|
5233
|
-
* const [excluded, satisfying] = yield* Stream.partition(
|
|
5234
|
-
* Stream.make(1, 2, 3, 4),
|
|
5235
|
-
* (n) => n % 2 === 0
|
|
5236
|
-
* )
|
|
5237
|
-
* const left = yield* Stream.runCollect(excluded)
|
|
5238
|
-
* const right = yield* Stream.runCollect(satisfying)
|
|
5239
|
-
* yield* Console.log(left)
|
|
5240
|
-
* // Output: [ 1, 3 ]
|
|
5241
|
-
* yield* Console.log(right)
|
|
5242
|
-
* // Output: [ 2, 4 ]
|
|
5243
|
-
* })
|
|
5244
|
-
* ```
|
|
5245
|
-
*/
|
|
5246
|
-
<C extends A, B extends A, A = C>(refinement: Refinement<NoInfer<A>, B>, options?: {
|
|
5247
|
-
readonly bufferSize?: number | undefined;
|
|
5248
|
-
}): <E, R>(self: Stream<C, E, R>) => Effect.Effect<[
|
|
5249
|
-
excluded: Stream<Exclude<C, B>, E>,
|
|
5250
|
-
satisfying: Stream<B, E>
|
|
5251
|
-
], never, R | Scope.Scope>;
|
|
5252
|
-
/**
|
|
5253
|
-
* Splits a stream into excluded and satisfying substreams using a predicate,
|
|
5254
|
-
* refinement, or Filter.
|
|
5255
|
-
*
|
|
5256
|
-
* The faster stream may advance up to `bufferSize` elements ahead of the slower
|
|
5257
|
-
* one.
|
|
5258
|
-
*
|
|
5259
|
-
* @since 4.0.0
|
|
5260
|
-
* @category Filtering
|
|
5261
|
-
*
|
|
5262
|
-
* @example
|
|
5263
|
-
* ```ts
|
|
5264
|
-
* import { Console, Effect, Stream } from "effect"
|
|
5111
|
+
* import { Console, Effect, Result, Stream } from "effect"
|
|
5265
5112
|
*
|
|
5266
5113
|
* const program = Effect.gen(function*() {
|
|
5267
5114
|
* const [excluded, satisfying] = yield* Stream.partition(
|
|
5268
5115
|
* Stream.make(1, 2, 3, 4),
|
|
5269
|
-
* (n) => n % 2 === 0
|
|
5116
|
+
* (n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n)
|
|
5270
5117
|
* )
|
|
5271
5118
|
* const left = yield* Stream.runCollect(excluded)
|
|
5272
5119
|
* const right = yield* Stream.runCollect(satisfying)
|
|
@@ -5277,15 +5124,14 @@ export declare const partition: {
|
|
|
5277
5124
|
* })
|
|
5278
5125
|
* ```
|
|
5279
5126
|
*/
|
|
5280
|
-
<A,
|
|
5127
|
+
<A, Pass, Fail>(filter: Filter.Filter<NoInfer<A>, Pass, Fail>, options?: {
|
|
5281
5128
|
readonly bufferSize?: number | undefined;
|
|
5282
5129
|
}): <E, R>(self: Stream<A, E, R>) => Effect.Effect<[
|
|
5283
|
-
excluded: Stream<
|
|
5284
|
-
satisfying: Stream<
|
|
5130
|
+
excluded: Stream<Fail, E>,
|
|
5131
|
+
satisfying: Stream<Pass, E>
|
|
5285
5132
|
], never, R | Scope.Scope>;
|
|
5286
5133
|
/**
|
|
5287
|
-
* Splits a stream into excluded and satisfying substreams using a
|
|
5288
|
-
* refinement, or Filter.
|
|
5134
|
+
* Splits a stream into excluded and satisfying substreams using a `Filter`.
|
|
5289
5135
|
*
|
|
5290
5136
|
* The faster stream may advance up to `bufferSize` elements ahead of the slower
|
|
5291
5137
|
* one.
|
|
@@ -5295,46 +5141,12 @@ export declare const partition: {
|
|
|
5295
5141
|
*
|
|
5296
5142
|
* @example
|
|
5297
5143
|
* ```ts
|
|
5298
|
-
* import { Console, Effect, Stream } from "effect"
|
|
5299
|
-
*
|
|
5300
|
-
* const program = Effect.gen(function*() {
|
|
5301
|
-
* const [excluded, satisfying] = yield* Stream.partition(
|
|
5302
|
-
* Stream.make(1, 2, 3, 4),
|
|
5303
|
-
* (n) => n % 2 === 0
|
|
5304
|
-
* )
|
|
5305
|
-
* const left = yield* Stream.runCollect(excluded)
|
|
5306
|
-
* const right = yield* Stream.runCollect(satisfying)
|
|
5307
|
-
* yield* Console.log(left)
|
|
5308
|
-
* // Output: [ 1, 3 ]
|
|
5309
|
-
* yield* Console.log(right)
|
|
5310
|
-
* // Output: [ 2, 4 ]
|
|
5311
|
-
* })
|
|
5312
|
-
* ```
|
|
5313
|
-
*/
|
|
5314
|
-
<C extends A, E, R, B extends A, A = C>(self: Stream<C, E, R>, refinement: Refinement<A, B>, options?: {
|
|
5315
|
-
readonly bufferSize?: number | undefined;
|
|
5316
|
-
}): Effect.Effect<[
|
|
5317
|
-
excluded: Stream<Exclude<C, B>, E>,
|
|
5318
|
-
satisfying: Stream<B, E>
|
|
5319
|
-
], never, R | Scope.Scope>;
|
|
5320
|
-
/**
|
|
5321
|
-
* Splits a stream into excluded and satisfying substreams using a predicate,
|
|
5322
|
-
* refinement, or Filter.
|
|
5323
|
-
*
|
|
5324
|
-
* The faster stream may advance up to `bufferSize` elements ahead of the slower
|
|
5325
|
-
* one.
|
|
5326
|
-
*
|
|
5327
|
-
* @since 4.0.0
|
|
5328
|
-
* @category Filtering
|
|
5329
|
-
*
|
|
5330
|
-
* @example
|
|
5331
|
-
* ```ts
|
|
5332
|
-
* import { Console, Effect, Stream } from "effect"
|
|
5144
|
+
* import { Console, Effect, Result, Stream } from "effect"
|
|
5333
5145
|
*
|
|
5334
5146
|
* const program = Effect.gen(function*() {
|
|
5335
5147
|
* const [excluded, satisfying] = yield* Stream.partition(
|
|
5336
5148
|
* Stream.make(1, 2, 3, 4),
|
|
5337
|
-
* (n) => n % 2 === 0
|
|
5149
|
+
* (n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n)
|
|
5338
5150
|
* )
|
|
5339
5151
|
* const left = yield* Stream.runCollect(excluded)
|
|
5340
5152
|
* const right = yield* Stream.runCollect(satisfying)
|
|
@@ -5345,11 +5157,11 @@ export declare const partition: {
|
|
|
5345
5157
|
* })
|
|
5346
5158
|
* ```
|
|
5347
5159
|
*/
|
|
5348
|
-
<A, E, R,
|
|
5160
|
+
<A, E, R, Pass, Fail>(self: Stream<A, E, R>, filter: Filter.Filter<NoInfer<A>, Pass, Fail>, options?: {
|
|
5349
5161
|
readonly bufferSize?: number | undefined;
|
|
5350
5162
|
}): Effect.Effect<[
|
|
5351
|
-
excluded: Stream<
|
|
5352
|
-
satisfying: Stream<
|
|
5163
|
+
excluded: Stream<Fail, E>,
|
|
5164
|
+
satisfying: Stream<Pass, E>
|
|
5353
5165
|
], never, R | Scope.Scope>;
|
|
5354
5166
|
};
|
|
5355
5167
|
/**
|
|
@@ -6043,7 +5855,7 @@ export declare const tapError: {
|
|
|
6043
5855
|
<A, E, R, A2, E2, R2>(self: Stream<A, E, R>, f: (error: E) => Effect.Effect<A2, E2, R2>): Stream<A, E | E2, R | R2>;
|
|
6044
5856
|
};
|
|
6045
5857
|
/**
|
|
6046
|
-
* Recovers from errors that match a
|
|
5858
|
+
* Recovers from errors that match a predicate by switching to a recovery stream.
|
|
6047
5859
|
*
|
|
6048
5860
|
* When a failure matches the filter, the stream switches to the recovery
|
|
6049
5861
|
* stream. Non-matching failures propagate downstream, so the error type is
|
|
@@ -6057,12 +5869,12 @@ export declare const tapError: {
|
|
|
6057
5869
|
*
|
|
6058
5870
|
* @example
|
|
6059
5871
|
* ```ts
|
|
6060
|
-
* import { Console, Effect,
|
|
5872
|
+
* import { Console, Effect, Stream } from "effect"
|
|
6061
5873
|
*
|
|
6062
5874
|
* const stream = Stream.make(1, 2).pipe(
|
|
6063
5875
|
* Stream.concat(Stream.fail(42)),
|
|
6064
5876
|
* Stream.catchIf(
|
|
6065
|
-
*
|
|
5877
|
+
* (error): error is 42 => error === 42,
|
|
6066
5878
|
* () => Stream.make(999)
|
|
6067
5879
|
* )
|
|
6068
5880
|
* )
|
|
@@ -6081,7 +5893,7 @@ export declare const tapError: {
|
|
|
6081
5893
|
*/
|
|
6082
5894
|
export declare const catchIf: {
|
|
6083
5895
|
/**
|
|
6084
|
-
* Recovers from errors that match a
|
|
5896
|
+
* Recovers from errors that match a predicate by switching to a recovery stream.
|
|
6085
5897
|
*
|
|
6086
5898
|
* When a failure matches the filter, the stream switches to the recovery
|
|
6087
5899
|
* stream. Non-matching failures propagate downstream, so the error type is
|
|
@@ -6095,12 +5907,12 @@ export declare const catchIf: {
|
|
|
6095
5907
|
*
|
|
6096
5908
|
* @example
|
|
6097
5909
|
* ```ts
|
|
6098
|
-
* import { Console, Effect,
|
|
5910
|
+
* import { Console, Effect, Stream } from "effect"
|
|
6099
5911
|
*
|
|
6100
5912
|
* const stream = Stream.make(1, 2).pipe(
|
|
6101
5913
|
* Stream.concat(Stream.fail(42)),
|
|
6102
5914
|
* Stream.catchIf(
|
|
6103
|
-
*
|
|
5915
|
+
* (error): error is 42 => error === 42,
|
|
6104
5916
|
* () => Stream.make(999)
|
|
6105
5917
|
* )
|
|
6106
5918
|
* )
|
|
@@ -6119,7 +5931,7 @@ export declare const catchIf: {
|
|
|
6119
5931
|
*/
|
|
6120
5932
|
<E, EB extends E, A2, E2, R2, A3 = never, E3 = Exclude<E, EB>, R3 = never>(refinement: Refinement<NoInfer<E>, EB>, f: (e: EB) => Stream<A2, E2, R2>, orElse?: ((e: Exclude<E, EB>) => Stream<A3, E3, R3>) | undefined): <A, R>(self: Stream<A, E, R>) => Stream<A2 | A | A3, E2 | E3, R2 | R | R3>;
|
|
6121
5933
|
/**
|
|
6122
|
-
* Recovers from errors that match a
|
|
5934
|
+
* Recovers from errors that match a predicate by switching to a recovery stream.
|
|
6123
5935
|
*
|
|
6124
5936
|
* When a failure matches the filter, the stream switches to the recovery
|
|
6125
5937
|
* stream. Non-matching failures propagate downstream, so the error type is
|
|
@@ -6133,12 +5945,12 @@ export declare const catchIf: {
|
|
|
6133
5945
|
*
|
|
6134
5946
|
* @example
|
|
6135
5947
|
* ```ts
|
|
6136
|
-
* import { Console, Effect,
|
|
5948
|
+
* import { Console, Effect, Stream } from "effect"
|
|
6137
5949
|
*
|
|
6138
5950
|
* const stream = Stream.make(1, 2).pipe(
|
|
6139
5951
|
* Stream.concat(Stream.fail(42)),
|
|
6140
5952
|
* Stream.catchIf(
|
|
6141
|
-
*
|
|
5953
|
+
* (error): error is 42 => error === 42,
|
|
6142
5954
|
* () => Stream.make(999)
|
|
6143
5955
|
* )
|
|
6144
5956
|
* )
|
|
@@ -6155,9 +5967,9 @@ export declare const catchIf: {
|
|
|
6155
5967
|
* @since 4.0.0
|
|
6156
5968
|
* @category Error Handling
|
|
6157
5969
|
*/
|
|
6158
|
-
<E,
|
|
5970
|
+
<E, A2, E2, R2, A3 = never, E3 = E, R3 = never>(predicate: Predicate<NoInfer<E>>, f: (e: NoInfer<E>) => Stream<A2, E2, R2>, orElse?: ((e: NoInfer<E>) => Stream<A3, E3, R3>) | undefined): <A, R>(self: Stream<A, E, R>) => Stream<A2 | A | A3, E2 | E3, R2 | R | R3>;
|
|
6159
5971
|
/**
|
|
6160
|
-
* Recovers from errors that match a
|
|
5972
|
+
* Recovers from errors that match a predicate by switching to a recovery stream.
|
|
6161
5973
|
*
|
|
6162
5974
|
* When a failure matches the filter, the stream switches to the recovery
|
|
6163
5975
|
* stream. Non-matching failures propagate downstream, so the error type is
|
|
@@ -6171,12 +5983,12 @@ export declare const catchIf: {
|
|
|
6171
5983
|
*
|
|
6172
5984
|
* @example
|
|
6173
5985
|
* ```ts
|
|
6174
|
-
* import { Console, Effect,
|
|
5986
|
+
* import { Console, Effect, Stream } from "effect"
|
|
6175
5987
|
*
|
|
6176
5988
|
* const stream = Stream.make(1, 2).pipe(
|
|
6177
5989
|
* Stream.concat(Stream.fail(42)),
|
|
6178
5990
|
* Stream.catchIf(
|
|
6179
|
-
*
|
|
5991
|
+
* (error): error is 42 => error === 42,
|
|
6180
5992
|
* () => Stream.make(999)
|
|
6181
5993
|
* )
|
|
6182
5994
|
* )
|
|
@@ -6195,7 +6007,7 @@ export declare const catchIf: {
|
|
|
6195
6007
|
*/
|
|
6196
6008
|
<A, E, R, EB extends E, A2, E2, R2, A3 = never, E3 = Exclude<E, EB>, R3 = never>(self: Stream<A, E, R>, refinement: Refinement<E, EB>, f: (e: EB) => Stream<A2, E2, R2>, orElse?: ((e: Exclude<E, EB>) => Stream<A3, E3, R3>) | undefined): Stream<A | A2 | A3, E2 | E3, R | R2 | R3>;
|
|
6197
6009
|
/**
|
|
6198
|
-
* Recovers from errors that match a
|
|
6010
|
+
* Recovers from errors that match a predicate by switching to a recovery stream.
|
|
6199
6011
|
*
|
|
6200
6012
|
* When a failure matches the filter, the stream switches to the recovery
|
|
6201
6013
|
* stream. Non-matching failures propagate downstream, so the error type is
|
|
@@ -6209,12 +6021,12 @@ export declare const catchIf: {
|
|
|
6209
6021
|
*
|
|
6210
6022
|
* @example
|
|
6211
6023
|
* ```ts
|
|
6212
|
-
* import { Console, Effect,
|
|
6024
|
+
* import { Console, Effect, Stream } from "effect"
|
|
6213
6025
|
*
|
|
6214
6026
|
* const stream = Stream.make(1, 2).pipe(
|
|
6215
6027
|
* Stream.concat(Stream.fail(42)),
|
|
6216
6028
|
* Stream.catchIf(
|
|
6217
|
-
*
|
|
6029
|
+
* (error): error is 42 => error === 42,
|
|
6218
6030
|
* () => Stream.make(999)
|
|
6219
6031
|
* )
|
|
6220
6032
|
* )
|
|
@@ -6231,7 +6043,32 @@ export declare const catchIf: {
|
|
|
6231
6043
|
* @since 4.0.0
|
|
6232
6044
|
* @category Error Handling
|
|
6233
6045
|
*/
|
|
6234
|
-
<A, E, R,
|
|
6046
|
+
<A, E, R, A2, E2, R2, A3 = never, E3 = E, R3 = never>(self: Stream<A, E, R>, predicate: Predicate<E>, f: (e: E) => Stream<A2, E2, R2>, orElse?: ((e: E) => Stream<A3, E3, R3>) | undefined): Stream<A | A2 | A3, E2 | E3, R | R2 | R3>;
|
|
6047
|
+
};
|
|
6048
|
+
/**
|
|
6049
|
+
* Recovers from errors that match a `Filter` by switching to a recovery
|
|
6050
|
+
* stream.
|
|
6051
|
+
*
|
|
6052
|
+
* @since 4.0.0
|
|
6053
|
+
* @category Error Handling
|
|
6054
|
+
*/
|
|
6055
|
+
export declare const catchFilter: {
|
|
6056
|
+
/**
|
|
6057
|
+
* Recovers from errors that match a `Filter` by switching to a recovery
|
|
6058
|
+
* stream.
|
|
6059
|
+
*
|
|
6060
|
+
* @since 4.0.0
|
|
6061
|
+
* @category Error Handling
|
|
6062
|
+
*/
|
|
6063
|
+
<E, EB, A2, E2, R2, X, A3 = never, E3 = X, R3 = never>(filter: Filter.Filter<NoInfer<E>, EB, X>, f: (failure: EB) => Stream<A2, E2, R2>, orElse?: ((failure: X) => Stream<A3, E3, R3>) | undefined): <A, R>(self: Stream<A, E, R>) => Stream<A | A2 | A3, E2 | E3, R | R2 | R3>;
|
|
6064
|
+
/**
|
|
6065
|
+
* Recovers from errors that match a `Filter` by switching to a recovery
|
|
6066
|
+
* stream.
|
|
6067
|
+
*
|
|
6068
|
+
* @since 4.0.0
|
|
6069
|
+
* @category Error Handling
|
|
6070
|
+
*/
|
|
6071
|
+
<A, E, R, EB, A2, E2, R2, X, A3 = never, E3 = X, R3 = never>(self: Stream<A, E, R>, filter: Filter.Filter<NoInfer<E>, EB, X>, f: (failure: EB) => Stream<A2, E2, R2>, orElse?: ((failure: X) => Stream<A3, E3, R3>) | undefined): Stream<A | A2 | A3, E2 | E3, R | R2 | R3>;
|
|
6235
6072
|
};
|
|
6236
6073
|
/**
|
|
6237
6074
|
* Recovers from failures whose `_tag` matches the provided value by switching to
|
|
@@ -6896,7 +6733,7 @@ export declare const catchCauseIf: {
|
|
|
6896
6733
|
* @since 4.0.0
|
|
6897
6734
|
* @category Error Handling
|
|
6898
6735
|
*/
|
|
6899
|
-
<E,
|
|
6736
|
+
<E, A2, E2, R2>(predicate: Predicate<Cause.Cause<E>>, f: (cause: Cause.Cause<E>) => Stream<A2, E2, R2>): <A, R>(self: Stream<A, E, R>) => Stream<A | A2, E | E2, R2 | R>;
|
|
6900
6737
|
/**
|
|
6901
6738
|
* Recovers from stream failures by filtering the `Cause` and switching to a recovery stream.
|
|
6902
6739
|
* Non-matching causes are re-emitted as failures.
|
|
@@ -6930,7 +6767,32 @@ export declare const catchCauseIf: {
|
|
|
6930
6767
|
* @since 4.0.0
|
|
6931
6768
|
* @category Error Handling
|
|
6932
6769
|
*/
|
|
6933
|
-
<A, E, R, A2, E2, R2
|
|
6770
|
+
<A, E, R, A2, E2, R2>(self: Stream<A, E, R>, predicate: Predicate<Cause.Cause<E>>, f: (cause: Cause.Cause<E>) => Stream<A2, E2, R2>): Stream<A | A2, E | E2, R | R2>;
|
|
6771
|
+
};
|
|
6772
|
+
/**
|
|
6773
|
+
* Recovers from stream failures by filtering the `Cause` and switching to a
|
|
6774
|
+
* recovery stream.
|
|
6775
|
+
*
|
|
6776
|
+
* @since 4.0.0
|
|
6777
|
+
* @category Error Handling
|
|
6778
|
+
*/
|
|
6779
|
+
export declare const catchCauseFilter: {
|
|
6780
|
+
/**
|
|
6781
|
+
* Recovers from stream failures by filtering the `Cause` and switching to a
|
|
6782
|
+
* recovery stream.
|
|
6783
|
+
*
|
|
6784
|
+
* @since 4.0.0
|
|
6785
|
+
* @category Error Handling
|
|
6786
|
+
*/
|
|
6787
|
+
<E, EB, A2, E2, R2, X extends Cause.Cause<any>>(filter: Filter.Filter<Cause.Cause<E>, EB, X>, f: (failure: EB, cause: Cause.Cause<E>) => Stream<A2, E2, R2>): <A, R>(self: Stream<A, E, R>) => Stream<A | A2, Cause.Cause.Error<X> | E2, R2 | R>;
|
|
6788
|
+
/**
|
|
6789
|
+
* Recovers from stream failures by filtering the `Cause` and switching to a
|
|
6790
|
+
* recovery stream.
|
|
6791
|
+
*
|
|
6792
|
+
* @since 4.0.0
|
|
6793
|
+
* @category Error Handling
|
|
6794
|
+
*/
|
|
6795
|
+
<A, E, R, EB, A2, E2, R2, X extends Cause.Cause<any>>(self: Stream<A, E, R>, filter: Filter.Filter<Cause.Cause<E>, EB, X>, f: (failure: EB, cause: Cause.Cause<E>) => Stream<A2, E2, R2>): Stream<A | A2, Cause.Cause.Error<X> | E2, R | R2>;
|
|
6934
6796
|
};
|
|
6935
6797
|
/**
|
|
6936
6798
|
* Switches to a fallback stream if this stream is empty.
|
|
@@ -7811,7 +7673,7 @@ export declare const takeWhile: {
|
|
|
7811
7673
|
* @since 2.0.0
|
|
7812
7674
|
* @category Filtering
|
|
7813
7675
|
*/
|
|
7814
|
-
<A,
|
|
7676
|
+
<A, E, R, B extends A>(self: Stream<A, E, R>, refinement: (a: NoInfer<A>, n: number) => a is B): Stream<B, E, R>;
|
|
7815
7677
|
/**
|
|
7816
7678
|
* Takes the longest initial prefix of elements that satisfy the predicate.
|
|
7817
7679
|
*
|
|
@@ -7835,52 +7697,26 @@ export declare const takeWhile: {
|
|
|
7835
7697
|
* @since 2.0.0
|
|
7836
7698
|
* @category Filtering
|
|
7837
7699
|
*/
|
|
7838
|
-
<A, E, R
|
|
7700
|
+
<A, E, R>(self: Stream<A, E, R>, predicate: (a: NoInfer<A>, n: number) => boolean): Stream<A, E, R>;
|
|
7701
|
+
};
|
|
7702
|
+
/**
|
|
7703
|
+
* Takes the longest initial prefix of elements that satisfy the filter.
|
|
7704
|
+
*
|
|
7705
|
+
* @since 4.0.0
|
|
7706
|
+
* @category Filtering
|
|
7707
|
+
*/
|
|
7708
|
+
export declare const takeWhileFilter: {
|
|
7839
7709
|
/**
|
|
7840
|
-
* Takes the longest initial prefix of elements that satisfy the
|
|
7841
|
-
*
|
|
7842
|
-
* @example
|
|
7843
|
-
* ```ts
|
|
7844
|
-
* import { Console, Effect, Stream } from "effect"
|
|
7710
|
+
* Takes the longest initial prefix of elements that satisfy the filter.
|
|
7845
7711
|
*
|
|
7846
|
-
*
|
|
7847
|
-
* Stream.takeWhile((n) => n % 3 !== 0)
|
|
7848
|
-
* )
|
|
7849
|
-
*
|
|
7850
|
-
* const program = Effect.gen(function*() {
|
|
7851
|
-
* const result = yield* Stream.runCollect(stream)
|
|
7852
|
-
* yield* Console.log(result)
|
|
7853
|
-
* })
|
|
7854
|
-
*
|
|
7855
|
-
* Effect.runPromise(program)
|
|
7856
|
-
* // Output: [ 1, 2 ]
|
|
7857
|
-
* ```
|
|
7858
|
-
*
|
|
7859
|
-
* @since 2.0.0
|
|
7712
|
+
* @since 4.0.0
|
|
7860
7713
|
* @category Filtering
|
|
7861
7714
|
*/
|
|
7862
|
-
<A,
|
|
7715
|
+
<A, B, X>(f: Filter.Filter<NoInfer<A>, B, X>): <E, R>(self: Stream<A, E, R>) => Stream<B, E, R>;
|
|
7863
7716
|
/**
|
|
7864
|
-
* Takes the longest initial prefix of elements that satisfy the
|
|
7865
|
-
*
|
|
7866
|
-
* @example
|
|
7867
|
-
* ```ts
|
|
7868
|
-
* import { Console, Effect, Stream } from "effect"
|
|
7869
|
-
*
|
|
7870
|
-
* const stream = Stream.range(1, 5).pipe(
|
|
7871
|
-
* Stream.takeWhile((n) => n % 3 !== 0)
|
|
7872
|
-
* )
|
|
7873
|
-
*
|
|
7874
|
-
* const program = Effect.gen(function*() {
|
|
7875
|
-
* const result = yield* Stream.runCollect(stream)
|
|
7876
|
-
* yield* Console.log(result)
|
|
7877
|
-
* })
|
|
7717
|
+
* Takes the longest initial prefix of elements that satisfy the filter.
|
|
7878
7718
|
*
|
|
7879
|
-
*
|
|
7880
|
-
* // Output: [ 1, 2 ]
|
|
7881
|
-
* ```
|
|
7882
|
-
*
|
|
7883
|
-
* @since 2.0.0
|
|
7719
|
+
* @since 4.0.0
|
|
7884
7720
|
* @category Filtering
|
|
7885
7721
|
*/
|
|
7886
7722
|
<A, E, R, B, X>(self: Stream<A, E, R>, f: Filter.Filter<NoInfer<A>, B, X>): Stream<B, E, R>;
|
|
@@ -8236,53 +8072,29 @@ export declare const dropWhile: {
|
|
|
8236
8072
|
* @since 2.0.0
|
|
8237
8073
|
* @category Filtering
|
|
8238
8074
|
*/
|
|
8239
|
-
<A,
|
|
8075
|
+
<A, E, R>(self: Stream<A, E, R>, predicate: (a: NoInfer<A>, index: number) => boolean): Stream<A, E, R>;
|
|
8076
|
+
};
|
|
8077
|
+
/**
|
|
8078
|
+
* Drops elements while the filter succeeds.
|
|
8079
|
+
*
|
|
8080
|
+
* @since 4.0.0
|
|
8081
|
+
* @category Filtering
|
|
8082
|
+
*/
|
|
8083
|
+
export declare const dropWhileFilter: {
|
|
8240
8084
|
/**
|
|
8241
|
-
* Drops elements
|
|
8242
|
-
*
|
|
8243
|
-
* @example
|
|
8244
|
-
* ```ts
|
|
8245
|
-
* import { Console, Effect, Stream } from "effect"
|
|
8246
|
-
*
|
|
8247
|
-
* const program = Effect.gen(function*() {
|
|
8248
|
-
* const values = yield* Stream.make(1, 2, 3, 4, 5).pipe(
|
|
8249
|
-
* Stream.dropWhile((n) => n < 3),
|
|
8250
|
-
* Stream.runCollect
|
|
8251
|
-
* )
|
|
8252
|
-
* yield* Console.log(values)
|
|
8253
|
-
* })
|
|
8254
|
-
*
|
|
8255
|
-
* Effect.runPromise(program)
|
|
8256
|
-
* // Output: [ 3, 4, 5 ]
|
|
8257
|
-
* ```
|
|
8085
|
+
* Drops elements while the filter succeeds.
|
|
8258
8086
|
*
|
|
8259
|
-
* @since
|
|
8087
|
+
* @since 4.0.0
|
|
8260
8088
|
* @category Filtering
|
|
8261
8089
|
*/
|
|
8262
|
-
<A,
|
|
8090
|
+
<A, B, X>(filter: Filter.Filter<NoInfer<A>, B, X>): <E, R>(self: Stream<A, E, R>) => Stream<A, E, R>;
|
|
8263
8091
|
/**
|
|
8264
|
-
* Drops elements
|
|
8265
|
-
*
|
|
8266
|
-
* @example
|
|
8267
|
-
* ```ts
|
|
8268
|
-
* import { Console, Effect, Stream } from "effect"
|
|
8269
|
-
*
|
|
8270
|
-
* const program = Effect.gen(function*() {
|
|
8271
|
-
* const values = yield* Stream.make(1, 2, 3, 4, 5).pipe(
|
|
8272
|
-
* Stream.dropWhile((n) => n < 3),
|
|
8273
|
-
* Stream.runCollect
|
|
8274
|
-
* )
|
|
8275
|
-
* yield* Console.log(values)
|
|
8276
|
-
* })
|
|
8092
|
+
* Drops elements while the filter succeeds.
|
|
8277
8093
|
*
|
|
8278
|
-
*
|
|
8279
|
-
* // Output: [ 3, 4, 5 ]
|
|
8280
|
-
* ```
|
|
8281
|
-
*
|
|
8282
|
-
* @since 2.0.0
|
|
8094
|
+
* @since 4.0.0
|
|
8283
8095
|
* @category Filtering
|
|
8284
8096
|
*/
|
|
8285
|
-
<A, E, R, B, X>(self: Stream<A, E, R>,
|
|
8097
|
+
<A, E, R, B, X>(self: Stream<A, E, R>, filter: Filter.Filter<NoInfer<A>, B, X>): Stream<A, E, R>;
|
|
8286
8098
|
};
|
|
8287
8099
|
/**
|
|
8288
8100
|
* Drops elements while the specified effectful predicate evaluates to `true`.
|