@typed/fx 1.0.14 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Fx.d.ts +6 -0
- package/dist/Fx.d.ts.map +1 -1
- package/dist/Fx.js.map +1 -1
- package/dist/Subject/HoldSubject.d.ts +1 -1
- package/dist/Subject/HoldSubject.d.ts.map +1 -1
- package/dist/Subject/HoldSubject.js +1 -1
- package/dist/Subject/HoldSubject.js.map +1 -1
- package/dist/Subject/RefSubject.js +2 -2
- package/dist/Subject/RefSubject.js.map +1 -1
- package/dist/Subject/SynchronizedSubject.js +2 -2
- package/dist/Subject/SynchronizedSubject.js.map +1 -1
- package/dist/_internal/RefCounter.js +1 -1
- package/dist/_internal/RefCounter.js.map +1 -1
- package/dist/constructor/at.d.ts +1 -1
- package/dist/constructor/at.d.ts.map +1 -1
- package/dist/constructor/periodic.d.ts +1 -1
- package/dist/constructor/periodic.d.ts.map +1 -1
- package/dist/constructor/service.d.ts +1 -1
- package/dist/constructor/service.d.ts.map +1 -1
- package/dist/constructor/serviceWith.d.ts +1 -1
- package/dist/constructor/serviceWith.d.ts.map +1 -1
- package/dist/constructor/serviceWithEffect.d.ts +1 -1
- package/dist/constructor/serviceWithEffect.d.ts.map +1 -1
- package/dist/constructor/serviceWithFx.d.ts +1 -1
- package/dist/constructor/serviceWithFx.d.ts.map +1 -1
- package/dist/operator/catchTag.d.ts +20 -0
- package/dist/operator/catchTag.d.ts.map +1 -0
- package/dist/operator/catchTag.js +14 -0
- package/dist/operator/catchTag.js.map +1 -0
- package/dist/operator/contramapContext.d.ts +1 -1
- package/dist/operator/contramapContext.d.ts.map +1 -1
- package/dist/operator/contramapContext.js +1 -1
- package/dist/operator/contramapContext.js.map +1 -1
- package/dist/operator/debounce.d.ts +1 -1
- package/dist/operator/debounce.d.ts.map +1 -1
- package/dist/operator/delay.d.ts +1 -1
- package/dist/operator/delay.d.ts.map +1 -1
- package/dist/operator/exhaustMap.d.ts +3 -2
- package/dist/operator/exhaustMap.d.ts.map +1 -1
- package/dist/operator/exhaustMap.js +2 -4
- package/dist/operator/exhaustMap.js.map +1 -1
- package/dist/operator/flatMap.d.ts +3 -1
- package/dist/operator/flatMap.d.ts.map +1 -1
- package/dist/operator/flatMap.js +2 -4
- package/dist/operator/flatMap.js.map +1 -1
- package/dist/operator/hold.d.ts +1 -1
- package/dist/operator/hold.d.ts.map +1 -1
- package/dist/operator/hold.js +1 -1
- package/dist/operator/hold.js.map +1 -1
- package/dist/operator/index.d.ts +1 -0
- package/dist/operator/index.d.ts.map +1 -1
- package/dist/operator/index.js +1 -0
- package/dist/operator/index.js.map +1 -1
- package/dist/operator/map.d.ts +4 -1
- package/dist/operator/map.d.ts.map +1 -1
- package/dist/operator/map.js +2 -3
- package/dist/operator/map.js.map +1 -1
- package/dist/operator/multicast.d.ts +1 -1
- package/dist/operator/multicast.d.ts.map +1 -1
- package/dist/operator/onInterrupt.d.ts +1 -1
- package/dist/operator/onInterrupt.d.ts.map +1 -1
- package/dist/operator/provideContext.d.ts +1 -1
- package/dist/operator/provideContext.d.ts.map +1 -1
- package/dist/operator/provideContext.js +1 -1
- package/dist/operator/provideContext.js.map +1 -1
- package/dist/operator/provideService.d.ts +1 -1
- package/dist/operator/provideService.d.ts.map +1 -1
- package/dist/operator/provideServiceEffect.d.ts +1 -1
- package/dist/operator/provideServiceEffect.d.ts.map +1 -1
- package/dist/operator/skipRepeats.js +1 -1
- package/dist/operator/skipRepeats.js.map +1 -1
- package/dist/operator/switchMap.d.ts +3 -1
- package/dist/operator/switchMap.d.ts.map +1 -1
- package/dist/operator/switchMap.js +2 -4
- package/dist/operator/switchMap.js.map +1 -1
- package/dist/operator/switchMapCause.d.ts +7 -0
- package/dist/operator/switchMapCause.d.ts.map +1 -1
- package/dist/operator/switchMapCause.js +4 -0
- package/dist/operator/switchMapCause.js.map +1 -1
- package/dist/operator/throttle.d.ts +1 -1
- package/dist/operator/throttle.d.ts.map +1 -1
- package/dist/typeclass/Bicovariant.d.ts +1 -0
- package/dist/typeclass/Bicovariant.d.ts.map +1 -1
- package/dist/typeclass/Bicovariant.js +3 -2
- package/dist/typeclass/Bicovariant.js.map +1 -1
- package/dist/typeclass/Covariant.d.ts.map +1 -1
- package/dist/typeclass/Covariant.js +4 -1
- package/dist/typeclass/Covariant.js.map +1 -1
- package/dist/typeclass/SemiProduct.d.ts +3 -0
- package/dist/typeclass/SemiProduct.d.ts.map +1 -1
- package/dist/typeclass/SemiProduct.js +5 -2
- package/dist/typeclass/SemiProduct.js.map +1 -1
- package/package.json +5 -5
- package/src/Fx.ts +6 -0
- package/src/Subject/HoldSubject.test.ts +1 -1
- package/src/Subject/HoldSubject.ts +1 -1
- package/src/Subject/RefSubject.ts +2 -2
- package/src/Subject/SynchronizedSubject.ts +2 -2
- package/src/_internal/RefCounter.ts +1 -1
- package/src/constructor/at.ts +1 -1
- package/src/constructor/periodic.ts +1 -1
- package/src/constructor/service.ts +1 -1
- package/src/constructor/serviceWith.ts +1 -1
- package/src/constructor/serviceWithEffect.ts +1 -1
- package/src/constructor/serviceWithFx.ts +1 -1
- package/src/operator/catchTag.ts +56 -0
- package/src/operator/combine.test.ts +1 -1
- package/src/operator/concatMap.test.ts +1 -1
- package/src/operator/contramapContext.ts +1 -1
- package/src/operator/debounce.test.ts +1 -1
- package/src/operator/debounce.ts +1 -1
- package/src/operator/delay.ts +1 -1
- package/src/operator/exhaustMap.test.ts +1 -1
- package/src/operator/exhaustMap.ts +7 -4
- package/src/operator/exhaustMapLatest.test.ts +1 -1
- package/src/operator/flatMap.test.ts +1 -1
- package/src/operator/flatMap.ts +7 -6
- package/src/operator/flatMapConcurrently.test.ts +1 -1
- package/src/operator/hold.test.ts +1 -1
- package/src/operator/hold.ts +1 -1
- package/src/operator/index.ts +1 -0
- package/src/operator/map.ts +6 -3
- package/src/operator/merge.test.ts +1 -1
- package/src/operator/mergeRace.test.ts +1 -1
- package/src/operator/multicast.test.ts +1 -1
- package/src/operator/multicast.ts +1 -1
- package/src/operator/onInterrupt.ts +1 -1
- package/src/operator/provideContext.ts +1 -1
- package/src/operator/provideService.test.ts +1 -1
- package/src/operator/provideService.ts +1 -1
- package/src/operator/provideServiceEffect.test.ts +1 -1
- package/src/operator/provideServiceEffect.ts +1 -1
- package/src/operator/race.test.ts +1 -1
- package/src/operator/race.ts +1 -1
- package/src/operator/scanEffect.test.ts +1 -1
- package/src/operator/separate.test.ts +1 -1
- package/src/operator/skipRepeats.ts +1 -1
- package/src/operator/snapshot.test.ts +1 -1
- package/src/operator/snapshotEffect.test.ts +1 -1
- package/src/operator/struct.test.ts +1 -1
- package/src/operator/switchMap.test.ts +1 -1
- package/src/operator/switchMap.ts +7 -6
- package/src/operator/switchMapCause.test.ts +1 -1
- package/src/operator/switchMapCause.ts +15 -0
- package/src/operator/switchMatch.test.ts +1 -1
- package/src/operator/throttle.test.ts +1 -1
- package/src/operator/throttle.ts +1 -1
- package/src/operator/zip.test.ts +1 -1
- package/src/typeclass/Bicovariant.ts +8 -2
- package/src/typeclass/Covariant.ts +4 -1
- package/src/typeclass/SemiProduct.ts +11 -5
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -2,7 +2,7 @@ import { deepStrictEqual } from 'assert'
|
|
|
2
2
|
|
|
3
3
|
import * as Effect from '@effect/io/Effect'
|
|
4
4
|
import { pipe } from '@fp-ts/core/Function'
|
|
5
|
-
import * as Duration from '@
|
|
5
|
+
import * as Duration from '@effect/data/Duration'
|
|
6
6
|
import { describe, it } from 'vitest'
|
|
7
7
|
|
|
8
8
|
import { fromIterable } from '../constructor/fromIterable.js'
|
|
@@ -2,14 +2,17 @@ import * as Cause from '@effect/io/Cause'
|
|
|
2
2
|
import * as Effect from '@effect/io/Effect'
|
|
3
3
|
import type * as Fiber from '@effect/io/Fiber'
|
|
4
4
|
import * as Ref from '@effect/io/Ref/Synchronized'
|
|
5
|
-
import { pipe } from '@fp-ts/core/Function'
|
|
5
|
+
import { dual, pipe } from '@fp-ts/core/Function'
|
|
6
|
+
import type { FlatMap } from '@fp-ts/core/typeclass/FlatMap'
|
|
6
7
|
|
|
7
8
|
import { Fx } from '../Fx.js'
|
|
8
9
|
import { withRefCounter } from '../_internal/RefCounter.js'
|
|
10
|
+
import type { FxTypeLambda } from '../typeclass/TypeLambda.js'
|
|
9
11
|
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
export const exhaustMap: FlatMap<FxTypeLambda>['flatMap'] = dual(
|
|
13
|
+
2,
|
|
14
|
+
<R, E, A, R2, E2, B>(fx: Fx<R, E, A>, f: (a: A) => Fx<R2, E2, B>) => new ExhaustMapFx(fx, f),
|
|
15
|
+
)
|
|
13
16
|
|
|
14
17
|
class ExhaustMapFx<R, E, A, R2, E2, B>
|
|
15
18
|
extends Fx.Variance<R | R2, E | E2, B>
|
|
@@ -2,7 +2,7 @@ import { deepStrictEqual } from 'assert'
|
|
|
2
2
|
|
|
3
3
|
import * as Effect from '@effect/io/Effect'
|
|
4
4
|
import { pipe } from '@fp-ts/core/Function'
|
|
5
|
-
import * as Duration from '@
|
|
5
|
+
import * as Duration from '@effect/data/Duration'
|
|
6
6
|
import { describe, it } from 'vitest'
|
|
7
7
|
|
|
8
8
|
import { fromIterable } from '../constructor/fromIterable.js'
|
|
@@ -2,7 +2,7 @@ import { deepStrictEqual } from 'assert'
|
|
|
2
2
|
|
|
3
3
|
import * as Effect from '@effect/io/Effect'
|
|
4
4
|
import { pipe } from '@fp-ts/core/Function'
|
|
5
|
-
import { millis } from '@
|
|
5
|
+
import { millis } from '@effect/data/Duration'
|
|
6
6
|
import { describe, it } from 'vitest'
|
|
7
7
|
|
|
8
8
|
import { at } from '../constructor/at.js'
|
package/src/operator/flatMap.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import * as Cause from '@effect/io/Cause'
|
|
2
2
|
import * as Effect from '@effect/io/Effect'
|
|
3
|
-
import { identity, pipe } from '@fp-ts/core/Function'
|
|
3
|
+
import { dual, identity, pipe } from '@fp-ts/core/Function'
|
|
4
|
+
import type { FlatMap } from '@fp-ts/core/typeclass/FlatMap'
|
|
4
5
|
|
|
5
6
|
import { Fx } from '../Fx.js'
|
|
6
7
|
import { withRefCounter } from '../_internal/RefCounter.js'
|
|
8
|
+
import type { FxTypeLambda } from '../index.js'
|
|
7
9
|
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
10
|
+
export const flatMap: FlatMap<FxTypeLambda>['flatMap'] = dual(
|
|
11
|
+
2,
|
|
12
|
+
<R, E, A, R2, E2, B>(fx: Fx<R, E, A>, f: (a: A) => Fx<R2, E2, B>) => new FlatMapFx(fx, f),
|
|
13
|
+
)
|
|
13
14
|
|
|
14
15
|
export const flatten: <R, E, R2, E2, A>(fx: Fx<R, E, Fx<R2, E2, A>>) => Fx<R | R2, E | E2, A> =
|
|
15
16
|
flatMap(identity)
|
|
@@ -2,7 +2,7 @@ import { deepStrictEqual } from 'assert'
|
|
|
2
2
|
|
|
3
3
|
import * as Effect from '@effect/io/Effect'
|
|
4
4
|
import { pipe } from '@fp-ts/core/Function'
|
|
5
|
-
import { millis } from '@
|
|
5
|
+
import { millis } from '@effect/data/Duration'
|
|
6
6
|
import { describe, it } from 'vitest'
|
|
7
7
|
|
|
8
8
|
import { at } from '../constructor/at.js'
|
|
@@ -2,7 +2,7 @@ import { deepStrictEqual } from 'assert'
|
|
|
2
2
|
|
|
3
3
|
import * as Effect from '@effect/io/Effect'
|
|
4
4
|
import * as Fiber from '@effect/io/Fiber'
|
|
5
|
-
import { millis } from '@
|
|
5
|
+
import { millis } from '@effect/data/Duration'
|
|
6
6
|
import { describe, it } from 'vitest'
|
|
7
7
|
|
|
8
8
|
import { at } from '../constructor/at.js'
|
package/src/operator/hold.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as Fiber from '@effect/io/Fiber'
|
|
|
4
4
|
import type { Scope } from '@effect/io/Scope'
|
|
5
5
|
import { pipe } from '@fp-ts/core/Function'
|
|
6
6
|
import * as Option from '@fp-ts/core/Option'
|
|
7
|
-
import * as MutableRef from '@
|
|
7
|
+
import * as MutableRef from '@effect/data/MutableRef'
|
|
8
8
|
|
|
9
9
|
import type { Fx } from '../Fx.js'
|
|
10
10
|
import { asap } from '../_internal/RefCounter.js'
|
package/src/operator/index.ts
CHANGED
package/src/operator/map.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { dual } from '@fp-ts/core/Function'
|
|
2
|
+
|
|
1
3
|
import { Fx } from '../Fx.js'
|
|
2
4
|
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
export const map: {
|
|
6
|
+
<R, E, A, B>(fx: Fx<R, E, A>, f: (a: A) => B): Fx<R, E, B>
|
|
7
|
+
<A, B>(f: (a: A) => B): <R, E>(fx: Fx<R, E, A>) => Fx<R, E, B>
|
|
8
|
+
} = dual(2, <R, E, A, B>(fx: Fx<R, E, A>, f: (a: A) => B) => new MapFx(fx, f))
|
|
6
9
|
|
|
7
10
|
class MapFx<R, E, A, B> extends Fx.Variance<R, E, B> implements Fx<R, E, B> {
|
|
8
11
|
constructor(readonly fx: Fx<R, E, A>, readonly f: (a: A) => B) {
|
|
@@ -2,7 +2,7 @@ import { deepStrictEqual } from 'assert'
|
|
|
2
2
|
|
|
3
3
|
import * as Effect from '@effect/io/Effect'
|
|
4
4
|
import { pipe } from '@fp-ts/core/Function'
|
|
5
|
-
import { millis } from '@
|
|
5
|
+
import { millis } from '@effect/data/Duration'
|
|
6
6
|
import { describe, it } from 'vitest'
|
|
7
7
|
|
|
8
8
|
import { at } from '../constructor/at.js'
|
|
@@ -2,7 +2,7 @@ import { deepStrictEqual } from 'assert'
|
|
|
2
2
|
|
|
3
3
|
import * as Effect from '@effect/io/Effect'
|
|
4
4
|
import { pipe } from '@fp-ts/core/Function'
|
|
5
|
-
import { millis } from '@
|
|
5
|
+
import { millis } from '@effect/data/Duration'
|
|
6
6
|
import { describe, it } from 'vitest'
|
|
7
7
|
|
|
8
8
|
import { at } from '../constructor/at.js'
|
|
@@ -3,7 +3,7 @@ import { deepStrictEqual } from 'assert'
|
|
|
3
3
|
import * as Effect from '@effect/io/Effect'
|
|
4
4
|
import * as Fiber from '@effect/io/Fiber'
|
|
5
5
|
import { pipe } from '@fp-ts/core/Function'
|
|
6
|
-
import { millis } from '@
|
|
6
|
+
import { millis } from '@effect/data/Duration'
|
|
7
7
|
import { describe, it } from 'vitest'
|
|
8
8
|
|
|
9
9
|
import { fromIterable } from '../constructor/fromIterable.js'
|
|
@@ -5,7 +5,7 @@ import * as Fiber from '@effect/io/Fiber'
|
|
|
5
5
|
import type { RuntimeFiber } from '@effect/io/Fiber'
|
|
6
6
|
import type { Scope } from '@effect/io/Scope'
|
|
7
7
|
import { pipe } from '@fp-ts/core/Function'
|
|
8
|
-
import type { Context } from '@
|
|
8
|
+
import type { Context } from '@effect/data/Context'
|
|
9
9
|
|
|
10
10
|
import { Fx } from '../Fx.js'
|
|
11
11
|
import { asap } from '../_internal/RefCounter.js'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Effect from '@effect/io/Effect'
|
|
2
2
|
import type { FiberId } from '@effect/io/Fiber/Id'
|
|
3
3
|
import { flow, pipe } from '@fp-ts/core/Function'
|
|
4
|
-
import type { HashSet } from '@
|
|
4
|
+
import type { HashSet } from '@effect/data/HashSet'
|
|
5
5
|
|
|
6
6
|
import { Fx } from '../Fx.js'
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Effect from '@effect/io/Effect'
|
|
2
2
|
import type { Scope } from '@effect/io/Scope'
|
|
3
3
|
import { pipe } from '@fp-ts/core/Function'
|
|
4
|
-
import * as Context from '@
|
|
4
|
+
import * as Context from '@effect/data/Context'
|
|
5
5
|
|
|
6
6
|
import { Fx } from '../Fx.js'
|
|
7
7
|
|
|
@@ -2,7 +2,7 @@ import { deepStrictEqual } from 'assert'
|
|
|
2
2
|
|
|
3
3
|
import * as Effect from '@effect/io/Effect'
|
|
4
4
|
import { pipe } from '@fp-ts/core/Function'
|
|
5
|
-
import { Tag } from '@
|
|
5
|
+
import { Tag } from '@effect/data/Context'
|
|
6
6
|
import { describe, it } from 'vitest'
|
|
7
7
|
|
|
8
8
|
import { serviceWith } from '../constructor/serviceWith.js'
|
|
@@ -2,7 +2,7 @@ import { deepStrictEqual } from 'assert'
|
|
|
2
2
|
|
|
3
3
|
import * as Effect from '@effect/io/Effect'
|
|
4
4
|
import { pipe } from '@fp-ts/core/Function'
|
|
5
|
-
import { Tag } from '@
|
|
5
|
+
import { Tag } from '@effect/data/Context'
|
|
6
6
|
import { describe, it } from 'vitest'
|
|
7
7
|
|
|
8
8
|
import { serviceWith } from '../constructor/serviceWith.js'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Effect from '@effect/io/Effect'
|
|
2
2
|
import type { Scope } from '@effect/io/Scope'
|
|
3
3
|
import { pipe } from '@fp-ts/core/Function'
|
|
4
|
-
import type * as Context from '@
|
|
4
|
+
import type * as Context from '@effect/data/Context'
|
|
5
5
|
|
|
6
6
|
import { Fx } from '../Fx.js'
|
|
7
7
|
|
|
@@ -2,7 +2,7 @@ import { deepStrictEqual } from 'assert'
|
|
|
2
2
|
|
|
3
3
|
import * as Effect from '@effect/io/Effect'
|
|
4
4
|
import { pipe } from '@fp-ts/core/Function'
|
|
5
|
-
import { millis } from '@
|
|
5
|
+
import { millis } from '@effect/data/Duration'
|
|
6
6
|
import { describe, it } from 'vitest'
|
|
7
7
|
|
|
8
8
|
import { at } from '../constructor/at.js'
|
package/src/operator/race.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as ExecutionStrategy from '@effect/io/ExecutionStrategy'
|
|
|
4
4
|
import * as Exit from '@effect/io/Exit'
|
|
5
5
|
import * as Scope from '@effect/io/Scope'
|
|
6
6
|
import { pipe } from '@fp-ts/core/Function'
|
|
7
|
-
import type { Chunk } from '@
|
|
7
|
+
import type { Chunk } from '@effect/data/Chunk'
|
|
8
8
|
|
|
9
9
|
import { Fx } from '../Fx.js'
|
|
10
10
|
import { asap } from '../_internal/RefCounter.js'
|
|
@@ -2,7 +2,7 @@ import { deepStrictEqual } from 'assert'
|
|
|
2
2
|
|
|
3
3
|
import * as Effect from '@effect/io/Effect'
|
|
4
4
|
import { pipe } from '@fp-ts/core/Function'
|
|
5
|
-
import { millis } from '@
|
|
5
|
+
import { millis } from '@effect/data/Duration'
|
|
6
6
|
import { describe, it } from 'vitest'
|
|
7
7
|
|
|
8
8
|
import { fromArray } from '../constructor/fromArray.js'
|
|
@@ -3,7 +3,7 @@ import { deepStrictEqual } from 'assert'
|
|
|
3
3
|
import * as Effect from '@effect/io/Effect'
|
|
4
4
|
import * as Fiber from '@effect/io/Fiber'
|
|
5
5
|
import * as Either from '@fp-ts/core/Either'
|
|
6
|
-
import { millis } from '@
|
|
6
|
+
import { millis } from '@effect/data/Duration'
|
|
7
7
|
import { describe, it } from 'vitest'
|
|
8
8
|
|
|
9
9
|
import { at } from '../constructor/at.js'
|
|
@@ -2,7 +2,7 @@ import { deepStrictEqual } from 'assert'
|
|
|
2
2
|
|
|
3
3
|
import * as Effect from '@effect/io/Effect'
|
|
4
4
|
import { pipe } from '@fp-ts/core/Function'
|
|
5
|
-
import { millis } from '@
|
|
5
|
+
import { millis } from '@effect/data/Duration'
|
|
6
6
|
import { describe, it } from 'vitest'
|
|
7
7
|
|
|
8
8
|
import { at } from '../constructor/at.js'
|
|
@@ -2,7 +2,7 @@ import { deepStrictEqual } from 'assert'
|
|
|
2
2
|
|
|
3
3
|
import * as Effect from '@effect/io/Effect'
|
|
4
4
|
import { pipe } from '@fp-ts/core/Function'
|
|
5
|
-
import { millis } from '@
|
|
5
|
+
import { millis } from '@effect/data/Duration'
|
|
6
6
|
import { describe, it } from 'vitest'
|
|
7
7
|
|
|
8
8
|
import { at } from '../constructor/at.js'
|
|
@@ -2,7 +2,7 @@ import { deepStrictEqual } from 'assert'
|
|
|
2
2
|
|
|
3
3
|
import * as Effect from '@effect/io/Effect'
|
|
4
4
|
import { pipe } from '@fp-ts/core/Function'
|
|
5
|
-
import { millis } from '@
|
|
5
|
+
import { millis } from '@effect/data/Duration'
|
|
6
6
|
import { describe, it } from 'vitest'
|
|
7
7
|
|
|
8
8
|
import { periodic } from '../constructor/periodic.js'
|
|
@@ -2,7 +2,7 @@ import { deepStrictEqual } from 'assert'
|
|
|
2
2
|
|
|
3
3
|
import * as Effect from '@effect/io/Effect'
|
|
4
4
|
import { pipe } from '@fp-ts/core/Function'
|
|
5
|
-
import { millis } from '@
|
|
5
|
+
import { millis } from '@effect/data/Duration'
|
|
6
6
|
import { describe, it } from 'vitest'
|
|
7
7
|
|
|
8
8
|
import { at } from '../constructor/at.js'
|
|
@@ -2,16 +2,17 @@ import * as Cause from '@effect/io/Cause'
|
|
|
2
2
|
import * as Effect from '@effect/io/Effect'
|
|
3
3
|
import * as Fiber from '@effect/io/Fiber'
|
|
4
4
|
import * as Ref from '@effect/io/Ref/Synchronized'
|
|
5
|
-
import { flow, pipe, identity } from '@fp-ts/core/Function'
|
|
5
|
+
import { flow, pipe, identity, dual } from '@fp-ts/core/Function'
|
|
6
|
+
import type { FlatMap } from '@fp-ts/core/typeclass/FlatMap'
|
|
6
7
|
|
|
7
8
|
import { Fx } from '../Fx.js'
|
|
8
9
|
import { withRefCounter } from '../_internal/RefCounter.js'
|
|
10
|
+
import type { FxTypeLambda } from '../typeclass/TypeLambda.js'
|
|
9
11
|
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
12
|
+
export const switchMap: FlatMap<FxTypeLambda>['flatMap'] = dual(
|
|
13
|
+
2,
|
|
14
|
+
<R, E, A, R2, E2, B>(fx: Fx<R, E, A>, f: (a: A) => Fx<R2, E2, B>) => new SwitchMapFx(fx, f),
|
|
15
|
+
)
|
|
15
16
|
|
|
16
17
|
export const switchLatest: <R, E, R2, E2, A>(fx: Fx<R, E, Fx<R2, E2, A>>) => Fx<R | R2, E | E2, A> =
|
|
17
18
|
switchMap(identity)
|
|
@@ -4,7 +4,7 @@ import * as Cause from '@effect/io/Cause'
|
|
|
4
4
|
import * as Effect from '@effect/io/Effect'
|
|
5
5
|
import * as Either from '@fp-ts/core/Either'
|
|
6
6
|
import { flow, pipe } from '@fp-ts/core/Function'
|
|
7
|
-
import { millis } from '@
|
|
7
|
+
import { millis } from '@effect/data/Duration'
|
|
8
8
|
import { describe, it } from 'vitest'
|
|
9
9
|
|
|
10
10
|
import { at } from '../constructor/at.js'
|
|
@@ -7,12 +7,27 @@ import { flow, pipe } from '@fp-ts/core/Function'
|
|
|
7
7
|
import { Fx } from '../Fx.js'
|
|
8
8
|
import { withRefCounter } from '../_internal/RefCounter.js'
|
|
9
9
|
|
|
10
|
+
import { catchTag_ } from './catchTag.js'
|
|
11
|
+
|
|
10
12
|
export function switchMapCause<E, R2, E2, B>(
|
|
11
13
|
f: (cause: Cause.Cause<E>) => Fx<R2, E2, B>,
|
|
12
14
|
): <R, A>(fx: Fx<R, E, A>) => Fx<R | R2, E2, A | B> {
|
|
13
15
|
return (fx) => new SwitchMapCauseFx(fx, f)
|
|
14
16
|
}
|
|
15
17
|
|
|
18
|
+
export function switchMapCatchTag<
|
|
19
|
+
K extends E['_tag'] & string,
|
|
20
|
+
E extends { readonly _tag: string },
|
|
21
|
+
R2,
|
|
22
|
+
E2,
|
|
23
|
+
B,
|
|
24
|
+
>(
|
|
25
|
+
k: K,
|
|
26
|
+
f: (e: Extract<E, { readonly _tag: K }>) => Fx<R2, E2, B>,
|
|
27
|
+
): <R, A>(fx: Fx<R, E, A>) => Fx<R | R2, E2 | Exclude<E, { readonly _tag: K }>, A | B> {
|
|
28
|
+
return (fx) => new SwitchMapCauseFx(fx, (cause) => catchTag_(cause, k, f))
|
|
29
|
+
}
|
|
30
|
+
|
|
16
31
|
class SwitchMapCauseFx<R, E, A, R2, E2, B>
|
|
17
32
|
extends Fx.Variance<R | R2, E2, A | B>
|
|
18
33
|
implements Fx<R | R2, E2, A | B>
|
|
@@ -2,7 +2,7 @@ import { deepStrictEqual } from 'assert'
|
|
|
2
2
|
|
|
3
3
|
import * as Effect from '@effect/io/Effect'
|
|
4
4
|
import { pipe } from '@fp-ts/core/Function'
|
|
5
|
-
import { millis } from '@
|
|
5
|
+
import { millis } from '@effect/data/Duration'
|
|
6
6
|
import { describe, it } from 'vitest'
|
|
7
7
|
|
|
8
8
|
import { at } from '../constructor/at.js'
|
|
@@ -2,7 +2,7 @@ import { deepStrictEqual } from 'assert'
|
|
|
2
2
|
|
|
3
3
|
import * as Effect from '@effect/io/Effect'
|
|
4
4
|
import { pipe } from '@fp-ts/core/Function'
|
|
5
|
-
import * as Duration from '@
|
|
5
|
+
import * as Duration from '@effect/data/Duration'
|
|
6
6
|
import { describe, it } from 'vitest'
|
|
7
7
|
|
|
8
8
|
import { fromArray } from '../constructor/fromArray.js'
|
package/src/operator/throttle.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Effect from '@effect/io/Effect'
|
|
2
2
|
import type * as Fiber from '@effect/io/Fiber'
|
|
3
3
|
import { pipe } from '@fp-ts/core/Function'
|
|
4
|
-
import type * as Duration from '@
|
|
4
|
+
import type * as Duration from '@effect/data/Duration'
|
|
5
5
|
|
|
6
6
|
import type { Fx } from '../Fx.js'
|
|
7
7
|
import { suspend } from '../constructor/suspend.js'
|
package/src/operator/zip.test.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { deepStrictEqual } from 'assert'
|
|
|
2
2
|
|
|
3
3
|
import * as Effect from '@effect/io/Effect'
|
|
4
4
|
import { pipe } from '@fp-ts/core/Function'
|
|
5
|
-
import { millis } from '@
|
|
5
|
+
import { millis } from '@effect/data/Duration'
|
|
6
6
|
import { describe, it } from 'vitest'
|
|
7
7
|
|
|
8
8
|
import { at } from '../constructor/at.js'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { pipe } from '@fp-ts/core/Function'
|
|
1
|
+
import { dual, pipe } from '@fp-ts/core/Function'
|
|
2
2
|
import * as B from '@fp-ts/core/typeclass/Bicovariant'
|
|
3
3
|
|
|
4
4
|
import type { Fx } from '../Fx.js'
|
|
@@ -7,8 +7,14 @@ import { mapError } from '../operator/mapError.js'
|
|
|
7
7
|
|
|
8
8
|
import type { FxTypeLambda } from './TypeLambda.js'
|
|
9
9
|
|
|
10
|
+
export const bimap: B.Bicovariant<FxTypeLambda>['bimap'] = dual(
|
|
11
|
+
3,
|
|
12
|
+
<R, E, A, E2, B>(self: Fx<R, E, A>, f: (e: E) => E2, g: (a: A) => B) =>
|
|
13
|
+
pipe(self, mapError(f), map(g)),
|
|
14
|
+
)
|
|
15
|
+
|
|
10
16
|
export const Bicovariant: B.Bicovariant<FxTypeLambda> = {
|
|
11
|
-
bimap
|
|
17
|
+
bimap,
|
|
12
18
|
}
|
|
13
19
|
|
|
14
20
|
export const mapLeft: <E1, E2>(f: (e: E1) => E2) => <R, A>(self: Fx<R, E1, A>) => Fx<R, E2, A> =
|
|
@@ -5,7 +5,10 @@ import { map } from '../operator/map.js'
|
|
|
5
5
|
|
|
6
6
|
import type { FxTypeLambda } from './TypeLambda.js'
|
|
7
7
|
|
|
8
|
-
export const Covariant: C.Covariant<FxTypeLambda> =
|
|
8
|
+
export const Covariant: C.Covariant<FxTypeLambda> = {
|
|
9
|
+
map,
|
|
10
|
+
imap: C.imap<FxTypeLambda>(map),
|
|
11
|
+
}
|
|
9
12
|
|
|
10
13
|
export const flap: <A>(a: A) => <R, E, B>(self: Fx<R, E, (a: A) => B>) => Fx<R, E, B> =
|
|
11
14
|
C.flap(Covariant)
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
+
import { dual } from '@fp-ts/core/Function'
|
|
1
2
|
import * as SP from '@fp-ts/core/typeclass/SemiProduct'
|
|
2
3
|
|
|
4
|
+
import type { Fx } from '../Fx.js'
|
|
3
5
|
import { combine } from '../operator/combine.js'
|
|
4
6
|
|
|
5
7
|
import { Covariant } from './Covariant.js'
|
|
6
8
|
import type { FxTypeLambda } from './TypeLambda.js'
|
|
7
9
|
|
|
10
|
+
export const product: SP.SemiProduct<FxTypeLambda>['product'] = dual(
|
|
11
|
+
2,
|
|
12
|
+
<R, E, A, R2, E2, B>(self: Fx<R, E, A>, that: Fx<R2, E2, B>) => combine(that)(self),
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
export const productMany = SP.productMany<FxTypeLambda>(Covariant.map, product)
|
|
16
|
+
|
|
8
17
|
export const SemiProduct: SP.SemiProduct<FxTypeLambda> = {
|
|
9
|
-
product
|
|
10
|
-
productMany
|
|
11
|
-
Covariant,
|
|
12
|
-
(s, o) => combine(o)(s) as any,
|
|
13
|
-
) as SP.SemiProduct<FxTypeLambda>['productMany'],
|
|
18
|
+
product,
|
|
19
|
+
productMany,
|
|
14
20
|
imap: Covariant.imap,
|
|
15
21
|
}
|