synstate 0.1.2 → 1.0.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 +199 -146
- package/dist/core/class/child-observable-class.d.mts.map +1 -1
- package/dist/core/class/child-observable-class.mjs +43 -10
- package/dist/core/class/child-observable-class.mjs.map +1 -1
- package/dist/core/class/observable-base-class.d.mts +4 -4
- package/dist/core/class/observable-base-class.d.mts.map +1 -1
- package/dist/core/class/observable-base-class.mjs +8 -8
- package/dist/core/class/observable-base-class.mjs.map +1 -1
- package/dist/core/class/root-observable-class.d.mts +1 -1
- package/dist/core/class/root-observable-class.d.mts.map +1 -1
- package/dist/core/class/root-observable-class.mjs +9 -9
- package/dist/core/class/root-observable-class.mjs.map +1 -1
- package/dist/core/combine/combine.d.mts +6 -6
- package/dist/core/combine/combine.mjs +11 -12
- package/dist/core/combine/combine.mjs.map +1 -1
- package/dist/core/combine/merge.d.mts +6 -6
- package/dist/core/combine/merge.mjs +9 -9
- package/dist/core/combine/merge.mjs.map +1 -1
- package/dist/core/combine/zip.d.mts +20 -19
- package/dist/core/combine/zip.d.mts.map +1 -1
- package/dist/core/combine/zip.mjs +22 -21
- package/dist/core/combine/zip.mjs.map +1 -1
- package/dist/core/create/{interval.d.mts → counter.d.mts} +14 -12
- package/dist/core/create/counter.d.mts.map +1 -0
- package/dist/core/create/{interval.mjs → counter.mjs} +21 -23
- package/dist/core/create/counter.mjs.map +1 -0
- package/dist/core/create/from-abortable-promise.d.mts +29 -0
- package/dist/core/create/from-abortable-promise.d.mts.map +1 -0
- package/dist/core/create/from-abortable-promise.mjs +70 -0
- package/dist/core/create/from-abortable-promise.mjs.map +1 -0
- package/dist/core/create/from-promise.d.mts +9 -6
- package/dist/core/create/from-promise.d.mts.map +1 -1
- package/dist/core/create/from-promise.mjs +8 -5
- package/dist/core/create/from-promise.mjs.map +1 -1
- package/dist/core/create/from-subscribable.d.mts +4 -4
- package/dist/core/create/from-subscribable.mjs +4 -4
- package/dist/core/create/index.d.mts +3 -3
- package/dist/core/create/index.d.mts.map +1 -1
- package/dist/core/create/index.mjs +4 -4
- package/dist/core/create/just.d.mts +32 -0
- package/dist/core/create/just.d.mts.map +1 -0
- package/dist/core/create/just.mjs +44 -0
- package/dist/core/create/just.mjs.map +1 -0
- package/dist/core/create/source.d.mts +7 -12
- package/dist/core/create/source.d.mts.map +1 -1
- package/dist/core/create/source.mjs +1 -6
- package/dist/core/create/source.mjs.map +1 -1
- package/dist/core/create/timer.d.mts +6 -4
- package/dist/core/create/timer.d.mts.map +1 -1
- package/dist/core/create/timer.mjs +6 -7
- package/dist/core/create/timer.mjs.map +1 -1
- package/dist/core/index.d.mts +0 -1
- package/dist/core/index.d.mts.map +1 -1
- package/dist/core/index.mjs +8 -13
- package/dist/core/index.mjs.map +1 -1
- package/dist/core/operators/audit.d.mts +97 -0
- package/dist/core/operators/audit.d.mts.map +1 -0
- package/dist/core/operators/audit.mjs +144 -0
- package/dist/core/operators/audit.mjs.map +1 -0
- package/dist/core/operators/debounce.d.mts +88 -0
- package/dist/core/operators/debounce.d.mts.map +1 -0
- package/dist/core/operators/debounce.mjs +130 -0
- package/dist/core/operators/debounce.mjs.map +1 -0
- package/dist/core/operators/filter.d.mts +5 -5
- package/dist/core/operators/filter.mjs +3 -3
- package/dist/core/operators/filter.mjs.map +1 -1
- package/dist/core/operators/index.d.mts +4 -4
- package/dist/core/operators/index.d.mts.map +1 -1
- package/dist/core/operators/index.mjs +4 -4
- package/dist/core/operators/{map-with-index.d.mts → map.d.mts} +11 -11
- package/dist/core/operators/map.d.mts.map +1 -0
- package/dist/core/operators/{map-with-index.mjs → map.mjs} +17 -17
- package/dist/core/operators/map.mjs.map +1 -0
- package/dist/core/operators/merge-map.d.mts +56 -29
- package/dist/core/operators/merge-map.d.mts.map +1 -1
- package/dist/core/operators/merge-map.mjs +58 -31
- package/dist/core/operators/merge-map.mjs.map +1 -1
- package/dist/core/operators/pairwise.d.mts +6 -6
- package/dist/core/operators/pairwise.mjs +9 -9
- package/dist/core/operators/pairwise.mjs.map +1 -1
- package/dist/core/operators/scan.d.mts +6 -6
- package/dist/core/operators/scan.mjs +9 -9
- package/dist/core/operators/scan.mjs.map +1 -1
- package/dist/core/operators/skip-if-no-change.d.mts +20 -8
- package/dist/core/operators/skip-if-no-change.d.mts.map +1 -1
- package/dist/core/operators/skip-if-no-change.mjs +23 -11
- package/dist/core/operators/skip-if-no-change.mjs.map +1 -1
- package/dist/core/operators/skip-until.d.mts +5 -5
- package/dist/core/operators/skip-until.mjs +8 -8
- package/dist/core/operators/skip-until.mjs.map +1 -1
- package/dist/core/operators/skip-while.d.mts +18 -8
- package/dist/core/operators/skip-while.d.mts.map +1 -1
- package/dist/core/operators/skip-while.mjs +26 -11
- package/dist/core/operators/skip-while.mjs.map +1 -1
- package/dist/core/operators/switch-map.d.mts +57 -26
- package/dist/core/operators/switch-map.d.mts.map +1 -1
- package/dist/core/operators/switch-map.mjs +59 -28
- package/dist/core/operators/switch-map.mjs.map +1 -1
- package/dist/core/operators/take-until.d.mts +5 -5
- package/dist/core/operators/take-until.mjs +8 -8
- package/dist/core/operators/take-until.mjs.map +1 -1
- package/dist/core/operators/take-while.d.mts +15 -7
- package/dist/core/operators/take-while.d.mts.map +1 -1
- package/dist/core/operators/take-while.mjs +18 -10
- package/dist/core/operators/take-while.mjs.map +1 -1
- package/dist/core/operators/throttle.d.mts +81 -0
- package/dist/core/operators/throttle.d.mts.map +1 -0
- package/dist/core/operators/throttle.mjs +126 -0
- package/dist/core/operators/throttle.mjs.map +1 -0
- package/dist/core/operators/with-buffered-from.d.mts +9 -9
- package/dist/core/operators/with-buffered-from.mjs +12 -12
- package/dist/core/operators/with-buffered-from.mjs.map +1 -1
- package/dist/core/operators/with-current-value-from.d.mts +10 -9
- package/dist/core/operators/with-current-value-from.d.mts.map +1 -1
- package/dist/core/operators/with-current-value-from.mjs +13 -12
- package/dist/core/operators/with-current-value-from.mjs.map +1 -1
- package/dist/core/operators/with-initial-value.d.mts +5 -5
- package/dist/core/operators/with-initial-value.mjs +8 -8
- package/dist/core/operators/with-initial-value.mjs.map +1 -1
- package/dist/core/predefined/index.mjs +0 -1
- package/dist/core/predefined/index.mjs.map +1 -1
- package/dist/core/predefined/operators/attach-index.d.mts +49 -0
- package/dist/core/predefined/operators/attach-index.d.mts.map +1 -1
- package/dist/core/predefined/operators/attach-index.mjs +51 -2
- package/dist/core/predefined/operators/attach-index.mjs.map +1 -1
- package/dist/core/predefined/operators/index.d.mts +0 -1
- package/dist/core/predefined/operators/index.d.mts.map +1 -1
- package/dist/core/predefined/operators/index.mjs +0 -1
- package/dist/core/predefined/operators/index.mjs.map +1 -1
- package/dist/core/predefined/operators/map-optional.d.mts +47 -0
- package/dist/core/predefined/operators/map-optional.d.mts.map +1 -1
- package/dist/core/predefined/operators/map-optional.mjs +49 -1
- package/dist/core/predefined/operators/map-optional.mjs.map +1 -1
- package/dist/core/predefined/operators/map-result-err.d.mts +47 -0
- package/dist/core/predefined/operators/map-result-err.d.mts.map +1 -1
- package/dist/core/predefined/operators/map-result-err.mjs +49 -1
- package/dist/core/predefined/operators/map-result-err.mjs.map +1 -1
- package/dist/core/predefined/operators/map-result-ok.d.mts +47 -0
- package/dist/core/predefined/operators/map-result-ok.d.mts.map +1 -1
- package/dist/core/predefined/operators/map-result-ok.mjs +49 -1
- package/dist/core/predefined/operators/map-result-ok.mjs.map +1 -1
- package/dist/core/predefined/operators/map-to.d.mts +40 -0
- package/dist/core/predefined/operators/map-to.d.mts.map +1 -1
- package/dist/core/predefined/operators/map-to.mjs +43 -1
- package/dist/core/predefined/operators/map-to.mjs.map +1 -1
- package/dist/core/predefined/operators/pluck.d.mts +39 -0
- package/dist/core/predefined/operators/pluck.d.mts.map +1 -1
- package/dist/core/predefined/operators/pluck.mjs +42 -1
- package/dist/core/predefined/operators/pluck.mjs.map +1 -1
- package/dist/core/predefined/operators/skip.d.mts +47 -0
- package/dist/core/predefined/operators/skip.d.mts.map +1 -1
- package/dist/core/predefined/operators/skip.mjs +47 -0
- package/dist/core/predefined/operators/skip.mjs.map +1 -1
- package/dist/core/predefined/operators/take.d.mts +41 -0
- package/dist/core/predefined/operators/take.d.mts.map +1 -1
- package/dist/core/predefined/operators/take.mjs +41 -0
- package/dist/core/predefined/operators/take.mjs.map +1 -1
- package/dist/core/predefined/operators/unwrap-optional.d.mts +40 -0
- package/dist/core/predefined/operators/unwrap-optional.d.mts.map +1 -1
- package/dist/core/predefined/operators/unwrap-optional.mjs +42 -1
- package/dist/core/predefined/operators/unwrap-optional.mjs.map +1 -1
- package/dist/core/predefined/operators/unwrap-result-err.d.mts +40 -0
- package/dist/core/predefined/operators/unwrap-result-err.d.mts.map +1 -1
- package/dist/core/predefined/operators/unwrap-result-err.mjs +42 -1
- package/dist/core/predefined/operators/unwrap-result-err.mjs.map +1 -1
- package/dist/core/predefined/operators/unwrap-result-ok.d.mts +40 -0
- package/dist/core/predefined/operators/unwrap-result-ok.d.mts.map +1 -1
- package/dist/core/predefined/operators/unwrap-result-ok.mjs +42 -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/index.d.mts +1 -0
- package/dist/core/types/index.d.mts.map +1 -1
- package/dist/core/types/observable-family.d.mts +8 -14
- package/dist/core/types/observable-family.d.mts.map +1 -1
- package/dist/core/types/observable.d.mts +3 -3
- package/dist/core/types/observable.d.mts.map +1 -1
- package/dist/core/types/timer.d.mts +2 -0
- package/dist/core/types/timer.d.mts.map +1 -0
- package/dist/core/types/timer.mjs +2 -0
- package/dist/core/types/timer.mjs.map +1 -0
- package/dist/core/utils/id-maker.d.mts +2 -2
- package/dist/core/utils/id-maker.d.mts.map +1 -1
- package/dist/core/utils/id-maker.mjs +3 -3
- package/dist/core/utils/id-maker.mjs.map +1 -1
- package/dist/core/utils/index.mjs +1 -1
- package/dist/entry-point.mjs +11 -14
- package/dist/entry-point.mjs.map +1 -1
- package/dist/globals.d.mts +0 -3
- package/dist/index.mjs +11 -14
- package/dist/index.mjs.map +1 -1
- package/dist/utils/collect-to-array.d.mts +3 -0
- package/dist/utils/collect-to-array.d.mts.map +1 -0
- package/dist/utils/collect-to-array.mjs +11 -0
- package/dist/utils/collect-to-array.mjs.map +1 -0
- package/dist/utils/create-boolean-state.d.mts +40 -0
- package/dist/utils/create-boolean-state.d.mts.map +1 -0
- package/dist/utils/create-boolean-state.mjs +53 -0
- package/dist/utils/create-boolean-state.mjs.map +1 -0
- package/dist/utils/create-event-emitter.d.mts +4 -4
- package/dist/utils/create-event-emitter.mjs +4 -4
- package/dist/utils/create-reducer.d.mts +10 -7
- package/dist/utils/create-reducer.d.mts.map +1 -1
- package/dist/utils/create-reducer.mjs +7 -7
- package/dist/utils/create-reducer.mjs.map +1 -1
- package/dist/utils/create-state.d.mts +8 -48
- package/dist/utils/create-state.d.mts.map +1 -1
- package/dist/utils/create-state.mjs +10 -60
- package/dist/utils/create-state.mjs.map +1 -1
- package/dist/utils/index.d.mts +2 -0
- package/dist/utils/index.d.mts.map +1 -1
- package/dist/utils/index.mjs +3 -1
- package/dist/utils/index.mjs.map +1 -1
- package/package.json +17 -11
- package/src/core/class/child-observable-class.mts +65 -9
- package/src/core/class/circular-dependency-comparison.test.mts +142 -0
- package/src/core/class/circular-dependency.test.mts +251 -0
- package/src/core/class/observable-base-class.mts +9 -9
- package/src/core/class/root-observable-class.mts +14 -10
- package/src/core/combine/combine.mts +13 -13
- package/src/core/combine/merge.mts +13 -14
- package/src/core/combine/zip.mts +26 -25
- package/src/core/create/{interval.mts → counter.mts} +32 -30
- package/src/core/create/from-abortable-promise.mts +83 -0
- package/src/core/create/from-promise.mts +10 -7
- package/src/core/create/from-subscribable.mts +4 -4
- package/src/core/create/index.mts +3 -3
- package/src/core/create/just.mts +43 -0
- package/src/core/create/source.mts +10 -14
- package/src/core/create/timer.mts +12 -11
- package/src/core/index.mts +0 -1
- package/src/core/operators/audit.mts +172 -0
- package/src/core/operators/debounce.mts +154 -0
- package/src/core/operators/filter.mts +9 -9
- package/src/core/operators/index.mts +4 -4
- package/src/core/operators/{map-with-index.mts → map.mts} +20 -20
- package/src/core/operators/merge-map.mts +59 -32
- package/src/core/operators/pairwise.mts +10 -10
- package/src/core/operators/scan.mts +10 -10
- package/src/core/operators/skip-if-no-change.mts +24 -12
- package/src/core/operators/skip-until.mts +9 -9
- package/src/core/operators/skip-while.mts +29 -12
- package/src/core/operators/switch-map.mts +60 -29
- package/src/core/operators/take-until.mts +9 -9
- package/src/core/operators/take-while.mts +19 -11
- package/src/core/operators/{throttle-time.mts → throttle.mts} +58 -38
- package/src/core/operators/with-buffered-from.mts +13 -13
- package/src/core/operators/with-current-value-from.mts +14 -13
- package/src/core/operators/with-initial-value.mts +9 -9
- package/src/core/predefined/operators/attach-index.mts +51 -2
- package/src/core/predefined/operators/index.mts +0 -1
- package/src/core/predefined/operators/map-optional.mts +48 -1
- package/src/core/predefined/operators/map-result-err.mts +48 -1
- package/src/core/predefined/operators/map-result-ok.mts +48 -1
- package/src/core/predefined/operators/map-to.mts +41 -1
- package/src/core/predefined/operators/pluck.mts +40 -1
- package/src/core/predefined/operators/skip.mts +47 -0
- package/src/core/predefined/operators/take.mts +41 -0
- package/src/core/predefined/operators/unwrap-optional.mts +41 -1
- package/src/core/predefined/operators/unwrap-result-err.mts +41 -1
- package/src/core/predefined/operators/unwrap-result-ok.mts +41 -1
- package/src/core/types/id.mts +1 -1
- package/src/core/types/index.mts +1 -0
- package/src/core/types/observable-family.mts +8 -24
- package/src/core/types/observable.mts +3 -3
- package/src/core/types/timer.mts +2 -0
- package/src/core/utils/id-maker.mts +4 -4
- package/src/globals.d.mts +0 -3
- package/src/utils/collect-to-array.mts +17 -0
- package/src/utils/create-boolean-state.mts +68 -0
- package/src/utils/create-event-emitter.mts +4 -4
- package/src/utils/create-reducer.mts +11 -8
- package/src/utils/create-state.mts +10 -75
- package/src/utils/index.mts +2 -0
- package/dist/core/create/from-array.d.mts +0 -39
- package/dist/core/create/from-array.d.mts.map +0 -1
- package/dist/core/create/from-array.mjs +0 -65
- package/dist/core/create/from-array.mjs.map +0 -1
- package/dist/core/create/interval.d.mts.map +0 -1
- package/dist/core/create/interval.mjs.map +0 -1
- package/dist/core/create/of.d.mts +0 -39
- package/dist/core/create/of.d.mts.map +0 -1
- package/dist/core/create/of.mjs +0 -63
- package/dist/core/create/of.mjs.map +0 -1
- package/dist/core/operators/audit-time.d.mts +0 -62
- package/dist/core/operators/audit-time.d.mts.map +0 -1
- package/dist/core/operators/audit-time.mjs +0 -109
- package/dist/core/operators/audit-time.mjs.map +0 -1
- package/dist/core/operators/debounce-time.d.mts +0 -51
- package/dist/core/operators/debounce-time.d.mts.map +0 -1
- package/dist/core/operators/debounce-time.mjs +0 -93
- package/dist/core/operators/debounce-time.mjs.map +0 -1
- package/dist/core/operators/map-with-index.d.mts.map +0 -1
- package/dist/core/operators/map-with-index.mjs.map +0 -1
- package/dist/core/operators/throttle-time.d.mts +0 -62
- package/dist/core/operators/throttle-time.d.mts.map +0 -1
- package/dist/core/operators/throttle-time.mjs +0 -107
- package/dist/core/operators/throttle-time.mjs.map +0 -1
- package/dist/core/predefined/operators/map.d.mts +0 -3
- package/dist/core/predefined/operators/map.d.mts.map +0 -1
- package/dist/core/predefined/operators/map.mjs +0 -8
- package/dist/core/predefined/operators/map.mjs.map +0 -1
- package/src/core/create/from-array.mts +0 -76
- package/src/core/create/of.mts +0 -73
- package/src/core/operators/audit-time.mts +0 -136
- package/src/core/operators/debounce-time.mts +0 -116
- package/src/core/predefined/operators/map.mts +0 -5
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { type OfObservable } from '../types/index.mjs';
|
|
2
|
-
/**
|
|
3
|
-
* Creates an observable that emits a single value and then completes.
|
|
4
|
-
*
|
|
5
|
-
* @template A - The type of the value
|
|
6
|
-
* @param value - The value to emit
|
|
7
|
-
* @param startManually - If true, waits for manual start (default: false)
|
|
8
|
-
* @returns An observable that emits the value
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* // Timeline:
|
|
13
|
-
* //
|
|
14
|
-
* // num$ 42 | (completes immediately)
|
|
15
|
-
* //
|
|
16
|
-
* // Explanation:
|
|
17
|
-
* // - of creates an observable that emits a single value, then completes
|
|
18
|
-
* // - Useful for converting a static value into an observable
|
|
19
|
-
*
|
|
20
|
-
* const num$ = of(42);
|
|
21
|
-
*
|
|
22
|
-
* const mut_history: number[] = [];
|
|
23
|
-
*
|
|
24
|
-
* await new Promise<void>((resolve) => {
|
|
25
|
-
* num$.subscribe(
|
|
26
|
-
* (x) => {
|
|
27
|
-
* mut_history.push(x);
|
|
28
|
-
* },
|
|
29
|
-
* () => {
|
|
30
|
-
* resolve();
|
|
31
|
-
* },
|
|
32
|
-
* );
|
|
33
|
-
* });
|
|
34
|
-
*
|
|
35
|
-
* assert.deepStrictEqual(mut_history, [42]);
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
export declare const of: <A>(value: A, startManually?: boolean) => OfObservable<A>;
|
|
39
|
-
//# sourceMappingURL=of.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"of.d.mts","sourceRoot":"","sources":["../../../src/core/create/of.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,EAAE,GAAI,CAAC,EAClB,OAAO,CAAC,EACR,gBAAe,OAAe,KAC7B,YAAY,CAAC,CAAC,CAAmD,CAAC"}
|
package/dist/core/create/of.mjs
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { Optional } from 'ts-data-forge';
|
|
2
|
-
import '../utils/id-maker.mjs';
|
|
3
|
-
import { RootObservableClass } from '../class/root-observable-class.mjs';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Creates an observable that emits a single value and then completes.
|
|
7
|
-
*
|
|
8
|
-
* @template A - The type of the value
|
|
9
|
-
* @param value - The value to emit
|
|
10
|
-
* @param startManually - If true, waits for manual start (default: false)
|
|
11
|
-
* @returns An observable that emits the value
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* // Timeline:
|
|
16
|
-
* //
|
|
17
|
-
* // num$ 42 | (completes immediately)
|
|
18
|
-
* //
|
|
19
|
-
* // Explanation:
|
|
20
|
-
* // - of creates an observable that emits a single value, then completes
|
|
21
|
-
* // - Useful for converting a static value into an observable
|
|
22
|
-
*
|
|
23
|
-
* const num$ = of(42);
|
|
24
|
-
*
|
|
25
|
-
* const mut_history: number[] = [];
|
|
26
|
-
*
|
|
27
|
-
* await new Promise<void>((resolve) => {
|
|
28
|
-
* num$.subscribe(
|
|
29
|
-
* (x) => {
|
|
30
|
-
* mut_history.push(x);
|
|
31
|
-
* },
|
|
32
|
-
* () => {
|
|
33
|
-
* resolve();
|
|
34
|
-
* },
|
|
35
|
-
* );
|
|
36
|
-
* });
|
|
37
|
-
*
|
|
38
|
-
* assert.deepStrictEqual(mut_history, [42]);
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
const of = (value, startManually = false) => new OfObservableClass(value, startManually);
|
|
42
|
-
class OfObservableClass extends RootObservableClass {
|
|
43
|
-
#value;
|
|
44
|
-
constructor(value, startManually = false) {
|
|
45
|
-
super({ initialValue: Optional.none });
|
|
46
|
-
this.#value = value;
|
|
47
|
-
if (!startManually) {
|
|
48
|
-
setTimeout(() => {
|
|
49
|
-
this.emit();
|
|
50
|
-
}, 0);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
emit() {
|
|
54
|
-
if (this.isCompleted)
|
|
55
|
-
return this;
|
|
56
|
-
this.startUpdate(this.#value);
|
|
57
|
-
this.complete();
|
|
58
|
-
return this;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export { of };
|
|
63
|
-
//# sourceMappingURL=of.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"of.mjs","sources":["../../../src/core/create/of.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCG;AACI,MAAM,EAAE,GAAG,CAChB,KAAQ,EACR,aAAA,GAAyB,KAAK,KACV,IAAI,iBAAiB,CAAI,KAAK,EAAE,aAAa;AAEnE,MAAM,iBACJ,SAAQ,mBAAsB,CAAA;AAGrB,IAAA,MAAM;IAEf,WAAA,CAAY,KAAQ,EAAE,aAAA,GAAyB,KAAK,EAAA;QAClD,KAAK,CAAC,EAAE,YAAY,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;AAEtC,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK;QAEnB,IAAI,CAAC,aAAa,EAAE;YAClB,UAAU,CAAC,MAAK;gBACd,IAAI,CAAC,IAAI,EAAE;YACb,CAAC,EAAE,CAAC,CAAC;QACP;IACF;IAEA,IAAI,GAAA;QACF,IAAI,IAAI,CAAC,WAAW;AAAE,YAAA,OAAO,IAAI;AAEjC,QAAA,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC;QAE7B,IAAI,CAAC,QAAQ,EAAE;AAEf,QAAA,OAAO,IAAI;IACb;AACD;;;;"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { type KeepInitialValueOperator } from '../types/index.mjs';
|
|
2
|
-
/**
|
|
3
|
-
* Emits the last value from the source observable after a specified time window has passed.
|
|
4
|
-
* Unlike throttleTime which emits the first value, auditTime emits the last value.
|
|
5
|
-
*
|
|
6
|
-
* @template A - The type of values from the source
|
|
7
|
-
* @param milliSeconds - The audit time window in milliseconds
|
|
8
|
-
* @returns An operator that audits emissions from the observable
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* // Timeline (1000ms audit):
|
|
13
|
-
* //
|
|
14
|
-
* // Time(ms) 0 100 200 300 400 ... 1000 1100
|
|
15
|
-
* // input$ e1 e2 e3 e4 e5
|
|
16
|
-
* // audited$ e5 (emitted at end of window)
|
|
17
|
-
* // |-------1000ms window------> ^
|
|
18
|
-
* //
|
|
19
|
-
* // Explanation:
|
|
20
|
-
* // - auditTime emits the LAST value received during each time window
|
|
21
|
-
* // - Unlike throttleTime (which emits the FIRST value), audit emits the LAST
|
|
22
|
-
* // - At 0-1000ms: e1-e5 are received
|
|
23
|
-
* // - At 1000ms: e5 (the last value in the window) is emitted
|
|
24
|
-
* // - Useful when you want the most recent value after a burst of events
|
|
25
|
-
*
|
|
26
|
-
* const input$ = source<number>();
|
|
27
|
-
*
|
|
28
|
-
* const audited$ = input$.pipe(auditTime(200));
|
|
29
|
-
*
|
|
30
|
-
* const mut_history: number[] = [];
|
|
31
|
-
*
|
|
32
|
-
* audited$.subscribe((value) => {
|
|
33
|
-
* mut_history.push(value);
|
|
34
|
-
* });
|
|
35
|
-
*
|
|
36
|
-
* input$.next(1);
|
|
37
|
-
*
|
|
38
|
-
* input$.next(2);
|
|
39
|
-
*
|
|
40
|
-
* input$.next(3);
|
|
41
|
-
*
|
|
42
|
-
* assert.deepStrictEqual(mut_history, []);
|
|
43
|
-
*
|
|
44
|
-
* await new Promise((resolve) => {
|
|
45
|
-
* setTimeout(resolve, 250);
|
|
46
|
-
* });
|
|
47
|
-
*
|
|
48
|
-
* assert.deepStrictEqual(mut_history, [3]);
|
|
49
|
-
*
|
|
50
|
-
* input$.next(4);
|
|
51
|
-
*
|
|
52
|
-
* input$.next(5);
|
|
53
|
-
*
|
|
54
|
-
* await new Promise((resolve) => {
|
|
55
|
-
* setTimeout(resolve, 250);
|
|
56
|
-
* });
|
|
57
|
-
*
|
|
58
|
-
* assert.deepStrictEqual(mut_history, [3, 5]);
|
|
59
|
-
* ```
|
|
60
|
-
*/
|
|
61
|
-
export declare const auditTime: <A>(milliSeconds: number) => KeepInitialValueOperator<A, A>;
|
|
62
|
-
//# sourceMappingURL=audit-time.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"audit-time.d.mts","sourceRoot":"","sources":["../../../src/core/operators/audit-time.mts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,wBAAwB,EAG9B,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,EACzB,cAAc,MAAM,KACnB,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAMQ,CAAC"}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { Optional } from 'ts-data-forge';
|
|
2
|
-
import { AsyncChildObservableClass } from '../class/child-observable-class.mjs';
|
|
3
|
-
import '../utils/id-maker.mjs';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Emits the last value from the source observable after a specified time window has passed.
|
|
7
|
-
* Unlike throttleTime which emits the first value, auditTime emits the last value.
|
|
8
|
-
*
|
|
9
|
-
* @template A - The type of values from the source
|
|
10
|
-
* @param milliSeconds - The audit time window in milliseconds
|
|
11
|
-
* @returns An operator that audits emissions from the observable
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* // Timeline (1000ms audit):
|
|
16
|
-
* //
|
|
17
|
-
* // Time(ms) 0 100 200 300 400 ... 1000 1100
|
|
18
|
-
* // input$ e1 e2 e3 e4 e5
|
|
19
|
-
* // audited$ e5 (emitted at end of window)
|
|
20
|
-
* // |-------1000ms window------> ^
|
|
21
|
-
* //
|
|
22
|
-
* // Explanation:
|
|
23
|
-
* // - auditTime emits the LAST value received during each time window
|
|
24
|
-
* // - Unlike throttleTime (which emits the FIRST value), audit emits the LAST
|
|
25
|
-
* // - At 0-1000ms: e1-e5 are received
|
|
26
|
-
* // - At 1000ms: e5 (the last value in the window) is emitted
|
|
27
|
-
* // - Useful when you want the most recent value after a burst of events
|
|
28
|
-
*
|
|
29
|
-
* const input$ = source<number>();
|
|
30
|
-
*
|
|
31
|
-
* const audited$ = input$.pipe(auditTime(200));
|
|
32
|
-
*
|
|
33
|
-
* const mut_history: number[] = [];
|
|
34
|
-
*
|
|
35
|
-
* audited$.subscribe((value) => {
|
|
36
|
-
* mut_history.push(value);
|
|
37
|
-
* });
|
|
38
|
-
*
|
|
39
|
-
* input$.next(1);
|
|
40
|
-
*
|
|
41
|
-
* input$.next(2);
|
|
42
|
-
*
|
|
43
|
-
* input$.next(3);
|
|
44
|
-
*
|
|
45
|
-
* assert.deepStrictEqual(mut_history, []);
|
|
46
|
-
*
|
|
47
|
-
* await new Promise((resolve) => {
|
|
48
|
-
* setTimeout(resolve, 250);
|
|
49
|
-
* });
|
|
50
|
-
*
|
|
51
|
-
* assert.deepStrictEqual(mut_history, [3]);
|
|
52
|
-
*
|
|
53
|
-
* input$.next(4);
|
|
54
|
-
*
|
|
55
|
-
* input$.next(5);
|
|
56
|
-
*
|
|
57
|
-
* await new Promise((resolve) => {
|
|
58
|
-
* setTimeout(resolve, 250);
|
|
59
|
-
* });
|
|
60
|
-
*
|
|
61
|
-
* assert.deepStrictEqual(mut_history, [3, 5]);
|
|
62
|
-
* ```
|
|
63
|
-
*/
|
|
64
|
-
const auditTime = (milliSeconds) =>
|
|
65
|
-
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
66
|
-
((parentObservable) => new AuditTimeObservableClass(parentObservable, milliSeconds));
|
|
67
|
-
class AuditTimeObservableClass extends AsyncChildObservableClass {
|
|
68
|
-
#milliSeconds;
|
|
69
|
-
#mut_timerId;
|
|
70
|
-
#mut_isSkipping;
|
|
71
|
-
constructor(parentObservable, milliSeconds) {
|
|
72
|
-
super({
|
|
73
|
-
parents: [parentObservable],
|
|
74
|
-
initialValue: parentObservable.getSnapshot(),
|
|
75
|
-
});
|
|
76
|
-
this.#mut_isSkipping = false;
|
|
77
|
-
this.#mut_timerId = undefined;
|
|
78
|
-
this.#milliSeconds = milliSeconds;
|
|
79
|
-
}
|
|
80
|
-
tryUpdate(updaterSymbol) {
|
|
81
|
-
const par = this.parents[0];
|
|
82
|
-
if (par.updaterSymbol !== updaterSymbol ||
|
|
83
|
-
Optional.isNone(par.getSnapshot()) ||
|
|
84
|
-
this.#mut_isSkipping) {
|
|
85
|
-
return; // skip update
|
|
86
|
-
}
|
|
87
|
-
// set timer
|
|
88
|
-
this.#mut_isSkipping = true;
|
|
89
|
-
this.#mut_timerId = setTimeout(() => {
|
|
90
|
-
const sn = par.getSnapshot();
|
|
91
|
-
if (Optional.isNone(sn))
|
|
92
|
-
return;
|
|
93
|
-
this.startUpdate(sn.value);
|
|
94
|
-
this.#mut_isSkipping = false;
|
|
95
|
-
}, this.#milliSeconds);
|
|
96
|
-
}
|
|
97
|
-
#resetTimer() {
|
|
98
|
-
if (this.#mut_timerId !== undefined) {
|
|
99
|
-
clearTimeout(this.#mut_timerId);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
complete() {
|
|
103
|
-
this.#resetTimer();
|
|
104
|
-
super.complete();
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export { auditTime };
|
|
109
|
-
//# sourceMappingURL=audit-time.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"audit-time.mjs","sources":["../../../src/core/operators/audit-time.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DG;AACI,MAAM,SAAS,GAAG,CACvB,YAAoB;AAEpB;AACA,CAAC,CAAC,gBAAgB,KAChB,IAAI,wBAAwB,CAC1B,gBAAgB,EAChB,YAAY,CACb;AAEL,MAAM,wBACJ,SAAQ,yBAA0C,CAAA;AAGzC,IAAA,aAAa;AACtB,IAAA,YAAY;AACZ,IAAA,eAAe;IAEf,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,eAAe,GAAG,KAAK;AAE5B,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,IACE,GAAG,CAAC,aAAa,KAAK,aAAa;AACnC,YAAA,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;YAClC,IAAI,CAAC,eAAe,EACpB;AACA,YAAA,OAAO;QACT;;AAGA,QAAA,IAAI,CAAC,eAAe,GAAG,IAAI;AAE3B,QAAA,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC,MAAK;AAClC,YAAA,MAAM,EAAE,GAAG,GAAG,CAAC,WAAW,EAAE;AAE5B,YAAA,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;gBAAE;AAEzB,YAAA,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,KAAK,CAAC;AAE1B,YAAA,IAAI,CAAC,eAAe,GAAG,KAAK;AAC9B,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;;;;"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { type KeepInitialValueOperator } from '../types/index.mjs';
|
|
2
|
-
/**
|
|
3
|
-
* Delays emissions from the source observable until a specified time has passed without another emission.
|
|
4
|
-
* Useful for handling user input events like typing or scrolling.
|
|
5
|
-
*
|
|
6
|
-
* @template A - The type of values from the source
|
|
7
|
-
* @param milliSeconds - The debounce duration in milliseconds
|
|
8
|
-
* @returns An operator that debounces the observable
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* // Timeline (300ms debounce):
|
|
13
|
-
* //
|
|
14
|
-
* // Time(ms) 0 100 200 300 400 500 600 ... 900 1000
|
|
15
|
-
* // input$ 'h' 'he' 'hel' 'hello'
|
|
16
|
-
* // debounced$ 'hello' (emitted after 300ms silence)
|
|
17
|
-
* //
|
|
18
|
-
* // Explanation:
|
|
19
|
-
* // - At 0ms: 'h' is emitted, timer starts
|
|
20
|
-
* // - At 100ms: 'he' is emitted, timer resets
|
|
21
|
-
* // - At 200ms: 'hel' is emitted, timer resets
|
|
22
|
-
* // - At 300ms: 'hello' is emitted, timer resets
|
|
23
|
-
* // - At 600ms: No new emission for 300ms, 'hello' is finally emitted
|
|
24
|
-
*
|
|
25
|
-
* const input$ = source<string>();
|
|
26
|
-
*
|
|
27
|
-
* const debounced$ = input$.pipe(debounceTime(300));
|
|
28
|
-
*
|
|
29
|
-
* const mut_history: string[] = [];
|
|
30
|
-
*
|
|
31
|
-
* debounced$.subscribe((value) => {
|
|
32
|
-
* mut_history.push(value);
|
|
33
|
-
* });
|
|
34
|
-
*
|
|
35
|
-
* input$.next('h');
|
|
36
|
-
*
|
|
37
|
-
* input$.next('he');
|
|
38
|
-
*
|
|
39
|
-
* input$.next('hel');
|
|
40
|
-
*
|
|
41
|
-
* input$.next('hello');
|
|
42
|
-
*
|
|
43
|
-
* await new Promise((resolve) => {
|
|
44
|
-
* setTimeout(resolve, 400);
|
|
45
|
-
* });
|
|
46
|
-
*
|
|
47
|
-
* assert.deepStrictEqual(mut_history, ['hello']);
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
export declare const debounceTime: <A>(milliSeconds: number) => KeepInitialValueOperator<A, A>;
|
|
51
|
-
//# sourceMappingURL=debounce-time.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { Optional } from 'ts-data-forge';
|
|
2
|
-
import { AsyncChildObservableClass } from '../class/child-observable-class.mjs';
|
|
3
|
-
import '../utils/id-maker.mjs';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Delays emissions from the source observable until a specified time has passed without another emission.
|
|
7
|
-
* Useful for handling user input events like typing or scrolling.
|
|
8
|
-
*
|
|
9
|
-
* @template A - The type of values from the source
|
|
10
|
-
* @param milliSeconds - The debounce duration in milliseconds
|
|
11
|
-
* @returns An operator that debounces the observable
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
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
|
-
*
|
|
28
|
-
* const input$ = source<string>();
|
|
29
|
-
*
|
|
30
|
-
* const debounced$ = input$.pipe(debounceTime(300));
|
|
31
|
-
*
|
|
32
|
-
* const mut_history: string[] = [];
|
|
33
|
-
*
|
|
34
|
-
* debounced$.subscribe((value) => {
|
|
35
|
-
* mut_history.push(value);
|
|
36
|
-
* });
|
|
37
|
-
*
|
|
38
|
-
* input$.next('h');
|
|
39
|
-
*
|
|
40
|
-
* input$.next('he');
|
|
41
|
-
*
|
|
42
|
-
* input$.next('hel');
|
|
43
|
-
*
|
|
44
|
-
* input$.next('hello');
|
|
45
|
-
*
|
|
46
|
-
* await new Promise((resolve) => {
|
|
47
|
-
* setTimeout(resolve, 400);
|
|
48
|
-
* });
|
|
49
|
-
*
|
|
50
|
-
* assert.deepStrictEqual(mut_history, ['hello']);
|
|
51
|
-
* ```
|
|
52
|
-
*/
|
|
53
|
-
const debounceTime = (milliSeconds) =>
|
|
54
|
-
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
55
|
-
((parentObservable) => new DebounceTimeObservableClass(parentObservable, milliSeconds));
|
|
56
|
-
class DebounceTimeObservableClass extends AsyncChildObservableClass {
|
|
57
|
-
#milliSeconds;
|
|
58
|
-
#mut_timerId;
|
|
59
|
-
constructor(parentObservable, milliSeconds) {
|
|
60
|
-
super({
|
|
61
|
-
parents: [parentObservable],
|
|
62
|
-
initialValue: parentObservable.getSnapshot(),
|
|
63
|
-
});
|
|
64
|
-
this.#mut_timerId = undefined;
|
|
65
|
-
this.#milliSeconds = milliSeconds;
|
|
66
|
-
}
|
|
67
|
-
tryUpdate(updaterSymbol) {
|
|
68
|
-
const par = this.parents[0];
|
|
69
|
-
const sn = par.getSnapshot();
|
|
70
|
-
if (par.updaterSymbol !== updaterSymbol || Optional.isNone(sn)) {
|
|
71
|
-
return; // skip update
|
|
72
|
-
}
|
|
73
|
-
this.#resetTimer();
|
|
74
|
-
// set timer
|
|
75
|
-
this.#mut_timerId = setTimeout(() => {
|
|
76
|
-
if (Optional.isNone(sn))
|
|
77
|
-
return;
|
|
78
|
-
this.startUpdate(sn.value);
|
|
79
|
-
}, this.#milliSeconds);
|
|
80
|
-
}
|
|
81
|
-
#resetTimer() {
|
|
82
|
-
if (this.#mut_timerId !== undefined) {
|
|
83
|
-
clearTimeout(this.#mut_timerId);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
complete() {
|
|
87
|
-
this.#resetTimer();
|
|
88
|
-
super.complete();
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export { debounceTime };
|
|
93
|
-
//# sourceMappingURL=debounce-time.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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;;;;"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { type KeepInitialValueOperator } from '../types/index.mjs';
|
|
2
|
-
/**
|
|
3
|
-
* Emits the first value, then ignores subsequent values for a specified duration.
|
|
4
|
-
* After the duration, the next emission is allowed through.
|
|
5
|
-
*
|
|
6
|
-
* @template A - The type of values from the source
|
|
7
|
-
* @param milliSeconds - The throttle duration in milliseconds
|
|
8
|
-
* @returns An operator that throttles emissions
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* // Timeline (1000ms throttle):
|
|
13
|
-
* //
|
|
14
|
-
* // Time(ms) 0 100 200 300 ... 1000 1100 1200 ... 2000 2100
|
|
15
|
-
* // scroll$ e1 e2 e3 e4 e5 e6 e7 e8 e9
|
|
16
|
-
* // throttled$ e1 e5 e8
|
|
17
|
-
* // |-------1000ms------> |------1000ms------> |------1000ms------>
|
|
18
|
-
* //
|
|
19
|
-
* // Explanation:
|
|
20
|
-
* // - throttleTime emits the first value immediately, then ignores subsequent values
|
|
21
|
-
* // for the specified duration (1000ms)
|
|
22
|
-
* // - At 0ms: e1 is emitted immediately
|
|
23
|
-
* // - At 100-300ms: e2, e3, e4 are ignored (within 1000ms window)
|
|
24
|
-
* // - At 1000ms: e5 is emitted (1000ms has passed since e1)
|
|
25
|
-
* // - At 1100-1200ms: e6, e7 are ignored
|
|
26
|
-
* // - At 2000ms: e8 is emitted (1000ms has passed since e5)
|
|
27
|
-
*
|
|
28
|
-
* const scroll$ = source<number>();
|
|
29
|
-
*
|
|
30
|
-
* const throttled$ = scroll$.pipe(throttleTime(200));
|
|
31
|
-
*
|
|
32
|
-
* const mut_history: number[] = [];
|
|
33
|
-
*
|
|
34
|
-
* throttled$.subscribe((value) => {
|
|
35
|
-
* mut_history.push(value);
|
|
36
|
-
* });
|
|
37
|
-
*
|
|
38
|
-
* scroll$.next(1);
|
|
39
|
-
*
|
|
40
|
-
* assert.deepStrictEqual(mut_history, [1]);
|
|
41
|
-
*
|
|
42
|
-
* await new Promise((resolve) => {
|
|
43
|
-
* setTimeout(resolve, 50);
|
|
44
|
-
* });
|
|
45
|
-
*
|
|
46
|
-
* scroll$.next(2);
|
|
47
|
-
*
|
|
48
|
-
* scroll$.next(3);
|
|
49
|
-
*
|
|
50
|
-
* assert.deepStrictEqual(mut_history, [1]);
|
|
51
|
-
*
|
|
52
|
-
* await new Promise((resolve) => {
|
|
53
|
-
* setTimeout(resolve, 200);
|
|
54
|
-
* });
|
|
55
|
-
*
|
|
56
|
-
* scroll$.next(4);
|
|
57
|
-
*
|
|
58
|
-
* assert.deepStrictEqual(mut_history, [1, 4]);
|
|
59
|
-
* ```
|
|
60
|
-
*/
|
|
61
|
-
export declare const throttleTime: <A>(milliSeconds: number) => KeepInitialValueOperator<A, A>;
|
|
62
|
-
//# sourceMappingURL=throttle-time.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throttle-time.d.mts","sourceRoot":"","sources":["../../../src/core/operators/throttle-time.mts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,wBAAwB,EAI9B,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,EAC5B,cAAc,MAAM,KACnB,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAMQ,CAAC"}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { Optional } from 'ts-data-forge';
|
|
2
|
-
import { SyncChildObservableClass } from '../class/child-observable-class.mjs';
|
|
3
|
-
import '../utils/id-maker.mjs';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Emits the first value, then ignores subsequent values for a specified duration.
|
|
7
|
-
* After the duration, the next emission is allowed through.
|
|
8
|
-
*
|
|
9
|
-
* @template A - The type of values from the source
|
|
10
|
-
* @param milliSeconds - The throttle duration in milliseconds
|
|
11
|
-
* @returns An operator that throttles emissions
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* // Timeline (1000ms throttle):
|
|
16
|
-
* //
|
|
17
|
-
* // Time(ms) 0 100 200 300 ... 1000 1100 1200 ... 2000 2100
|
|
18
|
-
* // scroll$ e1 e2 e3 e4 e5 e6 e7 e8 e9
|
|
19
|
-
* // throttled$ e1 e5 e8
|
|
20
|
-
* // |-------1000ms------> |------1000ms------> |------1000ms------>
|
|
21
|
-
* //
|
|
22
|
-
* // Explanation:
|
|
23
|
-
* // - throttleTime emits the first value immediately, then ignores subsequent values
|
|
24
|
-
* // for the specified duration (1000ms)
|
|
25
|
-
* // - At 0ms: e1 is emitted immediately
|
|
26
|
-
* // - At 100-300ms: e2, e3, e4 are ignored (within 1000ms window)
|
|
27
|
-
* // - At 1000ms: e5 is emitted (1000ms has passed since e1)
|
|
28
|
-
* // - At 1100-1200ms: e6, e7 are ignored
|
|
29
|
-
* // - At 2000ms: e8 is emitted (1000ms has passed since e5)
|
|
30
|
-
*
|
|
31
|
-
* const scroll$ = source<number>();
|
|
32
|
-
*
|
|
33
|
-
* const throttled$ = scroll$.pipe(throttleTime(200));
|
|
34
|
-
*
|
|
35
|
-
* const mut_history: number[] = [];
|
|
36
|
-
*
|
|
37
|
-
* throttled$.subscribe((value) => {
|
|
38
|
-
* mut_history.push(value);
|
|
39
|
-
* });
|
|
40
|
-
*
|
|
41
|
-
* scroll$.next(1);
|
|
42
|
-
*
|
|
43
|
-
* assert.deepStrictEqual(mut_history, [1]);
|
|
44
|
-
*
|
|
45
|
-
* await new Promise((resolve) => {
|
|
46
|
-
* setTimeout(resolve, 50);
|
|
47
|
-
* });
|
|
48
|
-
*
|
|
49
|
-
* scroll$.next(2);
|
|
50
|
-
*
|
|
51
|
-
* scroll$.next(3);
|
|
52
|
-
*
|
|
53
|
-
* assert.deepStrictEqual(mut_history, [1]);
|
|
54
|
-
*
|
|
55
|
-
* await new Promise((resolve) => {
|
|
56
|
-
* setTimeout(resolve, 200);
|
|
57
|
-
* });
|
|
58
|
-
*
|
|
59
|
-
* scroll$.next(4);
|
|
60
|
-
*
|
|
61
|
-
* assert.deepStrictEqual(mut_history, [1, 4]);
|
|
62
|
-
* ```
|
|
63
|
-
*/
|
|
64
|
-
const throttleTime = (milliSeconds) =>
|
|
65
|
-
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
66
|
-
((parentObservable) => new ThrottleTimeObservableClass(parentObservable, milliSeconds));
|
|
67
|
-
class ThrottleTimeObservableClass extends SyncChildObservableClass {
|
|
68
|
-
#milliSeconds;
|
|
69
|
-
#mut_timerId;
|
|
70
|
-
#mut_isSkipping;
|
|
71
|
-
constructor(parentObservable, milliSeconds) {
|
|
72
|
-
super({
|
|
73
|
-
parents: [parentObservable],
|
|
74
|
-
initialValue: parentObservable.getSnapshot(),
|
|
75
|
-
});
|
|
76
|
-
this.#mut_timerId = undefined;
|
|
77
|
-
this.#mut_isSkipping = false;
|
|
78
|
-
this.#milliSeconds = milliSeconds;
|
|
79
|
-
}
|
|
80
|
-
tryUpdate(updaterSymbol) {
|
|
81
|
-
const par = this.parents[0];
|
|
82
|
-
const sn = par.getSnapshot();
|
|
83
|
-
if (par.updaterSymbol !== updaterSymbol ||
|
|
84
|
-
Optional.isNone(sn) ||
|
|
85
|
-
this.#mut_isSkipping) {
|
|
86
|
-
return; // skip update
|
|
87
|
-
}
|
|
88
|
-
this.setNext(sn.value, updaterSymbol);
|
|
89
|
-
this.#mut_isSkipping = true;
|
|
90
|
-
// set timer
|
|
91
|
-
this.#mut_timerId = setTimeout(() => {
|
|
92
|
-
this.#mut_isSkipping = false;
|
|
93
|
-
}, this.#milliSeconds);
|
|
94
|
-
}
|
|
95
|
-
#resetTimer() {
|
|
96
|
-
if (this.#mut_timerId !== undefined) {
|
|
97
|
-
clearTimeout(this.#mut_timerId);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
complete() {
|
|
101
|
-
this.#resetTimer();
|
|
102
|
-
super.complete();
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export { throttleTime };
|
|
107
|
-
//# sourceMappingURL=throttle-time.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throttle-time.mjs","sources":["../../../src/core/operators/throttle-time.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DG;AACI,MAAM,YAAY,GAAG,CAC1B,YAAoB;AAEpB;AACA,CAAC,CAAC,gBAAgB,KAChB,IAAI,2BAA2B,CAC7B,gBAAgB,EAChB,YAAY,CACb;AAEL,MAAM,2BACJ,SAAQ,wBAAyC,CAAA;AAGxC,IAAA,aAAa;AACtB,IAAA,YAAY;AACZ,IAAA,eAAe;IAEf,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,eAAe,GAAG,KAAK;AAE5B,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,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;AAErC,QAAA,IAAI,CAAC,eAAe,GAAG,IAAI;;AAG3B,QAAA,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC,MAAK;AAClC,YAAA,IAAI,CAAC,eAAe,GAAG,KAAK;AAC9B,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;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"map.d.mts","sourceRoot":"","sources":["../../../../src/core/predefined/operators/map.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAEtE,eAAO,MAAM,GAAG,GAAI,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAG,wBAAwB,CAAC,CAAC,EAAE,CAAC,CACvD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"map.mjs","sources":["../../../../src/core/predefined/operators/map.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAGO,MAAM,GAAG,GAAG,CAAO,KAAkB,KAC1C,YAAY,CAAC,KAAK;;;;"}
|