@typed/fx 1.18.4 → 1.20.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/AsyncData/package.json +6 -0
- package/Emitter/package.json +6 -0
- package/Form/package.json +6 -0
- package/FormEntry/package.json +6 -0
- package/Fx/package.json +6 -0
- package/Guard/package.json +6 -0
- package/Idle/package.json +6 -0
- package/Match/package.json +6 -0
- package/Pull/package.json +6 -0
- package/Push/package.json +6 -0
- package/RefArray/package.json +6 -0
- package/RefChunk/package.json +6 -0
- package/RefHashMap/package.json +6 -0
- package/RefHashSet/package.json +6 -0
- package/RefSubject/package.json +6 -0
- package/Sink/package.json +6 -0
- package/Stream/package.json +6 -0
- package/Subject/package.json +6 -0
- package/TypeId/package.json +6 -0
- package/Typeclass/package.json +6 -0
- package/Versioned/package.json +6 -0
- package/dist/cjs/AsyncData.js +177 -0
- package/dist/cjs/AsyncData.js.map +1 -0
- package/dist/cjs/Emitter.js +24 -21
- package/dist/cjs/Emitter.js.map +1 -1
- package/dist/cjs/Form.js +78 -21
- package/dist/cjs/Form.js.map +1 -1
- package/dist/cjs/FormEntry.js +75 -48
- package/dist/cjs/FormEntry.js.map +1 -1
- package/dist/cjs/Fx.js +517 -872
- package/dist/cjs/Fx.js.map +1 -1
- package/dist/cjs/Guard.js +21 -13
- package/dist/cjs/Guard.js.map +1 -1
- package/dist/cjs/Idle.js +49 -37
- package/dist/cjs/Idle.js.map +1 -1
- package/dist/cjs/Match.js +99 -61
- package/dist/cjs/Match.js.map +1 -1
- package/dist/cjs/Pull.js.map +1 -1
- package/dist/cjs/Push.js +168 -0
- package/dist/cjs/Push.js.map +1 -0
- package/dist/cjs/RefArray.js +32 -30
- package/dist/cjs/RefArray.js.map +1 -1
- package/dist/cjs/RefChunk.js +26 -24
- package/dist/cjs/RefChunk.js.map +1 -1
- package/dist/cjs/RefHashMap.js +20 -20
- package/dist/cjs/RefHashMap.js.map +1 -1
- package/dist/cjs/RefHashSet.js +11 -8
- package/dist/cjs/RefHashSet.js.map +1 -1
- package/dist/cjs/RefSubject.js +899 -158
- package/dist/cjs/RefSubject.js.map +1 -1
- package/dist/cjs/Sink.js +588 -62
- package/dist/cjs/Sink.js.map +1 -1
- package/dist/cjs/Stream.js +15 -10
- package/dist/cjs/Stream.js.map +1 -1
- package/dist/cjs/Subject.js +153 -55
- package/dist/cjs/Subject.js.map +1 -1
- package/dist/cjs/TypeId.js +10 -5
- package/dist/cjs/TypeId.js.map +1 -1
- package/dist/cjs/Typeclass.js +28 -31
- package/dist/cjs/Typeclass.js.map +1 -1
- package/dist/cjs/Versioned.js +118 -57
- package/dist/cjs/Versioned.js.map +1 -1
- package/dist/cjs/index.js +44 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/internal/{deferred-ref.js → DeferredRef.js} +45 -13
- package/dist/cjs/internal/DeferredRef.js.map +1 -0
- package/dist/cjs/internal/UnionToTuple.js +6 -0
- package/dist/cjs/internal/UnionToTuple.js.map +1 -0
- package/dist/cjs/internal/core.js +1590 -779
- package/dist/cjs/internal/core.js.map +1 -1
- package/dist/cjs/internal/diff.js +114 -0
- package/dist/cjs/internal/diff.js.map +1 -0
- package/dist/cjs/internal/effect-loop-operator.js +288 -0
- package/dist/cjs/internal/effect-loop-operator.js.map +1 -0
- package/dist/cjs/internal/effect-operator.js +46 -37
- package/dist/cjs/internal/effect-operator.js.map +1 -1
- package/dist/cjs/internal/effect-producer.js +74 -0
- package/dist/cjs/internal/effect-producer.js.map +1 -0
- package/dist/cjs/internal/helpers.js +158 -128
- package/dist/cjs/internal/helpers.js.map +1 -1
- package/dist/cjs/internal/keyed.js +136 -173
- package/dist/cjs/internal/keyed.js.map +1 -1
- package/dist/cjs/internal/loop-operator.js +213 -0
- package/dist/cjs/internal/loop-operator.js.map +1 -0
- package/dist/cjs/internal/operator.js +79 -0
- package/dist/cjs/internal/operator.js.map +1 -0
- package/dist/cjs/internal/protos.js +19 -81
- package/dist/cjs/internal/protos.js.map +1 -1
- package/dist/cjs/internal/provide.js +47 -25
- package/dist/cjs/internal/provide.js.map +1 -1
- package/dist/cjs/internal/requestIdleCallback.js +5 -5
- package/dist/cjs/internal/requestIdleCallback.js.map +1 -1
- package/dist/cjs/internal/share.js +12 -15
- package/dist/cjs/internal/share.js.map +1 -1
- package/dist/cjs/internal/sync-operator.js +50 -22
- package/dist/cjs/internal/sync-operator.js.map +1 -1
- package/dist/cjs/internal/sync-producer.js +114 -0
- package/dist/cjs/internal/sync-producer.js.map +1 -0
- package/dist/cjs/internal/withKey.js +45 -51
- package/dist/cjs/internal/withKey.js.map +1 -1
- package/dist/dts/AsyncData.d.ts +185 -0
- package/dist/dts/AsyncData.d.ts.map +1 -0
- package/dist/dts/Emitter.d.ts +13 -20
- package/dist/dts/Emitter.d.ts.map +1 -1
- package/dist/dts/Form.d.ts +45 -28
- package/dist/dts/Form.d.ts.map +1 -1
- package/dist/dts/FormEntry.d.ts +25 -13
- package/dist/dts/FormEntry.d.ts.map +1 -1
- package/dist/dts/Fx.d.ts +983 -1387
- package/dist/dts/Fx.d.ts.map +1 -1
- package/dist/dts/Guard.d.ts +8 -1
- package/dist/dts/Guard.d.ts.map +1 -1
- package/dist/dts/Idle.d.ts +3 -3
- package/dist/dts/Idle.d.ts.map +1 -1
- package/dist/dts/Match.d.ts +8 -8
- package/dist/dts/Match.d.ts.map +1 -1
- package/dist/dts/Pull.d.ts +5 -5
- package/dist/dts/Pull.d.ts.map +1 -1
- package/dist/dts/Push.d.ts +170 -0
- package/dist/dts/Push.d.ts.map +1 -0
- package/dist/dts/RefArray.d.ts +21 -23
- package/dist/dts/RefArray.d.ts.map +1 -1
- package/dist/dts/RefChunk.d.ts +17 -19
- package/dist/dts/RefChunk.d.ts.map +1 -1
- package/dist/dts/RefHashMap.d.ts +19 -20
- package/dist/dts/RefHashMap.d.ts.map +1 -1
- package/dist/dts/RefHashSet.d.ts +12 -16
- package/dist/dts/RefHashSet.d.ts.map +1 -1
- package/dist/dts/RefSubject.d.ts +396 -187
- package/dist/dts/RefSubject.d.ts.map +1 -1
- package/dist/dts/Sink.d.ts +193 -93
- package/dist/dts/Sink.d.ts.map +1 -1
- package/dist/dts/Stream.d.ts +7 -1
- package/dist/dts/Stream.d.ts.map +1 -1
- package/dist/dts/Subject.d.ts +27 -36
- package/dist/dts/Subject.d.ts.map +1 -1
- package/dist/dts/TypeId.d.ts +10 -0
- package/dist/dts/TypeId.d.ts.map +1 -1
- package/dist/dts/Typeclass.d.ts +2 -2
- package/dist/dts/Typeclass.d.ts.map +1 -1
- package/dist/dts/Versioned.d.ts +50 -78
- package/dist/dts/Versioned.d.ts.map +1 -1
- package/dist/dts/index.d.ts +66 -6
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/internal/DeferredRef.d.ts +20 -0
- package/dist/dts/internal/DeferredRef.d.ts.map +1 -0
- package/dist/dts/internal/UnionToTuple.d.ts +6 -0
- package/dist/dts/internal/UnionToTuple.d.ts.map +1 -0
- package/dist/dts/internal/core.d.ts +218 -450
- package/dist/dts/internal/core.d.ts.map +1 -1
- package/dist/dts/internal/diff.d.ts +38 -0
- package/dist/dts/internal/diff.d.ts.map +1 -0
- package/dist/dts/internal/effect-loop-operator.d.ts +34 -0
- package/dist/dts/internal/effect-loop-operator.d.ts.map +1 -0
- package/dist/dts/internal/effect-operator.d.ts +8 -5
- package/dist/dts/internal/effect-operator.d.ts.map +1 -1
- package/dist/dts/internal/effect-producer.d.ts +25 -0
- package/dist/dts/internal/effect-producer.d.ts.map +1 -0
- package/dist/dts/internal/helpers.d.ts +33 -24
- package/dist/dts/internal/helpers.d.ts.map +1 -1
- package/dist/dts/internal/keyed.d.ts +3 -3
- package/dist/dts/internal/keyed.d.ts.map +1 -1
- package/dist/dts/internal/loop-operator.d.ts +40 -0
- package/dist/dts/internal/loop-operator.d.ts.map +1 -0
- package/dist/dts/internal/operator.d.ts +16 -0
- package/dist/dts/internal/operator.d.ts.map +1 -0
- package/dist/dts/internal/protos.d.ts +16 -43
- package/dist/dts/internal/protos.d.ts.map +1 -1
- package/dist/dts/internal/provide.d.ts +7 -1
- package/dist/dts/internal/provide.d.ts.map +1 -1
- package/dist/dts/internal/share.d.ts +12 -9
- package/dist/dts/internal/share.d.ts.map +1 -1
- package/dist/dts/internal/sync-operator.d.ts +7 -3
- package/dist/dts/internal/sync-operator.d.ts.map +1 -1
- package/dist/dts/internal/sync-producer.d.ts +36 -0
- package/dist/dts/internal/sync-producer.d.ts.map +1 -0
- package/dist/dts/internal/withKey.d.ts +3 -3
- package/dist/dts/internal/withKey.d.ts.map +1 -1
- package/dist/esm/AsyncData.js +151 -0
- package/dist/esm/AsyncData.js.map +1 -0
- package/dist/esm/Emitter.js +24 -21
- package/dist/esm/Emitter.js.map +1 -1
- package/dist/esm/Form.js +69 -14
- package/dist/esm/Form.js.map +1 -1
- package/dist/esm/FormEntry.js +77 -52
- package/dist/esm/FormEntry.js.map +1 -1
- package/dist/esm/Fx.js +509 -874
- package/dist/esm/Fx.js.map +1 -1
- package/dist/esm/Guard.js +5 -1
- package/dist/esm/Guard.js.map +1 -1
- package/dist/esm/Idle.js +49 -39
- package/dist/esm/Idle.js.map +1 -1
- package/dist/esm/Match.js +103 -63
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Pull.js.map +1 -1
- package/dist/esm/Push.js +159 -0
- package/dist/esm/Push.js.map +1 -0
- package/dist/esm/RefArray.js +32 -30
- package/dist/esm/RefArray.js.map +1 -1
- package/dist/esm/RefChunk.js +26 -24
- package/dist/esm/RefChunk.js.map +1 -1
- package/dist/esm/RefHashMap.js +20 -20
- package/dist/esm/RefHashMap.js.map +1 -1
- package/dist/esm/RefHashSet.js +11 -8
- package/dist/esm/RefHashSet.js.map +1 -1
- package/dist/esm/RefSubject.js +873 -150
- package/dist/esm/RefSubject.js.map +1 -1
- package/dist/esm/Sink.js +608 -57
- package/dist/esm/Sink.js.map +1 -1
- package/dist/esm/Stream.js +13 -9
- package/dist/esm/Stream.js.map +1 -1
- package/dist/esm/Subject.js +151 -56
- package/dist/esm/Subject.js.map +1 -1
- package/dist/esm/TypeId.js +9 -4
- package/dist/esm/TypeId.js.map +1 -1
- package/dist/esm/Typeclass.js +29 -29
- package/dist/esm/Typeclass.js.map +1 -1
- package/dist/esm/Versioned.js +110 -53
- package/dist/esm/Versioned.js.map +1 -1
- package/dist/esm/index.js +66 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/internal/DeferredRef.js +54 -0
- package/dist/esm/internal/DeferredRef.js.map +1 -0
- package/dist/esm/internal/UnionToTuple.js +2 -0
- package/dist/esm/internal/UnionToTuple.js.map +1 -0
- package/dist/esm/internal/core.js +1439 -719
- package/dist/esm/internal/core.js.map +1 -1
- package/dist/esm/internal/diff.js +82 -0
- package/dist/esm/internal/diff.js.map +1 -0
- package/dist/esm/internal/effect-loop-operator.js +269 -0
- package/dist/esm/internal/effect-loop-operator.js.map +1 -0
- package/dist/esm/internal/effect-operator.js +44 -37
- package/dist/esm/internal/effect-operator.js.map +1 -1
- package/dist/esm/internal/effect-producer.js +47 -0
- package/dist/esm/internal/effect-producer.js.map +1 -0
- package/dist/esm/internal/helpers.js +157 -129
- package/dist/esm/internal/helpers.js.map +1 -1
- package/dist/esm/internal/keyed.js +128 -139
- package/dist/esm/internal/keyed.js.map +1 -1
- package/dist/esm/internal/loop-operator.js +186 -0
- package/dist/esm/internal/loop-operator.js.map +1 -0
- package/dist/esm/internal/operator.js +68 -0
- package/dist/esm/internal/operator.js.map +1 -0
- package/dist/esm/internal/protos.js +16 -75
- package/dist/esm/internal/protos.js.map +1 -1
- package/dist/esm/internal/provide.js +33 -25
- package/dist/esm/internal/provide.js.map +1 -1
- package/dist/esm/internal/requestIdleCallback.js +5 -5
- package/dist/esm/internal/requestIdleCallback.js.map +1 -1
- package/dist/esm/internal/share.js +12 -12
- package/dist/esm/internal/share.js.map +1 -1
- package/dist/esm/internal/sync-operator.js +49 -21
- package/dist/esm/internal/sync-operator.js.map +1 -1
- package/dist/esm/internal/sync-producer.js +88 -0
- package/dist/esm/internal/sync-producer.js.map +1 -0
- package/dist/esm/internal/withKey.js +46 -47
- package/dist/esm/internal/withKey.js.map +1 -1
- package/package.json +22 -62
- package/src/AsyncData.ts +447 -0
- package/src/Emitter.ts +47 -38
- package/src/Form.ts +185 -65
- package/src/FormEntry.ts +142 -109
- package/src/Fx.ts +1685 -1851
- package/src/Guard.ts +12 -1
- package/src/Idle.ts +76 -62
- package/src/Match.ts +149 -93
- package/src/Pull.ts +8 -8
- package/src/Push.ts +472 -0
- package/src/RefArray.ts +53 -51
- package/src/RefChunk.ts +44 -41
- package/src/RefHashMap.ts +57 -43
- package/src/RefHashSet.ts +21 -31
- package/src/RefSubject.ts +1984 -457
- package/src/Sink.ts +922 -171
- package/src/Stream.ts +32 -20
- package/src/Subject.ts +230 -87
- package/src/TypeId.ts +16 -4
- package/src/Typeclass.ts +31 -32
- package/src/Versioned.ts +220 -168
- package/src/index.ts +78 -6
- package/src/internal/DeferredRef.ts +62 -0
- package/src/internal/UnionToTuple.ts +11 -0
- package/src/internal/core.ts +2491 -1950
- package/src/internal/diff.ts +157 -0
- package/src/internal/effect-loop-operator.ts +466 -0
- package/src/internal/effect-operator.ts +89 -54
- package/src/internal/effect-producer.ts +125 -0
- package/src/internal/helpers.ts +275 -205
- package/src/internal/keyed.ts +192 -241
- package/src/internal/loop-operator.ts +266 -0
- package/src/internal/operator.ts +87 -0
- package/src/internal/protos.ts +29 -104
- package/src/internal/provide.ts +48 -40
- package/src/internal/requestIdleCallback.ts +5 -6
- package/src/internal/share.ts +26 -24
- package/src/internal/sync-operator.ts +68 -27
- package/src/internal/sync-producer.ts +146 -0
- package/src/internal/withKey.ts +64 -74
- package/dist/cjs/Computed.js +0 -115
- package/dist/cjs/Computed.js.map +0 -1
- package/dist/cjs/Filtered.js +0 -95
- package/dist/cjs/Filtered.js.map +0 -1
- package/dist/cjs/Model.js +0 -119
- package/dist/cjs/Model.js.map +0 -1
- package/dist/cjs/RefAsyncData.js +0 -187
- package/dist/cjs/RefAsyncData.js.map +0 -1
- package/dist/cjs/RefAsyncDataArray.js +0 -38
- package/dist/cjs/RefAsyncDataArray.js.map +0 -1
- package/dist/cjs/RefBoolean.js +0 -45
- package/dist/cjs/RefBoolean.js.map +0 -1
- package/dist/cjs/RefNumber.js +0 -49
- package/dist/cjs/RefNumber.js.map +0 -1
- package/dist/cjs/internal/core-ref-subject.js +0 -254
- package/dist/cjs/internal/core-ref-subject.js.map +0 -1
- package/dist/cjs/internal/core-subject.js +0 -108
- package/dist/cjs/internal/core-subject.js.map +0 -1
- package/dist/cjs/internal/deferred-ref.js.map +0 -1
- package/dist/cjs/internal/effect-primitive.js +0 -47
- package/dist/cjs/internal/effect-primitive.js.map +0 -1
- package/dist/cjs/internal/fx-effect-proto.js +0 -58
- package/dist/cjs/internal/fx-effect-proto.js.map +0 -1
- package/dist/cjs/internal/fx-primitive.js +0 -193
- package/dist/cjs/internal/fx-primitive.js.map +0 -1
- package/dist/cjs/internal/fx.js +0 -240
- package/dist/cjs/internal/fx.js.map +0 -1
- package/dist/cjs/internal/matchers.js +0 -34
- package/dist/cjs/internal/matchers.js.map +0 -1
- package/dist/cjs/internal/run.js +0 -54
- package/dist/cjs/internal/run.js.map +0 -1
- package/dist/cjs/internal/schema-ref-subject.js +0 -132
- package/dist/cjs/internal/schema-ref-subject.js.map +0 -1
- package/dist/cjs/internal/versioned-transform.js +0 -46
- package/dist/cjs/internal/versioned-transform.js.map +0 -1
- package/dist/dts/Computed.d.ts +0 -106
- package/dist/dts/Computed.d.ts.map +0 -1
- package/dist/dts/Filtered.d.ts +0 -97
- package/dist/dts/Filtered.d.ts.map +0 -1
- package/dist/dts/Model.d.ts +0 -200
- package/dist/dts/Model.d.ts.map +0 -1
- package/dist/dts/RefAsyncData.d.ts +0 -236
- package/dist/dts/RefAsyncData.d.ts.map +0 -1
- package/dist/dts/RefAsyncDataArray.d.ts +0 -56
- package/dist/dts/RefAsyncDataArray.d.ts.map +0 -1
- package/dist/dts/RefBoolean.d.ts +0 -47
- package/dist/dts/RefBoolean.d.ts.map +0 -1
- package/dist/dts/RefNumber.d.ts +0 -48
- package/dist/dts/RefNumber.d.ts.map +0 -1
- package/dist/dts/internal/core-ref-subject.d.ts +0 -100
- package/dist/dts/internal/core-ref-subject.d.ts.map +0 -1
- package/dist/dts/internal/core-subject.d.ts +0 -5
- package/dist/dts/internal/core-subject.d.ts.map +0 -1
- package/dist/dts/internal/deferred-ref.d.ts +0 -12
- package/dist/dts/internal/deferred-ref.d.ts.map +0 -1
- package/dist/dts/internal/effect-primitive.d.ts +0 -6
- package/dist/dts/internal/effect-primitive.d.ts.map +0 -1
- package/dist/dts/internal/fx-effect-proto.d.ts +0 -30
- package/dist/dts/internal/fx-effect-proto.d.ts.map +0 -1
- package/dist/dts/internal/fx-primitive.d.ts +0 -109
- package/dist/dts/internal/fx-primitive.d.ts.map +0 -1
- package/dist/dts/internal/fx.d.ts +0 -245
- package/dist/dts/internal/fx.d.ts.map +0 -1
- package/dist/dts/internal/matchers.d.ts +0 -33
- package/dist/dts/internal/matchers.d.ts.map +0 -1
- package/dist/dts/internal/run.d.ts +0 -8
- package/dist/dts/internal/run.d.ts.map +0 -1
- package/dist/dts/internal/schema-ref-subject.d.ts +0 -5
- package/dist/dts/internal/schema-ref-subject.d.ts.map +0 -1
- package/dist/dts/internal/versioned-transform.d.ts +0 -17
- package/dist/dts/internal/versioned-transform.d.ts.map +0 -1
- package/dist/esm/Computed.js +0 -103
- package/dist/esm/Computed.js.map +0 -1
- package/dist/esm/Filtered.js +0 -83
- package/dist/esm/Filtered.js.map +0 -1
- package/dist/esm/Model.js +0 -100
- package/dist/esm/Model.js.map +0 -1
- package/dist/esm/RefAsyncData.js +0 -163
- package/dist/esm/RefAsyncData.js.map +0 -1
- package/dist/esm/RefAsyncDataArray.js +0 -27
- package/dist/esm/RefAsyncDataArray.js.map +0 -1
- package/dist/esm/RefBoolean.js +0 -31
- package/dist/esm/RefBoolean.js.map +0 -1
- package/dist/esm/RefNumber.js +0 -35
- package/dist/esm/RefNumber.js.map +0 -1
- package/dist/esm/internal/core-ref-subject.js +0 -242
- package/dist/esm/internal/core-ref-subject.js.map +0 -1
- package/dist/esm/internal/core-subject.js +0 -90
- package/dist/esm/internal/core-subject.js.map +0 -1
- package/dist/esm/internal/deferred-ref.js +0 -23
- package/dist/esm/internal/deferred-ref.js.map +0 -1
- package/dist/esm/internal/effect-primitive.js +0 -41
- package/dist/esm/internal/effect-primitive.js.map +0 -1
- package/dist/esm/internal/fx-effect-proto.js +0 -43
- package/dist/esm/internal/fx-effect-proto.js.map +0 -1
- package/dist/esm/internal/fx-primitive.js +0 -175
- package/dist/esm/internal/fx-primitive.js.map +0 -1
- package/dist/esm/internal/fx.js +0 -216
- package/dist/esm/internal/fx.js.map +0 -1
- package/dist/esm/internal/matchers.js +0 -38
- package/dist/esm/internal/matchers.js.map +0 -1
- package/dist/esm/internal/run.js +0 -32
- package/dist/esm/internal/run.js.map +0 -1
- package/dist/esm/internal/schema-ref-subject.js +0 -121
- package/dist/esm/internal/schema-ref-subject.js.map +0 -1
- package/dist/esm/internal/versioned-transform.js +0 -37
- package/dist/esm/internal/versioned-transform.js.map +0 -1
- package/src/Computed.ts +0 -289
- package/src/Filtered.ts +0 -274
- package/src/Model.ts +0 -483
- package/src/RefAsyncData.ts +0 -547
- package/src/RefAsyncDataArray.ts +0 -135
- package/src/RefBoolean.ts +0 -71
- package/src/RefNumber.ts +0 -77
- package/src/internal/core-ref-subject.ts +0 -528
- package/src/internal/core-subject.ts +0 -143
- package/src/internal/deferred-ref.ts +0 -26
- package/src/internal/effect-primitive.ts +0 -230
- package/src/internal/fx-effect-proto.ts +0 -56
- package/src/internal/fx-primitive.ts +0 -223
- package/src/internal/fx.ts +0 -619
- package/src/internal/matchers.ts +0 -83
- package/src/internal/run.ts +0 -51
- package/src/internal/schema-ref-subject.ts +0 -163
- package/src/internal/versioned-transform.ts +0 -48
|
@@ -3,922 +3,1733 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.acquireUseRelease =
|
|
7
|
-
exports.
|
|
8
|
-
exports.
|
|
9
|
-
exports.
|
|
10
|
-
exports.
|
|
11
|
-
exports.
|
|
12
|
-
exports.
|
|
13
|
-
exports.
|
|
14
|
-
exports.
|
|
15
|
-
exports.
|
|
16
|
-
exports.
|
|
17
|
-
exports.
|
|
6
|
+
exports.acquireUseRelease = acquireUseRelease;
|
|
7
|
+
exports.all = all;
|
|
8
|
+
exports.annotateLogs = annotateLogs;
|
|
9
|
+
exports.annotateSpans = annotateSpans;
|
|
10
|
+
exports.append = append;
|
|
11
|
+
exports.appendAll = appendAll;
|
|
12
|
+
exports.concatMap = concatMap;
|
|
13
|
+
exports.continueWith = continueWith;
|
|
14
|
+
exports.debounce = debounce;
|
|
15
|
+
exports.drop = exports.drain = exports.die = void 0;
|
|
16
|
+
exports.dropAfter = dropAfter;
|
|
17
|
+
exports.dropAfterEffect = dropAfterEffect;
|
|
18
|
+
exports.dropUntil = dropUntil;
|
|
19
|
+
exports.dropUntilEffect = dropUntilEffect;
|
|
20
|
+
exports.dropWhile = dropWhile;
|
|
21
|
+
exports.dropWhileEffect = dropWhileEffect;
|
|
22
|
+
exports.during = during;
|
|
23
|
+
exports.either = either;
|
|
24
|
+
exports.empty = void 0;
|
|
25
|
+
exports.exhaustFilterMapLatestEffect = exhaustFilterMapLatestEffect;
|
|
26
|
+
exports.exhaustMap = exhaustMap;
|
|
27
|
+
exports.exhaustMapCause = exhaustMapCause;
|
|
28
|
+
exports.exhaustMapEffect = exhaustMapEffect;
|
|
29
|
+
exports.exhaustMapError = exhaustMapError;
|
|
30
|
+
exports.exhaustMapLatest = exhaustMapLatest;
|
|
31
|
+
exports.exhaustMapLatestCause = exhaustMapLatestCause;
|
|
32
|
+
exports.exhaustMapLatestEffect = exhaustMapLatestEffect;
|
|
33
|
+
exports.exhaustMapLatestError = exhaustMapLatestError;
|
|
34
|
+
exports.exhaustMatchCause = exhaustMatchCause;
|
|
35
|
+
exports.exhaustMatchError = exhaustMatchError;
|
|
36
|
+
exports.exhaustMatchLatestCause = exhaustMatchLatestCause;
|
|
37
|
+
exports.exhaustMatchLatestError = exhaustMatchLatestError;
|
|
38
|
+
exports.exit = exit;
|
|
39
|
+
exports.filter = exports.failCause = exports.fail = void 0;
|
|
40
|
+
exports.filterCause = filterCause;
|
|
41
|
+
exports.filterCauseEffect = filterCauseEffect;
|
|
42
|
+
exports.filterEffect = void 0;
|
|
43
|
+
exports.filterError = filterError;
|
|
44
|
+
exports.filterErrorEffect = filterErrorEffect;
|
|
45
|
+
exports.filterMap = void 0;
|
|
46
|
+
exports.filterMapCause = filterMapCause;
|
|
47
|
+
exports.filterMapCauseEffect = filterMapCauseEffect;
|
|
48
|
+
exports.filterMapEffect = void 0;
|
|
49
|
+
exports.filterMapError = filterMapError;
|
|
50
|
+
exports.filterMapErrorEffect = filterMapErrorEffect;
|
|
51
|
+
exports.filterMapLoop = void 0;
|
|
52
|
+
exports.filterMapLoopCause = filterMapLoopCause;
|
|
53
|
+
exports.filterMapLoopCauseEffect = filterMapLoopCauseEffect;
|
|
54
|
+
exports.filterMapLoopEffect = void 0;
|
|
55
|
+
exports.filterMapLoopError = filterMapLoopError;
|
|
56
|
+
exports.filterMapLoopErrorEffect = filterMapLoopErrorEffect;
|
|
57
|
+
exports.findFirst = findFirst;
|
|
58
|
+
exports.first = first;
|
|
59
|
+
exports.flatMap = flatMap;
|
|
60
|
+
exports.flatMapCause = flatMapCause;
|
|
61
|
+
exports.flatMapCauseConcurrently = flatMapCauseConcurrently;
|
|
62
|
+
exports.flatMapCauseWithStrategy = flatMapCauseWithStrategy;
|
|
63
|
+
exports.flatMapConcurrently = flatMapConcurrently;
|
|
64
|
+
exports.flatMapConcurrentlyEffect = flatMapConcurrentlyEffect;
|
|
65
|
+
exports.flatMapEffect = flatMapEffect;
|
|
66
|
+
exports.flatMapError = flatMapError;
|
|
67
|
+
exports.flatMapErrorConcurrently = flatMapErrorConcurrently;
|
|
68
|
+
exports.flatMapErrorWithStrategy = flatMapErrorWithStrategy;
|
|
69
|
+
exports.flatMapWithStrategy = flatMapWithStrategy;
|
|
70
|
+
exports.fromArray = void 0;
|
|
71
|
+
exports.fromAsyncIterable = fromAsyncIterable;
|
|
72
|
+
exports.fromEffect = void 0;
|
|
73
|
+
exports.fromFxEffect = fromFxEffect;
|
|
74
|
+
exports.fromSync = exports.fromScheduled = exports.fromIterable = void 0;
|
|
75
|
+
exports.gen = gen;
|
|
76
|
+
exports.genScoped = genScoped;
|
|
77
|
+
exports.if = if_;
|
|
78
|
+
exports.interruptible = void 0;
|
|
79
|
+
exports.isEmpty = isEmpty;
|
|
80
|
+
exports.isFailCause = isFailCause;
|
|
81
|
+
exports.isNever = isNever;
|
|
82
|
+
exports.isPadWith = isPadWith;
|
|
83
|
+
exports.isProducer = isProducer;
|
|
84
|
+
exports.isProducerEffect = isProducerEffect;
|
|
85
|
+
exports.isProducerEffectTransformer = isProducerEffectTransformer;
|
|
86
|
+
exports.isProducerSyncTransformer = isProducerSyncTransformer;
|
|
87
|
+
exports.isSlice = isSlice;
|
|
88
|
+
exports.isTransformer = isTransformer;
|
|
89
|
+
exports.locally = locally;
|
|
90
|
+
exports.locallyWith = locallyWith;
|
|
91
|
+
exports.loop = void 0;
|
|
92
|
+
exports.loopCause = loopCause;
|
|
93
|
+
exports.loopCauseEffect = loopCauseEffect;
|
|
94
|
+
exports.loopEffect = void 0;
|
|
95
|
+
exports.loopError = loopError;
|
|
96
|
+
exports.loopErrorEffect = loopErrorEffect;
|
|
97
|
+
exports.make = make;
|
|
98
|
+
exports.map = void 0;
|
|
99
|
+
exports.mapBoth = mapBoth;
|
|
100
|
+
exports.mapCause = mapCause;
|
|
101
|
+
exports.mapCauseEffect = mapCauseEffect;
|
|
102
|
+
exports.mapEffect = void 0;
|
|
103
|
+
exports.mapError = mapError;
|
|
104
|
+
exports.mapErrorEffect = mapErrorEffect;
|
|
105
|
+
exports.matchCause = matchCause;
|
|
106
|
+
exports.matchCauseConcurrently = matchCauseConcurrently;
|
|
107
|
+
exports.matchCauseWithStrategy = matchCauseWithStrategy;
|
|
108
|
+
exports.matchError = matchError;
|
|
109
|
+
exports.matchErrorConcurrently = matchErrorConcurrently;
|
|
110
|
+
exports.matchErrorWithStrategy = matchErrorWithStrategy;
|
|
18
111
|
exports.merge = merge;
|
|
19
|
-
exports.
|
|
20
|
-
exports.
|
|
21
|
-
exports.
|
|
22
|
-
exports.
|
|
112
|
+
exports.mergeAll = mergeAll;
|
|
113
|
+
exports.mergeFirst = mergeFirst;
|
|
114
|
+
exports.mergeOrdered = mergeOrdered;
|
|
115
|
+
exports.mergeOrderedConcurrently = mergeOrderedConcurrently;
|
|
116
|
+
exports.mergeRace = mergeRace;
|
|
117
|
+
exports.mergeSwitch = mergeSwitch;
|
|
118
|
+
exports.mergeWithStrategy = mergeWithStrategy;
|
|
119
|
+
exports.middleware = middleware;
|
|
120
|
+
exports.observe = exports.never = void 0;
|
|
121
|
+
exports.onError = onError;
|
|
122
|
+
exports.onExit = onExit;
|
|
123
|
+
exports.onInterrupt = onInterrupt;
|
|
124
|
+
exports.orElse = orElse;
|
|
125
|
+
exports.orElseCause = orElseCause;
|
|
126
|
+
exports.padWith = padWith;
|
|
127
|
+
exports.prepend = prepend;
|
|
128
|
+
exports.prependAll = prependAll;
|
|
129
|
+
exports.provide = provide;
|
|
130
|
+
exports.provideContext = provideContext;
|
|
131
|
+
exports.provideLayer = provideLayer;
|
|
132
|
+
exports.provideRuntime = provideRuntime;
|
|
133
|
+
exports.provideService = provideService;
|
|
134
|
+
exports.provideServiceEffect = provideServiceEffect;
|
|
23
135
|
exports.race = race;
|
|
24
|
-
exports.
|
|
136
|
+
exports.raceAll = raceAll;
|
|
137
|
+
exports.reduce = void 0;
|
|
138
|
+
exports.sample = sample;
|
|
139
|
+
exports.scan = scan;
|
|
140
|
+
exports.scoped = exports.schedule = void 0;
|
|
141
|
+
exports.since = since;
|
|
142
|
+
exports.skipRepeats = skipRepeats;
|
|
143
|
+
exports.skipRepeatsWith = skipRepeatsWith;
|
|
144
|
+
exports.slice = void 0;
|
|
145
|
+
exports.snapshot = snapshot;
|
|
146
|
+
exports.snapshotEffect = snapshotEffect;
|
|
25
147
|
exports.struct = struct;
|
|
26
|
-
exports.succeed =
|
|
27
|
-
exports.
|
|
28
|
-
exports.
|
|
29
|
-
exports.
|
|
30
|
-
exports.
|
|
31
|
-
exports.
|
|
32
|
-
exports.
|
|
33
|
-
|
|
148
|
+
exports.succeed = void 0;
|
|
149
|
+
exports.suspend = suspend;
|
|
150
|
+
exports.switchMap = switchMap;
|
|
151
|
+
exports.switchMapCause = switchMapCause;
|
|
152
|
+
exports.switchMapEffect = switchMapEffect;
|
|
153
|
+
exports.switchMapError = switchMapError;
|
|
154
|
+
exports.switchMatchCause = switchMatchCause;
|
|
155
|
+
exports.switchMatchError = switchMatchError;
|
|
156
|
+
exports.take = void 0;
|
|
157
|
+
exports.takeUntil = takeUntil;
|
|
158
|
+
exports.takeUntilEffect = takeUntilEffect;
|
|
159
|
+
exports.takeWhile = takeWhile;
|
|
160
|
+
exports.takeWhileEffect = takeWhileEffect;
|
|
161
|
+
exports.tapEffect = void 0;
|
|
162
|
+
exports.throttle = throttle;
|
|
163
|
+
exports.throttleLatest = throttleLatest;
|
|
164
|
+
exports.toEnqueue = toEnqueue;
|
|
165
|
+
exports.toReadonlyArray = void 0;
|
|
166
|
+
exports.tuple = tuple;
|
|
167
|
+
exports.uninterruptible = void 0;
|
|
168
|
+
exports.until = until;
|
|
169
|
+
exports.when = when;
|
|
170
|
+
exports.withConcurrency = withConcurrency;
|
|
171
|
+
exports.withConfigProvider = withConfigProvider;
|
|
172
|
+
exports.withLogSpan = withLogSpan;
|
|
173
|
+
exports.withMaxOpsBeforeYield = withMaxOpsBeforeYield;
|
|
174
|
+
exports.withParentSpan = withParentSpan;
|
|
175
|
+
exports.withPrevious = void 0;
|
|
176
|
+
exports.withRequestBatching = withRequestBatching;
|
|
177
|
+
exports.withRequestCache = withRequestCache;
|
|
178
|
+
exports.withRequestCaching = withRequestCaching;
|
|
179
|
+
exports.withScheduler = withScheduler;
|
|
180
|
+
exports.withSpan = withSpan;
|
|
181
|
+
exports.withTracer = withTracer;
|
|
182
|
+
exports.withTracerTiming = withTracerTiming;
|
|
183
|
+
var Context = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@typed/context"));
|
|
184
|
+
var Boolean = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Boolean"));
|
|
185
|
+
var Cause = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Cause"));
|
|
186
|
+
var Clock = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Clock"));
|
|
187
|
+
var Deferred = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Deferred"));
|
|
188
|
+
var Effect = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Effect"));
|
|
189
|
+
var Either = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Either"));
|
|
190
|
+
var Equal = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Equal"));
|
|
191
|
+
var ExecutionStrategy = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/ExecutionStrategy"));
|
|
192
|
+
var Exit = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Exit"));
|
|
193
|
+
var Fiber = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Fiber"));
|
|
34
194
|
var _Function = /*#__PURE__*/require("effect/Function");
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
var
|
|
38
|
-
var
|
|
39
|
-
var
|
|
40
|
-
var
|
|
41
|
-
var strategies = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./strategies.js"));
|
|
42
|
-
var _syncOperator = /*#__PURE__*/require("./sync-operator.js");
|
|
43
|
-
var Emitter = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("../Emitter.js"));
|
|
195
|
+
var Layer = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Layer"));
|
|
196
|
+
var Option = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Option"));
|
|
197
|
+
var Predicate = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Predicate"));
|
|
198
|
+
var Ref = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Ref"));
|
|
199
|
+
var Scope = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Scope"));
|
|
200
|
+
var Tracer = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Tracer"));
|
|
44
201
|
var Sink = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("../Sink.js"));
|
|
45
202
|
var _bounds = /*#__PURE__*/require("./bounds.js");
|
|
46
|
-
var
|
|
47
|
-
var
|
|
48
|
-
var
|
|
203
|
+
var EffectLoopOp = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./effect-loop-operator.js"));
|
|
204
|
+
var EffectOp = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./effect-operator.js"));
|
|
205
|
+
var EffectProducer = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./effect-producer.js"));
|
|
206
|
+
var _helpers = /*#__PURE__*/require("./helpers.js");
|
|
207
|
+
var SyncLoopOp = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./loop-operator.js"));
|
|
208
|
+
var Op = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./operator.js"));
|
|
49
209
|
var _protos = /*#__PURE__*/require("./protos.js");
|
|
50
|
-
var
|
|
210
|
+
var Provide = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./provide.js"));
|
|
211
|
+
var _strategies = /*#__PURE__*/require("./strategies.js");
|
|
212
|
+
var SyncOp = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./sync-operator.js"));
|
|
213
|
+
var SyncProducer = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./sync-producer.js"));
|
|
51
214
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
52
215
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
53
|
-
const
|
|
54
|
-
|
|
216
|
+
const DISCARD = {
|
|
217
|
+
discard: true
|
|
218
|
+
};
|
|
219
|
+
const UNBOUNDED = {
|
|
220
|
+
concurrency: "unbounded"
|
|
221
|
+
};
|
|
222
|
+
function make(run) {
|
|
223
|
+
return new Make(run);
|
|
224
|
+
}
|
|
225
|
+
class Make extends _protos.FxBase {
|
|
226
|
+
_run;
|
|
227
|
+
constructor(_run) {
|
|
228
|
+
super();
|
|
229
|
+
this._run = _run;
|
|
230
|
+
}
|
|
231
|
+
run(sink) {
|
|
232
|
+
return Effect.contextWithEffect(ctx => this._run(Sink.provide(sink, ctx)));
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
class Producer extends _protos.FxBase {
|
|
236
|
+
i0;
|
|
237
|
+
constructor(i0) {
|
|
238
|
+
super();
|
|
239
|
+
this.i0 = i0;
|
|
240
|
+
}
|
|
241
|
+
run(sink) {
|
|
242
|
+
return SyncProducer.runSink(this.i0, sink);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* @internal
|
|
247
|
+
*/
|
|
248
|
+
function isProducer(fx) {
|
|
249
|
+
return fx.constructor === Producer;
|
|
250
|
+
}
|
|
251
|
+
const succeed = value => new Producer(SyncProducer.Success(value));
|
|
252
|
+
exports.succeed = succeed;
|
|
253
|
+
const fromSync = f => new Producer(SyncProducer.FromSync(f));
|
|
254
|
+
exports.fromSync = fromSync;
|
|
255
|
+
const fromArray = array => new Producer(SyncProducer.FromArray(array));
|
|
256
|
+
exports.fromArray = fromArray;
|
|
257
|
+
const fromIterable = iterable => new Producer(SyncProducer.FromIterable(iterable));
|
|
258
|
+
exports.fromIterable = fromIterable;
|
|
259
|
+
class ProducerEffect extends _protos.FxBase {
|
|
260
|
+
i0;
|
|
261
|
+
constructor(i0) {
|
|
262
|
+
super();
|
|
263
|
+
this.i0 = i0;
|
|
264
|
+
}
|
|
265
|
+
run(sink) {
|
|
266
|
+
return EffectProducer.runSink(this.i0, sink);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* @internal
|
|
271
|
+
*/
|
|
272
|
+
function isProducerEffect(fx) {
|
|
273
|
+
return fx.constructor === ProducerEffect;
|
|
274
|
+
}
|
|
275
|
+
const fromEffect = effect => (0, _helpers.matchEffectPrimitive)(effect, {
|
|
276
|
+
// Match over Effect primitives and return Fx primitives to allow fusion to take place
|
|
277
|
+
Success: succeed,
|
|
278
|
+
Failure: failCause,
|
|
279
|
+
Sync: fromSync,
|
|
280
|
+
Left: fail,
|
|
281
|
+
Right: succeed,
|
|
282
|
+
Some: succeed,
|
|
283
|
+
None: fail,
|
|
284
|
+
Otherwise: effect => new ProducerEffect(EffectProducer.FromEffect(effect))
|
|
285
|
+
});
|
|
286
|
+
exports.fromEffect = fromEffect;
|
|
287
|
+
const fromScheduled = (input, schedule) => new ProducerEffect(EffectProducer.FromScheduled(input, schedule));
|
|
288
|
+
exports.fromScheduled = fromScheduled;
|
|
289
|
+
const schedule = (input, schedule) => new ProducerEffect(EffectProducer.Scheduled(input, schedule));
|
|
290
|
+
exports.schedule = schedule;
|
|
291
|
+
class FailCause extends _protos.FxBase {
|
|
292
|
+
i0;
|
|
293
|
+
constructor(i0) {
|
|
294
|
+
super();
|
|
295
|
+
this.i0 = i0;
|
|
296
|
+
}
|
|
297
|
+
run(sink) {
|
|
298
|
+
return sink.onFailure(this.i0);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* @internal
|
|
303
|
+
*/
|
|
304
|
+
function isFailCause(fx) {
|
|
305
|
+
return fx.constructor === FailCause;
|
|
306
|
+
}
|
|
307
|
+
const failCause = cause => new FailCause(cause);
|
|
308
|
+
exports.failCause = failCause;
|
|
309
|
+
const fail = error => failCause(Cause.fail(error));
|
|
310
|
+
exports.fail = fail;
|
|
311
|
+
const die = error => failCause(Cause.die(error));
|
|
312
|
+
exports.die = die;
|
|
313
|
+
class Transformer extends _protos.FxBase {
|
|
55
314
|
i0;
|
|
56
315
|
i1;
|
|
57
316
|
constructor(i0, i1) {
|
|
58
|
-
super(
|
|
317
|
+
super();
|
|
59
318
|
this.i0 = i0;
|
|
60
319
|
this.i1 = i1;
|
|
61
320
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (fx.length === 0) return empty;
|
|
65
|
-
const nonEmptyFx = fx.filter(fx => !(fx instanceof _fxPrimitive.Empty));
|
|
66
|
-
if (nonEmptyFx.length === 0) return empty;
|
|
67
|
-
if (nonEmptyFx.length === 1) return nonEmptyFx[0];
|
|
68
|
-
const neverIndex = nonEmptyFx.findIndex(fx => fx instanceof _fxPrimitive.Never);
|
|
69
|
-
if (neverIndex === -1) return new Merge(nonEmptyFx, strategy);
|
|
70
|
-
switch (strategy._tag) {
|
|
71
|
-
case "Switch":
|
|
72
|
-
case "Ordered":
|
|
73
|
-
// Will only emit up to the first Never
|
|
74
|
-
return new Merge(nonEmptyFx.slice(0, neverIndex + 1), strategy);
|
|
75
|
-
// No use creating fibers for Fx that don't emit
|
|
76
|
-
case "Unordered":
|
|
77
|
-
return new Merge(nonEmptyFx, strategy);
|
|
78
|
-
}
|
|
321
|
+
run(sink) {
|
|
322
|
+
return this.i0.run(Op.compileOperatorSink(this.i1, sink));
|
|
79
323
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
i0,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
concurrency: i1.concurrency === Infinity ? "unbounded" : i1.concurrency
|
|
100
|
-
}));
|
|
324
|
+
static make(fx, operator) {
|
|
325
|
+
if (isEmpty(fx) || isNever(fx)) return fx;else if (isProducer(fx)) {
|
|
326
|
+
return new ProducerSyncTransformer(fx.i0, operator);
|
|
327
|
+
} else if (isTransformer(fx)) {
|
|
328
|
+
return new Transformer(fx.i0, Op.fuseOperators(fx.i1, operator));
|
|
329
|
+
} else if (isProducerSyncTransformer(fx)) {
|
|
330
|
+
return new ProducerSyncTransformer(fx.i0, Op.fuseOperators(fx.i1, operator));
|
|
331
|
+
} else if (isProducerEffect(fx)) {
|
|
332
|
+
return new ProducerEffectTransformer(fx.i0, operator);
|
|
333
|
+
} else if (isProducerEffectTransformer(fx)) {
|
|
334
|
+
return new ProducerEffectTransformer(fx.i0, Op.fuseOperators(fx.i1, operator));
|
|
335
|
+
} else if (isSuspend(fx)) {
|
|
336
|
+
return new SuspendedTransformer(fx.i0, operator);
|
|
337
|
+
} else if (isSuspendedTransformer(fx)) {
|
|
338
|
+
return new SuspendedTransformer(fx.i0, Op.fuseOperators(fx.i1, operator));
|
|
339
|
+
} else if (isFailCause(fx)) {
|
|
340
|
+
return fx;
|
|
341
|
+
} else {
|
|
342
|
+
return new Transformer(fx, operator);
|
|
101
343
|
}
|
|
102
344
|
}
|
|
103
345
|
}
|
|
104
|
-
|
|
346
|
+
/**
|
|
347
|
+
* @internal
|
|
348
|
+
*/
|
|
349
|
+
function isTransformer(fx) {
|
|
350
|
+
return fx.constructor === Transformer;
|
|
351
|
+
}
|
|
352
|
+
class ProducerSyncTransformer extends _protos.FxBase {
|
|
105
353
|
i0;
|
|
106
354
|
i1;
|
|
107
355
|
constructor(i0, i1) {
|
|
108
|
-
super(
|
|
356
|
+
super();
|
|
109
357
|
this.i0 = i0;
|
|
110
358
|
this.i1 = i1;
|
|
111
359
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
360
|
+
run(sink) {
|
|
361
|
+
return SyncProducer.runSink(this.i0, Op.compileOperatorSink(this.i1, sink));
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* @internal
|
|
366
|
+
*/
|
|
367
|
+
function isProducerSyncTransformer(fx) {
|
|
368
|
+
return fx.constructor === ProducerSyncTransformer;
|
|
369
|
+
}
|
|
370
|
+
const map = (fx, f) => Transformer.make(fx, SyncOp.Map(f));
|
|
371
|
+
exports.map = map;
|
|
372
|
+
const filter = (fx, f) => Transformer.make(fx, SyncOp.Filter(f));
|
|
373
|
+
exports.filter = filter;
|
|
374
|
+
const filterMap = (fx, f) => Transformer.make(fx, SyncOp.FilterMap(f));
|
|
375
|
+
exports.filterMap = filterMap;
|
|
376
|
+
const mapEffect = (fx, f) => Transformer.make(fx, EffectOp.MapEffect(f));
|
|
377
|
+
exports.mapEffect = mapEffect;
|
|
378
|
+
const filterMapEffect = (fx, f) => Transformer.make(fx, EffectOp.FilterMapEffect(f));
|
|
379
|
+
exports.filterMapEffect = filterMapEffect;
|
|
380
|
+
const filterEffect = (fx, f) => Transformer.make(fx, EffectOp.FilterEffect(f));
|
|
381
|
+
exports.filterEffect = filterEffect;
|
|
382
|
+
const tapEffect = (fx, f) => Transformer.make(fx, EffectOp.TapEffect(f));
|
|
383
|
+
exports.tapEffect = tapEffect;
|
|
384
|
+
const loop = (fx, seed, f) => Transformer.make(fx, SyncLoopOp.LoopOperator(seed, f));
|
|
385
|
+
exports.loop = loop;
|
|
386
|
+
const withPrevious = fx => loop(fx, Option.none(), (acc, a) => [[acc, a], Option.some(a)]);
|
|
387
|
+
exports.withPrevious = withPrevious;
|
|
388
|
+
const filterMapLoop = (fx, seed, f) => Transformer.make(fx, SyncLoopOp.FilterMapLoopOperator(seed, f));
|
|
389
|
+
exports.filterMapLoop = filterMapLoop;
|
|
390
|
+
const loopEffect = (fx, seed, f) => Transformer.make(fx, EffectLoopOp.LoopEffectOperator(seed, f));
|
|
391
|
+
exports.loopEffect = loopEffect;
|
|
392
|
+
const filterMapLoopEffect = (fx, seed, f) => Transformer.make(fx, EffectLoopOp.FilterMapLoopEffectOperator(seed, f));
|
|
393
|
+
exports.filterMapLoopEffect = filterMapLoopEffect;
|
|
394
|
+
const observe = (fx, f) => Observe.make(fx, f);
|
|
395
|
+
exports.observe = observe;
|
|
396
|
+
const constUnit = () => Effect.unit;
|
|
397
|
+
const drain = fx => Observe.make(fx, constUnit);
|
|
398
|
+
exports.drain = drain;
|
|
399
|
+
class Observe extends _protos.EffectBase {
|
|
400
|
+
i0;
|
|
401
|
+
i1;
|
|
402
|
+
constructor(i0, i1) {
|
|
403
|
+
super();
|
|
404
|
+
this.i0 = i0;
|
|
405
|
+
this.i1 = i1;
|
|
406
|
+
}
|
|
407
|
+
toEffect() {
|
|
408
|
+
return Effect.asyncEffect(resume => {
|
|
409
|
+
const {
|
|
410
|
+
i0: fx,
|
|
411
|
+
i1: f
|
|
412
|
+
} = this;
|
|
413
|
+
const onFailure = cause => Effect.sync(() => resume(Effect.failCause(cause)));
|
|
414
|
+
return Effect.zipRight(fx.run(Sink.make(onFailure, a => Effect.catchAllCause(f(a), onFailure))), Effect.sync(() => resume(Effect.unit)));
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
static make(fx, f) {
|
|
418
|
+
if (isEmpty(fx)) {
|
|
419
|
+
return Effect.unit;
|
|
420
|
+
} else if (isNever(fx)) {
|
|
421
|
+
return Effect.never;
|
|
422
|
+
} else if (isProducer(fx)) {
|
|
423
|
+
return SyncProducer.runEffect(fx.i0, f);
|
|
424
|
+
} else if (isProducerSyncTransformer(fx)) {
|
|
425
|
+
return Op.matchOperator(fx.i1, {
|
|
426
|
+
SyncOperator: op => SyncOp.matchSyncOperator(op, {
|
|
427
|
+
Map: op => SyncProducer.effectOnce(() => SyncProducer.runEffect(fx.i0, a => f(op.f(a)))),
|
|
428
|
+
Filter: op => SyncProducer.effectOnce(() => SyncProducer.runEffect(fx.i0, Effect.unifiedFn(a => op.f(a) ? f(a) : Effect.unit))),
|
|
429
|
+
FilterMap: op => SyncProducer.effectOnce(() => SyncProducer.runEffect(fx.i0, Effect.unifiedFn(a => Option.match(op.f(a), {
|
|
430
|
+
onNone: () => Effect.unit,
|
|
431
|
+
onSome: f
|
|
432
|
+
}))))
|
|
433
|
+
}),
|
|
434
|
+
EffectOperator: op => EffectOp.matchEffectOperator(op, {
|
|
435
|
+
MapEffect: op => SyncProducer.runEffect(fx.i0, a => Effect.flatMap(op.f(a), f)),
|
|
436
|
+
FilterMapEffect: op => SyncProducer.runEffect(fx.i0, a => Effect.flatMap(op.f(a), Effect.unifiedFn(Option.match({
|
|
437
|
+
onNone: () => Effect.unit,
|
|
438
|
+
onSome: f
|
|
439
|
+
})))),
|
|
440
|
+
FilterEffect: op => SyncProducer.runEffect(fx.i0, Effect.unifiedFn(a => Effect.flatMap(op.f(a), Effect.unifiedFn(b => b ? f(a) : Effect.unit)))),
|
|
441
|
+
TapEffect: op => SyncProducer.runEffect(fx.i0, a => Effect.flatMap(op.f(a), () => f(a)))
|
|
442
|
+
}),
|
|
443
|
+
SyncLoopOperator: op => SyncLoopOp.matchSyncLoopOperator(op, {
|
|
444
|
+
Loop: op => SyncProducer.effectOnce(() => SyncProducer.runReduceEffect(fx.i0, op.seed, (acc, a) => {
|
|
445
|
+
const [c, b] = op.f(acc, a);
|
|
446
|
+
return Effect.as(f(c), b);
|
|
447
|
+
})),
|
|
448
|
+
FilterMapLoop: op => SyncProducer.effectOnce(() => SyncProducer.runReduceEffect(fx.i0, op.seed, (acc, a) => {
|
|
449
|
+
const [c, b] = op.f(acc, a);
|
|
450
|
+
return Option.match(c, {
|
|
451
|
+
onNone: () => Effect.succeed(acc),
|
|
452
|
+
onSome: c => Effect.as(f(c), b)
|
|
453
|
+
});
|
|
454
|
+
}))
|
|
455
|
+
}),
|
|
456
|
+
EffectLoopOperator: op => EffectLoopOp.matchEffectLoopOperator(op, {
|
|
457
|
+
LoopEffect: op => SyncProducer.runReduceEffect(fx.i0, op.seed, (acc, a) => Effect.flatMap(op.f(acc, a), ([c, b]) => Effect.as(f(c), b))),
|
|
458
|
+
FilterMapLoopEffect: op => SyncProducer.runReduceEffect(fx.i0, op.seed, (acc, a) => Effect.flatMap(op.f(acc, a), ([c, b]) => Option.match(c, {
|
|
459
|
+
onNone: () => Effect.succeed(b),
|
|
460
|
+
onSome: c => Effect.as(f(c), b)
|
|
461
|
+
})))
|
|
462
|
+
})
|
|
463
|
+
});
|
|
464
|
+
} else if (isProducerEffect(fx)) {
|
|
465
|
+
return EffectProducer.runEffect(fx.i0, f);
|
|
466
|
+
} else if (isProducerEffectTransformer(fx)) {
|
|
467
|
+
return Op.matchOperator(fx.i1, {
|
|
468
|
+
SyncOperator: op => SyncOp.matchSyncOperator(op, {
|
|
469
|
+
Map: op => SyncProducer.effectOnce(() => EffectProducer.runEffect(fx.i0, a => f(op.f(a)))),
|
|
470
|
+
Filter: op => SyncProducer.effectOnce(() => EffectProducer.runEffect(fx.i0, Effect.unifiedFn(a => op.f(a) ? f(a) : Effect.unit))),
|
|
471
|
+
FilterMap: op => SyncProducer.effectOnce(() => EffectProducer.runEffect(fx.i0, Effect.unifiedFn(a => Option.match(op.f(a), {
|
|
472
|
+
onNone: () => Effect.unit,
|
|
473
|
+
onSome: f
|
|
474
|
+
}))))
|
|
475
|
+
}),
|
|
476
|
+
EffectOperator: op => EffectOp.matchEffectOperator(op, {
|
|
477
|
+
MapEffect: op => EffectProducer.runEffect(fx.i0, a => Effect.flatMap(op.f(a), f)),
|
|
478
|
+
FilterMapEffect: op => EffectProducer.runEffect(fx.i0, a => Effect.flatMap(op.f(a), Effect.unifiedFn(Option.match({
|
|
479
|
+
onNone: () => Effect.unit,
|
|
480
|
+
onSome: f
|
|
481
|
+
})))),
|
|
482
|
+
FilterEffect: op => EffectProducer.runEffect(fx.i0, Effect.unifiedFn(a => Effect.flatMap(op.f(a), Effect.unifiedFn(b => b ? f(a) : Effect.unit)))),
|
|
483
|
+
TapEffect: op => EffectProducer.runEffect(fx.i0, a => Effect.flatMap(op.f(a), () => f(a)))
|
|
484
|
+
}),
|
|
485
|
+
SyncLoopOperator: op => SyncLoopOp.matchSyncLoopOperator(op, {
|
|
486
|
+
Loop: op => SyncProducer.effectOnce(() => EffectProducer.runReduceEffect(fx.i0, op.seed, (acc, a) => {
|
|
487
|
+
const [c, b] = op.f(acc, a);
|
|
488
|
+
return Effect.as(f(c), b);
|
|
489
|
+
})),
|
|
490
|
+
FilterMapLoop: op => SyncProducer.effectOnce(() => EffectProducer.runReduceEffect(fx.i0, op.seed, (acc, a) => {
|
|
491
|
+
const [c, b] = op.f(acc, a);
|
|
492
|
+
return Option.match(c, {
|
|
493
|
+
onNone: () => Effect.succeed(acc),
|
|
494
|
+
onSome: c => Effect.as(f(c), b)
|
|
495
|
+
});
|
|
496
|
+
}))
|
|
497
|
+
}),
|
|
498
|
+
EffectLoopOperator: op => EffectLoopOp.matchEffectLoopOperator(op, {
|
|
499
|
+
LoopEffect: op => EffectProducer.runReduceEffect(fx.i0, op.seed, (acc, a) => Effect.flatMap(op.f(acc, a), ([c, b]) => Effect.as(f(c), b))),
|
|
500
|
+
FilterMapLoopEffect: op => EffectProducer.runReduceEffect(fx.i0, op.seed, (acc, a) => Effect.flatMap(op.f(acc, a), ([c, b]) => Option.match(c, {
|
|
501
|
+
onNone: () => Effect.succeed(b),
|
|
502
|
+
onSome: c => Effect.as(f(c), b)
|
|
503
|
+
})))
|
|
504
|
+
})
|
|
505
|
+
});
|
|
506
|
+
} else if (isFailCause(fx)) {
|
|
507
|
+
return Effect.failCause(fx.i0);
|
|
117
508
|
} else {
|
|
118
|
-
return new
|
|
509
|
+
return new Observe(fx, f);
|
|
119
510
|
}
|
|
120
511
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
min
|
|
126
|
-
} = this.i1;
|
|
127
|
-
return withEarlyExit(({
|
|
128
|
-
sink
|
|
129
|
-
}) => _effect.Effect.suspend(() => {
|
|
130
|
-
let toSkip = min;
|
|
131
|
-
let toTake = max;
|
|
132
|
-
return (0, _run.run)(fx, Sink.WithContext(sink.onFailure, a => _effect.Effect.suspend(() => {
|
|
133
|
-
if (toSkip > 0) {
|
|
134
|
-
toSkip -= 1;
|
|
135
|
-
return _effect.Effect.unit;
|
|
136
|
-
} else if (toTake > 0) {
|
|
137
|
-
toTake -= 1;
|
|
138
|
-
return _effect.Effect.flatMap(sink.onSuccess(a), () => toTake <= 0 ? sink.earlyExit : _effect.Effect.unit);
|
|
139
|
-
} else {
|
|
140
|
-
return sink.earlyExit;
|
|
141
|
-
}
|
|
142
|
-
})));
|
|
143
|
-
}));
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
class Loop extends _fxPrimitive.ToFx {
|
|
512
|
+
}
|
|
513
|
+
const reduce = (fx, seed, f) => Reduce.make(fx, seed, f);
|
|
514
|
+
exports.reduce = reduce;
|
|
515
|
+
class Reduce extends _protos.EffectBase {
|
|
147
516
|
i0;
|
|
148
517
|
i1;
|
|
149
518
|
i2;
|
|
150
519
|
constructor(i0, i1, i2) {
|
|
151
|
-
super(
|
|
520
|
+
super();
|
|
152
521
|
this.i0 = i0;
|
|
153
522
|
this.i1 = i1;
|
|
154
523
|
this.i2 = i2;
|
|
155
524
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
525
|
+
toEffect() {
|
|
526
|
+
return Effect.suspend(() => {
|
|
527
|
+
let acc = this.i1;
|
|
528
|
+
return Effect.map(observe(this.i0, a => Effect.sync(() => acc = this.i2(acc, a))), () => acc);
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
static make(fx, seed, f) {
|
|
532
|
+
// TODO: optimize Effect trasformers
|
|
533
|
+
if (isEmpty(fx)) return Effect.succeed(seed);else if (isProducer(fx)) {
|
|
534
|
+
return SyncProducer.runReduce(fx.i0, seed, f);
|
|
535
|
+
} else if (isProducerSyncTransformer(fx)) {
|
|
536
|
+
return Op.matchOperator(fx.i1, {
|
|
537
|
+
SyncOperator: op => SyncProducer.syncOnce(() => SyncOp.runSyncReduce(fx.i0, op, seed, f)),
|
|
538
|
+
EffectOperator: op => EffectOp.runSyncReduce(fx.i0, op, seed, f),
|
|
539
|
+
SyncLoopOperator: op => SyncLoopOp.matchSyncLoopOperator(op, {
|
|
540
|
+
Loop: op => Effect.map(SyncProducer.runReduce(fx.i0, [op.seed, seed], ([opAcc, acc], a) => {
|
|
541
|
+
const [c, b] = op.f(opAcc, a);
|
|
542
|
+
const newAcc = f(acc, c);
|
|
543
|
+
return [b, newAcc];
|
|
544
|
+
}), x => x[1]),
|
|
545
|
+
FilterMapLoop: op => Effect.map(SyncProducer.runReduce(fx.i0, [op.seed, seed], ([opAcc, acc], a) => {
|
|
546
|
+
const [c, b] = op.f(opAcc, a);
|
|
547
|
+
const newAcc = Option.match(c, {
|
|
548
|
+
onNone: () => acc,
|
|
549
|
+
onSome: c => f(acc, c)
|
|
550
|
+
});
|
|
551
|
+
return [b, newAcc];
|
|
552
|
+
}), x => x[1])
|
|
553
|
+
}),
|
|
554
|
+
EffectLoopOperator: op => EffectLoopOp.matchEffectLoopOperator(op, {
|
|
555
|
+
LoopEffect: op => Effect.map(SyncProducer.runReduceEffect(fx.i0, [op.seed, seed], ([opAcc, acc], a) => {
|
|
556
|
+
return Effect.flatMap(op.f(opAcc, a), ([c, b]) => {
|
|
557
|
+
const newAcc = f(acc, c);
|
|
558
|
+
return Effect.succeed([b, newAcc]);
|
|
559
|
+
});
|
|
560
|
+
}), x => x[1]),
|
|
561
|
+
FilterMapLoopEffect: op => Effect.map(SyncProducer.runReduceEffect(fx.i0, [op.seed, seed], ([opAcc, acc], a) => {
|
|
562
|
+
return Effect.map(op.f(opAcc, a), ([c, b]) => {
|
|
563
|
+
const newAcc = Option.match(c, {
|
|
564
|
+
onNone: () => acc,
|
|
565
|
+
onSome: () => f(acc, b)
|
|
566
|
+
});
|
|
567
|
+
return [b, newAcc];
|
|
568
|
+
});
|
|
569
|
+
}), x => x[1])
|
|
570
|
+
})
|
|
571
|
+
});
|
|
572
|
+
} else if (isProducerEffect(fx)) {
|
|
573
|
+
return EffectProducer.runReduceEffect(fx.i0, seed, (b, a) => Effect.succeed(f(b, a)));
|
|
574
|
+
} else if (isFailCause(fx)) {
|
|
575
|
+
return Effect.failCause(fx.i0);
|
|
161
576
|
} else {
|
|
162
|
-
return new
|
|
577
|
+
return new Reduce(fx, seed, f);
|
|
163
578
|
}
|
|
164
579
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
580
|
+
}
|
|
581
|
+
const toReadonlyArray = fx => Effect.suspend(() => {
|
|
582
|
+
const init = [];
|
|
583
|
+
return Reduce.make(fx, init, (acc, a) => {
|
|
584
|
+
acc.push(a);
|
|
585
|
+
return acc;
|
|
586
|
+
});
|
|
587
|
+
});
|
|
588
|
+
exports.toReadonlyArray = toReadonlyArray;
|
|
589
|
+
const slice = (fx, drop, take) => Slice.make(fx, (0, _bounds.boundsFrom)(drop, take));
|
|
590
|
+
exports.slice = slice;
|
|
591
|
+
const take = (fx, n) => slice(fx, 0, n);
|
|
592
|
+
exports.take = take;
|
|
593
|
+
const drop = (fx, n) => slice(fx, n, Infinity);
|
|
594
|
+
exports.drop = drop;
|
|
595
|
+
class Slice extends _protos.FxBase {
|
|
596
|
+
i0;
|
|
597
|
+
i1;
|
|
598
|
+
constructor(i0, i1) {
|
|
599
|
+
super();
|
|
600
|
+
this.i0 = i0;
|
|
601
|
+
this.i1 = i1;
|
|
602
|
+
}
|
|
603
|
+
run(sink) {
|
|
604
|
+
return Sink.slice(sink, this.i1, s => this.i0.run(s));
|
|
605
|
+
}
|
|
606
|
+
static make(fx, bounds) {
|
|
607
|
+
if ((0, _bounds.isNilBounds)(bounds)) return empty;
|
|
608
|
+
if ((0, _bounds.isInfiniteBounds)(bounds)) return fx;
|
|
609
|
+
if (isSlice(fx)) {
|
|
610
|
+
return Slice.make(fx.i0, (0, _bounds.mergeBounds)(fx.i1, bounds));
|
|
611
|
+
} else if (isTransformer(fx) && fx.i1._tag === "Map") {
|
|
612
|
+
// Commute map and slice
|
|
613
|
+
return map(Slice.make(fx.i0, bounds), fx.i1.f);
|
|
614
|
+
} else {
|
|
615
|
+
return new Slice(fx, bounds);
|
|
616
|
+
}
|
|
174
617
|
}
|
|
175
618
|
}
|
|
176
|
-
|
|
619
|
+
/**
|
|
620
|
+
* @internal
|
|
621
|
+
*/
|
|
622
|
+
function isSlice(fx) {
|
|
623
|
+
return fx.constructor === Slice;
|
|
624
|
+
}
|
|
625
|
+
function skipRepeatsWith(fx, eq) {
|
|
626
|
+
return filterMapLoop(fx, Option.none(), (previous, a) => {
|
|
627
|
+
if (Option.isSome(previous) && eq(a, previous.value)) {
|
|
628
|
+
return [Option.none(), Option.some(a)];
|
|
629
|
+
} else {
|
|
630
|
+
return [Option.some(a), Option.some(a)];
|
|
631
|
+
}
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
function skipRepeats(fx) {
|
|
635
|
+
return skipRepeatsWith(fx, Equal.equals);
|
|
636
|
+
}
|
|
637
|
+
class ProducerEffectTransformer extends _protos.FxBase {
|
|
177
638
|
i0;
|
|
178
639
|
i1;
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
super(i0, i1, i2);
|
|
640
|
+
constructor(i0, i1) {
|
|
641
|
+
super();
|
|
182
642
|
this.i0 = i0;
|
|
183
643
|
this.i1 = i1;
|
|
184
|
-
this.i2 = i2;
|
|
185
644
|
}
|
|
186
|
-
|
|
187
|
-
return
|
|
645
|
+
run(sink) {
|
|
646
|
+
return EffectProducer.runSink(this.i0, Op.compileOperatorSink(this.i1, sink));
|
|
188
647
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}));
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* @internal
|
|
651
|
+
*/
|
|
652
|
+
function isProducerEffectTransformer(fx) {
|
|
653
|
+
return fx.constructor === ProducerEffectTransformer;
|
|
654
|
+
}
|
|
655
|
+
class Empty extends _protos.FxBase {
|
|
656
|
+
run() {
|
|
657
|
+
return Effect.unit;
|
|
200
658
|
}
|
|
201
659
|
}
|
|
202
|
-
|
|
660
|
+
/**
|
|
661
|
+
* @internal
|
|
662
|
+
*/
|
|
663
|
+
function isEmpty(fx) {
|
|
664
|
+
return fx.constructor === Empty;
|
|
665
|
+
}
|
|
666
|
+
const empty = exports.empty = /*#__PURE__*/new Empty();
|
|
667
|
+
class Never extends _protos.FxBase {
|
|
668
|
+
run() {
|
|
669
|
+
return Effect.never;
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* @internal
|
|
674
|
+
*/
|
|
675
|
+
function isNever(fx) {
|
|
676
|
+
return fx.constructor === Never;
|
|
677
|
+
}
|
|
678
|
+
const never = exports.never = /*#__PURE__*/new Never();
|
|
679
|
+
function padWith(fx, start, end) {
|
|
680
|
+
return new PadWith(fx, start, end);
|
|
681
|
+
}
|
|
682
|
+
function prependAll(fx, start) {
|
|
683
|
+
return new PadWith(fx, start, []);
|
|
684
|
+
}
|
|
685
|
+
function appendAll(fx, end) {
|
|
686
|
+
return new PadWith(fx, [], end);
|
|
687
|
+
}
|
|
688
|
+
function prepend(fx, start) {
|
|
689
|
+
return new PadWith(fx, [start], []);
|
|
690
|
+
}
|
|
691
|
+
function append(fx, end) {
|
|
692
|
+
return new PadWith(fx, [], [end]);
|
|
693
|
+
}
|
|
694
|
+
function scan(fx, seed, f) {
|
|
695
|
+
return prepend(loop(fx, seed, (b, a) => {
|
|
696
|
+
const b2 = f(b, a);
|
|
697
|
+
return [b2, b2];
|
|
698
|
+
}), seed);
|
|
699
|
+
}
|
|
700
|
+
class PadWith extends _protos.FxBase {
|
|
203
701
|
i0;
|
|
204
702
|
i1;
|
|
205
703
|
i2;
|
|
206
704
|
constructor(i0, i1, i2) {
|
|
207
|
-
super(
|
|
705
|
+
super();
|
|
208
706
|
this.i0 = i0;
|
|
209
707
|
this.i1 = i1;
|
|
210
708
|
this.i2 = i2;
|
|
211
709
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
710
|
+
run(sink) {
|
|
711
|
+
const onSuccess = a => sink.onSuccess(a);
|
|
712
|
+
return Effect.forEach(this.i1, onSuccess, DISCARD).pipe(Effect.zipRight(this.i0.run(sink)), Effect.zipRight(Effect.forEach(this.i2, onSuccess, DISCARD)));
|
|
713
|
+
}
|
|
714
|
+
static make(fx, start, end) {
|
|
715
|
+
if (isEmpty(fx) || isNever(fx)) return fx;else if (isPadWith(fx)) {
|
|
716
|
+
return new PadWith(fx.i0, concat(start, fx.i1), concat(fx.i2, end));
|
|
217
717
|
} else {
|
|
218
|
-
return new
|
|
718
|
+
return new PadWith(fx, start, end);
|
|
219
719
|
}
|
|
220
720
|
}
|
|
221
|
-
toFx() {
|
|
222
|
-
const {
|
|
223
|
-
i0,
|
|
224
|
-
i1,
|
|
225
|
-
i2
|
|
226
|
-
} = this;
|
|
227
|
-
return fromSink(sink => _effect.Effect.flatMap(_effect.SynchronizedRef.make(i2), ref => (0, _run.run)(i0, Sink.WithContext(sink.onFailure, a => _effect.SynchronizedRef.updateEffect(ref, b => _effect.Effect.matchCauseEffect(i1(b, a), {
|
|
228
|
-
onFailure: cause => _effect.Effect.as(sink.onFailure(cause), b),
|
|
229
|
-
onSuccess: ([c, b2]) => _effect.Effect.as(sink.onSuccess(c), b2)
|
|
230
|
-
}))))));
|
|
231
|
-
}
|
|
232
721
|
}
|
|
233
|
-
|
|
722
|
+
function concat(a, b) {
|
|
723
|
+
return {
|
|
724
|
+
*[Symbol.iterator]() {
|
|
725
|
+
yield* a;
|
|
726
|
+
yield* b;
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* @internal
|
|
732
|
+
*/
|
|
733
|
+
function isPadWith(fx) {
|
|
734
|
+
return fx.constructor === PadWith;
|
|
735
|
+
}
|
|
736
|
+
function flatMapWithStrategy(fx, f, strategy, executionStrategy = ExecutionStrategy.sequential) {
|
|
737
|
+
return FlatMapWithStrategy.make(fx, f, strategy, executionStrategy);
|
|
738
|
+
}
|
|
739
|
+
function switchMap(fx, f, executionStrategy) {
|
|
740
|
+
return flatMapWithStrategy(fx, f, _strategies.Switch, executionStrategy);
|
|
741
|
+
}
|
|
742
|
+
function switchMapEffect(fx, f, executionStrategy) {
|
|
743
|
+
return switchMap(fx, a => fromEffect(f(a)), executionStrategy);
|
|
744
|
+
}
|
|
745
|
+
function exhaustMap(fx, f, executionStrategy) {
|
|
746
|
+
return flatMapWithStrategy(fx, f, _strategies.Exhaust, executionStrategy);
|
|
747
|
+
}
|
|
748
|
+
function exhaustMapEffect(fx, f, executionStrategy) {
|
|
749
|
+
return exhaustMap(fx, a => fromEffect(f(a)), executionStrategy);
|
|
750
|
+
}
|
|
751
|
+
function exhaustMapLatest(fx, f, executionStrategy) {
|
|
752
|
+
return flatMapWithStrategy(fx, f, _strategies.ExhaustLatest, executionStrategy);
|
|
753
|
+
}
|
|
754
|
+
function exhaustMapLatestEffect(fx, f, executionStrategy) {
|
|
755
|
+
return exhaustMapLatest(fx, a => fromEffect(f(a)), executionStrategy);
|
|
756
|
+
}
|
|
757
|
+
function exhaustFilterMapLatestEffect(fx, f, executionStrategy) {
|
|
758
|
+
return exhaustMapLatest(fx, a => fromFxEffect(Effect.map(f(a), Option.match({
|
|
759
|
+
onNone: () => empty,
|
|
760
|
+
onSome: succeed
|
|
761
|
+
}))), executionStrategy);
|
|
762
|
+
}
|
|
763
|
+
function flatMapConcurrently(fx, f, capacity, executionStrategy) {
|
|
764
|
+
return flatMapWithStrategy(fx, f, (0, _strategies.Bounded)(capacity), executionStrategy);
|
|
765
|
+
}
|
|
766
|
+
function concatMap(fx, f, executionStrategy) {
|
|
767
|
+
return flatMapConcurrently(fx, f, 1, executionStrategy);
|
|
768
|
+
}
|
|
769
|
+
function flatMapConcurrentlyEffect(fx, f, capacity, executionStrategy) {
|
|
770
|
+
return flatMapConcurrently(fx, a => fromEffect(f(a)), capacity, executionStrategy);
|
|
771
|
+
}
|
|
772
|
+
function flatMap(fx, f, executionStrategy) {
|
|
773
|
+
return flatMapWithStrategy(fx, f, _strategies.Unbounded, executionStrategy);
|
|
774
|
+
}
|
|
775
|
+
function flatMapEffect(fx, f, executionStrategy) {
|
|
776
|
+
return flatMap(fx, a => fromEffect(f(a)), executionStrategy);
|
|
777
|
+
}
|
|
778
|
+
class FlatMapWithStrategy extends _protos.FxBase {
|
|
234
779
|
i0;
|
|
235
780
|
i1;
|
|
236
781
|
i2;
|
|
237
|
-
|
|
238
|
-
|
|
782
|
+
i3;
|
|
783
|
+
withFork;
|
|
784
|
+
constructor(i0, i1, i2, i3) {
|
|
785
|
+
super();
|
|
239
786
|
this.i0 = i0;
|
|
240
787
|
this.i1 = i1;
|
|
241
788
|
this.i2 = i2;
|
|
789
|
+
this.i3 = i3;
|
|
790
|
+
this.withFork = (0, _helpers.withFlattenStrategy)(i2);
|
|
242
791
|
}
|
|
243
|
-
|
|
244
|
-
return
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
792
|
+
run(sink) {
|
|
793
|
+
return this.withFork(fork => Sink.withEarlyExit(sink, sink => this.i0.run(Sink.make(cause => Cause.isInterruptedOnly(cause) ? sink.earlyExit : sink.onFailure(cause), a => fork(this.i1(a).run(sink))))), this.i3);
|
|
794
|
+
}
|
|
795
|
+
static make(fx, f, strategy, executionStrategy) {
|
|
796
|
+
if (isEmpty(fx) || isNever(fx)) return fx;else if (isProducer(fx)) {
|
|
797
|
+
if (fx.i0._tag === "Success") return f(fx.i0.source);
|
|
798
|
+
if (fx.i0._tag === "FromSync") {
|
|
799
|
+
const producer = fx.i0;
|
|
800
|
+
return suspend(() => f(producer.source()));
|
|
801
|
+
}
|
|
802
|
+
const arr = Array.isArray(fx.i0.source) ? fx.i0.source : Array.from(fx.i0.source);
|
|
803
|
+
if (arr.length === 0) return empty;
|
|
804
|
+
if (arr.length === 1) return f(arr[0]);
|
|
805
|
+
switch (strategy._tag) {
|
|
806
|
+
case "Switch":
|
|
807
|
+
return f(arr[arr.length - 1]);
|
|
808
|
+
case "Exhaust":
|
|
809
|
+
return f(arr[0]);
|
|
810
|
+
case "ExhaustLatest":
|
|
811
|
+
return arr.length > 1 ? continueWith(f(arr[0]), () => f(arr[arr.length - 1])) : f(arr[0]);
|
|
812
|
+
default:
|
|
813
|
+
return new FlatMapWithStrategy(fx, f, strategy, executionStrategy);
|
|
814
|
+
}
|
|
815
|
+
} else if (isProducerEffect(fx) && fx.i0._tag === "FromEffect") {
|
|
816
|
+
return fromFxEffect(Effect.map(fx.i0.source, f));
|
|
817
|
+
} else if (isTransformer(fx) && fx.i1._tag === "Map") {
|
|
818
|
+
const {
|
|
819
|
+
f: op
|
|
820
|
+
} = fx.i1;
|
|
821
|
+
return new FlatMapWithStrategy(fx.i0, a => f(op(a)), strategy, executionStrategy);
|
|
822
|
+
} else {
|
|
823
|
+
return new FlatMapWithStrategy(fx, f, strategy, executionStrategy);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
function fromFxEffect(effect) {
|
|
828
|
+
return new FromFxEffect(effect);
|
|
829
|
+
}
|
|
830
|
+
class FromFxEffect extends _protos.FxBase {
|
|
831
|
+
i0;
|
|
832
|
+
constructor(i0) {
|
|
833
|
+
super();
|
|
834
|
+
this.i0 = i0;
|
|
835
|
+
}
|
|
836
|
+
run(sink) {
|
|
837
|
+
return Effect.matchCauseEffect(this.i0, {
|
|
838
|
+
onFailure: cause => sink.onFailure(cause),
|
|
839
|
+
onSuccess: fx => fx.run(sink)
|
|
840
|
+
});
|
|
256
841
|
}
|
|
257
842
|
}
|
|
258
|
-
|
|
843
|
+
function gen(f) {
|
|
844
|
+
return fromFxEffect(Effect.gen(f));
|
|
845
|
+
}
|
|
846
|
+
function genScoped(f) {
|
|
847
|
+
return scoped(fromFxEffect(Effect.gen(f)));
|
|
848
|
+
}
|
|
849
|
+
function continueWith(fx, f) {
|
|
850
|
+
return ContinueWith.make(fx, f);
|
|
851
|
+
}
|
|
852
|
+
class ContinueWith extends _protos.FxBase {
|
|
259
853
|
i0;
|
|
260
854
|
i1;
|
|
261
855
|
constructor(i0, i1) {
|
|
262
|
-
super(
|
|
856
|
+
super();
|
|
263
857
|
this.i0 = i0;
|
|
264
858
|
this.i1 = i1;
|
|
265
859
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
860
|
+
run(sink) {
|
|
861
|
+
return Effect.flatMap(this.i0.run(sink), () => this.i1().run(sink));
|
|
862
|
+
}
|
|
863
|
+
static make(fx, f) {
|
|
864
|
+
if (isEmpty(fx)) return f();else if (isNever(fx)) return fx;else if (isProducer(fx)) {
|
|
865
|
+
return SyncProducer.matchSyncProducer(fx.i0, {
|
|
866
|
+
Success: source => prependAll(f(), [source]),
|
|
867
|
+
FromSync: source => suspend(() => prependAll(f(), [source()])),
|
|
868
|
+
FromArray: source => prependAll(f(), source),
|
|
869
|
+
FromIterable: source => prependAll(f(), source)
|
|
870
|
+
});
|
|
269
871
|
} else {
|
|
270
|
-
return new
|
|
872
|
+
return new ContinueWith(fx, f);
|
|
271
873
|
}
|
|
272
874
|
}
|
|
273
|
-
toFx() {
|
|
274
|
-
return fromSink(sink => _effect.Effect.catchAllCause(Provide.provideToEffect((0, _run.run)(this.i0, sink), this.i1), sink.onFailure));
|
|
275
|
-
}
|
|
276
875
|
}
|
|
277
|
-
|
|
876
|
+
function orElseCause(fx, f) {
|
|
877
|
+
return OrElseCause.make(fx, f);
|
|
878
|
+
}
|
|
879
|
+
class OrElseCause extends _protos.FxBase {
|
|
278
880
|
i0;
|
|
279
881
|
i1;
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
super(i0, i1, i2);
|
|
882
|
+
constructor(i0, i1) {
|
|
883
|
+
super();
|
|
283
884
|
this.i0 = i0;
|
|
284
885
|
this.i1 = i1;
|
|
285
|
-
this.i2 = i2;
|
|
286
886
|
}
|
|
287
|
-
|
|
288
|
-
return (
|
|
289
|
-
RefSubject: fx2 => this.runScoped(this.i0, fx2, this.i2),
|
|
290
|
-
Fx: fx2 => this.runScoped(this.i0, fx2, this.i2),
|
|
291
|
-
Effect: effect2 => mapEffect(this.i0, a => _effect.Effect.flatMap(effect2, b => this.i2(a, b))),
|
|
292
|
-
Cause: cause2 => matchCause(this.i0, {
|
|
293
|
-
onFailure: cause1 => _effect.Effect.failCause(_effect.Cause.sequential(cause1, cause2)),
|
|
294
|
-
onSuccess: () => _effect.Effect.failCause(cause2)
|
|
295
|
-
}),
|
|
296
|
-
Iterable: iterable => withEarlyExit(({
|
|
297
|
-
sink
|
|
298
|
-
}) => {
|
|
299
|
-
const iterator = iterable[Symbol.iterator]();
|
|
300
|
-
return (0, _run.run)(this.i0, Sink.WithContext(sink.onFailure, a => {
|
|
301
|
-
const result = iterator.next();
|
|
302
|
-
if (result.done) {
|
|
303
|
-
return sink.earlyExit;
|
|
304
|
-
} else {
|
|
305
|
-
return _effect.Effect.matchCauseEffect(this.i2(a, result.value), sink);
|
|
306
|
-
}
|
|
307
|
-
}));
|
|
308
|
-
}),
|
|
309
|
-
Otherwise: b => mapEffect(this.i0, a => this.i2(a, b))
|
|
310
|
-
});
|
|
887
|
+
run(sink) {
|
|
888
|
+
return Effect.catchAllCause(observe(this.i0, sink.onSuccess), cause => this.i1(cause).run(sink));
|
|
311
889
|
}
|
|
312
|
-
|
|
313
|
-
return
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
}) => _effect.Effect.flatMap(_effect.Ref.make(_effect.Option.none()), ref => _effect.Effect.flatMap(fork((0, _run.run)(fx2, Sink.WithContext(sink.onFailure, b => _effect.Ref.set(ref, _effect.Option.some(b))))), () => (0, _helpers.adjustTime)(1).pipe(_effect.Effect.zipRight((0, _run.run)(fx, Sink.WithContext(sink.onFailure, a => _effect.Effect.flatten(_effect.Ref.get(ref)).pipe(_effect.Effect.flatMap(b => _effect.Effect.matchCauseEffect(f(a, b), sink)), _effect.Effect.optionFromOptional, _effect.Effect.asUnit))))))));
|
|
890
|
+
static make(fx, f) {
|
|
891
|
+
if (isEmpty(fx)) return fx;else if (isNever(fx)) return fx;else {
|
|
892
|
+
return new OrElseCause(fx, f);
|
|
893
|
+
}
|
|
317
894
|
}
|
|
318
895
|
}
|
|
319
|
-
|
|
896
|
+
function orElse(fx, f) {
|
|
897
|
+
return OrElse.make(fx, f);
|
|
898
|
+
}
|
|
899
|
+
class OrElse extends _protos.FxBase {
|
|
320
900
|
i0;
|
|
321
901
|
i1;
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
super(i0, i1);
|
|
902
|
+
constructor(i0, i1) {
|
|
903
|
+
super();
|
|
325
904
|
this.i0 = i0;
|
|
326
905
|
this.i1 = i1;
|
|
327
|
-
this.i2 = i2;
|
|
328
906
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
907
|
+
run(sink) {
|
|
908
|
+
return Effect.catchAll(Effect.asyncEffect(resume => Effect.zipRight(this.i0.run(Sink.make(cause => Either.match(Cause.failureOrCause(cause), {
|
|
909
|
+
onLeft: e => Effect.succeed(resume(Effect.fail(e))),
|
|
910
|
+
onRight: cause => sink.onFailure(cause)
|
|
911
|
+
}), sink.onSuccess)), Effect.sync(() => resume(Effect.unit)))), error => this.i1(error).run(sink));
|
|
912
|
+
}
|
|
913
|
+
static make(fx, f) {
|
|
914
|
+
if (isEmpty(fx)) return fx;else if (isNever(fx)) return fx;else {
|
|
915
|
+
return new OrElse(fx, f);
|
|
334
916
|
}
|
|
335
917
|
}
|
|
336
|
-
|
|
337
|
-
|
|
918
|
+
}
|
|
919
|
+
function suspend(f) {
|
|
920
|
+
return new Suspend(f);
|
|
921
|
+
}
|
|
922
|
+
class Suspend extends _protos.FxBase {
|
|
923
|
+
i0;
|
|
924
|
+
constructor(i0) {
|
|
925
|
+
super();
|
|
926
|
+
this.i0 = i0;
|
|
927
|
+
}
|
|
928
|
+
run(sink) {
|
|
929
|
+
return this.i0().run(sink);
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
function isSuspend(fx) {
|
|
933
|
+
return fx.constructor === Suspend;
|
|
934
|
+
}
|
|
935
|
+
class SuspendedTransformer extends _protos.FxBase {
|
|
936
|
+
i0;
|
|
937
|
+
i1;
|
|
938
|
+
constructor(i0, i1) {
|
|
939
|
+
super();
|
|
940
|
+
this.i0 = i0;
|
|
941
|
+
this.i1 = i1;
|
|
942
|
+
}
|
|
943
|
+
run(sink) {
|
|
944
|
+
return this.i0().run(Op.compileOperatorSink(this.i1, sink));
|
|
338
945
|
}
|
|
339
946
|
}
|
|
340
|
-
function
|
|
341
|
-
return
|
|
947
|
+
function isSuspendedTransformer(fx) {
|
|
948
|
+
return fx.constructor === SuspendedTransformer;
|
|
342
949
|
}
|
|
343
|
-
function
|
|
344
|
-
return
|
|
950
|
+
function mergeWithStrategy(fx, stategy) {
|
|
951
|
+
return MergeWithStrategy.make(fx, stategy);
|
|
345
952
|
}
|
|
346
|
-
|
|
347
|
-
return
|
|
348
|
-
});
|
|
349
|
-
const mapBoth = exports.mapBoth = /*#__PURE__*/(0, _Function.dual)(2, function mapBoth(fx, options) {
|
|
350
|
-
return map(mapError(fx, options.onFailure), options.onSuccess);
|
|
351
|
-
});
|
|
352
|
-
const filter = exports.filter = /*#__PURE__*/(0, _Function.dual)(2, function map(fx, f) {
|
|
353
|
-
return _fxPrimitive.Transformer.make(fx, (0, _syncOperator.Filter)(f));
|
|
354
|
-
});
|
|
355
|
-
const filterMap = exports.filterMap = /*#__PURE__*/(0, _Function.dual)(2, function map(fx, f) {
|
|
356
|
-
return _fxPrimitive.Transformer.make(fx, (0, _syncOperator.FilterMap)(f));
|
|
357
|
-
});
|
|
358
|
-
const compact = fx => filterMap(fx, _Function.identity);
|
|
359
|
-
exports.compact = compact;
|
|
360
|
-
const mapErrorCause = exports.mapErrorCause = /*#__PURE__*/(0, _Function.dual)(2, function map(fx, f) {
|
|
361
|
-
return _fxPrimitive.TransformerCause.make(fx, (0, _syncOperator.Map)(f));
|
|
362
|
-
});
|
|
363
|
-
const mapError = exports.mapError = /*#__PURE__*/(0, _Function.dual)(2, function map(fx, f) {
|
|
364
|
-
return _fxPrimitive.TransformerCause.make(fx, (0, _syncOperator.Map)(_effect.Cause.map(f)));
|
|
365
|
-
});
|
|
366
|
-
const filterCause = exports.filterCause = /*#__PURE__*/(0, _Function.dual)(2, function map(fx, f) {
|
|
367
|
-
return _fxPrimitive.TransformerCause.make(fx, (0, _syncOperator.Filter)(f));
|
|
368
|
-
});
|
|
369
|
-
const filterMapCause = exports.filterMapCause = /*#__PURE__*/(0, _Function.dual)(2, function map(fx, f) {
|
|
370
|
-
return _fxPrimitive.TransformerCause.make(fx, (0, _syncOperator.FilterMap)(f));
|
|
371
|
-
});
|
|
372
|
-
const filterError = exports.filterError = /*#__PURE__*/(0, _Function.dual)(2, function map(fx, f) {
|
|
373
|
-
return filterMapCause(fx, cause => _effect.Cause.failureOrCause(cause).pipe(_effect.Either.match({
|
|
374
|
-
onLeft: e => f(e) ? _effect.Option.some(_effect.Cause.fail(e)) : _effect.Option.none(),
|
|
375
|
-
onRight: _effect.Option.some
|
|
376
|
-
})));
|
|
377
|
-
});
|
|
378
|
-
const filterMapError = exports.filterMapError = /*#__PURE__*/(0, _Function.dual)(2, function map(fx, f) {
|
|
379
|
-
return filterMapCause(fx, cause => _effect.Cause.failureOrCause(cause).pipe(_effect.Either.match({
|
|
380
|
-
onLeft: e => _effect.Option.map(f(e), _effect.Cause.fail),
|
|
381
|
-
onRight: _effect.Option.some
|
|
382
|
-
})));
|
|
383
|
-
});
|
|
384
|
-
const filterMapErrorEffect = exports.filterMapErrorEffect = /*#__PURE__*/(0, _Function.dual)(2, (fx, f) => {
|
|
385
|
-
return fromSink(sink => (0, _run.run)(fx, Sink.WithContext(cause => _effect.Either.match(_effect.Cause.failureOrCause(cause), {
|
|
386
|
-
onLeft: e => _effect.Effect.matchCauseEffect(f(e), {
|
|
387
|
-
onFailure: sink.onFailure,
|
|
388
|
-
onSuccess: _effect.Option.match({
|
|
389
|
-
onNone: () => _effect.Effect.unit,
|
|
390
|
-
onSome: b => sink.onFailure(_effect.Cause.fail(b))
|
|
391
|
-
})
|
|
392
|
-
}),
|
|
393
|
-
onRight: sink.onFailure
|
|
394
|
-
}), sink.onSuccess)));
|
|
395
|
-
});
|
|
396
|
-
function observe(fx, onSuccees) {
|
|
397
|
-
return helpers.withScopedFork(fork => _effect.Effect.flatMap(_effect.Deferred.make(), deferred => (0, _run.run)(fx, Sink.WithContext(cause => _effect.Deferred.failCause(deferred, cause), a => _effect.Effect.catchAllCause(onSuccees(a), cause => _effect.Deferred.failCause(deferred, cause)))).pipe(_effect.Effect.intoDeferred(deferred), fork, _effect.Effect.flatMap(() => _effect.Deferred.await(deferred)))));
|
|
953
|
+
function merge(fx, other) {
|
|
954
|
+
return mergeWithStrategy([fx, other], (0, _strategies.Unordered)(2));
|
|
398
955
|
}
|
|
399
|
-
function
|
|
400
|
-
return
|
|
956
|
+
function mergeAll(fx) {
|
|
957
|
+
return mergeWithStrategy(fx, (0, _strategies.Unordered)(Infinity));
|
|
401
958
|
}
|
|
402
|
-
function
|
|
403
|
-
return
|
|
404
|
-
const array = [];
|
|
405
|
-
return _effect.Effect.as(observe(fx, a => _effect.Effect.sync(() => array.push(a))), array);
|
|
406
|
-
});
|
|
959
|
+
function mergeOrdered(fx) {
|
|
960
|
+
return mergeOrderedConcurrently(fx, Infinity);
|
|
407
961
|
}
|
|
408
|
-
function
|
|
409
|
-
return
|
|
962
|
+
function mergeOrderedConcurrently(fx, concurrency) {
|
|
963
|
+
return mergeWithStrategy(fx, (0, _strategies.Ordered)(concurrency));
|
|
410
964
|
}
|
|
411
|
-
|
|
412
|
-
return
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
});
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
if (total === 0) return _effect.Effect.unit;
|
|
448
|
-
const values = new globalThis.Map();
|
|
449
|
-
const sample = () => Array.from({
|
|
450
|
-
length: total
|
|
451
|
-
}, (_, i) => values.get(i));
|
|
452
|
-
const emitIfReady = (value, index) => _effect.Effect.suspend(() => {
|
|
453
|
-
values.set(index, value);
|
|
454
|
-
if (values.size === total) {
|
|
455
|
-
return sink.onSuccess(sample());
|
|
456
|
-
} else {
|
|
457
|
-
return _effect.Effect.unit;
|
|
458
|
-
}
|
|
459
|
-
});
|
|
460
|
-
return _effect.Effect.all(fxs.map((fx, index) => (0, _run.run)(fx, Sink.WithContext(sink.onFailure, a => emitIfReady(a, index)))), {
|
|
461
|
-
concurrency: "unbounded"
|
|
965
|
+
function mergeSwitch(fx) {
|
|
966
|
+
return mergeWithStrategy(fx, _strategies.Switch);
|
|
967
|
+
}
|
|
968
|
+
class MergeWithStrategy extends _protos.FxBase {
|
|
969
|
+
i0;
|
|
970
|
+
i1;
|
|
971
|
+
constructor(i0, i1) {
|
|
972
|
+
super();
|
|
973
|
+
this.i0 = i0;
|
|
974
|
+
this.i1 = i1;
|
|
975
|
+
}
|
|
976
|
+
run(sink) {
|
|
977
|
+
switch (this.i1._tag) {
|
|
978
|
+
case "Unordered":
|
|
979
|
+
return runUnordered(this.i0, sink, this.i1.concurrency === Infinity ? "unbounded" : this.i1.concurrency);
|
|
980
|
+
case "Ordered":
|
|
981
|
+
return runOrdered(this.i0, sink, this.i1.concurrency === Infinity ? "unbounded" : this.i1.concurrency);
|
|
982
|
+
case "Switch":
|
|
983
|
+
return runSwitch(this.i0, sink);
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
static make(fx, strategy) {
|
|
987
|
+
if (fx.length === 0) return empty;else if (fx.length === 1) return fx[0];else return new MergeWithStrategy(fx.filter(Predicate.not(isEmpty)), strategy);
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
function runUnordered(fx, sink, concurrency) {
|
|
991
|
+
return Effect.forEach(fx, fx => fx.run(sink), {
|
|
992
|
+
concurrency,
|
|
993
|
+
discard: true
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
function runOrdered(fx, sink, concurrency) {
|
|
997
|
+
return Effect.suspend(() => {
|
|
998
|
+
const buffers = (0, _helpers.withBuffers)(fx.length, sink);
|
|
999
|
+
return Effect.all(fx.map((fx, i) => Effect.flatMap(fx.run(Sink.make(cause => Cause.isInterruptedOnly(cause) ? Effect.unit : sink.onFailure(cause), a => buffers.onSuccess(i, a))), () => buffers.onEnd(i))), {
|
|
1000
|
+
concurrency
|
|
462
1001
|
});
|
|
463
|
-
})
|
|
1002
|
+
});
|
|
464
1003
|
}
|
|
465
|
-
function
|
|
466
|
-
return
|
|
1004
|
+
function runSwitch(fx, sink) {
|
|
1005
|
+
return Effect.forEach(fx, fx => fx.run(sink), {
|
|
1006
|
+
concurrency: 1,
|
|
1007
|
+
discard: true
|
|
1008
|
+
});
|
|
467
1009
|
}
|
|
468
|
-
function
|
|
469
|
-
return
|
|
1010
|
+
function takeWhile(fx, f) {
|
|
1011
|
+
return TakeWhile.make(fx, f);
|
|
470
1012
|
}
|
|
471
|
-
|
|
472
|
-
return
|
|
473
|
-
});
|
|
474
|
-
function mergeBuffer(fxs) {
|
|
475
|
-
return Merge.make(fxs, strategies.Ordered(Infinity));
|
|
1013
|
+
function takeUntil(fx, f) {
|
|
1014
|
+
return TakeWhile.make(fx, Predicate.not(f));
|
|
476
1015
|
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
function pickWinner(i) {
|
|
492
|
-
if (winningIndex === -1) {
|
|
493
|
-
winningIndex = i;
|
|
494
|
-
resume(_effect.Effect.succeed([i, fibers]));
|
|
495
|
-
}
|
|
496
|
-
return winningIndex === i;
|
|
1016
|
+
class TakeWhile extends _protos.FxBase {
|
|
1017
|
+
i0;
|
|
1018
|
+
i1;
|
|
1019
|
+
constructor(i0, i1) {
|
|
1020
|
+
super();
|
|
1021
|
+
this.i0 = i0;
|
|
1022
|
+
this.i1 = i1;
|
|
1023
|
+
}
|
|
1024
|
+
run(sink) {
|
|
1025
|
+
return Sink.takeWhile(sink, this.i1, s => this.i0.run(s));
|
|
1026
|
+
}
|
|
1027
|
+
static make(fx, predicate) {
|
|
1028
|
+
if (isEmpty(fx) || isNever(fx)) return fx;else {
|
|
1029
|
+
return new TakeWhile(fx, predicate);
|
|
497
1030
|
}
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
function dropWhile(fx, f) {
|
|
1034
|
+
return DropUntil.make(fx, f);
|
|
1035
|
+
}
|
|
1036
|
+
function dropUntil(fx, f) {
|
|
1037
|
+
return DropUntil.make(fx, Predicate.not(f));
|
|
1038
|
+
}
|
|
1039
|
+
class DropUntil extends _protos.FxBase {
|
|
1040
|
+
i0;
|
|
1041
|
+
i1;
|
|
1042
|
+
constructor(i0, i1) {
|
|
1043
|
+
super();
|
|
1044
|
+
this.i0 = i0;
|
|
1045
|
+
this.i1 = i1;
|
|
1046
|
+
}
|
|
1047
|
+
run(sink) {
|
|
1048
|
+
return this.i0.run(Sink.dropWhile(sink, this.i1));
|
|
1049
|
+
}
|
|
1050
|
+
static make(fx, predicate) {
|
|
1051
|
+
if (isEmpty(fx) || isNever(fx)) return fx;else {
|
|
1052
|
+
return new DropUntil(fx, predicate);
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
function dropAfter(fx, f) {
|
|
1057
|
+
return DropAfter.make(fx, f);
|
|
1058
|
+
}
|
|
1059
|
+
class DropAfter extends _protos.FxBase {
|
|
1060
|
+
i0;
|
|
1061
|
+
i1;
|
|
1062
|
+
constructor(i0, i1) {
|
|
1063
|
+
super();
|
|
1064
|
+
this.i0 = i0;
|
|
1065
|
+
this.i1 = i1;
|
|
1066
|
+
}
|
|
1067
|
+
run(sink) {
|
|
1068
|
+
return this.i0.run(Sink.dropAfter(sink, this.i1));
|
|
1069
|
+
}
|
|
1070
|
+
static make(fx, predicate) {
|
|
1071
|
+
if (isEmpty(fx) || isNever(fx)) return fx;else {
|
|
1072
|
+
return new DropAfter(fx, predicate);
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
function takeWhileEffect(fx, f) {
|
|
1077
|
+
return TakeWhileEffect.make(fx, f);
|
|
1078
|
+
}
|
|
1079
|
+
function takeUntilEffect(fx, f) {
|
|
1080
|
+
return TakeWhileEffect.make(fx, a => Effect.map(f(a), Boolean.not));
|
|
1081
|
+
}
|
|
1082
|
+
class TakeWhileEffect extends _protos.FxBase {
|
|
1083
|
+
i0;
|
|
1084
|
+
i1;
|
|
1085
|
+
constructor(i0, i1) {
|
|
1086
|
+
super();
|
|
1087
|
+
this.i0 = i0;
|
|
1088
|
+
this.i1 = i1;
|
|
1089
|
+
}
|
|
1090
|
+
run(sink) {
|
|
1091
|
+
return Sink.takeWhileEffect(sink, this.i1, s => this.i0.run(s));
|
|
1092
|
+
}
|
|
1093
|
+
static make(fx, f) {
|
|
1094
|
+
if (isEmpty(fx) || isNever(fx)) return fx;else {
|
|
1095
|
+
return new TakeWhileEffect(fx, f);
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
function dropWhileEffect(fx, f) {
|
|
1100
|
+
return DropWhileEffect.make(fx, f);
|
|
1101
|
+
}
|
|
1102
|
+
function dropUntilEffect(fx, f) {
|
|
1103
|
+
return DropWhileEffect.make(fx, a => Effect.map(f(a), Boolean.not));
|
|
1104
|
+
}
|
|
1105
|
+
class DropWhileEffect extends _protos.FxBase {
|
|
1106
|
+
i0;
|
|
1107
|
+
i1;
|
|
1108
|
+
constructor(i0, i1) {
|
|
1109
|
+
super();
|
|
1110
|
+
this.i0 = i0;
|
|
1111
|
+
this.i1 = i1;
|
|
1112
|
+
}
|
|
1113
|
+
run(sink) {
|
|
1114
|
+
return this.i0.run(Sink.dropWhileEffect(sink, this.i1));
|
|
1115
|
+
}
|
|
1116
|
+
static make(fx, f) {
|
|
1117
|
+
if (isEmpty(fx) || isNever(fx)) return fx;else {
|
|
1118
|
+
return new DropWhileEffect(fx, f);
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
function dropAfterEffect(fx, f) {
|
|
1123
|
+
return DropAfterEffect.make(fx, f);
|
|
1124
|
+
}
|
|
1125
|
+
class DropAfterEffect extends _protos.FxBase {
|
|
1126
|
+
i0;
|
|
1127
|
+
i1;
|
|
1128
|
+
constructor(i0, i1) {
|
|
1129
|
+
super();
|
|
1130
|
+
this.i0 = i0;
|
|
1131
|
+
this.i1 = i1;
|
|
1132
|
+
}
|
|
1133
|
+
run(sink) {
|
|
1134
|
+
return this.i0.run(Sink.dropAfterEffect(sink, this.i1));
|
|
1135
|
+
}
|
|
1136
|
+
static make(fx, f) {
|
|
1137
|
+
if (isEmpty(fx) || isNever(fx)) return fx;else {
|
|
1138
|
+
return new DropAfterEffect(fx, f);
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
function during(fx, window) {
|
|
1143
|
+
return During.make(fx, window);
|
|
1144
|
+
}
|
|
1145
|
+
function since(fx, window) {
|
|
1146
|
+
return During.make(fx, map(window, () => never));
|
|
1147
|
+
}
|
|
1148
|
+
function until(fx, window) {
|
|
1149
|
+
return During.make(fx, succeed(window));
|
|
1150
|
+
}
|
|
1151
|
+
class During extends _protos.FxBase {
|
|
1152
|
+
i0;
|
|
1153
|
+
i1;
|
|
1154
|
+
constructor(i0, i1) {
|
|
1155
|
+
super();
|
|
1156
|
+
this.i0 = i0;
|
|
1157
|
+
this.i1 = i1;
|
|
1158
|
+
}
|
|
1159
|
+
run(sink) {
|
|
1160
|
+
return (0, _helpers.withScopedFork)(fork => Sink.withEarlyExit(sink, s => {
|
|
1161
|
+
let taking = false;
|
|
1162
|
+
const onFailure = cause => s.onFailure(cause);
|
|
1163
|
+
return Effect.flatMap(fork(take(this.i1, 1).run(Sink.make(onFailure, nested => {
|
|
1164
|
+
taking = true;
|
|
1165
|
+
return take(nested, 1).run(Sink.make(onFailure, () => s.earlyExit));
|
|
1166
|
+
}))), () => Effect.zipRight(
|
|
1167
|
+
// Allow fibers to start
|
|
1168
|
+
(0, _helpers.adjustTime)(1), this.i0.run(Sink.make(onFailure, a => taking ? s.onSuccess(a) : Effect.unit))));
|
|
1169
|
+
}), ExecutionStrategy.sequential);
|
|
1170
|
+
}
|
|
1171
|
+
static make(fx, window) {
|
|
1172
|
+
if (isEmpty(fx) || isNever(fx)) return fx;else {
|
|
1173
|
+
return new During(fx, window);
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
function middleware(fx, effect, sink) {
|
|
1178
|
+
return new Middleware(fx, effect, sink);
|
|
1179
|
+
}
|
|
1180
|
+
function onExit(fx, f) {
|
|
1181
|
+
return middleware(fx, Effect.onExit(f));
|
|
1182
|
+
}
|
|
1183
|
+
function onInterrupt(fx, f) {
|
|
1184
|
+
return middleware(fx, Effect.onInterrupt(f));
|
|
1185
|
+
}
|
|
1186
|
+
function onError(fx, f) {
|
|
1187
|
+
return middleware(fx, Effect.onError(f));
|
|
1188
|
+
}
|
|
1189
|
+
const scoped = fx => middleware(fx, Effect.scoped);
|
|
1190
|
+
exports.scoped = scoped;
|
|
1191
|
+
function annotateLogs(fx, key, value) {
|
|
1192
|
+
return middleware(fx, effect => Effect.annotateLogs(effect, key, value));
|
|
1193
|
+
}
|
|
1194
|
+
function annotateSpans(fx, key, value) {
|
|
1195
|
+
return middleware(fx, effect => Effect.annotateSpans(effect, key, value));
|
|
1196
|
+
}
|
|
1197
|
+
const interruptible = fx => middleware(fx, Effect.interruptible);
|
|
1198
|
+
exports.interruptible = interruptible;
|
|
1199
|
+
const uninterruptible = fx => middleware(fx, Effect.uninterruptible);
|
|
1200
|
+
exports.uninterruptible = uninterruptible;
|
|
1201
|
+
function locally(use, self, value) {
|
|
1202
|
+
return middleware(use, effect => Effect.locally(effect, self, value));
|
|
1203
|
+
}
|
|
1204
|
+
function locallyWith(use, self, f) {
|
|
1205
|
+
return middleware(use, effect => Effect.locallyWith(effect, self, f));
|
|
1206
|
+
}
|
|
1207
|
+
function withTracerTiming(fx, enabled) {
|
|
1208
|
+
return middleware(fx, effect => Effect.withTracerTiming(effect, enabled));
|
|
1209
|
+
}
|
|
1210
|
+
function withConcurrency(fx, concurrency) {
|
|
1211
|
+
return middleware(fx, effect => Effect.withConcurrency(effect, concurrency));
|
|
1212
|
+
}
|
|
1213
|
+
function withConfigProvider(fx, configProvider) {
|
|
1214
|
+
return middleware(fx, effect => Effect.withConfigProvider(effect, configProvider));
|
|
1215
|
+
}
|
|
1216
|
+
function withLogSpan(fx, span) {
|
|
1217
|
+
return middleware(fx, effect => Effect.withLogSpan(effect, span));
|
|
1218
|
+
}
|
|
1219
|
+
function withMaxOpsBeforeYield(fx, maxOps) {
|
|
1220
|
+
return middleware(fx, effect => Effect.withMaxOpsBeforeYield(effect, maxOps));
|
|
1221
|
+
}
|
|
1222
|
+
function withParentSpan(fx, parentSpan) {
|
|
1223
|
+
return middleware(fx, effect => Effect.withParentSpan(effect, parentSpan));
|
|
1224
|
+
}
|
|
1225
|
+
function withRequestBatching(fx, requestBatching) {
|
|
1226
|
+
return middleware(fx, effect => Effect.withRequestBatching(effect, requestBatching));
|
|
1227
|
+
}
|
|
1228
|
+
function withRequestCache(fx, cache) {
|
|
1229
|
+
return middleware(fx, effect => Effect.withRequestCache(effect, cache));
|
|
1230
|
+
}
|
|
1231
|
+
function withRequestCaching(fx, requestCaching) {
|
|
1232
|
+
return middleware(fx, effect => Effect.withRequestCaching(effect, requestCaching));
|
|
1233
|
+
}
|
|
1234
|
+
function withScheduler(fx, scheduler) {
|
|
1235
|
+
return middleware(fx, effect => Effect.withScheduler(effect, scheduler));
|
|
1236
|
+
}
|
|
1237
|
+
function withTracer(fx, tracer) {
|
|
1238
|
+
return middleware(fx, effect => Effect.withTracer(effect, tracer));
|
|
1239
|
+
}
|
|
1240
|
+
class Middleware extends _protos.FxBase {
|
|
1241
|
+
i0;
|
|
1242
|
+
i1;
|
|
1243
|
+
i2;
|
|
1244
|
+
constructor(i0, i1, i2) {
|
|
1245
|
+
super();
|
|
1246
|
+
this.i0 = i0;
|
|
1247
|
+
this.i1 = i1;
|
|
1248
|
+
this.i2 = i2;
|
|
1249
|
+
}
|
|
1250
|
+
run(sink) {
|
|
1251
|
+
return Effect.contextWithEffect(ctx => {
|
|
1252
|
+
const s = Sink.provide(sink, ctx);
|
|
1253
|
+
return this.i1(this.i0.run(this.i2 ? this.i2(s) : s));
|
|
1254
|
+
});
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
function acquireUseRelease(acquire, use, release) {
|
|
1258
|
+
return new AcquireUseRelease(acquire, use, release);
|
|
1259
|
+
}
|
|
1260
|
+
class AcquireUseRelease extends _protos.FxBase {
|
|
1261
|
+
acquire;
|
|
1262
|
+
use;
|
|
1263
|
+
release;
|
|
1264
|
+
constructor(acquire, use, release) {
|
|
1265
|
+
super();
|
|
1266
|
+
this.acquire = acquire;
|
|
1267
|
+
this.use = use;
|
|
1268
|
+
this.release = release;
|
|
1269
|
+
}
|
|
1270
|
+
run(sink) {
|
|
1271
|
+
return Effect.catchAllCause(Effect.acquireUseRelease(this.acquire, a => this.use(a).run(sink), (a, exit) => Effect.catchAllCause(this.release(a, exit), cause => sink.onFailure(cause))), cause => sink.onFailure(cause));
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
function withSpan(self, name, options = {}) {
|
|
1275
|
+
return acquireUseRelease(Effect.flatMap(Effect.optionFromOptional(Effect.currentSpan), parent => Effect.makeSpan(name, {
|
|
1276
|
+
...options,
|
|
1277
|
+
parent: options?.parent || Option.getOrUndefined(parent)
|
|
1278
|
+
})), span => middleware(self, effect => Effect.provideService(effect, Tracer.ParentSpan, span), s => Sink.setSpan(s, span)), (span, exit) => Effect.flatMap(Clock.currentTimeNanos, time => Effect.sync(() => span.end(time, exit))));
|
|
1279
|
+
}
|
|
1280
|
+
function provideContext(fx, context) {
|
|
1281
|
+
return ProvideFx.make(fx, Provide.ProvideContext(context));
|
|
1282
|
+
}
|
|
1283
|
+
function provideLayer(fx, layer) {
|
|
1284
|
+
return ProvideFx.make(fx, Provide.ProvideLayer(layer));
|
|
1285
|
+
}
|
|
1286
|
+
function provideRuntime(fx, runtime) {
|
|
1287
|
+
return ProvideFx.make(fx, Provide.ProvideRuntime(runtime));
|
|
1288
|
+
}
|
|
1289
|
+
function provideService(fx, service, instance) {
|
|
1290
|
+
return ProvideFx.make(fx, Provide.ProvideService(service, instance));
|
|
1291
|
+
}
|
|
1292
|
+
function provideServiceEffect(fx, service, instance) {
|
|
1293
|
+
return ProvideFx.make(fx, Provide.ProvideServiceEffect(service, instance));
|
|
1294
|
+
}
|
|
1295
|
+
function provide(fx, provide) {
|
|
1296
|
+
if (Layer.isLayer(provide)) return provideLayer(fx, provide);else if (Context.isContext(provide)) return provideContext(fx, provide);else return provideRuntime(fx, provide);
|
|
1297
|
+
}
|
|
1298
|
+
class ProvideFx extends _protos.FxBase {
|
|
1299
|
+
i0;
|
|
1300
|
+
i1;
|
|
1301
|
+
constructor(i0, i1) {
|
|
1302
|
+
super();
|
|
1303
|
+
this.i0 = i0;
|
|
1304
|
+
this.i1 = i1;
|
|
1305
|
+
}
|
|
1306
|
+
run(sink) {
|
|
1307
|
+
return Effect.acquireUseRelease(Scope.make(), scope => Effect.matchEffect(Provide.buildWithScope(this.i1, scope), {
|
|
1308
|
+
onFailure: error => sink.onFailure(Cause.fail(error)),
|
|
1309
|
+
onSuccess: ctx => Effect.provide(this.i0.run(sink), ctx)
|
|
1310
|
+
}), (scope, exit) => Scope.close(scope, exit));
|
|
1311
|
+
}
|
|
1312
|
+
static make(fx, provide) {
|
|
1313
|
+
if (isEmpty(fx) || isNever(fx)) return fx;else if (isProvideFx(fx)) {
|
|
1314
|
+
return new ProvideFx(fx.i0, Provide.merge(fx.i1, provide));
|
|
1315
|
+
} else {
|
|
1316
|
+
return new ProvideFx(fx, provide);
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
function isProvideFx(u) {
|
|
1321
|
+
return u.constructor === ProvideFx;
|
|
1322
|
+
}
|
|
1323
|
+
function mapCause(fx, f) {
|
|
1324
|
+
return new TransformerCause(fx, SyncOp.Map(f));
|
|
1325
|
+
}
|
|
1326
|
+
function mapError(fx, f) {
|
|
1327
|
+
return mapCause(fx, Cause.map(f));
|
|
1328
|
+
}
|
|
1329
|
+
function filterCause(fx, f) {
|
|
1330
|
+
return new TransformerCause(fx, SyncOp.Filter(f));
|
|
1331
|
+
}
|
|
1332
|
+
function filterError(fx, f) {
|
|
1333
|
+
return filterCause(fx, cause => Option.match(Cause.failureOption(cause), {
|
|
1334
|
+
onNone: _Function.constTrue,
|
|
1335
|
+
onSome: f
|
|
551
1336
|
}));
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
return
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
return
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
onFailure: sink.onFailure,
|
|
561
|
-
onSuccess: b => {
|
|
562
|
-
if (b) {
|
|
563
|
-
isDropping = true;
|
|
564
|
-
return _effect.Effect.unit;
|
|
565
|
-
} else {
|
|
566
|
-
return sink.onSuccess(a);
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
})));
|
|
1337
|
+
}
|
|
1338
|
+
function filterMapCause(fx, f) {
|
|
1339
|
+
return new TransformerCause(fx, SyncOp.FilterMap(f));
|
|
1340
|
+
}
|
|
1341
|
+
function filterMapError(fx, f) {
|
|
1342
|
+
return filterMapCause(fx, cause => Either.match(Cause.failureOrCause(cause), {
|
|
1343
|
+
onLeft: e => Option.map(f(e), Cause.fail),
|
|
1344
|
+
onRight: Option.some
|
|
570
1345
|
}));
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
return
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
return
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
return _fxPrimitive.TransformerEffect.make(fx, (0, _effectOperator.MapEffect)(f));
|
|
580
|
-
});
|
|
581
|
-
const tap = exports.tap = /*#__PURE__*/(0, _Function.dual)(2, function tap(fx, f) {
|
|
582
|
-
return _fxPrimitive.TransformerEffect.make(fx, (0, _effectOperator.TapEffect)(f));
|
|
583
|
-
});
|
|
584
|
-
const filterEffect = exports.filterEffect = /*#__PURE__*/(0, _Function.dual)(2, function filterEffect(fx, predicate) {
|
|
585
|
-
return _fxPrimitive.TransformerEffect.make(fx, (0, _effectOperator.FilterEffect)(predicate));
|
|
586
|
-
});
|
|
587
|
-
const filterMapEffect = exports.filterMapEffect = /*#__PURE__*/(0, _Function.dual)(2, function filterEffect(fx, f) {
|
|
588
|
-
return _fxPrimitive.TransformerEffect.make(fx, (0, _effectOperator.FilterMapEffect)(f));
|
|
589
|
-
});
|
|
590
|
-
const middleware = exports.middleware = /*#__PURE__*/(0, _Function.dual)(args => args.length === 3 || typeof args[0] !== "function", function middleware(fx, f, g) {
|
|
591
|
-
return Middleware.make(fx, f, g ?? _Function.identity);
|
|
592
|
-
});
|
|
593
|
-
const loop = exports.loop = /*#__PURE__*/(0, _Function.dual)(3, function loop(fx, seed, f) {
|
|
594
|
-
return Loop.make(fx, seed, f);
|
|
595
|
-
});
|
|
596
|
-
const loopEffect = exports.loopEffect = /*#__PURE__*/(0, _Function.dual)(3, function loopEffect(fx, seed, f) {
|
|
597
|
-
return LoopEffect.make(fx, f, seed);
|
|
598
|
-
});
|
|
599
|
-
const startWith = exports.startWith = /*#__PURE__*/(0, _Function.dual)(2, function startWith(fx, value) {
|
|
600
|
-
return fromSink(sink => _effect.Effect.flatMap(sink.onSuccess(value), () => (0, _run.run)(fx, sink)));
|
|
601
|
-
});
|
|
602
|
-
const endWith = exports.endWith = /*#__PURE__*/(0, _Function.dual)(2, function endWith(fx, value) {
|
|
603
|
-
return fromSink(sink => _effect.Effect.flatMap((0, _run.run)(fx, sink), () => sink.onSuccess(value)));
|
|
604
|
-
});
|
|
605
|
-
const scan = exports.scan = /*#__PURE__*/(0, _Function.dual)(3, function loop(fx, seed, f) {
|
|
606
|
-
return continueWith(new _fxPrimitive.Succeed(seed), () => Loop.make(fx, seed, (b, a) => {
|
|
607
|
-
const b2 = f(b, a);
|
|
608
|
-
return [b2, b2];
|
|
1346
|
+
}
|
|
1347
|
+
function mapCauseEffect(fx, f) {
|
|
1348
|
+
return new TransformerCause(fx, EffectOp.MapEffect(f));
|
|
1349
|
+
}
|
|
1350
|
+
function mapErrorEffect(fx, f) {
|
|
1351
|
+
return mapCauseEffect(fx, cause => Either.match(Cause.failureOrCause(cause), {
|
|
1352
|
+
onLeft: e => Effect.map(f(e), Cause.fail),
|
|
1353
|
+
onRight: cause => Effect.succeed(cause)
|
|
609
1354
|
}));
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
return
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
return
|
|
616
|
-
fork,
|
|
617
|
-
sink
|
|
618
|
-
}) => (0, _run.run)(fx, Sink.WithContext(cause => fork((0, _run.run)(from(f(cause)), sink)), sink.onSuccess)), strategy);
|
|
619
|
-
});
|
|
620
|
-
const flatMapErrorWithStrategy = exports.flatMapErrorWithStrategy = /*#__PURE__*/(0, _Function.dual)(3, function flatMapCause(fx, f, strategy) {
|
|
621
|
-
return new _fxPrimitive.WithFlattenStrategy(({
|
|
622
|
-
fork,
|
|
623
|
-
sink
|
|
624
|
-
}) => (0, _run.run)(fx, Sink.WithContext(cause => fork((0, _run.run)(from(cause.pipe(_effect.Cause.failureOrCause, _effect.Either.match({
|
|
1355
|
+
}
|
|
1356
|
+
function filterCauseEffect(fx, f) {
|
|
1357
|
+
return new TransformerCause(fx, EffectOp.FilterEffect(f));
|
|
1358
|
+
}
|
|
1359
|
+
function filterErrorEffect(fx, f) {
|
|
1360
|
+
return filterCauseEffect(fx, cause => Either.match(Cause.failureOrCause(cause), {
|
|
625
1361
|
onLeft: f,
|
|
626
|
-
onRight:
|
|
627
|
-
}))), sink)), sink.onSuccess)), strategy);
|
|
628
|
-
});
|
|
629
|
-
const flatMapCause = exports.flatMapCause = /*#__PURE__*/(0, _Function.dual)(2, function flatMapCause(fx, f) {
|
|
630
|
-
return flatMapCauseWithStrategy(fx, f, strategies.Unbounded);
|
|
631
|
-
});
|
|
632
|
-
const flatMapError = exports.flatMapError = /*#__PURE__*/(0, _Function.dual)(2, function flatMapError(fx, f) {
|
|
633
|
-
return flatMapErrorWithStrategy(fx, f, strategies.Unbounded);
|
|
634
|
-
});
|
|
635
|
-
const flatMapCauseConcurrently = exports.flatMapCauseConcurrently = /*#__PURE__*/(0, _Function.dual)(3, function flatMapCauseConcurrently(fx, f, concurrency) {
|
|
636
|
-
return flatMapCauseWithStrategy(fx, f, strategies.Bounded(concurrency));
|
|
637
|
-
});
|
|
638
|
-
const flatMapErrorConcurrently = exports.flatMapErrorConcurrently = /*#__PURE__*/(0, _Function.dual)(3, function flatMapCauseConcurrently(fx, f, concurrency) {
|
|
639
|
-
return flatMapErrorWithStrategy(fx, f, strategies.Bounded(concurrency));
|
|
640
|
-
});
|
|
641
|
-
const switchMapCause = exports.switchMapCause = /*#__PURE__*/(0, _Function.dual)(2, function switchMapCause(fx, f) {
|
|
642
|
-
return flatMapCauseWithStrategy(fx, f, strategies.Switch);
|
|
643
|
-
});
|
|
644
|
-
const switchMapError = exports.switchMapError = /*#__PURE__*/(0, _Function.dual)(2, function switchMapError(fx, f) {
|
|
645
|
-
return flatMapErrorWithStrategy(fx, f, strategies.Switch);
|
|
646
|
-
});
|
|
647
|
-
const exhaustMapCause = exports.exhaustMapCause = /*#__PURE__*/(0, _Function.dual)(2, function exhaustMapCause(fx, f) {
|
|
648
|
-
return flatMapCauseWithStrategy(fx, f, strategies.Exhaust);
|
|
649
|
-
});
|
|
650
|
-
const exhaustMapError = exports.exhaustMapError = /*#__PURE__*/(0, _Function.dual)(2, function switchMapError(fx, f) {
|
|
651
|
-
return flatMapErrorWithStrategy(fx, f, strategies.Exhaust);
|
|
652
|
-
});
|
|
653
|
-
const exhaustMapLatestCause = exports.exhaustMapLatestCause = /*#__PURE__*/(0, _Function.dual)(2, function exhaustMapLatestCause(fx, f) {
|
|
654
|
-
return flatMapCauseWithStrategy(fx, f, strategies.ExhaustLatest);
|
|
655
|
-
});
|
|
656
|
-
const exhaustMapLatestError = exports.exhaustMapLatestError = /*#__PURE__*/(0, _Function.dual)(2, function switchMapError(fx, f) {
|
|
657
|
-
return flatMapErrorWithStrategy(fx, f, strategies.ExhaustLatest);
|
|
658
|
-
});
|
|
659
|
-
const matchCauseWithStrategy = exports.matchCauseWithStrategy = /*#__PURE__*/(0, _Function.dual)(2, function flatMapCause(fx, options) {
|
|
660
|
-
return new _fxPrimitive.WithFlattenStrategy(({
|
|
661
|
-
fork,
|
|
662
|
-
sink
|
|
663
|
-
}) => (0, _run.run)(fx, Sink.WithContext(cause => fork((0, _run.run)(from(options.onFailure(cause)), sink)), a => fork((0, _run.run)(from(options.onSuccess(a)), sink)))), options.strategy);
|
|
664
|
-
});
|
|
665
|
-
const matchErrorWithStrategy = exports.matchErrorWithStrategy = /*#__PURE__*/(0, _Function.dual)(2, function flatMapCause(fx, options) {
|
|
666
|
-
return new _fxPrimitive.WithFlattenStrategy(({
|
|
667
|
-
fork,
|
|
668
|
-
sink
|
|
669
|
-
}) => (0, _run.run)(fx, Sink.WithContext(cause => fork((0, _run.run)(from(cause.pipe(_effect.Cause.failureOrCause, _effect.Either.match({
|
|
670
|
-
onLeft: options.onFailure,
|
|
671
|
-
onRight: failCause
|
|
672
|
-
}))), sink)), a => fork((0, _run.run)(from(options.onSuccess(a)), sink)))), options.strategy);
|
|
673
|
-
});
|
|
674
|
-
const matchCause = exports.matchCause = /*#__PURE__*/(0, _Function.dual)(2, function matchCause(fx, options) {
|
|
675
|
-
return matchCauseWithStrategy(fx, {
|
|
676
|
-
...options,
|
|
677
|
-
strategy: strategies.Unbounded
|
|
678
|
-
});
|
|
679
|
-
});
|
|
680
|
-
const match = exports.match = /*#__PURE__*/(0, _Function.dual)(2, function matchCause(fx, options) {
|
|
681
|
-
return matchErrorWithStrategy(fx, {
|
|
682
|
-
...options,
|
|
683
|
-
strategy: strategies.Unbounded
|
|
684
|
-
});
|
|
685
|
-
});
|
|
686
|
-
const matchCauseConcurrently = exports.matchCauseConcurrently = /*#__PURE__*/(0, _Function.dual)(2, function matchCause(fx, options) {
|
|
687
|
-
return matchCauseWithStrategy(fx, {
|
|
688
|
-
onFailure: options.onFailure,
|
|
689
|
-
onSuccess: options.onSuccess,
|
|
690
|
-
strategy: strategies.Bounded(options.concurrency)
|
|
691
|
-
});
|
|
692
|
-
});
|
|
693
|
-
const matchErrorConcurrently = exports.matchErrorConcurrently = /*#__PURE__*/(0, _Function.dual)(2, function matchErrorConcurrently(fx, options) {
|
|
694
|
-
return matchErrorWithStrategy(fx, {
|
|
695
|
-
...options,
|
|
696
|
-
strategy: strategies.Bounded(options.concurrency)
|
|
697
|
-
});
|
|
698
|
-
});
|
|
699
|
-
const switchMatchCause = exports.switchMatchCause = /*#__PURE__*/(0, _Function.dual)(2, function matchCause(fx, options) {
|
|
700
|
-
return matchCauseWithStrategy(fx, {
|
|
701
|
-
...options,
|
|
702
|
-
strategy: strategies.Switch
|
|
703
|
-
});
|
|
704
|
-
});
|
|
705
|
-
const switchMatch = exports.switchMatch = /*#__PURE__*/(0, _Function.dual)(2, function matchCause(fx, options) {
|
|
706
|
-
return matchErrorWithStrategy(fx, {
|
|
707
|
-
...options,
|
|
708
|
-
strategy: strategies.Switch
|
|
709
|
-
});
|
|
710
|
-
});
|
|
711
|
-
const exhaustMatchCause = exports.exhaustMatchCause = /*#__PURE__*/(0, _Function.dual)(2, function matchCause(fx, options) {
|
|
712
|
-
return matchCauseWithStrategy(fx, {
|
|
713
|
-
...options,
|
|
714
|
-
strategy: strategies.Exhaust
|
|
715
|
-
});
|
|
716
|
-
});
|
|
717
|
-
const exhaustMatch = exports.exhaustMatch = /*#__PURE__*/(0, _Function.dual)(2, function matchCause(fx, options) {
|
|
718
|
-
return matchErrorWithStrategy(fx, {
|
|
719
|
-
...options,
|
|
720
|
-
strategy: strategies.Exhaust
|
|
721
|
-
});
|
|
722
|
-
});
|
|
723
|
-
const exhaustLatestMatchCause = exports.exhaustLatestMatchCause = /*#__PURE__*/(0, _Function.dual)(2, function matchCause(fx, options) {
|
|
724
|
-
return matchCauseWithStrategy(fx, {
|
|
725
|
-
...options,
|
|
726
|
-
strategy: strategies.ExhaustLatest
|
|
727
|
-
});
|
|
728
|
-
});
|
|
729
|
-
const exhaustLatestMatch = exports.exhaustLatestMatch = /*#__PURE__*/(0, _Function.dual)(2, function matchCause(fx, options) {
|
|
730
|
-
return matchErrorWithStrategy(fx, {
|
|
731
|
-
...options,
|
|
732
|
-
strategy: strategies.ExhaustLatest
|
|
733
|
-
});
|
|
734
|
-
});
|
|
735
|
-
const withEarlyExit = f => new _fxPrimitive.WithEarlyExit(f);
|
|
736
|
-
exports.withEarlyExit = withEarlyExit;
|
|
737
|
-
const withScopedFork = f => new _fxPrimitive.WithScopedFork(f);
|
|
738
|
-
exports.withScopedFork = withScopedFork;
|
|
739
|
-
const withFlattenStrategy = (f, strategy) => new _fxPrimitive.WithFlattenStrategy(f, strategy);
|
|
740
|
-
exports.withFlattenStrategy = withFlattenStrategy;
|
|
741
|
-
const during = exports.during = /*#__PURE__*/(0, _Function.dual)(2, function during(fx, window) {
|
|
742
|
-
return withEarlyExit(({
|
|
743
|
-
fork,
|
|
744
|
-
sink
|
|
745
|
-
}) => _effect.Effect.suspend(() => {
|
|
746
|
-
let taking = false;
|
|
747
|
-
return _effect.Effect.flatMap(fork((0, _run.run)(take(window, 1), Sink.WithContext(sink.onFailure, nested => {
|
|
748
|
-
taking = true;
|
|
749
|
-
return fork((0, _run.run)(take(nested, 1), Sink.WithContext(sink.onFailure, () => sink.earlyExit)));
|
|
750
|
-
}))), () => (0, _helpers.adjustTime)(1).pipe(_effect.Effect.zipRight((0, _run.run)(fx, Sink.Sink(sink.onFailure, a => taking ? sink.onSuccess(a) : _effect.Effect.unit)))));
|
|
1362
|
+
onRight: () => Effect.succeed(true)
|
|
751
1363
|
}));
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
return
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
return
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
return fromSink(sink => _effect.Effect.catchAllCause(_effect.Effect.repeat(_effect.Effect.matchCauseEffect(fx, sink), scheduled), sink.onFailure));
|
|
761
|
-
});
|
|
762
|
-
const periodic = exports.periodic = /*#__PURE__*/(0, _Function.dual)(2, function periodic(fx, duration) {
|
|
763
|
-
return fromScheduled(fx, Schedule.spaced(duration));
|
|
764
|
-
});
|
|
765
|
-
const provide = exports.provide = /*#__PURE__*/(0, _Function.dual)(2, function provideContext(fx, context) {
|
|
766
|
-
if (_effect.Layer.isLayer(context)) {
|
|
767
|
-
return FxProvide.make(fx, Provide.ProvideLayer(context));
|
|
768
|
-
} else if ((0, _context.isContext)(context)) {
|
|
769
|
-
return FxProvide.make(fx, Provide.ProvideContext(context));
|
|
770
|
-
} else {
|
|
771
|
-
return FxProvide.make(fx, Provide.ProvideRuntime(context));
|
|
772
|
-
}
|
|
773
|
-
});
|
|
774
|
-
const provideService = exports.provideService = /*#__PURE__*/(0, _Function.dual)(3, function provideService(fx, tag, service) {
|
|
775
|
-
return FxProvide.make(fx, Provide.ProvideService(tag, service));
|
|
776
|
-
});
|
|
777
|
-
const provideServiceEffect = exports.provideServiceEffect = /*#__PURE__*/(0, _Function.dual)(3, function provideService(fx, tag, service) {
|
|
778
|
-
return FxProvide.make(fx, Provide.ProvideServiceEffect(tag, service));
|
|
779
|
-
});
|
|
780
|
-
const skipRepeatsWith = exports.skipRepeatsWith = /*#__PURE__*/(0, _Function.dual)(2, function skipRepeatsWith(fx, eq) {
|
|
781
|
-
return FilterMapLoop.make(fx, _effect.Option.none(), (previous, a) => _effect.Option.match(previous, {
|
|
782
|
-
onNone: () => _effect.Option.some([a, _effect.Option.some(a)]),
|
|
783
|
-
onSome: prev => eq(a, prev) ? _effect.Option.none() : _effect.Option.some([a, _effect.Option.some(a)])
|
|
1364
|
+
}
|
|
1365
|
+
function filterMapCauseEffect(fx, f) {
|
|
1366
|
+
return new TransformerCause(fx, EffectOp.FilterMapEffect(f));
|
|
1367
|
+
}
|
|
1368
|
+
function filterMapErrorEffect(fx, f) {
|
|
1369
|
+
return filterMapCauseEffect(fx, cause => Either.match(Cause.failureOrCause(cause), {
|
|
1370
|
+
onLeft: e => Effect.map(f(e), Option.map(Cause.fail)),
|
|
1371
|
+
onRight: cause => Effect.succeed(Option.some(cause))
|
|
784
1372
|
}));
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
seed
|
|
791
|
-
|
|
792
|
-
|
|
1373
|
+
}
|
|
1374
|
+
function loopCause(fx, seed, f) {
|
|
1375
|
+
return new TransformerCause(fx, SyncLoopOp.LoopOperator(seed, f));
|
|
1376
|
+
}
|
|
1377
|
+
function loopError(fx, seed, f) {
|
|
1378
|
+
return loopCause(fx, seed, (b, cause) => Either.match(Cause.failureOrCause(cause), {
|
|
1379
|
+
onLeft: e => {
|
|
1380
|
+
const [c, b2] = f(b, e);
|
|
1381
|
+
return [Cause.fail(c), b2];
|
|
1382
|
+
},
|
|
1383
|
+
onRight: cause => [cause, b]
|
|
1384
|
+
}));
|
|
1385
|
+
}
|
|
1386
|
+
function loopCauseEffect(fx, seed, f) {
|
|
1387
|
+
return new TransformerCause(fx, EffectLoopOp.LoopEffectOperator(seed, f));
|
|
1388
|
+
}
|
|
1389
|
+
function loopErrorEffect(fx, seed, f) {
|
|
1390
|
+
return loopCauseEffect(fx, seed, (b, cause) => Either.match(Cause.failureOrCause(cause), {
|
|
1391
|
+
onLeft: e => Effect.map(f(b, e), ([c, b2]) => [Cause.fail(c), b2]),
|
|
1392
|
+
onRight: cause => Effect.succeed([cause, b])
|
|
1393
|
+
}));
|
|
1394
|
+
}
|
|
1395
|
+
function filterMapLoopCause(fx, seed, f) {
|
|
1396
|
+
return new TransformerCause(fx, SyncLoopOp.FilterMapLoopOperator(seed, f));
|
|
1397
|
+
}
|
|
1398
|
+
function filterMapLoopError(fx, seed, f) {
|
|
1399
|
+
return filterMapLoopCause(fx, seed, (b, cause) => Either.match(Cause.failureOrCause(cause), {
|
|
1400
|
+
onLeft: e => {
|
|
1401
|
+
const [c, b2] = f(b, e);
|
|
1402
|
+
return [Option.map(Cause.fail)(c), b2];
|
|
1403
|
+
},
|
|
1404
|
+
onRight: cause => [Option.some(cause), b]
|
|
1405
|
+
}));
|
|
1406
|
+
}
|
|
1407
|
+
function filterMapLoopCauseEffect(fx, seed, f) {
|
|
1408
|
+
return new TransformerCause(fx, EffectLoopOp.FilterMapLoopEffectOperator(seed, f));
|
|
1409
|
+
}
|
|
1410
|
+
function filterMapLoopErrorEffect(fx, seed, f) {
|
|
1411
|
+
return filterMapLoopCauseEffect(fx, seed, (b, cause) => Either.match(Cause.failureOrCause(cause), {
|
|
1412
|
+
onLeft: e => Effect.map(f(b, e), ([c, b2]) => [Option.map(c, Cause.fail), b2]),
|
|
1413
|
+
onRight: cause => Effect.succeed([Option.some(cause), b])
|
|
1414
|
+
}));
|
|
1415
|
+
}
|
|
1416
|
+
class TransformerCause extends _protos.FxBase {
|
|
1417
|
+
i0;
|
|
1418
|
+
i1;
|
|
1419
|
+
constructor(i0, i1) {
|
|
793
1420
|
super();
|
|
794
|
-
this.
|
|
795
|
-
this.
|
|
796
|
-
this.f = f;
|
|
1421
|
+
this.i0 = i0;
|
|
1422
|
+
this.i1 = i1;
|
|
797
1423
|
}
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
return FilterMapReduce.make(fx.i0, seed, (0, _syncOperator.compileSyncReducer)(fx.i1, f));
|
|
801
|
-
}
|
|
802
|
-
return new Reduce(fx, seed, f);
|
|
1424
|
+
run(sink) {
|
|
1425
|
+
return this.i0.run(Op.compileOperatorSinkCause(this.i1, sink));
|
|
803
1426
|
}
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
1427
|
+
}
|
|
1428
|
+
function flatMapCauseWithStrategy(fx, f, flattenStrategy, executionStrategy = ExecutionStrategy.sequential) {
|
|
1429
|
+
return new FlatMapCauseWithStrategy(fx, f, flattenStrategy, executionStrategy);
|
|
1430
|
+
}
|
|
1431
|
+
function flatMapErrorWithStrategy(fx, f, flattenStrategy, executionStrategy = ExecutionStrategy.sequential) {
|
|
1432
|
+
return flatMapCauseWithStrategy(fx, cause => Either.match(Cause.failureOrCause(cause), {
|
|
1433
|
+
onLeft: f,
|
|
1434
|
+
onRight: cause => failCause(cause)
|
|
1435
|
+
}), flattenStrategy, executionStrategy);
|
|
1436
|
+
}
|
|
1437
|
+
function switchMapCause(fx, f, executionStrategy) {
|
|
1438
|
+
return flatMapCauseWithStrategy(fx, f, _strategies.Switch, executionStrategy);
|
|
1439
|
+
}
|
|
1440
|
+
function switchMapError(fx, f, executionStrategy) {
|
|
1441
|
+
return flatMapErrorWithStrategy(fx, f, _strategies.Switch, executionStrategy);
|
|
1442
|
+
}
|
|
1443
|
+
function flatMapCause(fx, f, executionStrategy) {
|
|
1444
|
+
return flatMapCauseWithStrategy(fx, f, _strategies.Unbounded, executionStrategy);
|
|
1445
|
+
}
|
|
1446
|
+
function flatMapError(fx, f, executionStrategy) {
|
|
1447
|
+
return flatMapErrorWithStrategy(fx, f, _strategies.Unbounded, executionStrategy);
|
|
1448
|
+
}
|
|
1449
|
+
function flatMapCauseConcurrently(fx, f, concurrency, executionStrategy) {
|
|
1450
|
+
return flatMapCauseWithStrategy(fx, f, (0, _strategies.Bounded)(concurrency), executionStrategy);
|
|
1451
|
+
}
|
|
1452
|
+
function flatMapErrorConcurrently(fx, f, concurrency, executionStrategy) {
|
|
1453
|
+
return flatMapErrorWithStrategy(fx, f, (0, _strategies.Bounded)(concurrency), executionStrategy);
|
|
1454
|
+
}
|
|
1455
|
+
function exhaustMapCause(fx, f, executionStrategy) {
|
|
1456
|
+
return flatMapCauseWithStrategy(fx, f, _strategies.Exhaust, executionStrategy);
|
|
1457
|
+
}
|
|
1458
|
+
function exhaustMapError(fx, f, executionStrategy) {
|
|
1459
|
+
return flatMapErrorWithStrategy(fx, f, _strategies.Exhaust, executionStrategy);
|
|
1460
|
+
}
|
|
1461
|
+
function exhaustMapLatestCause(fx, f, executionStrategy) {
|
|
1462
|
+
return flatMapCauseWithStrategy(fx, f, _strategies.ExhaustLatest, executionStrategy);
|
|
1463
|
+
}
|
|
1464
|
+
function exhaustMapLatestError(fx, f, executionStrategy) {
|
|
1465
|
+
return flatMapErrorWithStrategy(fx, f, _strategies.ExhaustLatest, executionStrategy);
|
|
1466
|
+
}
|
|
1467
|
+
class FlatMapCauseWithStrategy extends _protos.FxBase {
|
|
1468
|
+
i0;
|
|
1469
|
+
i1;
|
|
1470
|
+
i2;
|
|
1471
|
+
i3;
|
|
1472
|
+
withFork;
|
|
1473
|
+
constructor(i0, i1, i2, i3) {
|
|
1474
|
+
super();
|
|
1475
|
+
this.i0 = i0;
|
|
1476
|
+
this.i1 = i1;
|
|
1477
|
+
this.i2 = i2;
|
|
1478
|
+
this.i3 = i3;
|
|
1479
|
+
this.withFork = (0, _helpers.withFlattenStrategy)(this.i2);
|
|
1480
|
+
}
|
|
1481
|
+
run(sink) {
|
|
1482
|
+
return this.withFork(fork => this.i0.run(Sink.make(cause => fork(this.i1(cause).run(sink)), a => sink.onSuccess(a))), this.i3);
|
|
810
1483
|
}
|
|
811
1484
|
}
|
|
812
|
-
class
|
|
1485
|
+
class MatchWithStrategy extends _protos.FxBase {
|
|
813
1486
|
i0;
|
|
814
1487
|
i1;
|
|
815
1488
|
i2;
|
|
816
|
-
|
|
1489
|
+
i3;
|
|
1490
|
+
i4;
|
|
1491
|
+
withFork;
|
|
1492
|
+
constructor(i0, i1, i2, i3, i4) {
|
|
817
1493
|
super();
|
|
818
1494
|
this.i0 = i0;
|
|
819
1495
|
this.i1 = i1;
|
|
820
1496
|
this.i2 = i2;
|
|
1497
|
+
this.i3 = i3;
|
|
1498
|
+
this.i4 = i4;
|
|
1499
|
+
this.withFork = (0, _helpers.withFlattenStrategy)(this.i3);
|
|
821
1500
|
}
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
if (Array.isArray(fx.i0)) {
|
|
825
|
-
return new _protos.OnceEffect(_effect.Effect.sync(() => reduceFilterArray(fx.i0, seed, f)));
|
|
826
|
-
} else {
|
|
827
|
-
return _effect.Effect.sync(() => reduceFilterIterable(fx.i0, seed, f));
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
return new FilterMapReduce(fx, seed, f);
|
|
1501
|
+
run(sink) {
|
|
1502
|
+
return this.withFork(fork => this.i0.run(Sink.make(cause => fork(this.i1(cause).run(sink)), a => fork(this.i2(a).run(sink)))), this.i4);
|
|
831
1503
|
}
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
1504
|
+
}
|
|
1505
|
+
function matchCauseWithStrategy(fx, flattenStrategy, opts) {
|
|
1506
|
+
return new MatchWithStrategy(fx, opts.onFailure, opts.onSuccess, flattenStrategy, opts.executionStrategy || ExecutionStrategy.sequential);
|
|
1507
|
+
}
|
|
1508
|
+
function matchErrorWithStrategy(fx, flattenStrategy, {
|
|
1509
|
+
executionStrategy,
|
|
1510
|
+
onFailure,
|
|
1511
|
+
onSuccess
|
|
1512
|
+
}) {
|
|
1513
|
+
return new MatchWithStrategy(fx, cause => Either.match(Cause.failureOrCause(cause), {
|
|
1514
|
+
onLeft: onFailure,
|
|
1515
|
+
onRight: cause => failCause(cause)
|
|
1516
|
+
}), onSuccess, flattenStrategy, executionStrategy || ExecutionStrategy.sequential);
|
|
1517
|
+
}
|
|
1518
|
+
function matchCause(fx, opts) {
|
|
1519
|
+
return matchCauseWithStrategy(fx, _strategies.Unbounded, opts);
|
|
1520
|
+
}
|
|
1521
|
+
function matchError(fx, opts) {
|
|
1522
|
+
return matchErrorWithStrategy(fx, _strategies.Unbounded, opts);
|
|
1523
|
+
}
|
|
1524
|
+
function matchCauseConcurrently(fx, concurrency, opts) {
|
|
1525
|
+
return matchCauseWithStrategy(fx, (0, _strategies.Bounded)(concurrency), opts);
|
|
1526
|
+
}
|
|
1527
|
+
function matchErrorConcurrently(fx, concurrency, opts) {
|
|
1528
|
+
return matchErrorWithStrategy(fx, (0, _strategies.Bounded)(concurrency), opts);
|
|
1529
|
+
}
|
|
1530
|
+
function switchMatchCause(fx, opts) {
|
|
1531
|
+
return matchCauseWithStrategy(fx, _strategies.Switch, opts);
|
|
1532
|
+
}
|
|
1533
|
+
function switchMatchError(fx, opts) {
|
|
1534
|
+
return matchErrorWithStrategy(fx, _strategies.Switch, opts);
|
|
1535
|
+
}
|
|
1536
|
+
function exhaustMatchCause(fx, opts) {
|
|
1537
|
+
return matchCauseWithStrategy(fx, _strategies.Exhaust, opts);
|
|
1538
|
+
}
|
|
1539
|
+
function exhaustMatchError(fx, opts) {
|
|
1540
|
+
return matchErrorWithStrategy(fx, _strategies.Exhaust, opts);
|
|
1541
|
+
}
|
|
1542
|
+
function exhaustMatchLatestCause(fx, opts) {
|
|
1543
|
+
return matchCauseWithStrategy(fx, _strategies.ExhaustLatest, opts);
|
|
1544
|
+
}
|
|
1545
|
+
function exhaustMatchLatestError(fx, opts) {
|
|
1546
|
+
return matchErrorWithStrategy(fx, _strategies.ExhaustLatest, opts);
|
|
1547
|
+
}
|
|
1548
|
+
function tuple(fx) {
|
|
1549
|
+
return new Tuple(fx);
|
|
1550
|
+
}
|
|
1551
|
+
class Tuple extends _protos.FxBase {
|
|
1552
|
+
i0;
|
|
1553
|
+
constructor(i0) {
|
|
1554
|
+
super();
|
|
1555
|
+
this.i0 = i0;
|
|
1556
|
+
}
|
|
1557
|
+
run(sink) {
|
|
1558
|
+
return (0, _helpers.tupleSink)(sink, onSuccess => Effect.forEach(this.i0, (fx, i) => fx.run(Sink.make(sink.onFailure, a => onSuccess(i, a))), UNBOUNDED), this.i0.length);
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
function struct(fx) {
|
|
1562
|
+
const entries = Object.entries(fx);
|
|
1563
|
+
return map(tuple(entries.map(([key, fx]) => map(fx, a => [key, a]))), Object.fromEntries);
|
|
1564
|
+
}
|
|
1565
|
+
function all(fx) {
|
|
1566
|
+
if (Array.isArray(fx)) return tuple(fx);else return struct(fx);
|
|
1567
|
+
}
|
|
1568
|
+
function exit(fx) {
|
|
1569
|
+
return new ExitFx(fx);
|
|
1570
|
+
}
|
|
1571
|
+
class ExitFx extends _protos.FxBase {
|
|
1572
|
+
i0;
|
|
1573
|
+
constructor(i0) {
|
|
1574
|
+
super();
|
|
1575
|
+
this.i0 = i0;
|
|
1576
|
+
}
|
|
1577
|
+
run(sink) {
|
|
1578
|
+
return this.i0.run(Sink.make(cause => sink.onSuccess(Exit.failCause(cause)), a => sink.onSuccess(Exit.succeed(a))));
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
function toEnqueue(fx, queue) {
|
|
1582
|
+
return observe(fx, a => queue.offer(a));
|
|
1583
|
+
}
|
|
1584
|
+
function debounce(fx, delay) {
|
|
1585
|
+
return switchMapEffect(fx, a => Effect.as(Effect.sleep(delay), a));
|
|
1586
|
+
}
|
|
1587
|
+
function throttle(fx, delay) {
|
|
1588
|
+
return exhaustMapEffect(fx, a => Effect.as(Effect.sleep(delay), a));
|
|
1589
|
+
}
|
|
1590
|
+
function throttleLatest(fx, delay) {
|
|
1591
|
+
return exhaustMapLatestEffect(fx, a => Effect.as(Effect.sleep(delay), a));
|
|
1592
|
+
}
|
|
1593
|
+
function fromAsyncIterable(iterable) {
|
|
1594
|
+
return new FromAsyncIterable(iterable);
|
|
1595
|
+
}
|
|
1596
|
+
class FromAsyncIterable extends _protos.FxBase {
|
|
1597
|
+
i0;
|
|
1598
|
+
constructor(i0) {
|
|
1599
|
+
super();
|
|
1600
|
+
this.i0 = i0;
|
|
1601
|
+
}
|
|
1602
|
+
run(sink) {
|
|
1603
|
+
return Effect.asyncEffect(cb => {
|
|
1604
|
+
const iterator = this.i0[Symbol.asyncIterator]();
|
|
1605
|
+
const loop = result => result.done ? Effect.sync(() => cb(Effect.unit)) : Effect.zipRight(sink.onSuccess(result.value), Effect.flatMap(Effect.promise(() => iterator.next()), loop));
|
|
1606
|
+
return Effect.flatMap(Effect.promise(() => iterator.next()), loop);
|
|
840
1607
|
});
|
|
841
1608
|
}
|
|
842
1609
|
}
|
|
843
|
-
function
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
if (_effect.Option.isSome(option)) {
|
|
864
|
-
acc = option.value;
|
|
865
|
-
}
|
|
1610
|
+
function findFirst(fx, predicate) {
|
|
1611
|
+
return Effect.asyncEffect(cb => observe(fx, a => predicate(a) ? Effect.sync(() => cb(Effect.succeed(a))) : Effect.unit));
|
|
1612
|
+
}
|
|
1613
|
+
function first(fx) {
|
|
1614
|
+
return findFirst(fx, _Function.constTrue);
|
|
1615
|
+
}
|
|
1616
|
+
function either(fx) {
|
|
1617
|
+
return new EitherFx(fx);
|
|
1618
|
+
}
|
|
1619
|
+
class EitherFx extends _protos.FxBase {
|
|
1620
|
+
i0;
|
|
1621
|
+
constructor(i0) {
|
|
1622
|
+
super();
|
|
1623
|
+
this.i0 = i0;
|
|
1624
|
+
}
|
|
1625
|
+
run(sink) {
|
|
1626
|
+
return this.i0.run(Sink.make(cause => Either.match(Cause.failureOrCause(cause), {
|
|
1627
|
+
onLeft: e => sink.onSuccess(Either.left(e)),
|
|
1628
|
+
onRight: cause => sink.onFailure(cause)
|
|
1629
|
+
}), a => sink.onSuccess(Either.right(a))));
|
|
866
1630
|
}
|
|
867
|
-
return acc;
|
|
868
1631
|
}
|
|
869
|
-
|
|
870
|
-
return
|
|
871
|
-
});
|
|
872
|
-
function toChunk(fx) {
|
|
873
|
-
return reduce(fx, _effect.Chunk.empty(), _effect.Chunk.append);
|
|
1632
|
+
function mergeFirst(fx, that) {
|
|
1633
|
+
return merge(fx, filter(that, _Function.constFalse));
|
|
874
1634
|
}
|
|
875
|
-
|
|
1635
|
+
function mergeRace(fx, that) {
|
|
1636
|
+
return new MergeRace(fx, that);
|
|
1637
|
+
}
|
|
1638
|
+
class MergeRace extends _protos.FxBase {
|
|
1639
|
+
i0;
|
|
1640
|
+
i1;
|
|
1641
|
+
constructor(i0, i1) {
|
|
1642
|
+
super();
|
|
1643
|
+
this.i0 = i0;
|
|
1644
|
+
this.i1 = i1;
|
|
1645
|
+
}
|
|
1646
|
+
run(sink) {
|
|
1647
|
+
return Effect.gen(this, function* (_) {
|
|
1648
|
+
const fiber1 = yield* _(Effect.fork(this.i0.run(Sink.make(sink.onFailure, a => Effect.flatMap(sink.onSuccess(a), () => Fiber.interrupt(fiber2))))));
|
|
1649
|
+
const fiber2 = yield* _(Effect.fork(this.i1.run(sink)));
|
|
1650
|
+
return yield* _(Fiber.joinAll([fiber1, fiber2]));
|
|
1651
|
+
});
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
function raceAll(fx) {
|
|
1655
|
+
return new RaceAll(fx);
|
|
1656
|
+
}
|
|
1657
|
+
function race(fx, that) {
|
|
1658
|
+
return raceAll([fx, that]);
|
|
1659
|
+
}
|
|
1660
|
+
class RaceAll extends _protos.FxBase {
|
|
1661
|
+
i0;
|
|
1662
|
+
constructor(i0) {
|
|
1663
|
+
super();
|
|
1664
|
+
this.i0 = i0;
|
|
1665
|
+
}
|
|
1666
|
+
run(sink) {
|
|
1667
|
+
return Effect.gen(this, function* (_) {
|
|
1668
|
+
const winner = yield* _(Deferred.make());
|
|
1669
|
+
const fibers = [];
|
|
1670
|
+
for (const fx of this.i0) {
|
|
1671
|
+
const fiber = yield* _(Effect.fork(fx.run(Sink.make(sink.onFailure, a => Effect.flatMap(Deferred.succeed(winner, fiber), () => sink.onSuccess(a))))));
|
|
1672
|
+
fibers.push(fiber);
|
|
1673
|
+
}
|
|
1674
|
+
const winningFiber = yield* _(Deferred.await(winner));
|
|
1675
|
+
yield* _(Fiber.interruptAll(fibers.filter(x => x !== winningFiber)));
|
|
1676
|
+
return yield* _(Fiber.join(winningFiber));
|
|
1677
|
+
});
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
function snapshot(fx, sampled, f) {
|
|
876
1681
|
return new Snapshot(fx, sampled, f);
|
|
877
|
-
}
|
|
878
|
-
function
|
|
879
|
-
return
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
1682
|
+
}
|
|
1683
|
+
function sample(fx, sampled) {
|
|
1684
|
+
return snapshot(fx, sampled, (_, b) => b);
|
|
1685
|
+
}
|
|
1686
|
+
class Snapshot extends _protos.FxBase {
|
|
1687
|
+
i0;
|
|
1688
|
+
i1;
|
|
1689
|
+
i2;
|
|
1690
|
+
constructor(i0, i1, i2) {
|
|
1691
|
+
super();
|
|
1692
|
+
this.i0 = i0;
|
|
1693
|
+
this.i1 = i1;
|
|
1694
|
+
this.i2 = i2;
|
|
1695
|
+
}
|
|
1696
|
+
run(sink) {
|
|
1697
|
+
return Effect.flatMap(Ref.make(Option.none()), ref => Effect.all([this.i1.run(Sink.make(sink.onFailure, b => Ref.set(ref, Option.some(b)))), this.i0.run(Sink.make(sink.onFailure, a => Effect.flatMap(Ref.get(ref), Option.match({
|
|
1698
|
+
onNone: () => Effect.unit,
|
|
1699
|
+
onSome: b => sink.onSuccess(this.i2(a, b))
|
|
1700
|
+
}))))], UNBOUNDED));
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
function snapshotEffect(fx, sampled, f) {
|
|
1704
|
+
return new SnapshotEffect(fx, sampled, f);
|
|
1705
|
+
}
|
|
1706
|
+
class SnapshotEffect extends _protos.FxBase {
|
|
1707
|
+
i0;
|
|
1708
|
+
i1;
|
|
1709
|
+
i2;
|
|
1710
|
+
constructor(i0, i1, i2) {
|
|
1711
|
+
super();
|
|
1712
|
+
this.i0 = i0;
|
|
1713
|
+
this.i1 = i1;
|
|
1714
|
+
this.i2 = i2;
|
|
1715
|
+
}
|
|
1716
|
+
run(sink) {
|
|
1717
|
+
return Effect.flatMap(Ref.make(Option.none()), ref => Effect.flatMap(Effect.tap(Effect.fork(this.i1.run(Sink.make(sink.onFailure, b => Ref.set(ref, Option.some(b))))), () => this.i0.run(Sink.make(sink.onFailure, a => Effect.flatMap(Ref.get(ref), Option.match({
|
|
1718
|
+
onNone: () => Effect.unit,
|
|
1719
|
+
onSome: b => Effect.matchCauseEffect(this.i2(a, b), sink)
|
|
1720
|
+
}))))), Fiber.interrupt));
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
function if_(bool, options) {
|
|
1724
|
+
return switchMap(bool, b => b ? options.onTrue : options.onFalse);
|
|
1725
|
+
}
|
|
1726
|
+
function when(bool, options) {
|
|
1727
|
+
return if_(bool, {
|
|
1728
|
+
onTrue: succeed(options.onTrue),
|
|
1729
|
+
onFalse: succeed(options.onFalse)
|
|
894
1730
|
});
|
|
895
1731
|
}
|
|
896
|
-
function
|
|
897
|
-
return
|
|
898
|
-
const pull = _effect.Effect.either(yield* _(_effect.Stream.toPull(stream), _effect.Effect.provideService(_effect.Scope.Scope, scope)));
|
|
899
|
-
while (true) {
|
|
900
|
-
const either = yield* _(pull);
|
|
901
|
-
if (_effect.Either.isRight(either)) {
|
|
902
|
-
yield* _(_effect.Effect.forEach(either.right, sink.onSuccess));
|
|
903
|
-
} else if (_effect.Option.isNone(either.left)) {
|
|
904
|
-
return;
|
|
905
|
-
} else {
|
|
906
|
-
yield* _(sink.onFailure(_effect.Cause.fail(either.left.value)));
|
|
907
|
-
}
|
|
908
|
-
// Schedule subsequent pulls using the current scheduler.
|
|
909
|
-
yield* _(_effect.Effect.yieldNow(options));
|
|
910
|
-
}
|
|
911
|
-
}), _effect.Scope.close));
|
|
912
|
-
}
|
|
913
|
-
const matchers = {
|
|
914
|
-
RefSubject: _Function.identity,
|
|
915
|
-
Fx: _Function.identity,
|
|
916
|
-
Effect: fromEffect,
|
|
917
|
-
Cause: failCause,
|
|
918
|
-
Iterable: fromIterable,
|
|
919
|
-
Otherwise: succeed
|
|
920
|
-
};
|
|
921
|
-
function from(input) {
|
|
922
|
-
return (0, _matchers.matchFxInput)(input, matchers);
|
|
1732
|
+
function mapBoth(fx, f, g) {
|
|
1733
|
+
return map(mapError(fx, f), g);
|
|
923
1734
|
}
|
|
924
1735
|
//# sourceMappingURL=core.js.map
|