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
|
@@ -2,6 +2,64 @@ import { Optional, Result } from 'ts-data-forge';
|
|
|
2
2
|
import '../utils/id-maker.mjs';
|
|
3
3
|
import { RootObservableClass } from '../class/root-observable-class.mjs';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Converts any subscribable object into a SynState Observable.
|
|
7
|
+
* Works with objects that have a subscribe(onNext, onError, onComplete) method.
|
|
8
|
+
*
|
|
9
|
+
* @template A - The type of values from the subscribable
|
|
10
|
+
* @template E - The type of errors from the subscribable
|
|
11
|
+
* @param subscribable - An object with a subscribe method
|
|
12
|
+
* @returns An observable that wraps values in Result type
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* // Explanation:
|
|
17
|
+
* // - fromSubscribable converts any subscribable object into a SynState Observable
|
|
18
|
+
* // - Works with objects that have a subscribe(onNext, onError, onComplete) method
|
|
19
|
+
* // - Wraps values in Result type for error handling
|
|
20
|
+
* // - Useful for integrating with other reactive libraries or custom subscribables
|
|
21
|
+
*
|
|
22
|
+
* // Example: Converting a custom subscribable
|
|
23
|
+
* const customSubscribable = {
|
|
24
|
+
* subscribe: (
|
|
25
|
+
* onNext: (value: number) => void,
|
|
26
|
+
* _onError?: (error: unknown) => void,
|
|
27
|
+
* onComplete?: () => void,
|
|
28
|
+
* ) => {
|
|
29
|
+
* setTimeout(() => {
|
|
30
|
+
* onNext(1);
|
|
31
|
+
*
|
|
32
|
+
* onNext(2);
|
|
33
|
+
*
|
|
34
|
+
* onNext(3);
|
|
35
|
+
*
|
|
36
|
+
* onComplete?.();
|
|
37
|
+
* }, 0);
|
|
38
|
+
*
|
|
39
|
+
* return { unsubscribe: () => {} };
|
|
40
|
+
* },
|
|
41
|
+
* };
|
|
42
|
+
*
|
|
43
|
+
* const observable$ = fromSubscribable<number>(customSubscribable);
|
|
44
|
+
*
|
|
45
|
+
* const mut_history: number[] = [];
|
|
46
|
+
*
|
|
47
|
+
* await new Promise<void>((resolve) => {
|
|
48
|
+
* observable$.subscribe(
|
|
49
|
+
* (result) => {
|
|
50
|
+
* if (Result.isOk(result)) {
|
|
51
|
+
* mut_history.push(result.value);
|
|
52
|
+
* }
|
|
53
|
+
* },
|
|
54
|
+
* () => {
|
|
55
|
+
* resolve();
|
|
56
|
+
* },
|
|
57
|
+
* );
|
|
58
|
+
* });
|
|
59
|
+
*
|
|
60
|
+
* assert.deepStrictEqual(mut_history, [1, 2, 3]);
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
5
63
|
const fromSubscribable = (subscribable) => new FromSubscribableObservableClass(subscribable);
|
|
6
64
|
class FromSubscribableObservableClass extends RootObservableClass {
|
|
7
65
|
constructor(subscribable) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"from-subscribable.mjs","sources":["../../../src/core/create/from-subscribable.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"from-subscribable.mjs","sources":["../../../src/core/create/from-subscribable.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDG;AACI,MAAM,gBAAgB,GAAG,CAC9B,YAA6B,KAE7B,IAAI,+BAA+B,CAAC,YAAY;AAElD,MAAM,+BACJ,SAAQ,mBAAiC,CAAA;AAGzC,IAAA,WAAA,CAAY,YAA6B,EAAA;QACvC,KAAK,CAAC,EAAE,YAAY,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;AAEtC,QAAA,YAAY,CAAC,SAAS,CACpB,CAAC,SAAS,KAAI;YACZ,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;AACxC,QAAA,CAAC,EACD,CAAC,KAAe,KAAI;AAClB,YAAA,IAAI,CAAC,WAAW,CACd,MAAM,CAAC,GAAG;;YAER,KAAU,CACX,CACF;QACH,CAAC,EACD,MAAK;YACH,IAAI,CAAC,QAAQ,EAAE;AACjB,QAAA,CAAC,CACF;IACH;AACD;;;;"}
|
|
@@ -9,12 +9,37 @@ import { type IntervalObservable } from '../types/index.mjs';
|
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
11
|
* ```ts
|
|
12
|
-
*
|
|
12
|
+
* // Timeline:
|
|
13
|
+
* //
|
|
14
|
+
* // Time(s) 0 1 2 3 4 5
|
|
15
|
+
* // tick$ 0 1 2 3 4 5 ...
|
|
16
|
+
* //
|
|
17
|
+
* // Explanation:
|
|
18
|
+
* // - interval emits incrementing numbers at specified intervals
|
|
19
|
+
* // - Starts at 0 and continues indefinitely
|
|
20
|
+
* // - Useful for periodic tasks or animations
|
|
13
21
|
*
|
|
14
|
-
* tick
|
|
15
|
-
*
|
|
22
|
+
* const tick$ = interval(100);
|
|
23
|
+
*
|
|
24
|
+
* const mut_history: number[] = [];
|
|
25
|
+
*
|
|
26
|
+
* const subscription = tick$.subscribe((count) => {
|
|
27
|
+
* mut_history.push(count);
|
|
16
28
|
* });
|
|
17
|
-
*
|
|
29
|
+
*
|
|
30
|
+
* await new Promise((resolve) => {
|
|
31
|
+
* setTimeout(resolve, 350);
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* subscription.unsubscribe();
|
|
35
|
+
*
|
|
36
|
+
* assert.isTrue(Arr.isArrayAtLeastLength(mut_history, 3));
|
|
37
|
+
*
|
|
38
|
+
* assert.deepStrictEqual(mut_history[0], 0);
|
|
39
|
+
*
|
|
40
|
+
* assert.deepStrictEqual(mut_history[1], 1);
|
|
41
|
+
*
|
|
42
|
+
* assert.deepStrictEqual(mut_history[2], 2);
|
|
18
43
|
* ```
|
|
19
44
|
*/
|
|
20
45
|
export declare const interval: (milliSeconds: number, startManually?: boolean) => IntervalObservable;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interval.d.mts","sourceRoot":"","sources":["../../../src/core/create/interval.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D
|
|
1
|
+
{"version":3,"file":"interval.d.mts","sourceRoot":"","sources":["../../../src/core/create/interval.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,eAAO,MAAM,QAAQ,GACnB,cAAc,MAAM,EACpB,gBAAgB,OAAO,KACtB,kBACuD,CAAC"}
|
|
@@ -12,12 +12,37 @@ import { RootObservableClass } from '../class/root-observable-class.mjs';
|
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* ```ts
|
|
15
|
-
*
|
|
15
|
+
* // Timeline:
|
|
16
|
+
* //
|
|
17
|
+
* // Time(s) 0 1 2 3 4 5
|
|
18
|
+
* // tick$ 0 1 2 3 4 5 ...
|
|
19
|
+
* //
|
|
20
|
+
* // Explanation:
|
|
21
|
+
* // - interval emits incrementing numbers at specified intervals
|
|
22
|
+
* // - Starts at 0 and continues indefinitely
|
|
23
|
+
* // - Useful for periodic tasks or animations
|
|
16
24
|
*
|
|
17
|
-
* tick
|
|
18
|
-
*
|
|
25
|
+
* const tick$ = interval(100);
|
|
26
|
+
*
|
|
27
|
+
* const mut_history: number[] = [];
|
|
28
|
+
*
|
|
29
|
+
* const subscription = tick$.subscribe((count) => {
|
|
30
|
+
* mut_history.push(count);
|
|
19
31
|
* });
|
|
20
|
-
*
|
|
32
|
+
*
|
|
33
|
+
* await new Promise((resolve) => {
|
|
34
|
+
* setTimeout(resolve, 350);
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* subscription.unsubscribe();
|
|
38
|
+
*
|
|
39
|
+
* assert.isTrue(Arr.isArrayAtLeastLength(mut_history, 3));
|
|
40
|
+
*
|
|
41
|
+
* assert.deepStrictEqual(mut_history[0], 0);
|
|
42
|
+
*
|
|
43
|
+
* assert.deepStrictEqual(mut_history[1], 1);
|
|
44
|
+
*
|
|
45
|
+
* assert.deepStrictEqual(mut_history[2], 2);
|
|
21
46
|
* ```
|
|
22
47
|
*/
|
|
23
48
|
const interval = (milliSeconds, startManually) => new IntervalObservableClass(milliSeconds, startManually);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interval.mjs","sources":["../../../src/core/create/interval.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAIA
|
|
1
|
+
{"version":3,"file":"interval.mjs","sources":["../../../src/core/create/interval.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CG;AACI,MAAM,QAAQ,GAAG,CACtB,YAAoB,EACpB,aAAuB,KAEvB,IAAI,uBAAuB,CAAC,YAAY,EAAE,aAAa;AAEzD,MAAM,uBACJ,SAAQ,mBAA6B,CAAA;AAG5B,IAAA,aAAa;AACtB,IAAA,YAAY;AACZ,IAAA,aAAa;AACb,IAAA,YAAY;AACZ,IAAA,cAAc;IAEd,WAAA,CAAY,YAAoB,EAAE,aAAuB,EAAA;QACvD,KAAK,CAAC,EAAE,YAAY,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;AAEtC,QAAA,IAAI,CAAC,aAAa,GAAG,YAAY;AAEjC,QAAA,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC,CAAC,CAAC;AAEjC,QAAA,IAAI,CAAC,aAAa,GAAG,SAAS;AAE9B,QAAA,IAAI,CAAC,YAAY,GAAG,SAAS;AAE7B,QAAA,IAAI,CAAC,cAAc,GAAG,KAAK;AAE3B,QAAA,IAAI,aAAa,KAAK,IAAI,EAAE;YAC1B,IAAI,CAAC,KAAK,EAAE;QACd;IACF;IAEA,KAAK,GAAA;AACH,QAAA,IAAI,IAAI,CAAC,cAAc,EAAE;AACvB,YAAA,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC;AAElC,YAAA,OAAO,IAAI;QACb;AAEA,QAAA,IAAI,CAAC,cAAc,GAAG,IAAI;AAE1B,QAAA,IAAI,IAAI,CAAC,WAAW,EAAE;AACpB,YAAA,OAAO,CAAC,IAAI,CAAC,2CAA2C,CAAC;AAEzD,YAAA,OAAO,IAAI;QACb;;AAGA,QAAA,IAAI,CAAC,aAAa,GAAG,UAAU,CAAC,MAAK;AACnC,YAAA,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC;QACrC,CAAC,EAAE,CAAC,CAAC;AAEL,QAAA,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC,MAAK;AACnC,YAAA,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC;AAEtD,YAAA,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC;AACrC,QAAA,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC;AAEtB,QAAA,OAAO,IAAI;IACb;IAEA,WAAW,GAAA;AACT,QAAA,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE;AACvE,YAAA,aAAa,CAAC,IAAI,CAAC,aAAa,CAAC;AAEjC,YAAA,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC;QAClC;IACF;IAES,QAAQ,GAAA;QACf,IAAI,CAAC,WAAW,EAAE;QAElB,KAAK,CAAC,QAAQ,EAAE;IAClB;AACD;;;;"}
|
|
@@ -9,11 +9,30 @@ import { type OfObservable } from '../types/index.mjs';
|
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
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
|
+
*
|
|
12
20
|
* const num$ = of(42);
|
|
13
21
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
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]);
|
|
17
36
|
* ```
|
|
18
37
|
*/
|
|
19
38
|
export declare const of: <A>(value: A, startManually?: boolean) => OfObservable<A>;
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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
CHANGED
|
@@ -12,11 +12,30 @@ import { RootObservableClass } from '../class/root-observable-class.mjs';
|
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
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
|
+
*
|
|
15
23
|
* const num$ = of(42);
|
|
16
24
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
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]);
|
|
20
39
|
* ```
|
|
21
40
|
*/
|
|
22
41
|
const of = (value, startManually = false) => new OfObservableClass(value, startManually);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"of.mjs","sources":["../../../src/core/create/of.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAIA
|
|
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;;;;"}
|
|
@@ -8,21 +8,40 @@ import { type InitializedSourceObservable, type SourceObservable } from '../type
|
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```ts
|
|
11
|
+
* // Timeline:
|
|
12
|
+
* //
|
|
13
|
+
* // count$ 1 2 3 ...
|
|
14
|
+
* //
|
|
15
|
+
* // Explanation:
|
|
16
|
+
* // - source creates a new observable that you can manually emit values to
|
|
17
|
+
* // - Use .next() to emit values
|
|
18
|
+
* // - Foundation for building custom observables
|
|
19
|
+
*
|
|
11
20
|
* const count$ = source<number>();
|
|
12
21
|
*
|
|
22
|
+
* const mut_history: number[] = [];
|
|
23
|
+
*
|
|
13
24
|
* count$.subscribe((value) => {
|
|
14
|
-
*
|
|
25
|
+
* mut_history.push(value);
|
|
15
26
|
* });
|
|
16
27
|
*
|
|
17
28
|
* count$.next(1); // logs: 1
|
|
18
29
|
*
|
|
30
|
+
* assert.deepStrictEqual(mut_history, [1]);
|
|
31
|
+
*
|
|
19
32
|
* count$.next(2); // logs: 2
|
|
33
|
+
*
|
|
34
|
+
* assert.deepStrictEqual(mut_history, [1, 2]);
|
|
35
|
+
*
|
|
36
|
+
* count$.next(3); // logs: 3
|
|
37
|
+
*
|
|
38
|
+
* assert.deepStrictEqual(mut_history, [1, 2, 3]);
|
|
20
39
|
* ```
|
|
21
40
|
*/
|
|
22
41
|
export declare function source<A>(initialValue: A): InitializedSourceObservable<A>;
|
|
23
42
|
export declare function source<A>(): SourceObservable<A>;
|
|
24
43
|
/**
|
|
25
|
-
* Alias for `source
|
|
44
|
+
* Alias for `source`. Creates a new Observable source.
|
|
26
45
|
* @see source
|
|
27
46
|
*/
|
|
28
47
|
export declare const subject: typeof source;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source.d.mts","sourceRoot":"","sources":["../../../src/core/create/source.mts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAC;AAE5B
|
|
1
|
+
{"version":3,"file":"source.d.mts","sourceRoot":"","sources":["../../../src/core/create/source.mts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,2BAA2B,CAAC,CAAC,CAAC,CAAC;AAE3E,wBAAgB,MAAM,CAAC,CAAC,KAAK,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAMjD;;;GAGG;AACH,eAAO,MAAM,OAAO,eAAS,CAAC"}
|
|
@@ -6,10 +6,10 @@ function source(...args) {
|
|
|
6
6
|
return new SourceObservableClass(...args);
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
* Alias for `source
|
|
9
|
+
* Alias for `source`. Creates a new Observable source.
|
|
10
10
|
* @see source
|
|
11
11
|
*/
|
|
12
|
-
const subject = source;
|
|
12
|
+
const subject = source;
|
|
13
13
|
class SourceObservableClass extends RootObservableClass {
|
|
14
14
|
constructor(...args) {
|
|
15
15
|
super({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source.mjs","sources":["../../../src/core/create/source.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"source.mjs","sources":["../../../src/core/create/source.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAkDM,SAAU,MAAM,CAAI,GAAG,IAAkB,EAAA;AAC7C,IAAA,OAAO,IAAI,qBAAqB,CAAI,GAAG,IAAI,CAAC;AAC9C;AAEA;;;AAGG;AACI,MAAM,OAAO,GAAG;AAEvB,MAAM,qBACJ,SAAQ,mBAAsB,CAAA;AAG9B,IAAA,WAAA,CAAY,GAAG,IAAkB,EAAA;AAC/B,QAAA,KAAK,CAAC;AACJ,YAAA,YAAY,EAAE,GAAG,CAAC,UAAU,CAAC,IAAI;kBAC7B,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;kBACrB,QAAQ,CAAC,IAAI;AAClB,SAAA,CAAC;IACJ;AAEA,IAAA,IAAI,CAAC,SAAY,EAAA;QACf,IAAI,IAAI,CAAC,WAAW;YAAE;AAEtB,QAAA,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC;IAC7B;AACD;;;;"}
|
|
@@ -8,12 +8,31 @@ import { type TimerObservable } from '../types/index.mjs';
|
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```ts
|
|
11
|
-
*
|
|
11
|
+
* // Timeline:
|
|
12
|
+
* //
|
|
13
|
+
* // Time(ms) 0 ... 1000
|
|
14
|
+
* // delayed$ X (emits and completes)
|
|
15
|
+
* //
|
|
16
|
+
* // Explanation:
|
|
17
|
+
* // - timer emits once after the specified delay, then completes
|
|
18
|
+
* // - Useful for delayed actions or timeouts
|
|
12
19
|
*
|
|
13
|
-
* delayed
|
|
14
|
-
*
|
|
20
|
+
* const delayed$ = timer(100);
|
|
21
|
+
*
|
|
22
|
+
* const mut_history: number[] = [];
|
|
23
|
+
*
|
|
24
|
+
* await new Promise<void>((resolve) => {
|
|
25
|
+
* delayed$.subscribe(
|
|
26
|
+
* () => {
|
|
27
|
+
* mut_history.push(1);
|
|
28
|
+
* },
|
|
29
|
+
* () => {
|
|
30
|
+
* resolve();
|
|
31
|
+
* },
|
|
32
|
+
* );
|
|
15
33
|
* });
|
|
16
|
-
*
|
|
34
|
+
*
|
|
35
|
+
* assert.deepStrictEqual(mut_history, [1]);
|
|
17
36
|
* ```
|
|
18
37
|
*/
|
|
19
38
|
export declare const timer: (milliSeconds: number, startManually?: boolean) => TimerObservable;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timer.d.mts","sourceRoot":"","sources":["../../../src/core/create/timer.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D
|
|
1
|
+
{"version":3,"file":"timer.d.mts","sourceRoot":"","sources":["../../../src/core/create/timer.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,KAAK,GAChB,cAAc,MAAM,EACpB,gBAAe,OAAe,KAC7B,eAAwE,CAAC"}
|
|
@@ -11,12 +11,31 @@ import { RootObservableClass } from '../class/root-observable-class.mjs';
|
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* ```ts
|
|
14
|
-
*
|
|
14
|
+
* // Timeline:
|
|
15
|
+
* //
|
|
16
|
+
* // Time(ms) 0 ... 1000
|
|
17
|
+
* // delayed$ X (emits and completes)
|
|
18
|
+
* //
|
|
19
|
+
* // Explanation:
|
|
20
|
+
* // - timer emits once after the specified delay, then completes
|
|
21
|
+
* // - Useful for delayed actions or timeouts
|
|
15
22
|
*
|
|
16
|
-
* delayed
|
|
17
|
-
*
|
|
23
|
+
* const delayed$ = timer(100);
|
|
24
|
+
*
|
|
25
|
+
* const mut_history: number[] = [];
|
|
26
|
+
*
|
|
27
|
+
* await new Promise<void>((resolve) => {
|
|
28
|
+
* delayed$.subscribe(
|
|
29
|
+
* () => {
|
|
30
|
+
* mut_history.push(1);
|
|
31
|
+
* },
|
|
32
|
+
* () => {
|
|
33
|
+
* resolve();
|
|
34
|
+
* },
|
|
35
|
+
* );
|
|
18
36
|
* });
|
|
19
|
-
*
|
|
37
|
+
*
|
|
38
|
+
* assert.deepStrictEqual(mut_history, [1]);
|
|
20
39
|
* ```
|
|
21
40
|
*/
|
|
22
41
|
const timer = (milliSeconds, startManually = false) => new TimerObservableClass(milliSeconds, startManually);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timer.mjs","sources":["../../../src/core/create/timer.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAIA
|
|
1
|
+
{"version":3,"file":"timer.mjs","sources":["../../../src/core/create/timer.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCG;AACI,MAAM,KAAK,GAAG,CACnB,YAAoB,EACpB,aAAA,GAAyB,KAAK,KACV,IAAI,oBAAoB,CAAC,YAAY,EAAE,aAAa;AAE1E,MAAM,oBACJ,SAAQ,mBAAsB,CAAA;AAGrB,IAAA,aAAa;AACtB,IAAA,YAAY;AACZ,IAAA,cAAc;IAEd,WAAA,CAAY,YAAoB,EAAE,aAAsB,EAAA;QACtD,KAAK,CAAC,EAAE,YAAY,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;AAEtC,QAAA,IAAI,CAAC,aAAa,GAAG,YAAY;AAEjC,QAAA,IAAI,CAAC,YAAY,GAAG,SAAS;AAE7B,QAAA,IAAI,CAAC,cAAc,GAAG,KAAK;QAE3B,IAAI,CAAC,aAAa,EAAE;YAClB,IAAI,CAAC,KAAK,EAAE;QACd;IACF;IAEA,KAAK,GAAA;AACH,QAAA,IAAI,IAAI,CAAC,cAAc,EAAE;AACvB,YAAA,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC;AAElC,YAAA,OAAO,IAAI;QACb;AAEA,QAAA,IAAI,CAAC,cAAc,GAAG,IAAI;AAE1B,QAAA,IAAI,IAAI,CAAC,WAAW,EAAE;AACpB,YAAA,OAAO,CAAC,IAAI,CAAC,wCAAwC,CAAC;AAEtD,YAAA,OAAO,IAAI;QACb;AAEA,QAAA,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC,MAAK;AAClC,YAAA,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;YAEnB,IAAI,CAAC,QAAQ,EAAE;AACjB,QAAA,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC;AAEtB,QAAA,OAAO,IAAI;IACb;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;;;;"}
|
package/dist/core/index.d.mts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './class/index.mjs';
|
|
|
2
2
|
export * from './combine/index.mjs';
|
|
3
3
|
export * from './create/index.mjs';
|
|
4
4
|
export * from './operators/index.mjs';
|
|
5
|
+
export * from './predefined/index.mjs';
|
|
5
6
|
export * from './types/index.mjs';
|
|
6
7
|
export * from './utils/index.mjs';
|
|
7
8
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/core/index.mts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/core/index.mts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC"}
|
package/dist/core/index.mjs
CHANGED
|
@@ -14,20 +14,32 @@ export { timer } from './create/timer.mjs';
|
|
|
14
14
|
export { auditTime } from './operators/audit-time.mjs';
|
|
15
15
|
export { debounceTime } from './operators/debounce-time.mjs';
|
|
16
16
|
export { filter } from './operators/filter.mjs';
|
|
17
|
-
export {
|
|
17
|
+
export { mapWithIndex } from './operators/map-with-index.mjs';
|
|
18
18
|
export { flatMap, mergeMap } from './operators/merge-map.mjs';
|
|
19
19
|
export { pairwise } from './operators/pairwise.mjs';
|
|
20
20
|
export { scan } from './operators/scan.mjs';
|
|
21
21
|
export { distinctUntilChanged, skipIfNoChange } from './operators/skip-if-no-change.mjs';
|
|
22
22
|
export { skipUntil } from './operators/skip-until.mjs';
|
|
23
|
-
export {
|
|
23
|
+
export { skipWhile } from './operators/skip-while.mjs';
|
|
24
24
|
export { switchMap } from './operators/switch-map.mjs';
|
|
25
25
|
export { takeUntil } from './operators/take-until.mjs';
|
|
26
|
-
export {
|
|
26
|
+
export { takeWhile } from './operators/take-while.mjs';
|
|
27
27
|
export { throttleTime } from './operators/throttle-time.mjs';
|
|
28
28
|
export { withBuffered, withBufferedFrom } from './operators/with-buffered-from.mjs';
|
|
29
29
|
export { withCurrentValueFrom, withLatestFrom } from './operators/with-current-value-from.mjs';
|
|
30
30
|
export { withInitialValue } from './operators/with-initial-value.mjs';
|
|
31
|
+
export { attachIndex, withIndex } from './predefined/operators/attach-index.mjs';
|
|
32
|
+
export { mapOptional } from './predefined/operators/map-optional.mjs';
|
|
33
|
+
export { mapResultErr } from './predefined/operators/map-result-err.mjs';
|
|
34
|
+
export { mapResultOk } from './predefined/operators/map-result-ok.mjs';
|
|
35
|
+
export { mapTo } from './predefined/operators/map-to.mjs';
|
|
36
|
+
export { map } from './predefined/operators/map.mjs';
|
|
37
|
+
export { getKey, pluck } from './predefined/operators/pluck.mjs';
|
|
38
|
+
export { skip } from './predefined/operators/skip.mjs';
|
|
39
|
+
export { take } from './predefined/operators/take.mjs';
|
|
40
|
+
export { unwrapOptional } from './predefined/operators/unwrap-optional.mjs';
|
|
41
|
+
export { unwrapResultErr } from './predefined/operators/unwrap-result-err.mjs';
|
|
42
|
+
export { unwrapResultOk } from './predefined/operators/unwrap-result-ok.mjs';
|
|
31
43
|
import 'ts-data-forge';
|
|
32
44
|
export { isChildObservable, isManagerObservable, isRootObservable } from './types/observable.mjs';
|
|
33
45
|
export { issueObservableId, issueSubscriberId, issueUpdaterSymbol } from './utils/id-maker.mjs';
|
package/dist/core/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,3 +1,62 @@
|
|
|
1
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
|
+
*/
|
|
2
61
|
export declare const auditTime: <A>(milliSeconds: number) => KeepInitialValueOperator<A, A>;
|
|
3
62
|
//# sourceMappingURL=audit-time.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
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,eAAO,MAAM,SAAS,GAAI,CAAC,EACzB,cAAc,MAAM,KACnB,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAMQ,CAAC"}
|
|
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"}
|
|
@@ -2,6 +2,65 @@ import { Optional } from 'ts-data-forge';
|
|
|
2
2
|
import { AsyncChildObservableClass } from '../class/child-observable-class.mjs';
|
|
3
3
|
import '../utils/id-maker.mjs';
|
|
4
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
|
+
*/
|
|
5
64
|
const auditTime = (milliSeconds) =>
|
|
6
65
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
7
66
|
((parentObservable) => new AuditTimeObservableClass(parentObservable, milliSeconds));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit-time.mjs","sources":["../../../src/core/operators/audit-time.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;
|
|
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;;;;"}
|
|
@@ -9,12 +9,27 @@ import { type KeepInitialValueOperator } from '../types/index.mjs';
|
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
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
|
+
*
|
|
12
25
|
* const input$ = source<string>();
|
|
13
26
|
*
|
|
14
27
|
* const debounced$ = input$.pipe(debounceTime(300));
|
|
15
28
|
*
|
|
29
|
+
* const mut_history: string[] = [];
|
|
30
|
+
*
|
|
16
31
|
* debounced$.subscribe((value) => {
|
|
17
|
-
*
|
|
32
|
+
* mut_history.push(value);
|
|
18
33
|
* });
|
|
19
34
|
*
|
|
20
35
|
* input$.next('h');
|
|
@@ -24,7 +39,12 @@ import { type KeepInitialValueOperator } from '../types/index.mjs';
|
|
|
24
39
|
* input$.next('hel');
|
|
25
40
|
*
|
|
26
41
|
* input$.next('hello');
|
|
27
|
-
*
|
|
42
|
+
*
|
|
43
|
+
* await new Promise((resolve) => {
|
|
44
|
+
* setTimeout(resolve, 400);
|
|
45
|
+
* });
|
|
46
|
+
*
|
|
47
|
+
* assert.deepStrictEqual(mut_history, ['hello']);
|
|
28
48
|
* ```
|
|
29
49
|
*/
|
|
30
50
|
export declare const debounceTime: <A>(milliSeconds: number) => KeepInitialValueOperator<A, A>;
|