synstate 3.0.6 → 3.2.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/README.md +59 -1
- package/dist/core/base/create-child-observable.d.mts.map +1 -1
- package/dist/core/base/create-child-observable.mjs +0 -1
- package/dist/core/base/create-child-observable.mjs.map +1 -1
- package/dist/core/base/create-observable-base.d.mts +2 -2
- package/dist/core/base/create-observable-base.d.mts.map +1 -1
- package/dist/core/base/create-observable-base.mjs +0 -1
- package/dist/core/base/create-observable-base.mjs.map +1 -1
- package/dist/core/base/create-root-observable.d.mts +1 -1
- package/dist/core/base/create-root-observable.d.mts.map +1 -1
- package/dist/core/combine/combine.d.mts +2 -2
- package/dist/core/combine/combine.d.mts.map +1 -1
- package/dist/core/combine/combine.mjs +0 -1
- package/dist/core/combine/combine.mjs.map +1 -1
- package/dist/core/combine/merge.d.mts +2 -2
- package/dist/core/combine/merge.d.mts.map +1 -1
- package/dist/core/combine/merge.mjs +0 -2
- package/dist/core/combine/merge.mjs.map +1 -1
- package/dist/core/combine/zip.d.mts +2 -2
- package/dist/core/combine/zip.d.mts.map +1 -1
- package/dist/core/combine/zip.mjs +0 -2
- package/dist/core/combine/zip.mjs.map +1 -1
- package/dist/core/create/counter.d.mts +11 -3
- package/dist/core/create/counter.d.mts.map +1 -1
- package/dist/core/create/counter.mjs +17 -7
- package/dist/core/create/counter.mjs.map +1 -1
- package/dist/core/create/from-abortable-promise.d.mts +1 -1
- package/dist/core/create/from-abortable-promise.d.mts.map +1 -1
- package/dist/core/create/from-abortable-promise.mjs +0 -2
- package/dist/core/create/from-abortable-promise.mjs.map +1 -1
- package/dist/core/create/from-promise.d.mts +1 -1
- package/dist/core/create/from-promise.d.mts.map +1 -1
- package/dist/core/create/from-promise.mjs +0 -1
- package/dist/core/create/from-promise.mjs.map +1 -1
- package/dist/core/create/from-subscribable.d.mts +1 -1
- package/dist/core/create/from-subscribable.d.mts.map +1 -1
- package/dist/core/create/from-subscribable.mjs +0 -1
- package/dist/core/create/from-subscribable.mjs.map +1 -1
- package/dist/core/create/just.d.mts +1 -1
- package/dist/core/create/just.d.mts.map +1 -1
- package/dist/core/create/just.mjs +0 -1
- package/dist/core/create/just.mjs.map +1 -1
- package/dist/core/create/source.d.mts +1 -1
- package/dist/core/create/source.d.mts.map +1 -1
- package/dist/core/create/timer.d.mts +1 -1
- package/dist/core/create/timer.d.mts.map +1 -1
- package/dist/core/operators/audit.d.mts +1 -1
- package/dist/core/operators/audit.d.mts.map +1 -1
- package/dist/core/operators/audit.mjs +0 -1
- package/dist/core/operators/audit.mjs.map +1 -1
- package/dist/core/operators/debounce.d.mts +1 -1
- package/dist/core/operators/debounce.d.mts.map +1 -1
- package/dist/core/operators/debounce.mjs +0 -1
- package/dist/core/operators/debounce.mjs.map +1 -1
- package/dist/core/operators/filter.d.mts +1 -1
- package/dist/core/operators/filter.d.mts.map +1 -1
- package/dist/core/operators/filter.mjs +19 -0
- package/dist/core/operators/filter.mjs.map +1 -1
- package/dist/core/operators/map.d.mts +1 -1
- package/dist/core/operators/map.d.mts.map +1 -1
- package/dist/core/operators/map.mjs +0 -1
- package/dist/core/operators/map.mjs.map +1 -1
- package/dist/core/operators/merge-map.d.mts +1 -1
- package/dist/core/operators/merge-map.d.mts.map +1 -1
- package/dist/core/operators/pairwise.d.mts +2 -2
- package/dist/core/operators/pairwise.d.mts.map +1 -1
- package/dist/core/operators/scan.d.mts +1 -1
- package/dist/core/operators/scan.d.mts.map +1 -1
- package/dist/core/operators/skip-if-no-change.d.mts +1 -1
- package/dist/core/operators/skip-if-no-change.d.mts.map +1 -1
- package/dist/core/operators/skip-if-no-change.mjs +0 -1
- package/dist/core/operators/skip-if-no-change.mjs.map +1 -1
- package/dist/core/operators/skip-until.d.mts +1 -1
- package/dist/core/operators/skip-until.d.mts.map +1 -1
- package/dist/core/operators/skip-while.d.mts +1 -1
- package/dist/core/operators/skip-while.d.mts.map +1 -1
- package/dist/core/operators/switch-map.d.mts +1 -1
- package/dist/core/operators/switch-map.d.mts.map +1 -1
- package/dist/core/operators/take-until.d.mts +1 -1
- package/dist/core/operators/take-until.d.mts.map +1 -1
- package/dist/core/operators/take-until.mjs +0 -1
- package/dist/core/operators/take-until.mjs.map +1 -1
- package/dist/core/operators/take-while.d.mts +1 -1
- package/dist/core/operators/take-while.d.mts.map +1 -1
- package/dist/core/operators/throttle.d.mts +1 -1
- package/dist/core/operators/throttle.d.mts.map +1 -1
- package/dist/core/operators/throttle.mjs +0 -1
- package/dist/core/operators/throttle.mjs.map +1 -1
- package/dist/core/operators/with-buffered-from.d.mts +1 -1
- package/dist/core/operators/with-buffered-from.d.mts.map +1 -1
- package/dist/core/operators/with-buffered-from.mjs +0 -1
- package/dist/core/operators/with-buffered-from.mjs.map +1 -1
- package/dist/core/operators/with-current-value-from.d.mts +1 -1
- package/dist/core/operators/with-current-value-from.d.mts.map +1 -1
- package/dist/core/operators/with-initial-value.d.mts +1 -1
- package/dist/core/operators/with-initial-value.d.mts.map +1 -1
- package/dist/core/predefined/operators/attach-index.d.mts +2 -2
- package/dist/core/predefined/operators/attach-index.d.mts.map +1 -1
- package/dist/core/predefined/operators/map-optional.d.mts +1 -1
- package/dist/core/predefined/operators/map-optional.d.mts.map +1 -1
- package/dist/core/predefined/operators/map-result-err.d.mts +1 -1
- package/dist/core/predefined/operators/map-result-err.d.mts.map +1 -1
- package/dist/core/predefined/operators/map-result-ok.d.mts +1 -1
- package/dist/core/predefined/operators/map-result-ok.d.mts.map +1 -1
- package/dist/core/predefined/operators/map-to.d.mts +1 -1
- package/dist/core/predefined/operators/map-to.d.mts.map +1 -1
- package/dist/core/predefined/operators/pluck.d.mts +1 -1
- package/dist/core/predefined/operators/pluck.d.mts.map +1 -1
- package/dist/core/predefined/operators/skip.d.mts +2 -2
- package/dist/core/predefined/operators/skip.d.mts.map +1 -1
- package/dist/core/predefined/operators/take.d.mts +2 -2
- package/dist/core/predefined/operators/take.d.mts.map +1 -1
- package/dist/core/predefined/operators/unwrap-optional.d.mts +1 -1
- package/dist/core/predefined/operators/unwrap-optional.d.mts.map +1 -1
- package/dist/core/predefined/operators/unwrap-optional.mjs +0 -1
- package/dist/core/predefined/operators/unwrap-optional.mjs.map +1 -1
- package/dist/core/predefined/operators/unwrap-result-err.d.mts +1 -1
- package/dist/core/predefined/operators/unwrap-result-err.d.mts.map +1 -1
- package/dist/core/predefined/operators/unwrap-result-ok.d.mts +1 -1
- package/dist/core/predefined/operators/unwrap-result-ok.d.mts.map +1 -1
- package/dist/core/predefined/operators/unwrap-result-ok.mjs +0 -1
- package/dist/core/predefined/operators/unwrap-result-ok.mjs.map +1 -1
- package/dist/core/types/id.d.mts +1 -1
- package/dist/core/types/id.d.mts.map +1 -1
- package/dist/core/types/observable-family.d.mts +3 -3
- package/dist/core/types/observable-family.d.mts.map +1 -1
- package/dist/core/types/observable-kind.d.mts +1 -1
- package/dist/core/types/observable-kind.d.mts.map +1 -1
- package/dist/core/types/observable.d.mts +4 -4
- package/dist/core/types/observable.d.mts.map +1 -1
- package/dist/core/types/types.d.mts +1 -1
- package/dist/core/types/types.d.mts.map +1 -1
- package/dist/core/utils/id-maker.d.mts +1 -1
- package/dist/core/utils/id-maker.d.mts.map +1 -1
- package/dist/core/utils/id-maker.mjs +0 -1
- package/dist/core/utils/id-maker.mjs.map +1 -1
- package/dist/core/utils/max-depth.d.mts +1 -1
- package/dist/core/utils/max-depth.d.mts.map +1 -1
- package/dist/core/utils/observable-utils.d.mts +1 -1
- package/dist/core/utils/observable-utils.d.mts.map +1 -1
- package/dist/core/utils/utils.d.mts +1 -1
- package/dist/core/utils/utils.d.mts.map +1 -1
- package/dist/core/utils/utils.mjs +0 -1
- package/dist/core/utils/utils.mjs.map +1 -1
- package/dist/utils/collect-to-array.d.mts +1 -1
- package/dist/utils/collect-to-array.d.mts.map +1 -1
- package/dist/utils/create-boolean-state.d.mts +17 -14
- package/dist/utils/create-boolean-state.d.mts.map +1 -1
- package/dist/utils/create-boolean-state.mjs +4 -2
- package/dist/utils/create-boolean-state.mjs.map +1 -1
- package/dist/utils/create-reducer.d.mts +49 -2
- package/dist/utils/create-reducer.d.mts.map +1 -1
- package/dist/utils/create-reducer.mjs +31 -2
- package/dist/utils/create-reducer.mjs.map +1 -1
- package/dist/utils/create-state.d.mts +37 -2
- package/dist/utils/create-state.d.mts.map +1 -1
- package/dist/utils/create-state.mjs +36 -2
- package/dist/utils/create-state.mjs.map +1 -1
- package/package.json +13 -13
- package/src/core/base/create-child-observable.mts +1 -2
- package/src/core/base/create-observable-base.mts +17 -19
- package/src/core/base/create-root-observable.mts +1 -1
- package/src/core/base/observable-base.test.mts +7 -7
- package/src/core/combine/combine.mts +10 -11
- package/src/core/combine/merge.mts +8 -10
- package/src/core/combine/zip.mts +11 -13
- package/src/core/create/counter.mts +21 -11
- package/src/core/create/counter.test.mts +183 -0
- package/src/core/create/from-abortable-promise.mts +1 -3
- package/src/core/create/from-promise.mts +1 -2
- package/src/core/create/from-subscribable.mts +3 -4
- package/src/core/create/just.mts +1 -2
- package/src/core/create/source.mts +3 -3
- package/src/core/create/timer.mts +1 -1
- package/src/core/operators/audit.mts +5 -6
- package/src/core/operators/debounce.mts +5 -6
- package/src/core/operators/filter.mts +46 -5
- package/src/core/operators/map.mts +5 -6
- package/src/core/operators/merge-map.mts +5 -5
- package/src/core/operators/pairwise.mts +5 -5
- package/src/core/operators/scan.mts +4 -4
- package/src/core/operators/skip-if-no-change.mts +4 -5
- package/src/core/operators/skip-until.mts +4 -4
- package/src/core/operators/skip-while.mts +4 -4
- package/src/core/operators/switch-map.mts +5 -5
- package/src/core/operators/take-until.mts +4 -5
- package/src/core/operators/take-while.mts +5 -5
- package/src/core/operators/throttle.mts +5 -6
- package/src/core/operators/with-buffered-from.mts +4 -5
- package/src/core/operators/with-current-value-from.mts +4 -4
- package/src/core/operators/with-initial-value.mts +5 -5
- package/src/core/predefined/operators/attach-index.mts +2 -2
- package/src/core/predefined/operators/map-optional.mts +1 -1
- package/src/core/predefined/operators/map-result-err.mts +1 -1
- package/src/core/predefined/operators/map-result-ok.mts +1 -1
- package/src/core/predefined/operators/map-to.mts +1 -1
- package/src/core/predefined/operators/pluck.mts +1 -1
- package/src/core/predefined/operators/skip.mts +2 -2
- package/src/core/predefined/operators/take.mts +2 -2
- package/src/core/predefined/operators/unwrap-optional.mts +2 -3
- package/src/core/predefined/operators/unwrap-result-err.mts +2 -2
- package/src/core/predefined/operators/unwrap-result-ok.mts +2 -3
- package/src/core/types/id.mts +1 -1
- package/src/core/types/observable-family.mts +15 -15
- package/src/core/types/observable-kind.mts +1 -1
- package/src/core/types/observable.mts +4 -4
- package/src/core/types/types.mts +1 -1
- package/src/core/utils/id-maker.mts +4 -5
- package/src/core/utils/max-depth.mts +1 -1
- package/src/core/utils/observable-utils.mts +1 -1
- package/src/core/utils/utils.mts +1 -2
- package/src/utils/collect-to-array.mts +1 -1
- package/src/utils/create-boolean-state.mts +18 -14
- package/src/utils/create-boolean-state.test.mts +23 -0
- package/src/utils/create-reducer.mts +59 -2
- package/src/utils/create-reducer.test.mts +87 -0
- package/src/utils/create-state.mts +38 -2
- package/src/utils/create-state.test.mts +72 -0
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
asSafeUint,
|
|
3
3
|
expectType,
|
|
4
|
+
isNotUndefined,
|
|
5
|
+
isString,
|
|
4
6
|
Optional,
|
|
5
7
|
pipe,
|
|
6
8
|
SafeUint,
|
|
7
9
|
} from 'ts-data-forge';
|
|
8
10
|
import { createSyncChildObservable } from '../base/index.mjs';
|
|
9
11
|
import { source } from '../create/index.mjs';
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
import type {
|
|
13
|
+
DropInitialValueOperator,
|
|
14
|
+
FilterOperatorObservable,
|
|
15
|
+
InitializedObservable,
|
|
16
|
+
Observable,
|
|
15
17
|
} from '../types/index.mjs';
|
|
16
18
|
import { withInitialValue } from './with-initial-value.mjs';
|
|
17
19
|
|
|
@@ -68,6 +70,11 @@ export function filter<A, B extends A>(
|
|
|
68
70
|
predicate: (value: A, index: SafeUint | -1) => value is B,
|
|
69
71
|
): DropInitialValueOperator<A, B>;
|
|
70
72
|
|
|
73
|
+
// A type-guard predicate and a boolean one are both functions at run time, so
|
|
74
|
+
// this set only refines the return type (#1952). It stays overloaded because
|
|
75
|
+
// one signature with a union parameter infers `unknown` for a generic guard
|
|
76
|
+
// such as `isNotUndefined`; see the type test below.
|
|
77
|
+
// @sumi-expect-error functions/no-refinement-overload
|
|
71
78
|
export function filter<A>(
|
|
72
79
|
predicate: (value: A, index: SafeUint | -1) => boolean,
|
|
73
80
|
): DropInitialValueOperator<A, A>;
|
|
@@ -139,4 +146,38 @@ if (import.meta.vitest !== undefined) {
|
|
|
139
146
|
|
|
140
147
|
expectType<typeof _d, Observable<number>>('=');
|
|
141
148
|
}
|
|
149
|
+
|
|
150
|
+
{
|
|
151
|
+
const s = source<number | undefined>();
|
|
152
|
+
|
|
153
|
+
const _guarded = s.pipe(filter((x): x is number => x !== undefined));
|
|
154
|
+
|
|
155
|
+
expectType<typeof _guarded, Observable<number>>('=');
|
|
156
|
+
|
|
157
|
+
const _inferred = s.pipe(filter((x) => x !== undefined));
|
|
158
|
+
|
|
159
|
+
expectType<typeof _inferred, Observable<number>>('=');
|
|
160
|
+
|
|
161
|
+
// A generic guard is what a single signature with a union parameter
|
|
162
|
+
// loses (it infers `unknown`), and why this set stays overloaded.
|
|
163
|
+
const _generic = s.pipe(filter(isNotUndefined));
|
|
164
|
+
|
|
165
|
+
expectType<typeof _generic, Observable<number>>('=');
|
|
166
|
+
|
|
167
|
+
const _withIndex = s.pipe(filter((x, i) => i === -1 || x === 0));
|
|
168
|
+
|
|
169
|
+
expectType<typeof _withIndex, Observable<number | undefined>>('=');
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
{
|
|
173
|
+
const _d = source<unknown>().pipe(filter(isString));
|
|
174
|
+
|
|
175
|
+
expectType<typeof _d, Observable<string>>('=');
|
|
176
|
+
|
|
177
|
+
const _standalone = filter((x: number) => x > 0);
|
|
178
|
+
|
|
179
|
+
expectType<typeof _standalone, DropInitialValueOperator<number, number>>(
|
|
180
|
+
'=',
|
|
181
|
+
);
|
|
182
|
+
}
|
|
142
183
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Optional, SafeUint, asSafeUint, expectType } from 'ts-data-forge';
|
|
2
2
|
import { createSyncChildObservable } from '../base/index.mjs';
|
|
3
3
|
import { source } from '../create/index.mjs';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import type {
|
|
5
|
+
InitializedObservable,
|
|
6
|
+
KeepInitialValueOperator,
|
|
7
|
+
MapOperatorObservable,
|
|
8
|
+
Observable,
|
|
9
9
|
} from '../types/index.mjs';
|
|
10
10
|
import { withInitialValue } from './with-initial-value.mjs';
|
|
11
11
|
|
|
@@ -51,7 +51,6 @@ export const map = <A, B>(
|
|
|
51
51
|
mapFn: (x: A, index: SafeUint | -1) => B,
|
|
52
52
|
): KeepInitialValueOperator<A, B> =>
|
|
53
53
|
// @sumi-expect-error banned-syntax/no-unsafe-type-assertion
|
|
54
|
-
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
55
54
|
((parentObservable) =>
|
|
56
55
|
createMapObservable(parentObservable, mapFn)) as KeepInitialValueOperator<
|
|
57
56
|
A,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Arr, Optional } from 'ts-data-forge';
|
|
2
2
|
import { createAsyncChildObservable } from '../base/index.mjs';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import type {
|
|
4
|
+
DropInitialValueOperator,
|
|
5
|
+
MergeMapOperatorObservable,
|
|
6
|
+
Observable,
|
|
7
|
+
Subscription,
|
|
8
8
|
} from '../types/index.mjs';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Optional } from 'ts-data-forge';
|
|
2
|
-
import {
|
|
2
|
+
import type { FixedLengthTuple } from 'ts-type-forge';
|
|
3
3
|
import { createSyncChildObservable } from '../base/index.mjs';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import type {
|
|
5
|
+
DropInitialValueOperator,
|
|
6
|
+
Observable,
|
|
7
|
+
PairwiseOperatorObservable,
|
|
8
8
|
} from '../types/index.mjs';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Optional } from 'ts-data-forge';
|
|
2
2
|
import { createInitializedSyncChildObservable } from '../base/index.mjs';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import type {
|
|
4
|
+
Observable,
|
|
5
|
+
ScanOperatorObservable,
|
|
6
|
+
WithInitialValueOperator,
|
|
7
7
|
} from '../types/index.mjs';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Optional } from 'ts-data-forge';
|
|
2
2
|
import { createSyncChildObservable } from '../base/index.mjs';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import type {
|
|
4
|
+
KeepInitialValueOperator,
|
|
5
|
+
Observable,
|
|
6
|
+
SkipIfNoChangeOperatorObservable,
|
|
7
7
|
} from '../types/index.mjs';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -71,7 +71,6 @@ export const skipIfNoChange = <A,>(
|
|
|
71
71
|
eq: (x: A, y: A) => boolean = (x, y) => Object.is(x, y),
|
|
72
72
|
): KeepInitialValueOperator<A, A> =>
|
|
73
73
|
// @sumi-expect-error banned-syntax/no-unsafe-type-assertion
|
|
74
|
-
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
75
74
|
((parentObservable) =>
|
|
76
75
|
createSkipIfNoChangeObservable(
|
|
77
76
|
parentObservable,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Optional } from 'ts-data-forge';
|
|
2
2
|
import { createSyncChildObservable } from '../base/index.mjs';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import type {
|
|
4
|
+
DropInitialValueOperator,
|
|
5
|
+
Observable,
|
|
6
|
+
SkipUntilOperatorObservable,
|
|
7
7
|
} from '../types/index.mjs';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Optional, SafeUint, asSafeUint, pipe } from 'ts-data-forge';
|
|
2
2
|
import { createSyncChildObservable } from '../base/index.mjs';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import type {
|
|
4
|
+
DropInitialValueOperator,
|
|
5
|
+
Observable,
|
|
6
|
+
SkipWhileOperatorObservable,
|
|
7
7
|
} from '../types/index.mjs';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Optional } from 'ts-data-forge';
|
|
2
2
|
import { createAsyncChildObservable } from '../base/index.mjs';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import type {
|
|
4
|
+
DropInitialValueOperator,
|
|
5
|
+
Observable,
|
|
6
|
+
Subscription,
|
|
7
|
+
SwitchMapOperatorObservable,
|
|
8
8
|
} from '../types/index.mjs';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Optional } from 'ts-data-forge';
|
|
2
2
|
import { createSyncChildObservable } from '../base/index.mjs';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import type {
|
|
4
|
+
KeepInitialValueOperator,
|
|
5
|
+
Observable,
|
|
6
|
+
TakeUntilOperatorObservable,
|
|
7
7
|
} from '../types/index.mjs';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -58,7 +58,6 @@ export const takeUntil = <A,>(
|
|
|
58
58
|
notifier: Observable<unknown>,
|
|
59
59
|
): KeepInitialValueOperator<A, A> =>
|
|
60
60
|
// @sumi-expect-error banned-syntax/no-unsafe-type-assertion
|
|
61
|
-
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
62
61
|
((parentObservable) =>
|
|
63
62
|
createTakeUntilObservable(
|
|
64
63
|
parentObservable,
|
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
} from 'ts-data-forge';
|
|
8
8
|
import { createSyncChildObservable } from '../base/index.mjs';
|
|
9
9
|
import { source } from '../create/index.mjs';
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
import type {
|
|
11
|
+
DropInitialValueOperator,
|
|
12
|
+
InitializedObservable,
|
|
13
|
+
Observable,
|
|
14
|
+
TakeWhileOperatorObservable,
|
|
15
15
|
} from '../types/index.mjs';
|
|
16
16
|
import { withInitialValue } from './with-initial-value.mjs';
|
|
17
17
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Optional } from 'ts-data-forge';
|
|
2
2
|
import { createSyncChildObservable } from '../base/index.mjs';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import type {
|
|
4
|
+
KeepInitialValueOperator,
|
|
5
|
+
Observable,
|
|
6
|
+
ThrottleOperatorObservable,
|
|
7
|
+
TimerId,
|
|
8
8
|
} from '../types/index.mjs';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -89,7 +89,6 @@ export const throttle = <A,>(
|
|
|
89
89
|
milliSeconds: number,
|
|
90
90
|
): KeepInitialValueOperator<A, A> =>
|
|
91
91
|
// @sumi-expect-error banned-syntax/no-unsafe-type-assertion
|
|
92
|
-
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
93
92
|
((parentObservable) =>
|
|
94
93
|
createThrottleObservable(
|
|
95
94
|
parentObservable,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Arr, Optional, pipe } from 'ts-data-forge';
|
|
2
2
|
import { createSyncChildObservable } from '../base/index.mjs';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import type {
|
|
4
|
+
KeepInitialValueOperator,
|
|
5
|
+
Observable,
|
|
6
|
+
WithBufferedFromOperatorObservable,
|
|
7
7
|
} from '../types/index.mjs';
|
|
8
8
|
import { maxDepth } from '../utils/index.mjs';
|
|
9
9
|
|
|
@@ -64,7 +64,6 @@ export const withBufferedFrom = <A, B>(
|
|
|
64
64
|
observable: Observable<B>,
|
|
65
65
|
): KeepInitialValueOperator<A, readonly [A, readonly B[]]> =>
|
|
66
66
|
// @sumi-expect-error banned-syntax/no-unsafe-type-assertion
|
|
67
|
-
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
68
67
|
((parentObservable) =>
|
|
69
68
|
createWithBufferedFromObservable(
|
|
70
69
|
parentObservable,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Optional, pipe } from 'ts-data-forge';
|
|
2
2
|
import { createSyncChildObservable } from '../base/index.mjs';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import type {
|
|
4
|
+
DropInitialValueOperator,
|
|
5
|
+
Observable,
|
|
6
|
+
WithCurrentValueFromOperatorObservable,
|
|
7
7
|
} from '../types/index.mjs';
|
|
8
8
|
import { maxDepth } from '../utils/index.mjs';
|
|
9
9
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { expectType, Optional } from 'ts-data-forge';
|
|
2
2
|
import { createInitializedSyncChildObservable } from '../base/index.mjs';
|
|
3
3
|
import { source } from '../create/index.mjs';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import type {
|
|
5
|
+
InitializedObservable,
|
|
6
|
+
Observable,
|
|
7
|
+
WithInitialValueOperator,
|
|
8
|
+
WithInitialValueOperatorObservable,
|
|
9
9
|
} from '../types/index.mjs';
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { SafeUint } from 'ts-type-forge';
|
|
2
2
|
import { map } from '../../operators/index.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import type { KeepInitialValueOperator } from '../../types/index.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Attaches a sequential index to each emitted value, producing `[index, value]` tuples.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Optional, type UnknownOptional } from 'ts-data-forge';
|
|
2
2
|
import { map } from '../../operators/index.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import type { KeepInitialValueOperator } from '../../types/index.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Transforms the inner value of an `Optional` type emitted by the source.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Result, type UnknownResult } from 'ts-data-forge';
|
|
2
2
|
import { map } from '../../operators/index.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import type { KeepInitialValueOperator } from '../../types/index.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Transforms the error value (`Err`) of a `Result` type emitted by the source.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Result, type UnknownResult } from 'ts-data-forge';
|
|
2
2
|
import { map } from '../../operators/index.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import type { KeepInitialValueOperator } from '../../types/index.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Transforms the success value (`Ok`) of a `Result` type emitted by the source.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { map } from '../../operators/index.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import type { KeepInitialValueOperator } from '../../types/index.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Maps all emitted values to a constant value, ignoring the source values.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PositiveSafeInt } from 'ts-data-forge';
|
|
2
|
-
import {
|
|
2
|
+
import type { PositiveSafeIntWithSmallInt } from 'ts-type-forge';
|
|
3
3
|
import { skipWhile } from '../../operators/index.mjs';
|
|
4
|
-
import {
|
|
4
|
+
import type { DropInitialValueOperator } from '../../types/index.mjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Skips the first `n` emissions from the source observable.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { PositiveSafeIntWithSmallInt } from 'ts-type-forge';
|
|
2
2
|
import { takeWhile } from '../../operators/index.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import type { DropInitialValueOperator } from '../../types/index.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Takes only the first `n` emissions from the source observable, then completes.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Optional, type UnknownOptional } from 'ts-data-forge';
|
|
2
|
-
import {
|
|
2
|
+
import type { Fn } from 'ts-type-forge';
|
|
3
3
|
import { map } from '../../operators/index.mjs';
|
|
4
|
-
import {
|
|
4
|
+
import type { KeepInitialValueOperator } from '../../types/index.mjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Unwraps `Optional` values, converting `Some(value)` to `value` and `None` to `undefined`.
|
|
@@ -47,5 +47,4 @@ export const unwrapOptional = <
|
|
|
47
47
|
O extends UnknownOptional,
|
|
48
48
|
>(): KeepInitialValueOperator<O, Optional.Unwrap<O> | undefined> =>
|
|
49
49
|
// @sumi-expect-error banned-syntax/no-unsafe-type-assertion
|
|
50
|
-
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
51
50
|
map(Optional.unwrap as Fn<O, Optional.Unwrap<O> | undefined>);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Result, type UnknownResult } from 'ts-data-forge';
|
|
2
|
-
import {
|
|
2
|
+
import type { Fn } from 'ts-type-forge';
|
|
3
3
|
import { map } from '../../operators/index.mjs';
|
|
4
|
-
import {
|
|
4
|
+
import type { KeepInitialValueOperator } from '../../types/index.mjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Unwraps the error value from a `Result`, converting `Err(error)` to `error` and `Ok` to `undefined`.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Result, type UnknownResult } from 'ts-data-forge';
|
|
2
|
-
import {
|
|
2
|
+
import type { Fn } from 'ts-type-forge';
|
|
3
3
|
import { map } from '../../operators/index.mjs';
|
|
4
|
-
import {
|
|
4
|
+
import type { KeepInitialValueOperator } from '../../types/index.mjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Unwraps the success value from a `Result`, converting `Ok(value)` to `value` and `Err` to `undefined`.
|
|
@@ -47,5 +47,4 @@ export const unwrapResultOk = <
|
|
|
47
47
|
R extends UnknownResult,
|
|
48
48
|
>(): KeepInitialValueOperator<R, Result.UnwrapOk<R> | undefined> =>
|
|
49
49
|
// @sumi-expect-error banned-syntax/no-unsafe-type-assertion
|
|
50
|
-
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
51
50
|
map(Result.unwrapOk as Fn<R, Result.UnwrapOk<R> | undefined>);
|
package/src/core/types/id.mts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { expectType, type Result } from 'ts-data-forge';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import type {
|
|
3
|
+
ArrayElement,
|
|
4
|
+
FixedLengthTuple,
|
|
5
|
+
NonEmptyTuple,
|
|
6
|
+
SafeUint,
|
|
7
7
|
} from 'ts-type-forge';
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
import type {
|
|
9
|
+
AsyncChildObservable,
|
|
10
|
+
InitializedObservable,
|
|
11
|
+
InitializedRootObservable,
|
|
12
|
+
InitializedSyncChildObservable,
|
|
13
|
+
Observable,
|
|
14
|
+
RootObservable,
|
|
15
|
+
SyncChildObservable,
|
|
16
|
+
Unwrap,
|
|
17
17
|
} from './observable.mjs';
|
|
18
|
-
import {
|
|
18
|
+
import type { NonEmptyUnknownList } from './types.mjs';
|
|
19
19
|
|
|
20
20
|
// RootObservable
|
|
21
21
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { expectType, type Optional, type Some } from 'ts-data-forge';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import type { FixedLengthTuple, StrictOmit } from 'ts-type-forge';
|
|
3
|
+
import type { ObservableId, UpdateToken } from './id.mjs';
|
|
4
|
+
import type { ObservableKind } from './observable-kind.mjs';
|
|
5
|
+
import type { NonEmptyUnknownList, Subscription } from './types.mjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Inheritance
|
package/src/core/types/types.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { expectType, type Queue } from 'ts-data-forge';
|
|
2
|
-
import {
|
|
2
|
+
import type { NonEmptyTuple } from 'ts-type-forge';
|
|
3
3
|
|
|
4
4
|
export type TupleToQueueTuple<T extends readonly unknown[]> = Readonly<{
|
|
5
5
|
[P in keyof T]: Queue<T[P]>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type {
|
|
2
|
+
ObservableId,
|
|
3
|
+
SubscriberId,
|
|
4
|
+
UpdateToken,
|
|
5
5
|
} from '../types/index.mjs';
|
|
6
6
|
|
|
7
7
|
function* idMaker<T extends symbol>(): Generator<T, T, T> {
|
|
@@ -9,7 +9,6 @@ function* idMaker<T extends symbol>(): Generator<T, T, T> {
|
|
|
9
9
|
|
|
10
10
|
while (true) {
|
|
11
11
|
// @sumi-expect-error banned-syntax/no-unsafe-type-assertion
|
|
12
|
-
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
13
12
|
yield Symbol(mut_i.toString()) as T;
|
|
14
13
|
|
|
15
14
|
mut_i += 1;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Arr, Optional, pipe } from 'ts-data-forge';
|
|
2
|
-
import {
|
|
2
|
+
import type { Observable } from '../types/index.mjs';
|
|
3
3
|
|
|
4
4
|
export const maxDepth = (parents: readonly Observable<unknown>[]): number =>
|
|
5
5
|
pipe(Arr.maxBy(parents, (p) => p.depth))
|
package/src/core/utils/utils.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Arr, asSafeInt, asUint32, SafeInt } from 'ts-data-forge';
|
|
2
|
-
import {
|
|
2
|
+
import type { NegativeInt32, Uint32 } from 'ts-type-forge';
|
|
3
3
|
|
|
4
4
|
export const halfInt = (x: SafeInt): SafeInt =>
|
|
5
5
|
x % 2 === 0
|
|
@@ -52,6 +52,5 @@ export const binarySearch = <N extends number>(
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
// @sumi-expect-error banned-syntax/no-unsafe-type-assertion
|
|
55
|
-
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
56
55
|
return mut_mid as NegativeInt32 | Uint32;
|
|
57
56
|
};
|