effect 2.4.18 → 2.4.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Readable/package.json +6 -0
- package/RegExp/package.json +6 -0
- package/Subscribable/package.json +6 -0
- package/dist/cjs/Duration.js +39 -2
- package/dist/cjs/Duration.js.map +1 -1
- package/dist/cjs/List.js +5 -4
- package/dist/cjs/List.js.map +1 -1
- package/dist/cjs/Readable.js +79 -0
- package/dist/cjs/Readable.js.map +1 -0
- package/dist/cjs/RegExp.js +24 -0
- package/dist/cjs/RegExp.js.map +1 -0
- package/dist/cjs/Subscribable.js +91 -0
- package/dist/cjs/Subscribable.js.map +1 -0
- package/dist/cjs/SubscriptionRef.js.map +1 -1
- package/dist/cjs/TestAnnotation.js +2 -1
- package/dist/cjs/TestAnnotation.js.map +1 -1
- package/dist/cjs/index.js +8 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/internal/cause.js +3 -2
- package/dist/cjs/internal/cause.js.map +1 -1
- package/dist/cjs/internal/configProvider.js +2 -2
- package/dist/cjs/internal/configProvider.js.map +1 -1
- package/dist/cjs/internal/core-effect.js +28 -14
- package/dist/cjs/internal/core-effect.js.map +1 -1
- package/dist/cjs/internal/core.js +16 -85
- package/dist/cjs/internal/core.js.map +1 -1
- package/dist/cjs/internal/effect/circular.js +5 -0
- package/dist/cjs/internal/effect/circular.js.map +1 -1
- package/dist/cjs/internal/errors.js +13 -0
- package/dist/cjs/internal/errors.js.map +1 -0
- package/dist/cjs/internal/fiberRuntime.js +79 -39
- package/dist/cjs/internal/fiberRuntime.js.map +1 -1
- package/dist/cjs/internal/hashMap.js +1 -1
- package/dist/cjs/internal/hashMap.js.map +1 -1
- package/dist/cjs/internal/matcher.js +5 -4
- package/dist/cjs/internal/matcher.js.map +1 -1
- package/dist/cjs/internal/ref.js +6 -1
- package/dist/cjs/internal/ref.js.map +1 -1
- package/dist/cjs/internal/schedule/intervals.js +2 -1
- package/dist/cjs/internal/schedule/intervals.js.map +1 -1
- package/dist/cjs/internal/subscriptionRef.js +8 -0
- package/dist/cjs/internal/subscriptionRef.js.map +1 -1
- package/dist/cjs/internal/trie.js +1 -1
- package/dist/cjs/internal/trie.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/dts/Duration.d.ts +16 -0
- package/dist/dts/Duration.d.ts.map +1 -1
- package/dist/dts/List.d.ts.map +1 -1
- package/dist/dts/Readable.d.ts +55 -0
- package/dist/dts/Readable.d.ts.map +1 -0
- package/dist/dts/Ref.d.ts +2 -2
- package/dist/dts/Ref.d.ts.map +1 -1
- package/dist/dts/RegExp.d.ts +17 -0
- package/dist/dts/RegExp.d.ts.map +1 -0
- package/dist/dts/Subscribable.d.ts +59 -0
- package/dist/dts/Subscribable.d.ts.map +1 -0
- package/dist/dts/SubscriptionRef.d.ts +2 -2
- package/dist/dts/SubscriptionRef.d.ts.map +1 -1
- package/dist/dts/TestAnnotation.d.ts.map +1 -1
- package/dist/dts/index.d.ts +14 -0
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/internal/errors.d.ts +5 -0
- package/dist/dts/internal/errors.d.ts.map +1 -0
- package/dist/esm/Duration.js +38 -1
- package/dist/esm/Duration.js.map +1 -1
- package/dist/esm/List.js +4 -3
- package/dist/esm/List.js.map +1 -1
- package/dist/esm/Readable.js +45 -0
- package/dist/esm/Readable.js.map +1 -0
- package/dist/esm/RegExp.js +17 -0
- package/dist/esm/RegExp.js.map +1 -0
- package/dist/esm/Subscribable.js +56 -0
- package/dist/esm/Subscribable.js.map +1 -0
- package/dist/esm/SubscriptionRef.js.map +1 -1
- package/dist/esm/TestAnnotation.js +2 -1
- package/dist/esm/TestAnnotation.js.map +1 -1
- package/dist/esm/index.js +14 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/internal/cause.js +3 -2
- package/dist/esm/internal/cause.js.map +1 -1
- package/dist/esm/internal/configProvider.js +2 -2
- package/dist/esm/internal/configProvider.js.map +1 -1
- package/dist/esm/internal/core-effect.js +25 -12
- package/dist/esm/internal/core-effect.js.map +1 -1
- package/dist/esm/internal/core.js +13 -82
- package/dist/esm/internal/core.js.map +1 -1
- package/dist/esm/internal/effect/circular.js +5 -0
- package/dist/esm/internal/effect/circular.js.map +1 -1
- package/dist/esm/internal/errors.js +6 -0
- package/dist/esm/internal/errors.js.map +1 -0
- package/dist/esm/internal/fiberRuntime.js +77 -36
- package/dist/esm/internal/fiberRuntime.js.map +1 -1
- package/dist/esm/internal/hashMap.js +1 -1
- package/dist/esm/internal/hashMap.js.map +1 -1
- package/dist/esm/internal/matcher.js +4 -3
- package/dist/esm/internal/matcher.js.map +1 -1
- package/dist/esm/internal/ref.js +6 -1
- package/dist/esm/internal/ref.js.map +1 -1
- package/dist/esm/internal/schedule/intervals.js +2 -1
- package/dist/esm/internal/schedule/intervals.js.map +1 -1
- package/dist/esm/internal/subscriptionRef.js +8 -0
- package/dist/esm/internal/subscriptionRef.js.map +1 -1
- package/dist/esm/internal/trie.js +1 -1
- package/dist/esm/internal/trie.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/package.json +25 -1
- package/src/Duration.ts +54 -1
- package/src/List.ts +5 -3
- package/src/Readable.ts +92 -0
- package/src/Ref.ts +2 -2
- package/src/RegExp.ts +17 -0
- package/src/Subscribable.ts +99 -0
- package/src/SubscriptionRef.ts +2 -2
- package/src/TestAnnotation.ts +2 -1
- package/src/index.ts +17 -0
- package/src/internal/cause.ts +3 -2
- package/src/internal/configProvider.ts +2 -3
- package/src/internal/core-effect.ts +78 -66
- package/src/internal/core.ts +13 -150
- package/src/internal/effect/circular.ts +7 -1
- package/src/internal/errors.ts +7 -0
- package/src/internal/fiberRuntime.ts +120 -86
- package/src/internal/hashMap.ts +1 -1
- package/src/internal/matcher.ts +5 -3
- package/src/internal/ref.ts +8 -2
- package/src/internal/schedule/intervals.ts +2 -1
- package/src/internal/subscriptionRef.ts +8 -0
- package/src/internal/trie.ts +1 -1
- package/src/internal/version.ts +1 -1
|
@@ -15,6 +15,7 @@ import * as MutableHashMap from "../../MutableHashMap.js"
|
|
|
15
15
|
import * as Option from "../../Option.js"
|
|
16
16
|
import { pipeArguments } from "../../Pipeable.js"
|
|
17
17
|
import * as Predicate from "../../Predicate.js"
|
|
18
|
+
import * as Readable from "../../Readable.js"
|
|
18
19
|
import type * as Ref from "../../Ref.js"
|
|
19
20
|
import type * as Schedule from "../../Schedule.js"
|
|
20
21
|
import { currentScheduler } from "../../Scheduler.js"
|
|
@@ -556,10 +557,15 @@ export const synchronizedVariance = {
|
|
|
556
557
|
class SynchronizedImpl<in out A> implements Synchronized.SynchronizedRef<A> {
|
|
557
558
|
readonly [SynchronizedTypeId] = synchronizedVariance
|
|
558
559
|
readonly [internalRef.RefTypeId] = internalRef.refVariance
|
|
560
|
+
readonly [Readable.TypeId]: Readable.TypeId
|
|
559
561
|
constructor(
|
|
560
562
|
readonly ref: Ref.Ref<A>,
|
|
561
563
|
readonly withLock: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
|
|
562
|
-
) {
|
|
564
|
+
) {
|
|
565
|
+
this[Readable.TypeId] = Readable.TypeId
|
|
566
|
+
this.get = internalRef.get(this.ref)
|
|
567
|
+
}
|
|
568
|
+
readonly get: Effect.Effect<A>
|
|
563
569
|
modify<B>(f: (a: A) => readonly [B, A]): Effect.Effect<B> {
|
|
564
570
|
return this.modifyEffect((a) => core.succeed(f(a)))
|
|
565
571
|
}
|
|
@@ -2668,7 +2668,7 @@ export const scopeWith = <A, E, R>(
|
|
|
2668
2668
|
|
|
2669
2669
|
/* @internal */
|
|
2670
2670
|
export const scopedEffect = <A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, Exclude<R, Scope.Scope>> =>
|
|
2671
|
-
core.flatMap(scopeMake(), (scope) => scopeUse(scope)
|
|
2671
|
+
core.flatMap(scopeMake(), (scope) => scopeUse(effect, scope))
|
|
2672
2672
|
|
|
2673
2673
|
/* @internal */
|
|
2674
2674
|
export const sequentialFinalizers = <A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> =>
|
|
@@ -2988,96 +2988,122 @@ export const withRuntimeFlagsScoped = (
|
|
|
2988
2988
|
)
|
|
2989
2989
|
}
|
|
2990
2990
|
|
|
2991
|
-
// circular with
|
|
2991
|
+
// circular with Scope
|
|
2992
|
+
|
|
2993
|
+
/** @internal */
|
|
2994
|
+
export const scopeTag = Context.GenericTag<Scope.Scope>("effect/Scope")
|
|
2992
2995
|
|
|
2993
2996
|
/* @internal */
|
|
2994
|
-
export const
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
2997
|
+
export const scope: Effect.Effect<Scope.Scope, never, Scope.Scope> = scopeTag
|
|
2998
|
+
|
|
2999
|
+
interface ScopeImpl extends Scope.CloseableScope {
|
|
3000
|
+
state: {
|
|
3001
|
+
readonly _tag: "Open"
|
|
3002
|
+
readonly finalizers: Set<Scope.Scope.Finalizer>
|
|
3003
|
+
} | {
|
|
3004
|
+
readonly _tag: "Closed"
|
|
3005
|
+
readonly exit: Exit.Exit<unknown, unknown>
|
|
3006
|
+
}
|
|
3007
|
+
}
|
|
3008
|
+
|
|
3009
|
+
const scopeUnsafeAddFinalizer = (scope: ScopeImpl, fin: Scope.Scope.Finalizer): void => {
|
|
3010
|
+
if (scope.state._tag === "Open") {
|
|
3011
|
+
scope.state.finalizers.add(fin)
|
|
3012
|
+
}
|
|
3013
|
+
}
|
|
3014
|
+
|
|
3015
|
+
const ScopeImplProto: Omit<ScopeImpl, "strategy" | "state"> = {
|
|
3016
|
+
[core.ScopeTypeId]: core.ScopeTypeId,
|
|
3017
|
+
[core.CloseableScopeTypeId]: core.CloseableScopeTypeId,
|
|
3018
|
+
pipe() {
|
|
3019
|
+
return pipeArguments(this, arguments)
|
|
3020
|
+
},
|
|
3021
|
+
fork(this: ScopeImpl, strategy) {
|
|
3022
|
+
return core.sync(() => {
|
|
3023
|
+
const newScope = scopeUnsafeMake(strategy)
|
|
3024
|
+
if (this.state._tag === "Closed") {
|
|
3025
|
+
newScope.state = this.state
|
|
3026
|
+
return newScope
|
|
3027
|
+
}
|
|
3028
|
+
const fin = (exit: Exit.Exit<unknown, unknown>) => newScope.close(exit)
|
|
3029
|
+
this.state.finalizers.add(fin)
|
|
3030
|
+
scopeUnsafeAddFinalizer(newScope, (_) =>
|
|
3031
|
+
core.sync(() => {
|
|
3032
|
+
if (this.state._tag === "Open") {
|
|
3033
|
+
this.state.finalizers.delete(fin)
|
|
3034
|
+
}
|
|
3035
|
+
}))
|
|
3036
|
+
return newScope
|
|
3037
|
+
})
|
|
3038
|
+
},
|
|
3039
|
+
close(this: ScopeImpl, exit) {
|
|
3040
|
+
return core.suspend(() => {
|
|
3041
|
+
if (this.state._tag === "Closed") {
|
|
3002
3042
|
return core.unit
|
|
3003
3043
|
}
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
Option.getOrElse(() => core.exitUnit)
|
|
3018
|
-
)
|
|
3044
|
+
const finalizers = Array.from(this.state.finalizers.values()).reverse()
|
|
3045
|
+
this.state = { _tag: "Closed", exit }
|
|
3046
|
+
if (finalizers.length === 0) {
|
|
3047
|
+
return core.unit
|
|
3048
|
+
}
|
|
3049
|
+
return executionStrategy.isSequential(this.strategy) ?
|
|
3050
|
+
pipe(
|
|
3051
|
+
core.forEachSequential(finalizers, (fin) => core.exit(fin(exit))),
|
|
3052
|
+
core.flatMap((results) =>
|
|
3053
|
+
pipe(
|
|
3054
|
+
core.exitCollectAll(results),
|
|
3055
|
+
Option.map(core.exitAsUnit),
|
|
3056
|
+
Option.getOrElse(() => core.exitUnit)
|
|
3019
3057
|
)
|
|
3020
|
-
)
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
)
|
|
3058
|
+
)
|
|
3059
|
+
) :
|
|
3060
|
+
executionStrategy.isParallel(this.strategy) ?
|
|
3061
|
+
pipe(
|
|
3062
|
+
forEachParUnbounded(finalizers, (fin) => core.exit(fin(exit)), false),
|
|
3063
|
+
core.flatMap((results) =>
|
|
3064
|
+
pipe(
|
|
3065
|
+
core.exitCollectAll(results, { parallel: true }),
|
|
3066
|
+
Option.map(core.exitAsUnit),
|
|
3067
|
+
Option.getOrElse(() => core.exitUnit)
|
|
3030
3068
|
)
|
|
3031
|
-
)
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
)
|
|
3069
|
+
)
|
|
3070
|
+
) :
|
|
3071
|
+
pipe(
|
|
3072
|
+
forEachParN(finalizers, this.strategy.parallelism, (fin) => core.exit(fin(exit)), false),
|
|
3073
|
+
core.flatMap((results) =>
|
|
3074
|
+
pipe(
|
|
3075
|
+
core.exitCollectAll(results, { parallel: true }),
|
|
3076
|
+
Option.map(core.exitAsUnit),
|
|
3077
|
+
Option.getOrElse(() => core.exitUnit)
|
|
3040
3078
|
)
|
|
3041
3079
|
)
|
|
3080
|
+
)
|
|
3081
|
+
})
|
|
3082
|
+
},
|
|
3083
|
+
addFinalizer(this: ScopeImpl, fin) {
|
|
3084
|
+
return core.suspend(() => {
|
|
3085
|
+
if (this.state._tag === "Closed") {
|
|
3086
|
+
return fin(this.state.exit)
|
|
3042
3087
|
}
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
/** @internal */
|
|
3049
|
-
export const scopeTag = Context.GenericTag<Scope.Scope>("effect/Scope")
|
|
3088
|
+
this.state.finalizers.add(fin)
|
|
3089
|
+
return core.unit
|
|
3090
|
+
})
|
|
3091
|
+
}
|
|
3092
|
+
}
|
|
3050
3093
|
|
|
3051
|
-
|
|
3052
|
-
|
|
3094
|
+
const scopeUnsafeMake = (
|
|
3095
|
+
strategy: ExecutionStrategy.ExecutionStrategy = executionStrategy.sequential
|
|
3096
|
+
): ScopeImpl => {
|
|
3097
|
+
const scope = Object.create(ScopeImplProto)
|
|
3098
|
+
scope.strategy = strategy
|
|
3099
|
+
scope.state = { _tag: "Open", finalizers: new Set() }
|
|
3100
|
+
return scope
|
|
3101
|
+
}
|
|
3053
3102
|
|
|
3054
3103
|
/* @internal */
|
|
3055
3104
|
export const scopeMake = (
|
|
3056
3105
|
strategy: ExecutionStrategy.ExecutionStrategy = executionStrategy.sequential
|
|
3057
|
-
): Effect.Effect<Scope.Scope.Closeable> =>
|
|
3058
|
-
core.map(core.releaseMapMake, (rm): Scope.Scope.Closeable => ({
|
|
3059
|
-
[core.ScopeTypeId]: core.ScopeTypeId,
|
|
3060
|
-
[core.CloseableScopeTypeId]: core.CloseableScopeTypeId,
|
|
3061
|
-
strategy,
|
|
3062
|
-
pipe() {
|
|
3063
|
-
return pipeArguments(this, arguments)
|
|
3064
|
-
},
|
|
3065
|
-
fork: (strategy) =>
|
|
3066
|
-
core.uninterruptible(
|
|
3067
|
-
pipe(
|
|
3068
|
-
scopeMake(strategy),
|
|
3069
|
-
core.flatMap((scope) =>
|
|
3070
|
-
pipe(
|
|
3071
|
-
core.releaseMapAdd(rm, (exit) => core.scopeClose(scope, exit)),
|
|
3072
|
-
core.tap((fin) => core.scopeAddFinalizerExit(scope, fin)),
|
|
3073
|
-
core.as(scope)
|
|
3074
|
-
)
|
|
3075
|
-
)
|
|
3076
|
-
)
|
|
3077
|
-
),
|
|
3078
|
-
close: (exit) => core.asUnit(releaseMapReleaseAll(strategy, exit)(rm)),
|
|
3079
|
-
addFinalizer: (fin) => core.asUnit(core.releaseMapAdd(fin)(rm))
|
|
3080
|
-
}))
|
|
3106
|
+
): Effect.Effect<Scope.Scope.Closeable> => core.sync(() => scopeUnsafeMake(strategy))
|
|
3081
3107
|
|
|
3082
3108
|
/* @internal */
|
|
3083
3109
|
export const scopeExtend = dual<
|
|
@@ -3552,15 +3578,23 @@ export const makeSpanScoped = (
|
|
|
3552
3578
|
readonly context?: Context.Context<never> | undefined
|
|
3553
3579
|
}
|
|
3554
3580
|
): Effect.Effect<Tracer.Span, never, Scope.Scope> =>
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
span.
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3581
|
+
core.uninterruptible(
|
|
3582
|
+
core.withFiberRuntime((fiber) => {
|
|
3583
|
+
const scope = Context.unsafeGet(fiber.getFiberRef(core.currentContext), scopeTag)
|
|
3584
|
+
const span = internalEffect.unsafeMakeSpan(fiber, name, options)
|
|
3585
|
+
const timingEnabled = fiber.getFiberRef(core.currentTracerTimingEnabled)
|
|
3586
|
+
const clock_ = Context.get(fiber.getFiberRef(defaultServices.currentServices), clock.clockTag)
|
|
3587
|
+
return core.as(
|
|
3588
|
+
core.scopeAddFinalizerExit(scope, (exit) =>
|
|
3589
|
+
core.sync(() => {
|
|
3590
|
+
if (span.status._tag === "Ended") {
|
|
3591
|
+
return
|
|
3592
|
+
}
|
|
3593
|
+
span.end(timingEnabled ? clock_.unsafeCurrentTimeNanos() : BigInt(0), exit)
|
|
3594
|
+
})),
|
|
3595
|
+
span
|
|
3596
|
+
)
|
|
3597
|
+
})
|
|
3564
3598
|
)
|
|
3565
3599
|
|
|
3566
3600
|
/* @internal */
|
package/src/internal/hashMap.ts
CHANGED
|
@@ -270,7 +270,7 @@ export const unsafeGet = Dual.dual<
|
|
|
270
270
|
>(2, (self, key) => {
|
|
271
271
|
const element = getHash(self, key, Hash.hash(key))
|
|
272
272
|
if (Option.isNone(element)) {
|
|
273
|
-
throw new Error("
|
|
273
|
+
throw new Error("Expected map to contain key")
|
|
274
274
|
}
|
|
275
275
|
return element.value
|
|
276
276
|
})
|
package/src/internal/matcher.ts
CHANGED
|
@@ -508,7 +508,7 @@ export const orElseAbsurd = <I, R, RA, A, Pr>(
|
|
|
508
508
|
self: Matcher<I, R, RA, A, Pr>
|
|
509
509
|
): [Pr] extends [never] ? (input: I) => Unify<A> : Unify<A> =>
|
|
510
510
|
orElse(() => {
|
|
511
|
-
throw new Error("absurd")
|
|
511
|
+
throw new Error("effect/Match/orElseAbsurd: absurd")
|
|
512
512
|
})(self)
|
|
513
513
|
|
|
514
514
|
/** @internal */
|
|
@@ -565,6 +565,8 @@ export const option: <I, F, R, A, Pr>(
|
|
|
565
565
|
})
|
|
566
566
|
}) as any
|
|
567
567
|
|
|
568
|
+
const getExhaustiveAbsurdErrorMessage = "effect/Match/exhaustive: absurd"
|
|
569
|
+
|
|
568
570
|
/** @internal */
|
|
569
571
|
export const exhaustive: <I, F, A, Pr>(
|
|
570
572
|
self: Matcher<I, F, never, A, Pr>
|
|
@@ -578,7 +580,7 @@ export const exhaustive: <I, F, A, Pr>(
|
|
|
578
580
|
return toEither.right
|
|
579
581
|
}
|
|
580
582
|
|
|
581
|
-
throw new Error(
|
|
583
|
+
throw new Error(getExhaustiveAbsurdErrorMessage)
|
|
582
584
|
}
|
|
583
585
|
|
|
584
586
|
return (u: I): A => {
|
|
@@ -589,6 +591,6 @@ export const exhaustive: <I, F, A, Pr>(
|
|
|
589
591
|
return result.right as any
|
|
590
592
|
}
|
|
591
593
|
|
|
592
|
-
throw new Error(
|
|
594
|
+
throw new Error(getExhaustiveAbsurdErrorMessage)
|
|
593
595
|
}
|
|
594
596
|
}) as any
|
package/src/internal/ref.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { dual } from "../Function.js"
|
|
|
3
3
|
import * as MutableRef from "../MutableRef.js"
|
|
4
4
|
import * as Option from "../Option.js"
|
|
5
5
|
import { pipeArguments } from "../Pipeable.js"
|
|
6
|
+
import * as Readable from "../Readable.js"
|
|
6
7
|
import type * as Ref from "../Ref.js"
|
|
7
8
|
import * as core from "./core.js"
|
|
8
9
|
|
|
@@ -17,7 +18,12 @@ export const refVariance = {
|
|
|
17
18
|
|
|
18
19
|
class RefImpl<in out A> implements Ref.Ref<A> {
|
|
19
20
|
readonly [RefTypeId] = refVariance
|
|
20
|
-
|
|
21
|
+
readonly [Readable.TypeId]: Readable.TypeId
|
|
22
|
+
constructor(readonly ref: MutableRef.MutableRef<A>) {
|
|
23
|
+
this[Readable.TypeId] = Readable.TypeId
|
|
24
|
+
this.get = core.sync(() => MutableRef.get(this.ref))
|
|
25
|
+
}
|
|
26
|
+
readonly get: Effect.Effect<A>
|
|
21
27
|
modify<B>(f: (a: A) => readonly [B, A]): Effect.Effect<B> {
|
|
22
28
|
return core.sync(() => {
|
|
23
29
|
const current = MutableRef.get(this.ref)
|
|
@@ -40,7 +46,7 @@ export const unsafeMake = <A>(value: A): Ref.Ref<A> => new RefImpl(MutableRef.ma
|
|
|
40
46
|
export const make = <A>(value: A): Effect.Effect<Ref.Ref<A>> => core.sync(() => unsafeMake(value))
|
|
41
47
|
|
|
42
48
|
/** @internal */
|
|
43
|
-
export const get = <A>(self: Ref.Ref<A>) => self.
|
|
49
|
+
export const get = <A>(self: Ref.Ref<A>) => self.get
|
|
44
50
|
|
|
45
51
|
/** @internal */
|
|
46
52
|
export const set = dual<
|
|
@@ -3,6 +3,7 @@ import { dual, pipe } from "../../Function.js"
|
|
|
3
3
|
import * as Option from "../../Option.js"
|
|
4
4
|
import * as Interval from "../../ScheduleInterval.js"
|
|
5
5
|
import type * as Intervals from "../../ScheduleIntervals.js"
|
|
6
|
+
import { getBugErrorMessage } from "../errors.js"
|
|
6
7
|
|
|
7
8
|
/** @internal */
|
|
8
9
|
const IntervalsSymbolKey = "effect/ScheduleIntervals"
|
|
@@ -109,7 +110,7 @@ const unionLoop = (
|
|
|
109
110
|
that = Chunk.tailNonEmpty(that)
|
|
110
111
|
}
|
|
111
112
|
} else {
|
|
112
|
-
throw new Error("
|
|
113
|
+
throw new Error(getBugErrorMessage("Intervals.unionLoop"))
|
|
113
114
|
}
|
|
114
115
|
}
|
|
115
116
|
return make(pipe(acc, Chunk.prepend(interval), Chunk.reverse))
|
|
@@ -2,8 +2,10 @@ import * as Effect from "../Effect.js"
|
|
|
2
2
|
import { dual, pipe } from "../Function.js"
|
|
3
3
|
import { pipeArguments } from "../Pipeable.js"
|
|
4
4
|
import * as PubSub from "../PubSub.js"
|
|
5
|
+
import * as Readable from "../Readable.js"
|
|
5
6
|
import * as Ref from "../Ref.js"
|
|
6
7
|
import type { Stream } from "../Stream.js"
|
|
8
|
+
import * as Subscribable from "../Subscribable.js"
|
|
7
9
|
import type * as SubscriptionRef from "../SubscriptionRef.js"
|
|
8
10
|
import * as Synchronized from "../SynchronizedRef.js"
|
|
9
11
|
import * as _circular from "./effect/circular.js"
|
|
@@ -25,6 +27,8 @@ const subscriptionRefVariance = {
|
|
|
25
27
|
|
|
26
28
|
/** @internal */
|
|
27
29
|
class SubscriptionRefImpl<in out A> implements SubscriptionRef.SubscriptionRef<A> {
|
|
30
|
+
readonly [Readable.TypeId]: Readable.TypeId
|
|
31
|
+
readonly [Subscribable.TypeId]: Subscribable.TypeId
|
|
28
32
|
readonly [Ref.RefTypeId] = _ref.refVariance
|
|
29
33
|
readonly [Synchronized.SynchronizedRefTypeId] = _circular.synchronizedVariance
|
|
30
34
|
readonly [SubscriptionRefTypeId] = subscriptionRefVariance
|
|
@@ -33,10 +37,14 @@ class SubscriptionRefImpl<in out A> implements SubscriptionRef.SubscriptionRef<A
|
|
|
33
37
|
readonly pubsub: PubSub.PubSub<A>,
|
|
34
38
|
readonly semaphore: Effect.Semaphore
|
|
35
39
|
) {
|
|
40
|
+
this[Readable.TypeId] = Readable.TypeId
|
|
41
|
+
this[Subscribable.TypeId] = Subscribable.TypeId
|
|
42
|
+
this.get = Ref.get(this.ref)
|
|
36
43
|
}
|
|
37
44
|
pipe() {
|
|
38
45
|
return pipeArguments(this, arguments)
|
|
39
46
|
}
|
|
47
|
+
readonly get: Effect.Effect<A>
|
|
40
48
|
get changes(): Stream<A> {
|
|
41
49
|
return pipe(
|
|
42
50
|
Ref.get(this.ref),
|
package/src/internal/trie.ts
CHANGED
|
@@ -420,7 +420,7 @@ export const unsafeGet = dual<
|
|
|
420
420
|
>(2, (self, key) => {
|
|
421
421
|
const element = get(self, key)
|
|
422
422
|
if (Option.isNone(element)) {
|
|
423
|
-
throw new Error("
|
|
423
|
+
throw new Error("Expected trie to contain key")
|
|
424
424
|
}
|
|
425
425
|
return element.value
|
|
426
426
|
})
|
package/src/internal/version.ts
CHANGED