synstate 0.1.0 → 0.1.2
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 +272 -532
- package/assets/synstate-icon.png +0 -0
- package/dist/core/combine/combine.d.mts +33 -3
- package/dist/core/combine/combine.d.mts.map +1 -1
- package/dist/core/combine/combine.mjs +34 -4
- 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 +21 -2
- package/dist/core/create/source.d.mts.map +1 -1
- package/dist/core/create/source.mjs +2 -2
- 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/index.d.mts +1 -0
- package/dist/core/index.d.mts.map +1 -1
- package/dist/core/index.mjs +15 -3
- package/dist/core/index.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/index.mjs +3 -3
- package/dist/core/operators/map-with-index.d.mts +19 -17
- package/dist/core/operators/map-with-index.d.mts.map +1 -1
- package/dist/core/operators/map-with-index.mjs +21 -23
- package/dist/core/operators/map-with-index.mjs.map +1 -1
- package/dist/core/operators/merge-map.d.mts +48 -6
- package/dist/core/operators/merge-map.d.mts.map +1 -1
- package/dist/core/operators/merge-map.mjs +48 -6
- 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 +26 -2
- package/dist/core/operators/skip-if-no-change.d.mts.map +1 -1
- package/dist/core/operators/skip-if-no-change.mjs +27 -3
- 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 -1
- package/dist/core/operators/skip-while.d.mts.map +1 -1
- package/dist/core/operators/skip-while.mjs +50 -5
- 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 -1
- package/dist/core/operators/take-while.d.mts.map +1 -1
- package/dist/core/operators/take-while.mjs +48 -3
- 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 +57 -0
- package/dist/core/operators/with-buffered-from.d.mts.map +1 -1
- package/dist/core/operators/with-buffered-from.mjs +58 -1
- package/dist/core/operators/with-buffered-from.mjs.map +1 -1
- package/dist/core/operators/with-current-value-from.d.mts +59 -0
- package/dist/core/operators/with-current-value-from.d.mts.map +1 -1
- package/dist/core/operators/with-current-value-from.mjs +60 -1
- 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/predefined/index.d.mts +2 -0
- package/dist/core/predefined/index.d.mts.map +1 -0
- package/dist/core/predefined/index.mjs +13 -0
- package/dist/core/predefined/index.mjs.map +1 -0
- package/dist/core/predefined/operators/attach-index.d.mts +8 -0
- package/dist/core/predefined/operators/attach-index.d.mts.map +1 -0
- package/dist/core/predefined/operators/attach-index.mjs +13 -0
- package/dist/core/predefined/operators/attach-index.mjs.map +1 -0
- package/dist/core/predefined/operators/index.d.mts +13 -0
- package/dist/core/predefined/operators/index.d.mts.map +1 -0
- package/dist/core/predefined/operators/index.mjs +13 -0
- package/dist/core/predefined/operators/index.mjs.map +1 -0
- package/dist/core/predefined/operators/map-optional.d.mts +4 -0
- package/dist/core/predefined/operators/map-optional.d.mts.map +1 -0
- package/dist/core/predefined/operators/map-optional.mjs +7 -0
- package/dist/core/predefined/operators/map-optional.mjs.map +1 -0
- package/dist/core/predefined/operators/map-result-err.d.mts +4 -0
- package/dist/core/predefined/operators/map-result-err.d.mts.map +1 -0
- package/dist/core/predefined/operators/map-result-err.mjs +7 -0
- package/dist/core/predefined/operators/map-result-err.mjs.map +1 -0
- package/dist/core/predefined/operators/map-result-ok.d.mts +4 -0
- package/dist/core/predefined/operators/map-result-ok.d.mts.map +1 -0
- package/dist/core/predefined/operators/map-result-ok.mjs +7 -0
- package/dist/core/predefined/operators/map-result-ok.mjs.map +1 -0
- package/dist/core/predefined/operators/map-to.d.mts +3 -0
- package/dist/core/predefined/operators/map-to.d.mts.map +1 -0
- package/dist/core/predefined/operators/map-to.mjs +6 -0
- package/dist/core/predefined/operators/map-to.mjs.map +1 -0
- package/dist/core/predefined/operators/map.d.mts +3 -0
- package/dist/core/predefined/operators/map.d.mts.map +1 -0
- package/dist/core/predefined/operators/map.mjs +8 -0
- package/dist/core/predefined/operators/map.mjs.map +1 -0
- package/dist/core/predefined/operators/pluck.d.mts +8 -0
- package/dist/core/predefined/operators/pluck.d.mts.map +1 -0
- package/dist/core/predefined/operators/pluck.mjs +11 -0
- package/dist/core/predefined/operators/pluck.mjs.map +1 -0
- package/dist/core/predefined/operators/skip.d.mts +3 -0
- package/dist/core/predefined/operators/skip.d.mts.map +1 -0
- package/dist/core/predefined/operators/skip.mjs +9 -0
- package/dist/core/predefined/operators/skip.mjs.map +1 -0
- package/dist/core/predefined/operators/take.d.mts +3 -0
- package/dist/core/predefined/operators/take.d.mts.map +1 -0
- package/dist/core/predefined/operators/take.mjs +8 -0
- package/dist/core/predefined/operators/take.mjs.map +1 -0
- package/dist/core/predefined/operators/unwrap-optional.d.mts +4 -0
- package/dist/core/predefined/operators/unwrap-optional.d.mts.map +1 -0
- package/dist/core/predefined/operators/unwrap-optional.mjs +9 -0
- package/dist/core/predefined/operators/unwrap-optional.mjs.map +1 -0
- package/dist/core/predefined/operators/unwrap-result-err.d.mts +4 -0
- package/dist/core/predefined/operators/unwrap-result-err.d.mts.map +1 -0
- package/dist/core/predefined/operators/unwrap-result-err.mjs +7 -0
- package/dist/core/predefined/operators/unwrap-result-err.mjs.map +1 -0
- package/dist/core/predefined/operators/unwrap-result-ok.d.mts +4 -0
- package/dist/core/predefined/operators/unwrap-result-ok.d.mts.map +1 -0
- package/dist/core/predefined/operators/unwrap-result-ok.mjs +9 -0
- package/dist/core/predefined/operators/unwrap-result-ok.mjs.map +1 -0
- package/dist/core/types/observable-family.d.mts +7 -7
- package/dist/entry-point.mjs +15 -3
- package/dist/entry-point.mjs.map +1 -1
- package/dist/index.mjs +15 -3
- package/dist/index.mjs.map +1 -1
- 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 +34 -4
- 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 +22 -3
- package/src/core/create/timer.mts +23 -4
- package/src/core/index.mts +1 -0
- 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 +22 -66
- package/src/core/operators/merge-map.mts +48 -6
- 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 +27 -3
- package/src/core/operators/skip-until.mts +50 -0
- package/src/core/operators/skip-while.mts +49 -16
- 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 +49 -8
- package/src/core/operators/throttle-time.mts +44 -5
- package/src/core/operators/with-buffered-from.mts +58 -1
- package/src/core/operators/with-current-value-from.mts +60 -1
- package/src/core/operators/with-initial-value.mts +24 -2
- package/src/core/predefined/index.mts +1 -0
- package/src/core/predefined/operators/attach-index.mts +13 -0
- package/src/core/predefined/operators/index.mts +12 -0
- package/src/core/predefined/operators/map-optional.mts +8 -0
- package/src/core/predefined/operators/map-result-err.mts +8 -0
- package/src/core/predefined/operators/map-result-ok.mts +8 -0
- package/src/core/predefined/operators/map-to.mts +5 -0
- package/src/core/predefined/operators/map.mts +5 -0
- package/src/core/predefined/operators/pluck.mts +12 -0
- package/src/core/predefined/operators/skip.mts +10 -0
- package/src/core/predefined/operators/take.mts +6 -0
- package/src/core/predefined/operators/unwrap-optional.mts +9 -0
- package/src/core/predefined/operators/unwrap-result-err.mts +8 -0
- package/src/core/predefined/operators/unwrap-result-ok.mts +9 -0
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debounce-time.d.mts","sourceRoot":"","sources":["../../../src/core/operators/debounce-time.mts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,wBAAwB,EAG9B,MAAM,oBAAoB,CAAC;AAE5B
|
|
1
|
+
{"version":3,"file":"debounce-time.d.mts","sourceRoot":"","sources":["../../../src/core/operators/debounce-time.mts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,wBAAwB,EAG9B,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,EAC5B,cAAc,MAAM,KACnB,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAMQ,CAAC"}
|
|
@@ -12,12 +12,27 @@ import '../utils/id-maker.mjs';
|
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* ```ts
|
|
15
|
+
* // Timeline (300ms debounce):
|
|
16
|
+
* //
|
|
17
|
+
* // Time(ms) 0 100 200 300 400 500 600 ... 900 1000
|
|
18
|
+
* // input$ 'h' 'he' 'hel' 'hello'
|
|
19
|
+
* // debounced$ 'hello' (emitted after 300ms silence)
|
|
20
|
+
* //
|
|
21
|
+
* // Explanation:
|
|
22
|
+
* // - At 0ms: 'h' is emitted, timer starts
|
|
23
|
+
* // - At 100ms: 'he' is emitted, timer resets
|
|
24
|
+
* // - At 200ms: 'hel' is emitted, timer resets
|
|
25
|
+
* // - At 300ms: 'hello' is emitted, timer resets
|
|
26
|
+
* // - At 600ms: No new emission for 300ms, 'hello' is finally emitted
|
|
27
|
+
*
|
|
15
28
|
* const input$ = source<string>();
|
|
16
29
|
*
|
|
17
30
|
* const debounced$ = input$.pipe(debounceTime(300));
|
|
18
31
|
*
|
|
32
|
+
* const mut_history: string[] = [];
|
|
33
|
+
*
|
|
19
34
|
* debounced$.subscribe((value) => {
|
|
20
|
-
*
|
|
35
|
+
* mut_history.push(value);
|
|
21
36
|
* });
|
|
22
37
|
*
|
|
23
38
|
* input$.next('h');
|
|
@@ -27,7 +42,12 @@ import '../utils/id-maker.mjs';
|
|
|
27
42
|
* input$.next('hel');
|
|
28
43
|
*
|
|
29
44
|
* input$.next('hello');
|
|
30
|
-
*
|
|
45
|
+
*
|
|
46
|
+
* await new Promise((resolve) => {
|
|
47
|
+
* setTimeout(resolve, 400);
|
|
48
|
+
* });
|
|
49
|
+
*
|
|
50
|
+
* assert.deepStrictEqual(mut_history, ['hello']);
|
|
31
51
|
* ```
|
|
32
52
|
*/
|
|
33
53
|
const debounceTime = (milliSeconds) =>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debounce-time.mjs","sources":["../../../src/core/operators/debounce-time.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AASA
|
|
1
|
+
{"version":3,"file":"debounce-time.mjs","sources":["../../../src/core/operators/debounce-time.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CG;AACI,MAAM,YAAY,GAAG,CAC1B,YAAoB;AAEpB;AACA,CAAC,CAAC,gBAAgB,KAChB,IAAI,2BAA2B,CAC7B,gBAAgB,EAChB,YAAY,CACb;AAEL,MAAM,2BACJ,SAAQ,yBAA0C,CAAA;AAGzC,IAAA,aAAa;AACtB,IAAA,YAAY;IAEZ,WAAA,CAAY,gBAA+B,EAAE,YAAoB,EAAA;AAC/D,QAAA,KAAK,CAAC;YACJ,OAAO,EAAE,CAAC,gBAAgB,CAAC;AAC3B,YAAA,YAAY,EAAE,gBAAgB,CAAC,WAAW,EAAE;AAC7C,SAAA,CAAC;AAEF,QAAA,IAAI,CAAC,YAAY,GAAG,SAAS;AAE7B,QAAA,IAAI,CAAC,aAAa,GAAG,YAAY;IACnC;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,IAAI,CAAC,WAAW,EAAE;;AAGlB,QAAA,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC,MAAK;AAClC,YAAA,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;gBAAE;AAEzB,YAAA,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,KAAK,CAAC;AAC5B,QAAA,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC;IACxB;IAEA,WAAW,GAAA;AACT,QAAA,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE;AACnC,YAAA,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC;QACjC;IACF;IAES,QAAQ,GAAA;QACf,IAAI,CAAC,WAAW,EAAE;QAElB,KAAK,CAAC,QAAQ,EAAE;IAClB;AACD;;;;"}
|
|
@@ -10,17 +10,42 @@ import { type DropInitialValueOperator } from '../types/index.mjs';
|
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* ```ts
|
|
13
|
+
* // Timeline:
|
|
14
|
+
* //
|
|
15
|
+
* // num$ 1 2 3 4 5 6
|
|
16
|
+
* // even$ 2 4 6
|
|
17
|
+
* //
|
|
18
|
+
* // Explanation:
|
|
19
|
+
* // - filter passes through only values that satisfy the predicate
|
|
20
|
+
* // - Only even numbers (2, 4, 6) are emitted
|
|
21
|
+
*
|
|
13
22
|
* const num$ = source<number>();
|
|
14
23
|
*
|
|
15
24
|
* const even$ = num$.pipe(filter((x) => x % 2 === 0));
|
|
16
25
|
*
|
|
26
|
+
* const mut_history: number[] = [];
|
|
27
|
+
*
|
|
17
28
|
* even$.subscribe((x) => {
|
|
18
|
-
*
|
|
29
|
+
* mut_history.push(x);
|
|
19
30
|
* });
|
|
20
31
|
*
|
|
21
32
|
* num$.next(1); // nothing logged
|
|
22
33
|
*
|
|
23
34
|
* num$.next(2); // logs: 2
|
|
35
|
+
*
|
|
36
|
+
* assert.deepStrictEqual(mut_history, [2]);
|
|
37
|
+
*
|
|
38
|
+
* num$.next(3); // nothing logged
|
|
39
|
+
*
|
|
40
|
+
* num$.next(4); // logs: 4
|
|
41
|
+
*
|
|
42
|
+
* assert.deepStrictEqual(mut_history, [2, 4]);
|
|
43
|
+
*
|
|
44
|
+
* num$.next(5);
|
|
45
|
+
*
|
|
46
|
+
* num$.next(6);
|
|
47
|
+
*
|
|
48
|
+
* assert.deepStrictEqual(mut_history, [2, 4, 6]);
|
|
24
49
|
* ```
|
|
25
50
|
*/
|
|
26
51
|
export declare function filter<A, B extends A>(predicate: (value: A, index: SafeUint | -1) => value is B): DropInitialValueOperator<A, B>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.d.mts","sourceRoot":"","sources":["../../../src/core/operators/filter.mts"],"names":[],"mappings":"AASA,OAAO,EACL,KAAK,wBAAwB,EAK9B,MAAM,oBAAoB,CAAC;AAG5B
|
|
1
|
+
{"version":3,"file":"filter.d.mts","sourceRoot":"","sources":["../../../src/core/operators/filter.mts"],"names":[],"mappings":"AASA,OAAO,EACL,KAAK,wBAAwB,EAK9B,MAAM,oBAAoB,CAAC;AAG5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,EACnC,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,GAAG,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,GACxD,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAElC,wBAAgB,MAAM,CAAC,CAAC,EACtB,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,GAAG,CAAC,CAAC,KAAK,OAAO,GACrD,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.mjs","sources":["../../../src/core/operators/filter.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"filter.mjs","sources":["../../../src/core/operators/filter.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AA2EM,SAAU,MAAM,CACpB,SAAsD,EAAA;AAEtD,IAAA,OAAO,CAAC,gBAAgB,KACtB,IAAI,qBAAqB,CAAC,gBAAgB,EAAE,SAAS,CAAC;AAC1D;AAEA,MAAM,qBACJ,SAAQ,wBAAyC,CAAA;AAGxC,IAAA,UAAU;AACnB,IAAA,UAAU;IAEV,WAAA,CACE,gBAA+B,EAC/B,SAAkD,EAAA;AAElD,QAAA,KAAK,CAAC;YACJ,OAAO,EAAE,CAAC,gBAAgB,CAAC;YAC3B,YAAY,EAAE,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,KACxD,QAAQ,CAAC,MAAM,CAAC,EAAE;kBACd,QAAQ,CAAC;kBACT,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE;AACtB,sBAAE;AACF,sBAAE,QAAQ,CAAC,IAAI,CACpB,CAAC,KAAK;AACR,SAAA,CAAC;AAEF,QAAA,IAAI,CAAC,UAAU,GAAG,EAAE;AAEpB,QAAA,IAAI,CAAC,UAAU,GAAG,SAAS;;AAGpB,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,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,EAAE;YAC9C,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC;;;AAG1C;;;;"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export { auditTime } from './audit-time.mjs';
|
|
2
2
|
export { debounceTime } from './debounce-time.mjs';
|
|
3
3
|
export { filter } from './filter.mjs';
|
|
4
|
-
export {
|
|
4
|
+
export { mapWithIndex } from './map-with-index.mjs';
|
|
5
5
|
export { flatMap, mergeMap } from './merge-map.mjs';
|
|
6
6
|
export { pairwise } from './pairwise.mjs';
|
|
7
7
|
export { scan } from './scan.mjs';
|
|
8
8
|
export { distinctUntilChanged, skipIfNoChange } from './skip-if-no-change.mjs';
|
|
9
9
|
export { skipUntil } from './skip-until.mjs';
|
|
10
|
-
export {
|
|
10
|
+
export { skipWhile } from './skip-while.mjs';
|
|
11
11
|
export { switchMap } from './switch-map.mjs';
|
|
12
12
|
export { takeUntil } from './take-until.mjs';
|
|
13
|
-
export {
|
|
13
|
+
export { takeWhile } from './take-while.mjs';
|
|
14
14
|
export { throttleTime } from './throttle-time.mjs';
|
|
15
15
|
export { withBuffered, withBufferedFrom } from './with-buffered-from.mjs';
|
|
16
16
|
export { withCurrentValueFrom, withLatestFrom } from './with-current-value-from.mjs';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Optional, Result } from 'ts-data-forge';
|
|
2
1
|
import { type KeepInitialValueOperator } from '../types/index.mjs';
|
|
3
2
|
/**
|
|
4
3
|
* Transforms each value emitted by the source using a mapping function that also receives the emission index.
|
|
@@ -10,30 +9,33 @@ import { type KeepInitialValueOperator } from '../types/index.mjs';
|
|
|
10
9
|
*
|
|
11
10
|
* @example
|
|
12
11
|
* ```ts
|
|
13
|
-
*
|
|
12
|
+
* // Timeline:
|
|
13
|
+
* //
|
|
14
|
+
* // num$ "a" "b" "c"
|
|
15
|
+
* // indexed$ "0: a" "1: b" "2: c"
|
|
16
|
+
* //
|
|
17
|
+
* // Explanation:
|
|
18
|
+
* // - mapWithIndex transforms each value along with its index
|
|
19
|
+
* // - Index starts at 0 and increments with each emission
|
|
20
|
+
*
|
|
21
|
+
* const num$ = source<string>();
|
|
14
22
|
*
|
|
15
23
|
* const indexed$ = num$.pipe(mapWithIndex((x, i) => `${i}: ${x}`));
|
|
16
24
|
*
|
|
25
|
+
* const mut_history: string[] = [];
|
|
26
|
+
*
|
|
17
27
|
* indexed$.subscribe((s) => {
|
|
18
|
-
*
|
|
28
|
+
* mut_history.push(s);
|
|
19
29
|
* });
|
|
20
30
|
*
|
|
21
|
-
* num$.next(
|
|
31
|
+
* num$.next('a'); // 0: a
|
|
32
|
+
*
|
|
33
|
+
* num$.next('b'); // 1: b
|
|
34
|
+
*
|
|
35
|
+
* num$.next('c'); // 2: c
|
|
22
36
|
*
|
|
23
|
-
*
|
|
37
|
+
* assert.deepStrictEqual(mut_history, ['0: a', '1: b', '2: c']);
|
|
24
38
|
* ```
|
|
25
39
|
*/
|
|
26
40
|
export declare const mapWithIndex: <A, B>(mapFn: (x: A, index: SafeUint | -1) => B) => KeepInitialValueOperator<A, B>;
|
|
27
|
-
export declare const map: <A, B>(mapFn: (x: A) => B) => KeepInitialValueOperator<A, B>;
|
|
28
|
-
export declare const mapTo: <A, B>(value: B) => KeepInitialValueOperator<A, B>;
|
|
29
|
-
export declare const pluck: <A, K extends keyof A>(key: K) => KeepInitialValueOperator<A, A[K]>;
|
|
30
|
-
export declare const getKey: <A, K extends keyof A>(key: K) => KeepInitialValueOperator<A, A[K]>;
|
|
31
|
-
export declare const attachIndex: <A>() => KeepInitialValueOperator<A, readonly [SafeUint | -1, A]>;
|
|
32
|
-
export declare const withIndex: <A>() => KeepInitialValueOperator<A, readonly [SafeUint | -1, A]>;
|
|
33
|
-
export declare const unwrapOptional: <O extends UnknownOptional>() => KeepInitialValueOperator<O, Optional.Unwrap<O> | undefined>;
|
|
34
|
-
export declare const unwrapResultOk: <R extends UnknownResult>() => KeepInitialValueOperator<R, Result.UnwrapOk<R> | undefined>;
|
|
35
|
-
export declare const unwrapResultErr: <R extends UnknownResult>() => KeepInitialValueOperator<R, Result.UnwrapErr<R> | undefined>;
|
|
36
|
-
export declare const mapOptional: <O extends UnknownOptional, B>(mapFn: (x: Optional.Unwrap<O>) => B) => KeepInitialValueOperator<O, Optional<B>>;
|
|
37
|
-
export declare const mapResultOk: <R extends UnknownResult, S2>(mapFn: (x: Result.UnwrapOk<R>) => S2) => KeepInitialValueOperator<R, Result<S2, Result.UnwrapErr<R>>>;
|
|
38
|
-
export declare const mapResultErr: <R extends UnknownResult, E2>(mapFn: (x: Result.UnwrapErr<R>) => E2) => KeepInitialValueOperator<R, Result<Result.UnwrapOk<R>, E2>>;
|
|
39
41
|
//# sourceMappingURL=map-with-index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-with-index.d.mts","sourceRoot":"","sources":["../../../src/core/operators/map-with-index.mts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"map-with-index.d.mts","sourceRoot":"","sources":["../../../src/core/operators/map-with-index.mts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,wBAAwB,EAI9B,MAAM,oBAAoB,CAAC;AAG5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,EAAE,CAAC,EAC/B,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,KACvC,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAMQ,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Optional, asSafeUint, SafeUint
|
|
1
|
+
import { Optional, asSafeUint, SafeUint } from 'ts-data-forge';
|
|
2
2
|
import { SyncChildObservableClass } from '../class/child-observable-class.mjs';
|
|
3
3
|
import '../utils/id-maker.mjs';
|
|
4
4
|
|
|
@@ -12,39 +12,37 @@ 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
|
|
24
37
|
*
|
|
25
|
-
* num$.next(
|
|
38
|
+
* num$.next('c'); // 2: c
|
|
39
|
+
*
|
|
40
|
+
* assert.deepStrictEqual(mut_history, ['0: a', '1: b', '2: c']);
|
|
26
41
|
* ```
|
|
27
42
|
*/
|
|
28
43
|
const mapWithIndex = (mapFn) =>
|
|
29
44
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
30
45
|
((parentObservable) => new MapWithIndexObservableClass(parentObservable, mapFn));
|
|
31
|
-
/* Specialized operators */
|
|
32
|
-
const map = (mapFn) => mapWithIndex(mapFn);
|
|
33
|
-
const mapTo = (value) => map(() => value);
|
|
34
|
-
const pluck = (key) => map((a) => a[key]);
|
|
35
|
-
const getKey = pluck; // alias
|
|
36
|
-
const attachIndex = () => mapWithIndex((a, i) => [i, a]);
|
|
37
|
-
const withIndex = attachIndex; // alias
|
|
38
|
-
const unwrapOptional = () =>
|
|
39
|
-
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
40
|
-
map(Optional.unwrap);
|
|
41
|
-
const unwrapResultOk = () =>
|
|
42
|
-
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
43
|
-
map(Result.unwrapOk);
|
|
44
|
-
const unwrapResultErr = () => map(Result.unwrapErr);
|
|
45
|
-
const mapOptional = (mapFn) => map((a) => Optional.map(a, mapFn));
|
|
46
|
-
const mapResultOk = (mapFn) => map((a) => Result.map(a, mapFn));
|
|
47
|
-
const mapResultErr = (mapFn) => map((a) => Result.mapErr(a, mapFn));
|
|
48
46
|
/* implementation */
|
|
49
47
|
class MapWithIndexObservableClass extends SyncChildObservableClass {
|
|
50
48
|
#mapFn;
|
|
@@ -69,5 +67,5 @@ class MapWithIndexObservableClass extends SyncChildObservableClass {
|
|
|
69
67
|
}
|
|
70
68
|
}
|
|
71
69
|
|
|
72
|
-
export {
|
|
70
|
+
export { mapWithIndex };
|
|
73
71
|
//# sourceMappingURL=map-with-index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-with-index.mjs","sources":["../../../src/core/operators/map-with-index.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"map-with-index.mjs","sources":["../../../src/core/operators/map-with-index.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCG;AACI,MAAM,YAAY,GAAG,CAC1B,KAAwC;AAExC;AACA,CAAC,CAAC,gBAAgB,KAChB,IAAI,2BAA2B,CAC7B,gBAAgB,EAChB,KAAK,CACN;AAEL;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`,
|
|
@@ -27,7 +69,7 @@ import { type DropInitialValueOperator, type Observable } from '../types/index.m
|
|
|
27
69
|
*/
|
|
28
70
|
export declare const mergeMap: <A, B>(mapToObservable: (curr: A) => Observable<B>) => DropInitialValueOperator<A, B>;
|
|
29
71
|
/**
|
|
30
|
-
* Alias for `mergeMap
|
|
72
|
+
* Alias for `mergeMap`.
|
|
31
73
|
* @see mergeMap
|
|
32
74
|
*/
|
|
33
75
|
export declare const flatMap: <A, B>(mapToObservable: (curr: A) => Observable<B>) => DropInitialValueOperator<A, B>;
|
|
@@ -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`,
|
|
@@ -30,7 +72,7 @@ import '../utils/id-maker.mjs';
|
|
|
30
72
|
*/
|
|
31
73
|
const mergeMap = (mapToObservable) => (parentObservable) => new MergeMapObservableClass(parentObservable, mapToObservable);
|
|
32
74
|
/**
|
|
33
|
-
* Alias for `mergeMap
|
|
75
|
+
* Alias for `mergeMap`.
|
|
34
76
|
* @see mergeMap
|
|
35
77
|
*/
|
|
36
78
|
const flatMap = 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);
|