synstate 3.0.4 → 3.0.5
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/core/base/create-child-observable.d.mts.map +1 -1
- package/dist/core/base/create-child-observable.mjs +7 -3
- package/dist/core/base/create-child-observable.mjs.map +1 -1
- package/dist/core/base/create-observable-base.d.mts +2 -1
- package/dist/core/base/create-observable-base.d.mts.map +1 -1
- package/dist/core/base/create-observable-base.mjs +5 -2
- package/dist/core/base/create-observable-base.mjs.map +1 -1
- package/dist/core/base/create-root-observable.d.mts.map +1 -1
- package/dist/core/base/create-root-observable.mjs.map +1 -1
- package/dist/core/combine/combine.d.mts.map +1 -1
- package/dist/core/combine/combine.mjs +7 -4
- package/dist/core/combine/combine.mjs.map +1 -1
- package/dist/core/combine/merge.d.mts.map +1 -1
- package/dist/core/combine/merge.mjs +4 -1
- package/dist/core/combine/merge.mjs.map +1 -1
- package/dist/core/combine/zip.d.mts.map +1 -1
- package/dist/core/combine/zip.mjs +8 -5
- package/dist/core/combine/zip.mjs.map +1 -1
- package/dist/core/create/from-abortable-promise.d.mts.map +1 -1
- package/dist/core/create/from-abortable-promise.mjs +6 -2
- package/dist/core/create/from-abortable-promise.mjs.map +1 -1
- package/dist/core/create/from-promise.d.mts.map +1 -1
- package/dist/core/create/from-promise.mjs +5 -2
- package/dist/core/create/from-promise.mjs.map +1 -1
- package/dist/core/create/from-subscribable.d.mts.map +1 -1
- package/dist/core/create/from-subscribable.mjs +1 -0
- package/dist/core/create/from-subscribable.mjs.map +1 -1
- package/dist/core/create/just.d.mts.map +1 -1
- package/dist/core/create/just.mjs +1 -0
- package/dist/core/create/just.mjs.map +1 -1
- package/dist/core/create/source.mjs +2 -1
- package/dist/core/create/source.mjs.map +1 -1
- package/dist/core/operators/audit.d.mts.map +1 -1
- package/dist/core/operators/audit.mjs +3 -1
- package/dist/core/operators/audit.mjs.map +1 -1
- package/dist/core/operators/debounce.d.mts.map +1 -1
- package/dist/core/operators/debounce.mjs +3 -1
- package/dist/core/operators/debounce.mjs.map +1 -1
- package/dist/core/operators/map.d.mts.map +1 -1
- package/dist/core/operators/map.mjs +1 -0
- package/dist/core/operators/map.mjs.map +1 -1
- package/dist/core/operators/skip-if-no-change.d.mts.map +1 -1
- package/dist/core/operators/skip-if-no-change.mjs +1 -0
- package/dist/core/operators/skip-if-no-change.mjs.map +1 -1
- package/dist/core/operators/take-until.d.mts.map +1 -1
- package/dist/core/operators/take-until.mjs +1 -0
- package/dist/core/operators/take-until.mjs.map +1 -1
- package/dist/core/operators/throttle.d.mts.map +1 -1
- package/dist/core/operators/throttle.mjs +1 -0
- package/dist/core/operators/throttle.mjs.map +1 -1
- package/dist/core/operators/with-buffered-from.d.mts.map +1 -1
- package/dist/core/operators/with-buffered-from.mjs +1 -0
- package/dist/core/operators/with-buffered-from.mjs.map +1 -1
- package/dist/core/operators/with-current-value-from.mjs +2 -1
- package/dist/core/operators/with-current-value-from.mjs.map +1 -1
- package/dist/core/predefined/operators/unwrap-optional.d.mts.map +1 -1
- package/dist/core/predefined/operators/unwrap-optional.mjs +1 -0
- package/dist/core/predefined/operators/unwrap-optional.mjs.map +1 -1
- package/dist/core/predefined/operators/unwrap-result-ok.d.mts.map +1 -1
- package/dist/core/predefined/operators/unwrap-result-ok.mjs +1 -0
- package/dist/core/predefined/operators/unwrap-result-ok.mjs.map +1 -1
- package/dist/core/types/observable.d.mts +1 -1
- package/dist/core/types/observable.d.mts.map +1 -1
- package/dist/core/types/observable.mjs +5 -0
- package/dist/core/types/observable.mjs.map +1 -1
- package/dist/core/utils/id-maker.d.mts.map +1 -1
- package/dist/core/utils/id-maker.mjs +1 -0
- package/dist/core/utils/id-maker.mjs.map +1 -1
- package/dist/core/utils/utils.d.mts.map +1 -1
- package/dist/core/utils/utils.mjs +5 -2
- package/dist/core/utils/utils.mjs.map +1 -1
- package/package.json +36 -38
- package/src/core/base/circular-dependency-comparison.test.mts +5 -6
- package/src/core/base/circular-dependency.test.mts +20 -21
- package/src/core/base/create-child-observable.mts +10 -3
- package/src/core/base/create-observable-base.mts +12 -4
- package/src/core/base/create-root-observable.mts +2 -0
- package/src/core/combine/combine.mts +13 -8
- package/src/core/combine/merge.mts +5 -1
- package/src/core/combine/zip.mts +12 -8
- package/src/core/create/from-abortable-promise.mts +8 -2
- package/src/core/create/from-promise.mts +7 -2
- package/src/core/create/from-subscribable.mts +1 -0
- package/src/core/create/just.mts +1 -0
- package/src/core/create/source.mts +3 -1
- package/src/core/operators/audit.mts +4 -1
- package/src/core/operators/debounce.mts +4 -1
- package/src/core/operators/map.mts +1 -0
- package/src/core/operators/skip-if-no-change.mts +1 -0
- package/src/core/operators/take-until.mts +1 -0
- package/src/core/operators/throttle.mts +1 -0
- package/src/core/operators/with-buffered-from.mts +1 -0
- package/src/core/operators/with-current-value-from.mts +3 -1
- package/src/core/predefined/operators/unwrap-optional.mts +1 -0
- package/src/core/predefined/operators/unwrap-result-ok.mts +1 -0
- package/src/core/types/observable.mts +11 -1
- package/src/core/utils/id-maker.mts +1 -0
- package/src/core/utils/utils.mts +7 -2
|
@@ -130,7 +130,9 @@ export const createObservableBaseHandle = <A,>(
|
|
|
130
130
|
};
|
|
131
131
|
|
|
132
132
|
const completeBase = (): void => {
|
|
133
|
-
if (mut_isCompleted)
|
|
133
|
+
if (mut_isCompleted) {
|
|
134
|
+
return; // terminate only once
|
|
135
|
+
}
|
|
134
136
|
|
|
135
137
|
// change state
|
|
136
138
|
mut_isCompleted = true;
|
|
@@ -220,7 +222,9 @@ export const createManagerObservableParts = <A,>(
|
|
|
220
222
|
const mut_descendantsIdSet: MutableSet<ObservableId> = new Set();
|
|
221
223
|
|
|
222
224
|
const addDescendant = <B,>(child: ChildObservable<B>): void => {
|
|
223
|
-
if (mut_descendantsIdSet.has(child.id))
|
|
225
|
+
if (mut_descendantsIdSet.has(child.id)) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
224
228
|
|
|
225
229
|
mut_descendantsIdSet.add(child.id);
|
|
226
230
|
|
|
@@ -270,7 +274,7 @@ type AssembleObservableArgs<
|
|
|
270
274
|
Extra extends ReadonlyRecord<string, unknown>,
|
|
271
275
|
> = Readonly<{
|
|
272
276
|
kind: Kind;
|
|
273
|
-
depth: number;
|
|
277
|
+
depth: Kind extends 'root' ? 0 : number;
|
|
274
278
|
handle: ObservableBaseHandle<A>;
|
|
275
279
|
tryUpdate: (updateToken: UpdateToken) => void;
|
|
276
280
|
tryComplete: () => void;
|
|
@@ -305,7 +309,10 @@ export const assembleObservable = <
|
|
|
305
309
|
extra,
|
|
306
310
|
}: AssembleObservableArgs<A, Kind, Extra>): Extra &
|
|
307
311
|
ObservableBase<A> &
|
|
308
|
-
Readonly<{
|
|
312
|
+
Readonly<{
|
|
313
|
+
kind: Kind;
|
|
314
|
+
depth: AssembleObservableArgs<A, Kind, Extra>['depth'];
|
|
315
|
+
}> => {
|
|
309
316
|
function pipe<B>(
|
|
310
317
|
operator: WithInitialValueOperator<A, B>,
|
|
311
318
|
): InitializedObservable<B>;
|
|
@@ -314,6 +321,7 @@ export const assembleObservable = <
|
|
|
314
321
|
|
|
315
322
|
function pipe<B>(operator: Operator<A, B>): Observable<B> {
|
|
316
323
|
return operator(
|
|
324
|
+
// @sumi-expect-error banned-syntax/no-unsafe-type-assertion
|
|
317
325
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
318
326
|
observable as unknown as InitializedObservable<A>,
|
|
319
327
|
);
|
|
@@ -47,6 +47,8 @@ export type RootObservableConfig<A> = Readonly<{
|
|
|
47
47
|
*/
|
|
48
48
|
export const createRootObservable = <
|
|
49
49
|
A,
|
|
50
|
+
// The default is deliberately empty: a root leaf without `init` adds no members.
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-generated-empty-object-type
|
|
50
52
|
Extension extends ReadonlyRecord<string, unknown> = ReadonlyRecord<
|
|
51
53
|
never,
|
|
52
54
|
never
|
|
@@ -74,6 +74,7 @@ import {
|
|
|
74
74
|
export const combine = <const OS extends NonEmptyTuple<Observable<unknown>>>(
|
|
75
75
|
parents: OS,
|
|
76
76
|
): CombineObservableRefined<OS> =>
|
|
77
|
+
// @sumi-expect-error banned-syntax/no-unsafe-type-assertion
|
|
77
78
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
78
79
|
createCombineObservable(parents) as unknown as CombineObservableRefined<OS>;
|
|
79
80
|
|
|
@@ -113,7 +114,9 @@ const createCombineObservable = <const A extends NonEmptyUnknownList>(
|
|
|
113
114
|
},
|
|
114
115
|
({ setNext }) =>
|
|
115
116
|
(updateToken) => {
|
|
116
|
-
if (parents.every((o) => o.updateToken !== updateToken))
|
|
117
|
+
if (parents.every((o) => o.updateToken !== updateToken)) {
|
|
118
|
+
return; // all parents are skipped
|
|
119
|
+
}
|
|
117
120
|
|
|
118
121
|
// Same shape-preserving chain as the initial value: `Arr.map` (not the
|
|
119
122
|
// native one, which drops the tuple shape) into the uniform
|
|
@@ -123,14 +126,16 @@ const createCombineObservable = <const A extends NonEmptyUnknownList>(
|
|
|
123
126
|
(a) => a.getSnapshot(),
|
|
124
127
|
);
|
|
125
128
|
|
|
126
|
-
if (Arr.every(parentValues, Optional.isSome)) {
|
|
127
|
-
|
|
128
|
-
parentValues,
|
|
129
|
-
(a) => a.value,
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
setNext(nextValue, updateToken);
|
|
129
|
+
if (!Arr.every(parentValues, Optional.isSome)) {
|
|
130
|
+
return;
|
|
133
131
|
}
|
|
132
|
+
|
|
133
|
+
const nextValue: Readonly<{ [K in keyof A]: A[K] }> = Arr.map(
|
|
134
|
+
parentValues,
|
|
135
|
+
(a) => a.value,
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
setNext(nextValue, updateToken);
|
|
134
139
|
},
|
|
135
140
|
);
|
|
136
141
|
};
|
|
@@ -65,6 +65,7 @@ import {
|
|
|
65
65
|
export const merge = <const OS extends NonEmptyTuple<Observable<unknown>>>(
|
|
66
66
|
parents: OS,
|
|
67
67
|
): MergeObservableRefined<OS> =>
|
|
68
|
+
// @sumi-expect-error banned-syntax/no-unsafe-type-assertion
|
|
68
69
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
69
70
|
createMergeObservable(parents) as MergeObservableRefined<OS>;
|
|
70
71
|
|
|
@@ -83,9 +84,12 @@ const createMergeObservable = <const P extends NonEmptyUnknownList>(
|
|
|
83
84
|
o.updateToken === updateToken && Optional.isSome(o.getSnapshot()),
|
|
84
85
|
);
|
|
85
86
|
|
|
86
|
-
if (parentToUse === undefined)
|
|
87
|
+
if (parentToUse === undefined) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
87
90
|
|
|
88
91
|
const nextValue =
|
|
92
|
+
// @sumi-expect-error banned-syntax/no-unsafe-type-assertion
|
|
89
93
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
90
94
|
Optional.unwrap(parentToUse.getSnapshot()) as ArrayElement<P>;
|
|
91
95
|
|
package/src/core/combine/zip.mts
CHANGED
|
@@ -67,6 +67,7 @@ import {
|
|
|
67
67
|
export const zip = <const OS extends NonEmptyTuple<Observable<unknown>>>(
|
|
68
68
|
parents: OS,
|
|
69
69
|
): ZipObservableRefined<OS> =>
|
|
70
|
+
// @sumi-expect-error banned-syntax/no-unsafe-type-assertion
|
|
70
71
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
71
72
|
createZipObservable(parents) as unknown as ZipObservableRefined<OS>;
|
|
72
73
|
|
|
@@ -110,15 +111,18 @@ const createZipObservable = <const A extends NonEmptyUnknownList>(
|
|
|
110
111
|
}
|
|
111
112
|
}
|
|
112
113
|
|
|
113
|
-
if (queues.
|
|
114
|
-
|
|
115
|
-
// `Arr.map` has a single result element type, so it reports
|
|
116
|
-
// `A[number] | undefined` per position rather than `A[P]`.
|
|
117
|
-
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
118
|
-
Arr.map(queues, (q) => Optional.unwrap(q.dequeue())) as A;
|
|
119
|
-
|
|
120
|
-
setNext(nextValue, updateToken);
|
|
114
|
+
if (queues.some((list) => list.isEmpty)) {
|
|
115
|
+
return;
|
|
121
116
|
}
|
|
117
|
+
|
|
118
|
+
const nextValue =
|
|
119
|
+
// `Arr.map` has a single result element type, so it reports
|
|
120
|
+
// `A[number] | undefined` per position rather than `A[P]`.
|
|
121
|
+
// @sumi-expect-error banned-syntax/no-unsafe-type-assertion
|
|
122
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
123
|
+
Arr.map(queues, (q) => Optional.unwrap(q.dequeue())) as A;
|
|
124
|
+
|
|
125
|
+
setNext(nextValue, updateToken);
|
|
122
126
|
},
|
|
123
127
|
);
|
|
124
128
|
};
|
|
@@ -70,6 +70,7 @@ import { type FromPromiseObservable } from '../types/index.mjs';
|
|
|
70
70
|
* ```
|
|
71
71
|
*/
|
|
72
72
|
export const fromAbortablePromise = <A, E = unknown>(
|
|
73
|
+
// @sumi-expect-error readonly/require-readonly-parameter
|
|
73
74
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
74
75
|
factory: (signal: AbortSignal) => Promise<A>,
|
|
75
76
|
): FromPromiseObservable<A, E> => {
|
|
@@ -87,12 +88,16 @@ export const fromAbortablePromise = <A, E = unknown>(
|
|
|
87
88
|
|
|
88
89
|
promise
|
|
89
90
|
.then((value) => {
|
|
90
|
-
if (isCompleted())
|
|
91
|
+
if (isCompleted()) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
91
94
|
|
|
92
95
|
startUpdate(Result.ok(value));
|
|
93
96
|
})
|
|
94
97
|
.catch((error: unknown) => {
|
|
95
|
-
if (isCompleted())
|
|
98
|
+
if (isCompleted()) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
96
101
|
|
|
97
102
|
// Silently ignore AbortError — it means the observable was
|
|
98
103
|
// intentionally completed (e.g., by switchMap).
|
|
@@ -102,6 +107,7 @@ export const fromAbortablePromise = <A, E = unknown>(
|
|
|
102
107
|
|
|
103
108
|
startUpdate(
|
|
104
109
|
Result.err(
|
|
110
|
+
// @sumi-expect-error banned-syntax/no-unsafe-type-assertion
|
|
105
111
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
106
112
|
error as E,
|
|
107
113
|
),
|
|
@@ -57,15 +57,20 @@ export const fromPromise = <A, E = unknown>(
|
|
|
57
57
|
({ startUpdate, isCompleted, complete }) => {
|
|
58
58
|
promise
|
|
59
59
|
.then((value) => {
|
|
60
|
-
if (isCompleted())
|
|
60
|
+
if (isCompleted()) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
61
63
|
|
|
62
64
|
startUpdate(Result.ok(value));
|
|
63
65
|
})
|
|
64
66
|
.catch((error: unknown) => {
|
|
65
|
-
if (isCompleted())
|
|
67
|
+
if (isCompleted()) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
66
70
|
|
|
67
71
|
startUpdate(
|
|
68
72
|
Result.err(
|
|
73
|
+
// @sumi-expect-error banned-syntax/no-unsafe-type-assertion
|
|
69
74
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
70
75
|
error as E,
|
|
71
76
|
),
|
|
@@ -76,6 +76,7 @@ export const fromSubscribable = <A, E = unknown>(
|
|
|
76
76
|
(error?: unknown) => {
|
|
77
77
|
startUpdate(
|
|
78
78
|
Result.err(
|
|
79
|
+
// @sumi-expect-error banned-syntax/no-unsafe-type-assertion
|
|
79
80
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
80
81
|
error as E,
|
|
81
82
|
),
|
package/src/core/create/just.mts
CHANGED
|
@@ -39,6 +39,7 @@ export const just = <const A,>(value: A): InitializedRootObservable<A> => {
|
|
|
39
39
|
|
|
40
40
|
obs.complete();
|
|
41
41
|
|
|
42
|
+
// @sumi-expect-error banned-syntax/no-unsafe-type-assertion
|
|
42
43
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
43
44
|
return obs as InitializedRootObservable<A>;
|
|
44
45
|
};
|
|
@@ -59,7 +59,9 @@ export function source<const A>(...args: readonly A[]): SourceObservable<A> {
|
|
|
59
59
|
},
|
|
60
60
|
({ startUpdate, isCompleted }) => ({
|
|
61
61
|
next: (nextValue: A) => {
|
|
62
|
-
if (isCompleted())
|
|
62
|
+
if (isCompleted()) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
63
65
|
|
|
64
66
|
startUpdate(nextValue);
|
|
65
67
|
},
|
|
@@ -104,6 +104,7 @@ import {
|
|
|
104
104
|
export const audit = <A,>(
|
|
105
105
|
milliSeconds: number,
|
|
106
106
|
): KeepInitialValueOperator<A, A> =>
|
|
107
|
+
// @sumi-expect-error banned-syntax/no-unsafe-type-assertion
|
|
107
108
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
108
109
|
((parentObservable) =>
|
|
109
110
|
createAuditObservable(
|
|
@@ -147,7 +148,9 @@ const createAuditObservable = <A,>(
|
|
|
147
148
|
mut_timerId = setTimeout(() => {
|
|
148
149
|
const sn = parentObservable.getSnapshot();
|
|
149
150
|
|
|
150
|
-
if (Optional.isNone(sn))
|
|
151
|
+
if (Optional.isNone(sn)) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
151
154
|
|
|
152
155
|
startUpdate(sn.value);
|
|
153
156
|
|
|
@@ -95,6 +95,7 @@ import {
|
|
|
95
95
|
export const debounce = <A,>(
|
|
96
96
|
milliSeconds: number,
|
|
97
97
|
): KeepInitialValueOperator<A, A> =>
|
|
98
|
+
// @sumi-expect-error banned-syntax/no-unsafe-type-assertion
|
|
98
99
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
99
100
|
((parentObservable) =>
|
|
100
101
|
createDebounceObservable(
|
|
@@ -135,7 +136,9 @@ const createDebounceObservable = <A,>(
|
|
|
135
136
|
|
|
136
137
|
// set timer
|
|
137
138
|
mut_timerId = setTimeout(() => {
|
|
138
|
-
if (Optional.isNone(sn))
|
|
139
|
+
if (Optional.isNone(sn)) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
139
142
|
|
|
140
143
|
startUpdate(sn.value);
|
|
141
144
|
}, milliSeconds);
|
|
@@ -50,6 +50,7 @@ import { withInitialValue } from './with-initial-value.mjs';
|
|
|
50
50
|
export const map = <A, B>(
|
|
51
51
|
mapFn: (x: A, index: SafeUint | -1) => B,
|
|
52
52
|
): KeepInitialValueOperator<A, B> =>
|
|
53
|
+
// @sumi-expect-error banned-syntax/no-unsafe-type-assertion
|
|
53
54
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
54
55
|
((parentObservable) =>
|
|
55
56
|
createMapObservable(parentObservable, mapFn)) as KeepInitialValueOperator<
|
|
@@ -70,6 +70,7 @@ import {
|
|
|
70
70
|
export const skipIfNoChange = <A,>(
|
|
71
71
|
eq: (x: A, y: A) => boolean = (x, y) => Object.is(x, y),
|
|
72
72
|
): KeepInitialValueOperator<A, A> =>
|
|
73
|
+
// @sumi-expect-error banned-syntax/no-unsafe-type-assertion
|
|
73
74
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
74
75
|
((parentObservable) =>
|
|
75
76
|
createSkipIfNoChangeObservable(
|
|
@@ -57,6 +57,7 @@ import {
|
|
|
57
57
|
export const takeUntil = <A,>(
|
|
58
58
|
notifier: Observable<unknown>,
|
|
59
59
|
): KeepInitialValueOperator<A, A> =>
|
|
60
|
+
// @sumi-expect-error banned-syntax/no-unsafe-type-assertion
|
|
60
61
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
61
62
|
((parentObservable) =>
|
|
62
63
|
createTakeUntilObservable(
|
|
@@ -88,6 +88,7 @@ import {
|
|
|
88
88
|
export const throttle = <A,>(
|
|
89
89
|
milliSeconds: number,
|
|
90
90
|
): KeepInitialValueOperator<A, A> =>
|
|
91
|
+
// @sumi-expect-error banned-syntax/no-unsafe-type-assertion
|
|
91
92
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
92
93
|
((parentObservable) =>
|
|
93
94
|
createThrottleObservable(
|
|
@@ -63,6 +63,7 @@ import { maxDepth } from '../utils/index.mjs';
|
|
|
63
63
|
export const withBufferedFrom = <A, B>(
|
|
64
64
|
observable: Observable<B>,
|
|
65
65
|
): KeepInitialValueOperator<A, readonly [A, readonly B[]]> =>
|
|
66
|
+
// @sumi-expect-error banned-syntax/no-unsafe-type-assertion
|
|
66
67
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
67
68
|
((parentObservable) =>
|
|
68
69
|
createWithBufferedFromObservable(
|
|
@@ -106,7 +106,9 @@ const createWithCurrentValueFromObservable = <A, B>(
|
|
|
106
106
|
|
|
107
107
|
const curr = observable.getSnapshot();
|
|
108
108
|
|
|
109
|
-
if (Optional.isNone(curr))
|
|
109
|
+
if (Optional.isNone(curr)) {
|
|
110
|
+
return; // skip update
|
|
111
|
+
}
|
|
110
112
|
|
|
111
113
|
setNext([ps.value, curr.value], updateToken);
|
|
112
114
|
},
|
|
@@ -46,5 +46,6 @@ import { type KeepInitialValueOperator } from '../../types/index.mjs';
|
|
|
46
46
|
export const unwrapOptional = <
|
|
47
47
|
O extends UnknownOptional,
|
|
48
48
|
>(): KeepInitialValueOperator<O, Optional.Unwrap<O> | undefined> =>
|
|
49
|
+
// @sumi-expect-error banned-syntax/no-unsafe-type-assertion
|
|
49
50
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
50
51
|
map(Optional.unwrap as Fn<O, Optional.Unwrap<O> | undefined>);
|
|
@@ -46,5 +46,6 @@ import { type KeepInitialValueOperator } from '../../types/index.mjs';
|
|
|
46
46
|
export const unwrapResultOk = <
|
|
47
47
|
R extends UnknownResult,
|
|
48
48
|
>(): KeepInitialValueOperator<R, Result.UnwrapOk<R> | undefined> =>
|
|
49
|
+
// @sumi-expect-error banned-syntax/no-unsafe-type-assertion
|
|
49
50
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
50
51
|
map(Result.unwrapOk as Fn<R, Result.UnwrapOk<R> | undefined>);
|
|
@@ -23,7 +23,7 @@ type CreateObservableType<A, Kind extends ObservableKind> = Readonly<{
|
|
|
23
23
|
kind: Kind;
|
|
24
24
|
|
|
25
25
|
// reactive dependency tree structure
|
|
26
|
-
depth:
|
|
26
|
+
depth: Kind extends 'root' ? 0 : number;
|
|
27
27
|
addChild: <B>(child: ChildObservable<B>) => void;
|
|
28
28
|
|
|
29
29
|
// state
|
|
@@ -193,6 +193,16 @@ expectType<keyof AsyncChildObservable<unknown>, 'addDescendant'>('>=');
|
|
|
193
193
|
|
|
194
194
|
expectType<keyof RootObservable<unknown>, 'addDescendant'>('>=');
|
|
195
195
|
|
|
196
|
+
expectType<RootObservable<unknown>['depth'], 0>('=');
|
|
197
|
+
|
|
198
|
+
expectType<InitializedRootObservable<unknown>['depth'], 0>('=');
|
|
199
|
+
|
|
200
|
+
expectType<SyncChildObservable<unknown>['depth'], number>('=');
|
|
201
|
+
|
|
202
|
+
expectType<AsyncChildObservable<unknown>['depth'], number>('=');
|
|
203
|
+
|
|
204
|
+
expectType<ObservableBase<unknown>['depth'], number>('=');
|
|
205
|
+
|
|
196
206
|
expectType<Unwrap<Wrap<readonly [1, 2, 3]>>, readonly [1, 2, 3]>('=');
|
|
197
207
|
|
|
198
208
|
expectType<number, ObservableValue<Observable<number>>>('<=');
|
|
@@ -8,6 +8,7 @@ function* idMaker<T extends symbol>(): Generator<T, T, T> {
|
|
|
8
8
|
let mut_i = 0;
|
|
9
9
|
|
|
10
10
|
while (true) {
|
|
11
|
+
// @sumi-expect-error banned-syntax/no-unsafe-type-assertion
|
|
11
12
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
12
13
|
yield Symbol(mut_i.toString()) as T;
|
|
13
14
|
|
package/src/core/utils/utils.mts
CHANGED
|
@@ -34,9 +34,13 @@ export const binarySearch = <N extends number>(
|
|
|
34
34
|
while (mut_left <= mut_right) {
|
|
35
35
|
const curr = sortedArray[mut_mid];
|
|
36
36
|
|
|
37
|
-
if (x === curr)
|
|
37
|
+
if (x === curr) {
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
38
40
|
|
|
39
|
-
if (curr === undefined)
|
|
41
|
+
if (curr === undefined) {
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
40
44
|
|
|
41
45
|
if (curr > x) {
|
|
42
46
|
mut_right = SafeInt.sub(mut_mid, 1);
|
|
@@ -47,6 +51,7 @@ export const binarySearch = <N extends number>(
|
|
|
47
51
|
mut_mid = SafeInt.add(mut_left, halfInt(SafeInt.sub(mut_right, mut_left)));
|
|
48
52
|
}
|
|
49
53
|
|
|
54
|
+
// @sumi-expect-error banned-syntax/no-unsafe-type-assertion
|
|
50
55
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
51
56
|
return mut_mid as NegativeInt32 | Uint32;
|
|
52
57
|
};
|