synstate 0.1.0 → 0.1.1
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/LICENSE +201 -0
- package/README.md +124 -350
- package/assets/synstate-icon.png +0 -0
- package/dist/core/combine/combine.d.mts +32 -2
- package/dist/core/combine/combine.d.mts.map +1 -1
- package/dist/core/combine/combine.mjs +32 -2
- package/dist/core/combine/combine.mjs.map +1 -1
- package/dist/core/combine/merge.d.mts +30 -4
- package/dist/core/combine/merge.d.mts.map +1 -1
- package/dist/core/combine/merge.mjs +30 -4
- package/dist/core/combine/merge.mjs.map +1 -1
- package/dist/core/combine/zip.d.mts +28 -3
- package/dist/core/combine/zip.d.mts.map +1 -1
- package/dist/core/combine/zip.mjs +28 -3
- package/dist/core/combine/zip.mjs.map +1 -1
- package/dist/core/create/from-array.d.mts +21 -3
- package/dist/core/create/from-array.d.mts.map +1 -1
- package/dist/core/create/from-array.mjs +21 -3
- package/dist/core/create/from-array.mjs.map +1 -1
- package/dist/core/create/from-promise.d.mts +29 -7
- package/dist/core/create/from-promise.d.mts.map +1 -1
- package/dist/core/create/from-promise.mjs +29 -7
- package/dist/core/create/from-promise.mjs.map +1 -1
- package/dist/core/create/from-subscribable.d.mts +58 -0
- package/dist/core/create/from-subscribable.d.mts.map +1 -1
- package/dist/core/create/from-subscribable.mjs +58 -0
- package/dist/core/create/from-subscribable.mjs.map +1 -1
- package/dist/core/create/interval.d.mts +29 -4
- package/dist/core/create/interval.d.mts.map +1 -1
- package/dist/core/create/interval.mjs +29 -4
- package/dist/core/create/interval.mjs.map +1 -1
- package/dist/core/create/of.d.mts +22 -3
- package/dist/core/create/of.d.mts.map +1 -1
- package/dist/core/create/of.mjs +22 -3
- package/dist/core/create/of.mjs.map +1 -1
- package/dist/core/create/source.d.mts +20 -1
- package/dist/core/create/source.d.mts.map +1 -1
- package/dist/core/create/source.mjs.map +1 -1
- package/dist/core/create/timer.d.mts +23 -4
- package/dist/core/create/timer.d.mts.map +1 -1
- package/dist/core/create/timer.mjs +23 -4
- package/dist/core/create/timer.mjs.map +1 -1
- package/dist/core/operators/audit-time.d.mts +59 -0
- package/dist/core/operators/audit-time.d.mts.map +1 -1
- package/dist/core/operators/audit-time.mjs +59 -0
- package/dist/core/operators/audit-time.mjs.map +1 -1
- package/dist/core/operators/debounce-time.d.mts +22 -2
- package/dist/core/operators/debounce-time.d.mts.map +1 -1
- package/dist/core/operators/debounce-time.mjs +22 -2
- package/dist/core/operators/debounce-time.mjs.map +1 -1
- package/dist/core/operators/filter.d.mts +26 -1
- package/dist/core/operators/filter.d.mts.map +1 -1
- package/dist/core/operators/filter.mjs.map +1 -1
- package/dist/core/operators/map-with-index.d.mts +19 -4
- package/dist/core/operators/map-with-index.d.mts.map +1 -1
- package/dist/core/operators/map-with-index.mjs +19 -4
- package/dist/core/operators/map-with-index.mjs.map +1 -1
- package/dist/core/operators/merge-map.d.mts +47 -5
- package/dist/core/operators/merge-map.d.mts.map +1 -1
- package/dist/core/operators/merge-map.mjs +47 -5
- package/dist/core/operators/merge-map.mjs.map +1 -1
- package/dist/core/operators/pairwise.d.mts +30 -1
- package/dist/core/operators/pairwise.d.mts.map +1 -1
- package/dist/core/operators/pairwise.mjs +30 -1
- package/dist/core/operators/pairwise.mjs.map +1 -1
- package/dist/core/operators/scan.d.mts +23 -1
- package/dist/core/operators/scan.d.mts.map +1 -1
- package/dist/core/operators/scan.mjs +23 -1
- package/dist/core/operators/scan.mjs.map +1 -1
- package/dist/core/operators/skip-if-no-change.d.mts +25 -1
- package/dist/core/operators/skip-if-no-change.d.mts.map +1 -1
- package/dist/core/operators/skip-if-no-change.mjs +25 -1
- package/dist/core/operators/skip-if-no-change.mjs.map +1 -1
- package/dist/core/operators/skip-until.d.mts +50 -0
- package/dist/core/operators/skip-until.d.mts.map +1 -1
- package/dist/core/operators/skip-until.mjs +50 -0
- package/dist/core/operators/skip-until.mjs.map +1 -1
- package/dist/core/operators/skip-while.d.mts +48 -0
- package/dist/core/operators/skip-while.d.mts.map +1 -1
- package/dist/core/operators/skip-while.mjs +48 -0
- package/dist/core/operators/skip-while.mjs.map +1 -1
- package/dist/core/operators/switch-map.d.mts +39 -5
- package/dist/core/operators/switch-map.d.mts.map +1 -1
- package/dist/core/operators/switch-map.mjs +39 -5
- package/dist/core/operators/switch-map.mjs.map +1 -1
- package/dist/core/operators/take-until.d.mts +20 -1
- package/dist/core/operators/take-until.d.mts.map +1 -1
- package/dist/core/operators/take-until.mjs +20 -1
- package/dist/core/operators/take-until.mjs.map +1 -1
- package/dist/core/operators/take-while.d.mts +47 -0
- package/dist/core/operators/take-while.d.mts.map +1 -1
- package/dist/core/operators/take-while.mjs +47 -0
- package/dist/core/operators/take-while.mjs.map +1 -1
- package/dist/core/operators/throttle-time.d.mts +44 -5
- package/dist/core/operators/throttle-time.d.mts.map +1 -1
- package/dist/core/operators/throttle-time.mjs +44 -5
- package/dist/core/operators/throttle-time.mjs.map +1 -1
- package/dist/core/operators/with-buffered-from.d.mts +53 -0
- package/dist/core/operators/with-buffered-from.d.mts.map +1 -1
- package/dist/core/operators/with-buffered-from.mjs +53 -0
- package/dist/core/operators/with-buffered-from.mjs.map +1 -1
- package/dist/core/operators/with-current-value-from.d.mts +55 -0
- package/dist/core/operators/with-current-value-from.d.mts.map +1 -1
- package/dist/core/operators/with-current-value-from.mjs +55 -0
- package/dist/core/operators/with-current-value-from.mjs.map +1 -1
- package/dist/core/operators/with-initial-value.d.mts +24 -2
- package/dist/core/operators/with-initial-value.d.mts.map +1 -1
- package/dist/core/operators/with-initial-value.mjs +24 -2
- package/dist/core/operators/with-initial-value.mjs.map +1 -1
- package/dist/core/types/observable-family.d.mts +7 -7
- package/dist/utils/create-event-emitter.d.mts +20 -2
- package/dist/utils/create-event-emitter.d.mts.map +1 -1
- package/dist/utils/create-event-emitter.mjs +20 -2
- package/dist/utils/create-event-emitter.mjs.map +1 -1
- package/dist/utils/create-reducer.d.mts +13 -1
- package/dist/utils/create-reducer.d.mts.map +1 -1
- package/dist/utils/create-reducer.mjs +13 -1
- package/dist/utils/create-reducer.mjs.map +1 -1
- package/dist/utils/create-state.d.mts +24 -4
- package/dist/utils/create-state.d.mts.map +1 -1
- package/dist/utils/create-state.mjs +24 -4
- package/dist/utils/create-state.mjs.map +1 -1
- package/package.json +13 -12
- package/src/core/combine/combine.mts +32 -2
- package/src/core/combine/merge.mts +30 -4
- package/src/core/combine/zip.mts +28 -3
- package/src/core/create/from-array.mts +21 -3
- package/src/core/create/from-promise.mts +29 -7
- package/src/core/create/from-subscribable.mts +58 -0
- package/src/core/create/interval.mts +29 -4
- package/src/core/create/of.mts +22 -3
- package/src/core/create/source.mts +20 -1
- package/src/core/create/timer.mts +23 -4
- package/src/core/operators/audit-time.mts +59 -0
- package/src/core/operators/debounce-time.mts +22 -2
- package/src/core/operators/filter.mts +26 -1
- package/src/core/operators/map-with-index.mts +19 -4
- package/src/core/operators/merge-map.mts +47 -5
- package/src/core/operators/pairwise.mts +30 -1
- package/src/core/operators/scan.mts +23 -1
- package/src/core/operators/skip-if-no-change.mts +25 -1
- package/src/core/operators/skip-until.mts +50 -0
- package/src/core/operators/skip-while.mts +48 -0
- package/src/core/operators/switch-map.mts +39 -5
- package/src/core/operators/take-until.mts +20 -1
- package/src/core/operators/take-while.mts +47 -0
- package/src/core/operators/throttle-time.mts +44 -5
- package/src/core/operators/with-buffered-from.mts +53 -0
- package/src/core/operators/with-current-value-from.mts +55 -0
- package/src/core/operators/with-initial-value.mts +24 -2
- package/src/core/types/observable-family.mts +7 -7
- package/src/utils/create-event-emitter.mts +20 -2
- package/src/utils/create-reducer.mts +13 -1
- package/src/utils/create-state.mts +24 -4
|
@@ -12,17 +12,32 @@ import '../utils/id-maker.mjs';
|
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* ```ts
|
|
15
|
-
*
|
|
15
|
+
* // Timeline:
|
|
16
|
+
* //
|
|
17
|
+
* // num$ "a" "b" "c"
|
|
18
|
+
* // indexed$ "0: a" "1: b" "2: c"
|
|
19
|
+
* //
|
|
20
|
+
* // Explanation:
|
|
21
|
+
* // - mapWithIndex transforms each value along with its index
|
|
22
|
+
* // - Index starts at 0 and increments with each emission
|
|
23
|
+
*
|
|
24
|
+
* const num$ = source<string>();
|
|
16
25
|
*
|
|
17
26
|
* const indexed$ = num$.pipe(mapWithIndex((x, i) => `${i}: ${x}`));
|
|
18
27
|
*
|
|
28
|
+
* const mut_history: string[] = [];
|
|
29
|
+
*
|
|
19
30
|
* indexed$.subscribe((s) => {
|
|
20
|
-
*
|
|
31
|
+
* mut_history.push(s);
|
|
21
32
|
* });
|
|
22
33
|
*
|
|
23
|
-
* num$.next(
|
|
34
|
+
* num$.next('a'); // 0: a
|
|
35
|
+
*
|
|
36
|
+
* num$.next('b'); // 1: b
|
|
37
|
+
*
|
|
38
|
+
* num$.next('c'); // 2: c
|
|
24
39
|
*
|
|
25
|
-
*
|
|
40
|
+
* assert.deepStrictEqual(mut_history, ['0: a', '1: b', '2: c']);
|
|
26
41
|
* ```
|
|
27
42
|
*/
|
|
28
43
|
const mapWithIndex = (mapFn) =>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-with-index.mjs","sources":["../../../src/core/operators/map-with-index.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAkBA
|
|
1
|
+
{"version":3,"file":"map-with-index.mjs","sources":["../../../src/core/operators/map-with-index.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAkBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCG;AACI,MAAM,YAAY,GAAG,CAC1B,KAAwC;AAExC;AACA,CAAC,CAAC,gBAAgB,KAChB,IAAI,2BAA2B,CAC7B,gBAAgB,EAChB,KAAK,CACN;AAEL;AAEO,MAAM,GAAG,GAAG,CAAO,KAAkB,KAC1C,YAAY,CAAC,KAAK;AAEb,MAAM,KAAK,GAAG,CAAO,KAAQ,KAClC,GAAG,CAAC,MAAM,KAAK;AAEV,MAAM,KAAK,GAAG,CACnB,GAAM,KACgC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC;AAElD,MAAM,MAAM,GAAG,MAAM;MAEf,WAAW,GAAG,MAGtB,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAU;AAEpC,MAAM,SAAS,GAAG,YAAY;AAE9B,MAAM,cAAc,GAAG;AAG5B;AACA,GAAG,CAAC,QAAQ,CAAC,MAA+C;AAEvD,MAAM,cAAc,GAAG;AAG5B;AACA,GAAG,CAAC,MAAM,CAAC,QAAiD;AAEvD,MAAM,eAAe,GAAG,MAG7B,GAAG,CAAC,MAAM,CAAC,SAAmD;MAEnD,WAAW,GAAG,CACzB,KAAmC,KAEnC,GAAG,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC;MAEtB,WAAW,GAAG,CACzB,KAAoC,KAEpC,GAAG,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC;MAEpB,YAAY,GAAG,CAC1B,KAAqC,KAErC,GAAG,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC;AAEpC;AAEA,MAAM,2BACJ,SAAQ,wBAAyC,CAAA;AAGxC,IAAA,MAAM;AACf,IAAA,UAAU;IAEV,WAAA,CACE,gBAA+B,EAC/B,KAAwC,EAAA;AAExC,QAAA,KAAK,CAAC;YACJ,OAAO,EAAE,CAAC,gBAAgB,CAAC;YAC3B,YAAY,EAAE,QAAQ,CAAC,GAAG,CAAC,gBAAgB,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,KAC3D,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CACb;AACF,SAAA,CAAC;AAEF,QAAA,IAAI,CAAC,UAAU,GAAG,EAAE;AAEpB,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK;;AAGZ,IAAA,SAAS,CAAC,aAA4B,EAAA;QAC7C,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;AAE3B,QAAA,MAAM,EAAE,GAAG,GAAG,CAAC,WAAW,EAAE;AAE5B,QAAA,IAAI,GAAG,CAAC,aAAa,KAAK,aAAa,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE;AAC9D,YAAA,OAAO;;AAGT,QAAA,IAAI,CAAC,UAAU;YACb,IAAI,CAAC,UAAU,KAAK,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC;AAE3E,QAAA,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC;;AAEtE;;;;"}
|
|
@@ -10,16 +10,58 @@ import { type DropInitialValueOperator, type Observable } from '../types/index.m
|
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* ```ts
|
|
13
|
+
* // Timeline:
|
|
14
|
+
* //
|
|
15
|
+
* // ids$ 1 2 3
|
|
16
|
+
* // requests fetch(1) fetch(2) fetch(3)
|
|
17
|
+
* // users$ result1 result2 result3
|
|
18
|
+
* // (parallel) (parallel) (parallel)
|
|
19
|
+
* //
|
|
20
|
+
* // Explanation:
|
|
21
|
+
* // - mergeMap runs all inner observables in parallel
|
|
22
|
+
* // - Results are emitted as they arrive (may be out of order)
|
|
23
|
+
* // - Does NOT cancel previous requests
|
|
24
|
+
* // - All requests run concurrently and all results are emitted
|
|
25
|
+
*
|
|
13
26
|
* const ids$ = source<number>();
|
|
14
27
|
*
|
|
15
|
-
* const users$ = ids$.pipe(
|
|
28
|
+
* const users$ = ids$.pipe(
|
|
29
|
+
* mergeMap((id) => {
|
|
30
|
+
* const result$ = source<{ id: number }>();
|
|
31
|
+
*
|
|
32
|
+
* setTimeout(() => {
|
|
33
|
+
* result$.next({ id });
|
|
34
|
+
*
|
|
35
|
+
* result$.complete();
|
|
36
|
+
* }, 10);
|
|
37
|
+
*
|
|
38
|
+
* return result$;
|
|
39
|
+
* }),
|
|
40
|
+
* );
|
|
16
41
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
42
|
+
* const mut_history: { id: number }[] = [];
|
|
43
|
+
*
|
|
44
|
+
* users$.subscribe((value) => {
|
|
45
|
+
* mut_history.push(value);
|
|
19
46
|
* });
|
|
20
|
-
* // All requests run in parallel, results merged as they arrive
|
|
21
47
|
*
|
|
22
|
-
*
|
|
48
|
+
* ids$.next(1);
|
|
49
|
+
*
|
|
50
|
+
* ids$.next(2);
|
|
51
|
+
*
|
|
52
|
+
* ids$.next(3);
|
|
53
|
+
*
|
|
54
|
+
* await new Promise((resolve) => {
|
|
55
|
+
* setTimeout(resolve, 200);
|
|
56
|
+
* });
|
|
57
|
+
*
|
|
58
|
+
* assert.deepStrictEqual(mut_history.length, 3);
|
|
59
|
+
*
|
|
60
|
+
* assert.isTrue(mut_history.some((u) => u.id === 1));
|
|
61
|
+
*
|
|
62
|
+
* assert.isTrue(mut_history.some((u) => u.id === 2));
|
|
63
|
+
*
|
|
64
|
+
* assert.isTrue(mut_history.some((u) => u.id === 3));
|
|
23
65
|
* ```
|
|
24
66
|
*
|
|
25
67
|
* @note To improve code readability, consider using `createState` instead of `mergeMap`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-map.d.mts","sourceRoot":"","sources":["../../../src/core/operators/merge-map.mts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,wBAAwB,EAE7B,KAAK,UAAU,EAGhB,MAAM,oBAAoB,CAAC;AAE5B
|
|
1
|
+
{"version":3,"file":"merge-map.d.mts","sourceRoot":"","sources":["../../../src/core/operators/merge-map.mts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,wBAAwB,EAE7B,KAAK,UAAU,EAGhB,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACH,eAAO,MAAM,QAAQ,GAClB,CAAC,EAAE,CAAC,EACH,iBAAiB,CAAC,IAAI,EAAE,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,KAC1C,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAEgC,CAAC;AAEnE;;;GAGG;AACH,eAAO,MAAM,OAAO,GAVjB,CAAC,EAAE,CAAC,mBACc,CAAC,IAAI,EAAE,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,KAC1C,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAQH,CAAC"}
|
|
@@ -13,16 +13,58 @@ import '../utils/id-maker.mjs';
|
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
15
15
|
* ```ts
|
|
16
|
+
* // Timeline:
|
|
17
|
+
* //
|
|
18
|
+
* // ids$ 1 2 3
|
|
19
|
+
* // requests fetch(1) fetch(2) fetch(3)
|
|
20
|
+
* // users$ result1 result2 result3
|
|
21
|
+
* // (parallel) (parallel) (parallel)
|
|
22
|
+
* //
|
|
23
|
+
* // Explanation:
|
|
24
|
+
* // - mergeMap runs all inner observables in parallel
|
|
25
|
+
* // - Results are emitted as they arrive (may be out of order)
|
|
26
|
+
* // - Does NOT cancel previous requests
|
|
27
|
+
* // - All requests run concurrently and all results are emitted
|
|
28
|
+
*
|
|
16
29
|
* const ids$ = source<number>();
|
|
17
30
|
*
|
|
18
|
-
* const users$ = ids$.pipe(
|
|
31
|
+
* const users$ = ids$.pipe(
|
|
32
|
+
* mergeMap((id) => {
|
|
33
|
+
* const result$ = source<{ id: number }>();
|
|
34
|
+
*
|
|
35
|
+
* setTimeout(() => {
|
|
36
|
+
* result$.next({ id });
|
|
37
|
+
*
|
|
38
|
+
* result$.complete();
|
|
39
|
+
* }, 10);
|
|
40
|
+
*
|
|
41
|
+
* return result$;
|
|
42
|
+
* }),
|
|
43
|
+
* );
|
|
19
44
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
45
|
+
* const mut_history: { id: number }[] = [];
|
|
46
|
+
*
|
|
47
|
+
* users$.subscribe((value) => {
|
|
48
|
+
* mut_history.push(value);
|
|
22
49
|
* });
|
|
23
|
-
* // All requests run in parallel, results merged as they arrive
|
|
24
50
|
*
|
|
25
|
-
*
|
|
51
|
+
* ids$.next(1);
|
|
52
|
+
*
|
|
53
|
+
* ids$.next(2);
|
|
54
|
+
*
|
|
55
|
+
* ids$.next(3);
|
|
56
|
+
*
|
|
57
|
+
* await new Promise((resolve) => {
|
|
58
|
+
* setTimeout(resolve, 200);
|
|
59
|
+
* });
|
|
60
|
+
*
|
|
61
|
+
* assert.deepStrictEqual(mut_history.length, 3);
|
|
62
|
+
*
|
|
63
|
+
* assert.isTrue(mut_history.some((u) => u.id === 1));
|
|
64
|
+
*
|
|
65
|
+
* assert.isTrue(mut_history.some((u) => u.id === 2));
|
|
66
|
+
*
|
|
67
|
+
* assert.isTrue(mut_history.some((u) => u.id === 3));
|
|
26
68
|
* ```
|
|
27
69
|
*
|
|
28
70
|
* @note To improve code readability, consider using `createState` instead of `mergeMap`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-map.mjs","sources":["../../../src/core/operators/merge-map.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAUA
|
|
1
|
+
{"version":3,"file":"merge-map.mjs","sources":["../../../src/core/operators/merge-map.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEG;MACU,QAAQ,GACnB,CACE,eAA2C,KAE7C,CAAC,gBAAgB,KACf,IAAI,uBAAuB,CAAC,gBAAgB,EAAE,eAAe;AAEjE;;;AAGG;AACI,MAAM,OAAO,GAAG;AAEvB,MAAM,uBACJ,SAAQ,yBAA0C,CAAA;AAGzC,IAAA,gBAAgB;AACzB,IAAA,gBAAgB;AAChB,IAAA,kBAAkB;IAElB,WAAA,CACE,gBAA+B,EAC/B,eAA2C,EAAA;AAE3C,QAAA,KAAK,CAAC;YACJ,OAAO,EAAE,CAAC,gBAAgB,CAAC;YAC3B,YAAY,EAAE,QAAQ,CAAC,IAAI;AAC5B,SAAA,CAAC;AAEF,QAAA,IAAI,CAAC,gBAAgB,GAAG,eAAe;AAEvC,QAAA,IAAI,CAAC,gBAAgB,GAAG,EAAE;AAE1B,QAAA,IAAI,CAAC,kBAAkB,GAAG,EAAE;IAC9B;AAES,IAAA,SAAS,CAAC,aAA4B,EAAA;QAC7C,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;AAE3B,QAAA,MAAM,EAAE,GAAG,GAAG,CAAC,WAAW,EAAE;AAE5B,QAAA,IAAI,GAAG,CAAC,aAAa,KAAK,aAAa,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE;AAC9D,YAAA,OAAO;QACT;QAEA,MAAM,UAAU,GAAG,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC,KAAK,CAAC;AAElD,QAAA,IAAI,CAAC,gBAAgB,GAAG,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC;QAEvE,MAAM,YAAY,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,IAAI,KAAI;AACjD,YAAA,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;AACxB,QAAA,CAAC,CAAC;AAEF,QAAA,IAAI,CAAC,kBAAkB,GAAG,GAAG,CAAC,QAAQ,CACpC,IAAI,CAAC,kBAAkB,EACvB,YAAY,CACb;IACH;IAES,QAAQ,GAAA;AACf,QAAA,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,kBAAkB,EAAE;YACvC,CAAC,CAAC,WAAW,EAAE;QACjB;AAEA,QAAA,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,gBAAgB,EAAE;YACrC,CAAC,CAAC,QAAQ,EAAE;QACd;QAEA,KAAK,CAAC,QAAQ,EAAE;IAClB;AACD;;;;"}
|
|
@@ -8,19 +8,48 @@ import { type DropInitialValueOperator } from '../types/index.mjs';
|
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```ts
|
|
11
|
+
* // Timeline:
|
|
12
|
+
* //
|
|
13
|
+
* // num$ 1 2 3 4
|
|
14
|
+
* // pairs$ [1,2] [2,3] [3,4]
|
|
15
|
+
* //
|
|
16
|
+
* // Explanation:
|
|
17
|
+
* // - pairwise emits the current and previous values as a tuple
|
|
18
|
+
* // - Nothing is emitted for the first value (no previous value yet)
|
|
19
|
+
* // - Useful for tracking changes between consecutive values
|
|
20
|
+
*
|
|
11
21
|
* const num$ = source<number>();
|
|
12
22
|
*
|
|
13
23
|
* const pairs$ = num$.pipe(pairwise());
|
|
14
24
|
*
|
|
25
|
+
* const mut_history: (readonly [number, number])[] = [];
|
|
26
|
+
*
|
|
15
27
|
* pairs$.subscribe(([prev, curr]) => {
|
|
16
|
-
*
|
|
28
|
+
* mut_history.push([prev, curr]);
|
|
17
29
|
* });
|
|
18
30
|
*
|
|
19
31
|
* num$.next(1); // nothing logged
|
|
20
32
|
*
|
|
33
|
+
* assert.deepStrictEqual(mut_history, []);
|
|
34
|
+
*
|
|
21
35
|
* num$.next(2); // logs: 1, 2
|
|
22
36
|
*
|
|
37
|
+
* assert.deepStrictEqual(mut_history, [[1, 2]]);
|
|
38
|
+
*
|
|
23
39
|
* num$.next(3); // logs: 2, 3
|
|
40
|
+
*
|
|
41
|
+
* assert.deepStrictEqual(mut_history, [
|
|
42
|
+
* [1, 2],
|
|
43
|
+
* [2, 3],
|
|
44
|
+
* ]);
|
|
45
|
+
*
|
|
46
|
+
* num$.next(4); // logs: 3, 4
|
|
47
|
+
*
|
|
48
|
+
* assert.deepStrictEqual(mut_history, [
|
|
49
|
+
* [1, 2],
|
|
50
|
+
* [2, 3],
|
|
51
|
+
* [3, 4],
|
|
52
|
+
* ]);
|
|
24
53
|
* ```
|
|
25
54
|
*/
|
|
26
55
|
export declare const pairwise: <A>() => DropInitialValueOperator<A, readonly [A, A]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pairwise.d.mts","sourceRoot":"","sources":["../../../src/core/operators/pairwise.mts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,wBAAwB,EAI9B,MAAM,oBAAoB,CAAC;AAE5B
|
|
1
|
+
{"version":3,"file":"pairwise.d.mts","sourceRoot":"","sources":["../../../src/core/operators/pairwise.mts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,wBAAwB,EAI9B,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,OAAM,wBAAwB,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CACxE,CAAC"}
|
|
@@ -11,19 +11,48 @@ import '../utils/id-maker.mjs';
|
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* ```ts
|
|
14
|
+
* // Timeline:
|
|
15
|
+
* //
|
|
16
|
+
* // num$ 1 2 3 4
|
|
17
|
+
* // pairs$ [1,2] [2,3] [3,4]
|
|
18
|
+
* //
|
|
19
|
+
* // Explanation:
|
|
20
|
+
* // - pairwise emits the current and previous values as a tuple
|
|
21
|
+
* // - Nothing is emitted for the first value (no previous value yet)
|
|
22
|
+
* // - Useful for tracking changes between consecutive values
|
|
23
|
+
*
|
|
14
24
|
* const num$ = source<number>();
|
|
15
25
|
*
|
|
16
26
|
* const pairs$ = num$.pipe(pairwise());
|
|
17
27
|
*
|
|
28
|
+
* const mut_history: (readonly [number, number])[] = [];
|
|
29
|
+
*
|
|
18
30
|
* pairs$.subscribe(([prev, curr]) => {
|
|
19
|
-
*
|
|
31
|
+
* mut_history.push([prev, curr]);
|
|
20
32
|
* });
|
|
21
33
|
*
|
|
22
34
|
* num$.next(1); // nothing logged
|
|
23
35
|
*
|
|
36
|
+
* assert.deepStrictEqual(mut_history, []);
|
|
37
|
+
*
|
|
24
38
|
* num$.next(2); // logs: 1, 2
|
|
25
39
|
*
|
|
40
|
+
* assert.deepStrictEqual(mut_history, [[1, 2]]);
|
|
41
|
+
*
|
|
26
42
|
* num$.next(3); // logs: 2, 3
|
|
43
|
+
*
|
|
44
|
+
* assert.deepStrictEqual(mut_history, [
|
|
45
|
+
* [1, 2],
|
|
46
|
+
* [2, 3],
|
|
47
|
+
* ]);
|
|
48
|
+
*
|
|
49
|
+
* num$.next(4); // logs: 3, 4
|
|
50
|
+
*
|
|
51
|
+
* assert.deepStrictEqual(mut_history, [
|
|
52
|
+
* [1, 2],
|
|
53
|
+
* [2, 3],
|
|
54
|
+
* [3, 4],
|
|
55
|
+
* ]);
|
|
27
56
|
* ```
|
|
28
57
|
*/
|
|
29
58
|
const pairwise = () => f;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pairwise.mjs","sources":["../../../src/core/operators/pairwise.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AASA
|
|
1
|
+
{"version":3,"file":"pairwise.mjs","sources":["../../../src/core/operators/pairwise.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDG;MACU,QAAQ,GAAG,MACtB;AAEF,MAAM,CAAC,GAAG,CAAK,gBAA+B,KAC5C,IAAI,uBAAuB,CAAC,gBAAgB,CAAC;AAE/C,MAAM,uBACJ,SAAQ,wBAAuD,CAAA;AAG/D,IAAA,kBAAkB;AAElB,IAAA,WAAA,CAAY,gBAA+B,EAAA;AACzC,QAAA,KAAK,CAAC;YACJ,OAAO,EAAE,CAAC,gBAAgB,CAAC;YAC3B,YAAY,EAAE,QAAQ,CAAC,IAAI;AAC5B,SAAA,CAAC;;;AAIF,QAAA,IAAI,CAAC,kBAAkB,GAAG,gBAAgB,CAAC,WAAW,EAAE;IAC1D;AAES,IAAA,SAAS,CAAC,aAA4B,EAAA;QAC7C,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;AAE3B,QAAA,MAAM,EAAE,GAAG,GAAG,CAAC,WAAW,EAAE;AAE5B,QAAA,IAAI,GAAG,CAAC,aAAa,KAAK,aAAa,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE;AAC9D,YAAA,OAAO;QACT;AAEA,QAAA,MAAM,IAAI,GAAG,IAAI,CAAC,kBAAkB;QAEpC,MAAM,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;;AAGnC,QAAA,IAAI,CAAC,kBAAkB,GAAG,GAAG,CAAC,WAAW,EAAE;QAE3C,IAAI,IAAI,EAAE;AACR,YAAA,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC;QACrD;IACF;AACD;;;;"}
|
|
@@ -11,19 +11,41 @@ import { type WithInitialValueOperator } from '../types/index.mjs';
|
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* ```ts
|
|
14
|
+
* // Timeline (accumulating sum):
|
|
15
|
+
* //
|
|
16
|
+
* // num$ 1 2 3 4 5
|
|
17
|
+
* // sum$ 1 3 6 10 15
|
|
18
|
+
* // | | | | |
|
|
19
|
+
* // 0+1 1+2 3+3 6+4 10+5
|
|
20
|
+
* //
|
|
21
|
+
* // Explanation:
|
|
22
|
+
* // - scan accumulates values over time using a reducer function
|
|
23
|
+
* // - Starting with seed value 0, each emission adds to the accumulator
|
|
24
|
+
* // - Similar to Array.reduce, but for streams
|
|
25
|
+
*
|
|
14
26
|
* const num$ = source<number>();
|
|
15
27
|
*
|
|
16
28
|
* const sum$ = num$.pipe(scan((acc, curr) => acc + curr, 0));
|
|
17
29
|
*
|
|
30
|
+
* const mut_history: number[] = [];
|
|
31
|
+
*
|
|
18
32
|
* sum$.subscribe((x) => {
|
|
19
|
-
*
|
|
33
|
+
* mut_history.push(x);
|
|
20
34
|
* });
|
|
21
35
|
*
|
|
36
|
+
* assert.deepStrictEqual(mut_history, [0]);
|
|
37
|
+
*
|
|
22
38
|
* num$.next(1); // logs: 1
|
|
23
39
|
*
|
|
40
|
+
* assert.deepStrictEqual(mut_history, [0, 1]);
|
|
41
|
+
*
|
|
24
42
|
* num$.next(2); // logs: 3
|
|
25
43
|
*
|
|
44
|
+
* assert.deepStrictEqual(mut_history, [0, 1, 3]);
|
|
45
|
+
*
|
|
26
46
|
* num$.next(3); // logs: 6
|
|
47
|
+
*
|
|
48
|
+
* assert.deepStrictEqual(mut_history, [0, 1, 3, 6]);
|
|
27
49
|
* ```
|
|
28
50
|
*/
|
|
29
51
|
export declare const scan: <A, B>(reducer: (acc: B, curr: A) => B, initialValue: B) => WithInitialValueOperator<A, B>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan.d.mts","sourceRoot":"","sources":["../../../src/core/operators/scan.mts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,wBAAwB,EAC9B,MAAM,oBAAoB,CAAC;AAE5B
|
|
1
|
+
{"version":3,"file":"scan.d.mts","sourceRoot":"","sources":["../../../src/core/operators/scan.mts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,wBAAwB,EAC9B,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,eAAO,MAAM,IAAI,GACd,CAAC,EAAE,CAAC,EACH,SAAS,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,EAC/B,cAAc,CAAC,KACd,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAEkC,CAAC"}
|
|
@@ -14,19 +14,41 @@ import '../utils/id-maker.mjs';
|
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
16
|
* ```ts
|
|
17
|
+
* // Timeline (accumulating sum):
|
|
18
|
+
* //
|
|
19
|
+
* // num$ 1 2 3 4 5
|
|
20
|
+
* // sum$ 1 3 6 10 15
|
|
21
|
+
* // | | | | |
|
|
22
|
+
* // 0+1 1+2 3+3 6+4 10+5
|
|
23
|
+
* //
|
|
24
|
+
* // Explanation:
|
|
25
|
+
* // - scan accumulates values over time using a reducer function
|
|
26
|
+
* // - Starting with seed value 0, each emission adds to the accumulator
|
|
27
|
+
* // - Similar to Array.reduce, but for streams
|
|
28
|
+
*
|
|
17
29
|
* const num$ = source<number>();
|
|
18
30
|
*
|
|
19
31
|
* const sum$ = num$.pipe(scan((acc, curr) => acc + curr, 0));
|
|
20
32
|
*
|
|
33
|
+
* const mut_history: number[] = [];
|
|
34
|
+
*
|
|
21
35
|
* sum$.subscribe((x) => {
|
|
22
|
-
*
|
|
36
|
+
* mut_history.push(x);
|
|
23
37
|
* });
|
|
24
38
|
*
|
|
39
|
+
* assert.deepStrictEqual(mut_history, [0]);
|
|
40
|
+
*
|
|
25
41
|
* num$.next(1); // logs: 1
|
|
26
42
|
*
|
|
43
|
+
* assert.deepStrictEqual(mut_history, [0, 1]);
|
|
44
|
+
*
|
|
27
45
|
* num$.next(2); // logs: 3
|
|
28
46
|
*
|
|
47
|
+
* assert.deepStrictEqual(mut_history, [0, 1, 3]);
|
|
48
|
+
*
|
|
29
49
|
* num$.next(3); // logs: 6
|
|
50
|
+
*
|
|
51
|
+
* assert.deepStrictEqual(mut_history, [0, 1, 3, 6]);
|
|
30
52
|
* ```
|
|
31
53
|
*/
|
|
32
54
|
const scan = (reducer, initialValue) => (parentObservable) => new ScanObservableClass(parentObservable, reducer, initialValue);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan.mjs","sources":["../../../src/core/operators/scan.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AASA
|
|
1
|
+
{"version":3,"file":"scan.mjs","sources":["../../../src/core/operators/scan.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDG;AACI,MAAM,IAAI,GACf,CACE,OAA+B,EAC/B,YAAe,KAEjB,CAAC,gBAAgB,KACf,IAAI,mBAAmB,CAAC,gBAAgB,EAAE,OAAO,EAAE,YAAY;AAEnE,MAAM,mBACJ,SAAQ,mCAAoD,CAAA;AAGnD,IAAA,QAAQ;AAEjB,IAAA,WAAA,CACE,gBAA+B,EAC/B,OAA+B,EAC/B,YAAe,EAAA;AAEf,QAAA,KAAK,CAAC;YACJ,OAAO,EAAE,CAAC,gBAAgB,CAAC;AAC3B,YAAA,YAAY,EAAE,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC;AAC1C,SAAA,CAAC;AAEF,QAAA,IAAI,CAAC,QAAQ,GAAG,OAAO;IACzB;AAES,IAAA,SAAS,CAAC,aAA4B,EAAA;QAC7C,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;AAE3B,QAAA,MAAM,GAAG,GAAG,GAAG,CAAC,WAAW,EAAE;AAE7B,QAAA,MAAM,EAAE,GAAG,IAAI,CAAC,WAAW,EAAE;AAE7B,QAAA,IACE,GAAG,CAAC,aAAa,KAAK,aAAa;AACnC,YAAA,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC;AACpB,YAAA,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,EACnB;AACA,YAAA,OAAO;QACT;AAEA,QAAA,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC;IACjE;AACD;;;;"}
|
|
@@ -9,19 +9,43 @@ import { type KeepInitialValueOperator } from '../types/index.mjs';
|
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
11
|
* ```ts
|
|
12
|
+
* // Timeline:
|
|
13
|
+
* //
|
|
14
|
+
* // num$ 1 1 2 2 2 3
|
|
15
|
+
* // distinct$ 1 2 3
|
|
16
|
+
* //
|
|
17
|
+
* // Explanation:
|
|
18
|
+
* // - skipIfNoChange filters out consecutive duplicate values
|
|
19
|
+
* // - Uses strict equality (===) for comparison
|
|
20
|
+
* // - Only emits when the value actually changes
|
|
21
|
+
*
|
|
12
22
|
* const num$ = source<number>();
|
|
13
23
|
*
|
|
14
24
|
* const distinct$ = num$.pipe(skipIfNoChange());
|
|
15
25
|
*
|
|
26
|
+
* const mut_history: number[] = [];
|
|
27
|
+
*
|
|
16
28
|
* distinct$.subscribe((x) => {
|
|
17
|
-
*
|
|
29
|
+
* mut_history.push(x);
|
|
18
30
|
* });
|
|
19
31
|
*
|
|
20
32
|
* num$.next(1); // logs: 1
|
|
21
33
|
*
|
|
34
|
+
* assert.deepStrictEqual(mut_history, [1]);
|
|
35
|
+
*
|
|
22
36
|
* num$.next(1); // nothing logged
|
|
23
37
|
*
|
|
38
|
+
* assert.deepStrictEqual(mut_history, [1]);
|
|
39
|
+
*
|
|
24
40
|
* num$.next(2); // logs: 2
|
|
41
|
+
*
|
|
42
|
+
* assert.deepStrictEqual(mut_history, [1, 2]);
|
|
43
|
+
*
|
|
44
|
+
* num$.next(2); // nothing logged
|
|
45
|
+
*
|
|
46
|
+
* num$.next(3); // logs: 3
|
|
47
|
+
*
|
|
48
|
+
* assert.deepStrictEqual(mut_history, [1, 2, 3]);
|
|
25
49
|
* ```
|
|
26
50
|
*/
|
|
27
51
|
export declare const skipIfNoChange: <A>(eq?: (x: A, y: A) => boolean) => KeepInitialValueOperator<A, A>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skip-if-no-change.d.mts","sourceRoot":"","sources":["../../../src/core/operators/skip-if-no-change.mts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,wBAAwB,EAI9B,MAAM,oBAAoB,CAAC;AAE5B
|
|
1
|
+
{"version":3,"file":"skip-if-no-change.d.mts","sourceRoot":"","sources":["../../../src/core/operators/skip-if-no-change.mts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,wBAAwB,EAI9B,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,EAC9B,KAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAmC,KACtD,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAMQ,CAAC;AAEzC;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAdF,CAAC,OAC1B,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAO,KAC1B,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAYkB,CAAC"}
|
|
@@ -12,19 +12,43 @@ import '../utils/id-maker.mjs';
|
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* ```ts
|
|
15
|
+
* // Timeline:
|
|
16
|
+
* //
|
|
17
|
+
* // num$ 1 1 2 2 2 3
|
|
18
|
+
* // distinct$ 1 2 3
|
|
19
|
+
* //
|
|
20
|
+
* // Explanation:
|
|
21
|
+
* // - skipIfNoChange filters out consecutive duplicate values
|
|
22
|
+
* // - Uses strict equality (===) for comparison
|
|
23
|
+
* // - Only emits when the value actually changes
|
|
24
|
+
*
|
|
15
25
|
* const num$ = source<number>();
|
|
16
26
|
*
|
|
17
27
|
* const distinct$ = num$.pipe(skipIfNoChange());
|
|
18
28
|
*
|
|
29
|
+
* const mut_history: number[] = [];
|
|
30
|
+
*
|
|
19
31
|
* distinct$.subscribe((x) => {
|
|
20
|
-
*
|
|
32
|
+
* mut_history.push(x);
|
|
21
33
|
* });
|
|
22
34
|
*
|
|
23
35
|
* num$.next(1); // logs: 1
|
|
24
36
|
*
|
|
37
|
+
* assert.deepStrictEqual(mut_history, [1]);
|
|
38
|
+
*
|
|
25
39
|
* num$.next(1); // nothing logged
|
|
26
40
|
*
|
|
41
|
+
* assert.deepStrictEqual(mut_history, [1]);
|
|
42
|
+
*
|
|
27
43
|
* num$.next(2); // logs: 2
|
|
44
|
+
*
|
|
45
|
+
* assert.deepStrictEqual(mut_history, [1, 2]);
|
|
46
|
+
*
|
|
47
|
+
* num$.next(2); // nothing logged
|
|
48
|
+
*
|
|
49
|
+
* num$.next(3); // logs: 3
|
|
50
|
+
*
|
|
51
|
+
* assert.deepStrictEqual(mut_history, [1, 2, 3]);
|
|
28
52
|
* ```
|
|
29
53
|
*/
|
|
30
54
|
const skipIfNoChange = (eq = (x, y) => Object.is(x, y)) =>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skip-if-no-change.mjs","sources":["../../../src/core/operators/skip-if-no-change.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AASA
|
|
1
|
+
{"version":3,"file":"skip-if-no-change.mjs","sources":["../../../src/core/operators/skip-if-no-change.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDG;MACU,cAAc,GAAG,CAC5B,EAAA,GAA8B,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AAEvD;AACA,CAAC,CAAC,gBAAgB,KAChB,IAAI,6BAA6B,CAC/B,gBAAgB,EAChB,EAAE,CACH;AAEL;;;AAGG;AACI,MAAM,oBAAoB,GAAG,eAAe;AAEnD,MAAM,6BACJ,SAAQ,wBAAyC,CAAA;AAGxC,IAAA,GAAG;AACZ,IAAA,kBAAkB;IAElB,WAAA,CAAY,gBAA+B,EAAE,EAA2B,EAAA;AACtE,QAAA,KAAK,CAAC;YACJ,OAAO,EAAE,CAAC,gBAAgB,CAAC;AAC3B,YAAA,YAAY,EAAE,gBAAgB,CAAC,WAAW,EAAE;AAC7C,SAAA,CAAC;;;AAIF,QAAA,IAAI,CAAC,kBAAkB,GAAG,gBAAgB,CAAC,WAAW,EAAE;AAExD,QAAA,IAAI,CAAC,GAAG,GAAG,EAAE;IACf;AAES,IAAA,SAAS,CAAC,aAA4B,EAAA;QAC7C,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;AAE3B,QAAA,MAAM,EAAE,GAAG,GAAG,CAAC,WAAW,EAAE;AAE5B,QAAA,IAAI,GAAG,CAAC,aAAa,KAAK,aAAa,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE;AAC9D,YAAA,OAAO;QACT;AAEA,QAAA,MAAM,IAAI,GAAG,IAAI,CAAC,kBAAkB;QAEpC,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC;;AAGrE,QAAA,IAAI,CAAC,kBAAkB,GAAG,EAAE;QAE5B,IAAI,IAAI,EAAE;YACR,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC;QACvC;IACF;AACD;;;;"}
|
|
@@ -1,3 +1,53 @@
|
|
|
1
1
|
import { type DropInitialValueOperator, type Observable } from '../types/index.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Skips all values from the source observable until the notifier observable emits.
|
|
4
|
+
*
|
|
5
|
+
* @template A - The type of values from the source
|
|
6
|
+
* @param notifier - An observable that signals when to start emitting
|
|
7
|
+
* @returns An operator that skips values until the notifier emits
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* // Timeline:
|
|
12
|
+
* //
|
|
13
|
+
* // num$ 1 2 3 start 4 5 6
|
|
14
|
+
* // startNotifier X
|
|
15
|
+
* // skipped$ 4 5 6
|
|
16
|
+
* // |------ skipped -------|
|
|
17
|
+
* //
|
|
18
|
+
* // Explanation:
|
|
19
|
+
* // - skipUntil ignores all values until the notifier emits
|
|
20
|
+
* // - After the notifier emits, all subsequent values are passed through
|
|
21
|
+
* // - Opposite of takeUntil (which completes when notifier emits)
|
|
22
|
+
*
|
|
23
|
+
* const num$ = source<number>();
|
|
24
|
+
*
|
|
25
|
+
* const [startNotifier, start_] = createEventEmitter();
|
|
26
|
+
*
|
|
27
|
+
* const skipped$ = num$.pipe(skipUntil(startNotifier));
|
|
28
|
+
*
|
|
29
|
+
* const mut_history: number[] = [];
|
|
30
|
+
*
|
|
31
|
+
* skipped$.subscribe((x) => {
|
|
32
|
+
* mut_history.push(x);
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* num$.next(1); // nothing logged
|
|
36
|
+
*
|
|
37
|
+
* num$.next(2); // nothing logged
|
|
38
|
+
*
|
|
39
|
+
* assert.deepStrictEqual(mut_history, []);
|
|
40
|
+
*
|
|
41
|
+
* start_();
|
|
42
|
+
*
|
|
43
|
+
* num$.next(4); // logs: 4
|
|
44
|
+
*
|
|
45
|
+
* assert.deepStrictEqual(mut_history, [4]);
|
|
46
|
+
*
|
|
47
|
+
* num$.next(5); // logs: 5
|
|
48
|
+
*
|
|
49
|
+
* assert.deepStrictEqual(mut_history, [4, 5]);
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
2
52
|
export declare const skipUntil: <A>(notifier: Observable<unknown>) => DropInitialValueOperator<A, A>;
|
|
3
53
|
//# sourceMappingURL=skip-until.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skip-until.d.mts","sourceRoot":"","sources":["../../../src/core/operators/skip-until.mts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,UAAU,EAGhB,MAAM,oBAAoB,CAAC;AAE5B,eAAO,MAAM,SAAS,GACnB,CAAC,EAAG,UAAU,UAAU,CAAC,OAAO,CAAC,KAAG,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAER,CAAC"}
|
|
1
|
+
{"version":3,"file":"skip-until.d.mts","sourceRoot":"","sources":["../../../src/core/operators/skip-until.mts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,UAAU,EAGhB,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,eAAO,MAAM,SAAS,GACnB,CAAC,EAAG,UAAU,UAAU,CAAC,OAAO,CAAC,KAAG,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAER,CAAC"}
|
|
@@ -2,6 +2,56 @@ import { Optional } from 'ts-data-forge';
|
|
|
2
2
|
import { SyncChildObservableClass } from '../class/child-observable-class.mjs';
|
|
3
3
|
import '../utils/id-maker.mjs';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Skips all values from the source observable until the notifier observable emits.
|
|
7
|
+
*
|
|
8
|
+
* @template A - The type of values from the source
|
|
9
|
+
* @param notifier - An observable that signals when to start emitting
|
|
10
|
+
* @returns An operator that skips values until the notifier emits
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* // Timeline:
|
|
15
|
+
* //
|
|
16
|
+
* // num$ 1 2 3 start 4 5 6
|
|
17
|
+
* // startNotifier X
|
|
18
|
+
* // skipped$ 4 5 6
|
|
19
|
+
* // |------ skipped -------|
|
|
20
|
+
* //
|
|
21
|
+
* // Explanation:
|
|
22
|
+
* // - skipUntil ignores all values until the notifier emits
|
|
23
|
+
* // - After the notifier emits, all subsequent values are passed through
|
|
24
|
+
* // - Opposite of takeUntil (which completes when notifier emits)
|
|
25
|
+
*
|
|
26
|
+
* const num$ = source<number>();
|
|
27
|
+
*
|
|
28
|
+
* const [startNotifier, start_] = createEventEmitter();
|
|
29
|
+
*
|
|
30
|
+
* const skipped$ = num$.pipe(skipUntil(startNotifier));
|
|
31
|
+
*
|
|
32
|
+
* const mut_history: number[] = [];
|
|
33
|
+
*
|
|
34
|
+
* skipped$.subscribe((x) => {
|
|
35
|
+
* mut_history.push(x);
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* num$.next(1); // nothing logged
|
|
39
|
+
*
|
|
40
|
+
* num$.next(2); // nothing logged
|
|
41
|
+
*
|
|
42
|
+
* assert.deepStrictEqual(mut_history, []);
|
|
43
|
+
*
|
|
44
|
+
* start_();
|
|
45
|
+
*
|
|
46
|
+
* num$.next(4); // logs: 4
|
|
47
|
+
*
|
|
48
|
+
* assert.deepStrictEqual(mut_history, [4]);
|
|
49
|
+
*
|
|
50
|
+
* num$.next(5); // logs: 5
|
|
51
|
+
*
|
|
52
|
+
* assert.deepStrictEqual(mut_history, [4, 5]);
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
5
55
|
const skipUntil = (notifier) => (parentObservable) => new SkipUntilObservableClass(parentObservable, notifier);
|
|
6
56
|
class SkipUntilObservableClass extends SyncChildObservableClass {
|
|
7
57
|
#mut_isSkipping;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skip-until.mjs","sources":["../../../src/core/operators/skip-until.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"skip-until.mjs","sources":["../../../src/core/operators/skip-until.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDG;MACU,SAAS,GACpB,CAAK,QAA6B,KAClC,CAAC,gBAAgB,KACf,IAAI,wBAAwB,CAAC,gBAAgB,EAAE,QAAQ;AAE3D,MAAM,wBACJ,SAAQ,wBAAyC,CAAA;AAGjD,IAAA,eAAe;IAEf,WAAA,CAAY,gBAA+B,EAAE,QAA6B,EAAA;AACxE,QAAA,KAAK,CAAC;YACJ,OAAO,EAAE,CAAC,gBAAgB,CAAC;YAC3B,YAAY,EAAE,QAAQ,CAAC,IAAI;AAC5B,SAAA,CAAC;AAEF,QAAA,IAAI,CAAC,eAAe,GAAG,IAAI;AAE3B,QAAA,QAAQ,CAAC,SAAS,CAChB,MAAK;AACH,YAAA,IAAI,CAAC,eAAe,GAAG,KAAK;QAC9B,CAAC,EACD,MAAK;AACH,YAAA,IAAI,CAAC,eAAe,GAAG,KAAK;AAC9B,QAAA,CAAC,CACF;IACH;AAES,IAAA,SAAS,CAAC,aAA4B,EAAA;QAC7C,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;AAE3B,QAAA,MAAM,EAAE,GAAG,GAAG,CAAC,WAAW,EAAE;AAE5B,QAAA,IACE,GAAG,CAAC,aAAa,KAAK,aAAa;AACnC,YAAA,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACnB,IAAI,CAAC,eAAe,EACpB;AACA,YAAA,OAAO;QACT;QAEA,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC;IACvC;AACD;;;;"}
|