@fncts/observable 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Action.d.ts +6 -0
- package/AnimationFrameAction.d.ts +11 -0
- package/AnimationFrameScheduler.d.ts +6 -0
- package/AsyncAction.d.ts +19 -0
- package/AsyncScheduler.d.ts +11 -0
- package/BehaviorSubject.d.ts +10 -0
- package/Notification.d.ts +59 -0
- package/Observable/api/connect.d.ts +10 -0
- package/Observable/api/connectable.d.ts +24 -0
- package/Observable/api/fromCallback.d.ts +11 -0
- package/Observable/api/fromEvent.d.ts +4 -0
- package/Observable/api/index.d.ts +14 -0
- package/Observable/api/race.d.ts +9 -0
- package/Observable/api/raceWith.d.ts +6 -0
- package/Observable/api/repeatWhen.d.ts +5 -0
- package/Observable/api/retryWhen.d.ts +10 -0
- package/Observable/api/share.d.ts +16 -0
- package/Observable/api/window.d.ts +8 -0
- package/Observable/api/windowCount.d.ts +6 -0
- package/Observable/api/windowTime.d.ts +12 -0
- package/Observable/api/windowToggle.d.ts +8 -0
- package/Observable/api/windowWhen.d.ts +9 -0
- package/Observable/api.d.ts +668 -0
- package/Observable/definition.d.ts +32 -0
- package/Observable/dom/animationFrames.d.ts +6 -0
- package/Observable/instances.d.ts +1 -0
- package/Observable.d.ts +19 -0
- package/Observer.d.ts +6 -0
- package/Operator.d.ts +19 -0
- package/Scheduler.d.ts +22 -0
- package/Subject.d.ts +48 -0
- package/Subscriber.d.ts +27 -0
- package/Subscription.d.ts +41 -0
- package/_cjs/Action.cjs +27 -0
- package/_cjs/Action.cjs.map +1 -0
- package/_cjs/AnimationFrameAction.cjs +48 -0
- package/_cjs/AnimationFrameAction.cjs.map +1 -0
- package/_cjs/AnimationFrameScheduler.cjs +51 -0
- package/_cjs/AnimationFrameScheduler.cjs.map +1 -0
- package/_cjs/AsyncAction.cjs +116 -0
- package/_cjs/AsyncAction.cjs.map +1 -0
- package/_cjs/AsyncScheduler.cjs +61 -0
- package/_cjs/AsyncScheduler.cjs.map +1 -0
- package/_cjs/BehaviorSubject.cjs +52 -0
- package/_cjs/BehaviorSubject.cjs.map +1 -0
- package/_cjs/Notification.cjs +110 -0
- package/_cjs/Notification.cjs.map +1 -0
- package/_cjs/Observable/api/connect.cjs +35 -0
- package/_cjs/Observable/api/connect.cjs.map +1 -0
- package/_cjs/Observable/api/connectable.cjs +64 -0
- package/_cjs/Observable/api/connectable.cjs.map +1 -0
- package/_cjs/Observable/api/fromCallback.cjs +74 -0
- package/_cjs/Observable/api/fromCallback.cjs.map +1 -0
- package/_cjs/Observable/api/fromEvent.cjs +22 -0
- package/_cjs/Observable/api/fromEvent.cjs.map +1 -0
- package/_cjs/Observable/api/index.cjs +188 -0
- package/_cjs/Observable/api/index.cjs.map +1 -0
- package/_cjs/Observable/api/race.cjs +47 -0
- package/_cjs/Observable/api/race.cjs.map +1 -0
- package/_cjs/Observable/api/raceWith.cjs +24 -0
- package/_cjs/Observable/api/raceWith.cjs.map +1 -0
- package/_cjs/Observable/api/repeatWhen.cjs +72 -0
- package/_cjs/Observable/api/repeatWhen.cjs.map +1 -0
- package/_cjs/Observable/api/retryWhen.cjs +61 -0
- package/_cjs/Observable/api/retryWhen.cjs.map +1 -0
- package/_cjs/Observable/api/share.cjs +115 -0
- package/_cjs/Observable/api/share.cjs.map +1 -0
- package/_cjs/Observable/api/window.cjs +53 -0
- package/_cjs/Observable/api/window.cjs.map +1 -0
- package/_cjs/Observable/api/windowCount.cjs +62 -0
- package/_cjs/Observable/api/windowCount.cjs.map +1 -0
- package/_cjs/Observable/api/windowTime.cjs +90 -0
- package/_cjs/Observable/api/windowTime.cjs.map +1 -0
- package/_cjs/Observable/api/windowToggle.cjs +92 -0
- package/_cjs/Observable/api/windowToggle.cjs.map +1 -0
- package/_cjs/Observable/api/windowWhen.cjs +68 -0
- package/_cjs/Observable/api/windowWhen.cjs.map +1 -0
- package/_cjs/Observable/api.cjs +2558 -0
- package/_cjs/Observable/api.cjs.map +1 -0
- package/_cjs/Observable/definition.cjs +76 -0
- package/_cjs/Observable/definition.cjs.map +1 -0
- package/_cjs/Observable/dom/animationFrames.cjs +51 -0
- package/_cjs/Observable/dom/animationFrames.cjs.map +1 -0
- package/_cjs/Observable/instances.cjs +6 -0
- package/_cjs/Observable/instances.cjs.map +1 -0
- package/_cjs/Observable.cjs +253 -0
- package/_cjs/Observable.cjs.map +1 -0
- package/_cjs/Observer.cjs +6 -0
- package/_cjs/Observer.cjs.map +1 -0
- package/_cjs/Operator.cjs +83 -0
- package/_cjs/Operator.cjs.map +1 -0
- package/_cjs/Scheduler.cjs +62 -0
- package/_cjs/Scheduler.cjs.map +1 -0
- package/_cjs/Subject.cjs +228 -0
- package/_cjs/Subject.cjs.map +1 -0
- package/_cjs/Subscriber.cjs +172 -0
- package/_cjs/Subscriber.cjs.map +1 -0
- package/_cjs/Subscription.cjs +174 -0
- package/_cjs/Subscription.cjs.map +1 -0
- package/_cjs/demo.cjs +40 -0
- package/_cjs/demo.cjs.map +1 -0
- package/_cjs/global.cjs +4 -0
- package/_cjs/global.cjs.map +1 -0
- package/_cjs/index.cjs +65 -0
- package/_cjs/index.cjs.map +1 -0
- package/_cjs/internal/animationFrameProvider.cjs +51 -0
- package/_cjs/internal/animationFrameProvider.cjs.map +1 -0
- package/_cjs/internal/args.cjs +26 -0
- package/_cjs/internal/args.cjs.map +1 -0
- package/_cjs/internal/intervalProvider.cjs +27 -0
- package/_cjs/internal/intervalProvider.cjs.map +1 -0
- package/_cjs/internal/performanceTimestampProvider.cjs +15 -0
- package/_cjs/internal/performanceTimestampProvider.cjs.map +1 -0
- package/_cjs/internal/timeoutProvider.cjs +27 -0
- package/_cjs/internal/timeoutProvider.cjs.map +1 -0
- package/_cjs/internal/timestampProvider.cjs +15 -0
- package/_cjs/internal/timestampProvider.cjs.map +1 -0
- package/_cjs/internal/util.cjs +107 -0
- package/_cjs/internal/util.cjs.map +1 -0
- package/_mjs/Action.mjs +14 -0
- package/_mjs/Action.mjs.map +1 -0
- package/_mjs/AnimationFrameAction.mjs +33 -0
- package/_mjs/AnimationFrameAction.mjs.map +1 -0
- package/_mjs/AnimationFrameScheduler.mjs +36 -0
- package/_mjs/AnimationFrameScheduler.mjs.map +1 -0
- package/_mjs/AsyncAction.mjs +99 -0
- package/_mjs/AsyncAction.mjs.map +1 -0
- package/_mjs/AsyncScheduler.mjs +45 -0
- package/_mjs/AsyncScheduler.mjs.map +1 -0
- package/_mjs/BehaviorSubject.mjs +38 -0
- package/_mjs/BehaviorSubject.mjs.map +1 -0
- package/_mjs/Notification.mjs +80 -0
- package/_mjs/Notification.mjs.map +1 -0
- package/_mjs/Observable/api/connect.mjs +21 -0
- package/_mjs/Observable/api/connect.mjs.map +1 -0
- package/_mjs/Observable/api/connectable.mjs +45 -0
- package/_mjs/Observable/api/connectable.mjs.map +1 -0
- package/_mjs/Observable/api/fromCallback.mjs +60 -0
- package/_mjs/Observable/api/fromCallback.mjs.map +1 -0
- package/_mjs/Observable/api/fromEvent.mjs +10 -0
- package/_mjs/Observable/api/fromEvent.mjs.map +1 -0
- package/_mjs/Observable/api/index.mjs +15 -0
- package/_mjs/Observable/api/index.mjs.map +1 -0
- package/_mjs/Observable/api/race.mjs +32 -0
- package/_mjs/Observable/api/race.mjs.map +1 -0
- package/_mjs/Observable/api/raceWith.mjs +12 -0
- package/_mjs/Observable/api/raceWith.mjs.map +1 -0
- package/_mjs/Observable/api/repeatWhen.mjs +57 -0
- package/_mjs/Observable/api/repeatWhen.mjs.map +1 -0
- package/_mjs/Observable/api/retryWhen.mjs +45 -0
- package/_mjs/Observable/api/retryWhen.mjs.map +1 -0
- package/_mjs/Observable/api/share.mjs +97 -0
- package/_mjs/Observable/api/share.mjs.map +1 -0
- package/_mjs/Observable/api/window.mjs +40 -0
- package/_mjs/Observable/api/window.mjs.map +1 -0
- package/_mjs/Observable/api/windowCount.mjs +50 -0
- package/_mjs/Observable/api/windowCount.mjs.map +1 -0
- package/_mjs/Observable/api/windowTime.mjs +73 -0
- package/_mjs/Observable/api/windowTime.mjs.map +1 -0
- package/_mjs/Observable/api/windowToggle.mjs +77 -0
- package/_mjs/Observable/api/windowToggle.mjs.map +1 -0
- package/_mjs/Observable/api/windowWhen.mjs +54 -0
- package/_mjs/Observable/api/windowWhen.mjs.map +1 -0
- package/_mjs/Observable/api.mjs +2291 -0
- package/_mjs/Observable/api.mjs.map +1 -0
- package/_mjs/Observable/definition.mjs +54 -0
- package/_mjs/Observable/definition.mjs.map +1 -0
- package/_mjs/Observable/dom/animationFrames.mjs +36 -0
- package/_mjs/Observable/dom/animationFrames.mjs.map +1 -0
- package/_mjs/Observable/instances.mjs +2 -0
- package/_mjs/Observable/instances.mjs.map +1 -0
- package/_mjs/Observable.mjs +25 -0
- package/_mjs/Observable.mjs.map +1 -0
- package/_mjs/Observer.mjs +2 -0
- package/_mjs/Observer.mjs.map +1 -0
- package/_mjs/Operator.mjs +63 -0
- package/_mjs/Operator.mjs.map +1 -0
- package/_mjs/Scheduler.mjs +41 -0
- package/_mjs/Scheduler.mjs.map +1 -0
- package/_mjs/Subject.mjs +204 -0
- package/_mjs/Subject.mjs.map +1 -0
- package/_mjs/Subscriber.mjs +147 -0
- package/_mjs/Subscriber.mjs.map +1 -0
- package/_mjs/Subscription.mjs +148 -0
- package/_mjs/Subscription.mjs.map +1 -0
- package/_mjs/demo.mjs +30 -0
- package/_mjs/demo.mjs.map +1 -0
- package/_mjs/global.mjs +2 -0
- package/_mjs/global.mjs.map +1 -0
- package/_mjs/index.mjs +15 -0
- package/_mjs/index.mjs.map +1 -0
- package/_mjs/internal/animationFrameProvider.mjs +38 -0
- package/_mjs/internal/animationFrameProvider.mjs.map +1 -0
- package/_mjs/internal/args.mjs +13 -0
- package/_mjs/internal/args.mjs.map +1 -0
- package/_mjs/internal/intervalProvider.mjs +20 -0
- package/_mjs/internal/intervalProvider.mjs.map +1 -0
- package/_mjs/internal/performanceTimestampProvider.mjs +8 -0
- package/_mjs/internal/performanceTimestampProvider.mjs.map +1 -0
- package/_mjs/internal/timeoutProvider.mjs +20 -0
- package/_mjs/internal/timeoutProvider.mjs.map +1 -0
- package/_mjs/internal/timestampProvider.mjs +8 -0
- package/_mjs/internal/timestampProvider.mjs.map +1 -0
- package/_mjs/internal/util.mjs +76 -0
- package/_mjs/internal/util.mjs.map +1 -0
- package/_src/Action.ts +10 -0
- package/_src/AnimationFrameAction.ts +27 -0
- package/_src/AnimationFrameScheduler.ts +30 -0
- package/_src/AsyncAction.ts +93 -0
- package/_src/AsyncScheduler.ts +41 -0
- package/_src/BehaviorSubject.ts +28 -0
- package/_src/Notification.ts +91 -0
- package/_src/Observable/api/connect.ts +23 -0
- package/_src/Observable/api/connectable.ts +52 -0
- package/_src/Observable/api/fromCallback.ts +57 -0
- package/_src/Observable/api/fromEvent.ts +12 -0
- package/_src/Observable/api/index.ts +14 -0
- package/_src/Observable/api/race.ts +31 -0
- package/_src/Observable/api/raceWith.ts +15 -0
- package/_src/Observable/api/repeatWhen.ts +63 -0
- package/_src/Observable/api/retryWhen.ts +47 -0
- package/_src/Observable/api/share.ts +107 -0
- package/_src/Observable/api/window.ts +44 -0
- package/_src/Observable/api/windowCount.ts +56 -0
- package/_src/Observable/api/windowTime.ts +102 -0
- package/_src/Observable/api/windowToggle.ts +84 -0
- package/_src/Observable/api/windowWhen.ts +59 -0
- package/_src/Observable/api.ts +2749 -0
- package/_src/Observable/definition.ts +69 -0
- package/_src/Observable/dom/animationFrames.ts +33 -0
- package/_src/Observable/instances.ts +106 -0
- package/_src/Observable.ts +27 -0
- package/_src/Observer.ts +5 -0
- package/_src/Operator.ts +73 -0
- package/_src/Scheduler.ts +52 -0
- package/_src/Subject.ts +171 -0
- package/_src/Subscriber.ts +130 -0
- package/_src/Subscription.ts +143 -0
- package/_src/demo.ts +29 -0
- package/_src/global.ts +141 -0
- package/_src/index.ts +14 -0
- package/_src/internal/animationFrameProvider.ts +37 -0
- package/_src/internal/args.ts +11 -0
- package/_src/internal/intervalProvider.ts +27 -0
- package/_src/internal/performanceTimestampProvider.ts +12 -0
- package/_src/internal/timeoutProvider.ts +27 -0
- package/_src/internal/timestampProvider.ts +14 -0
- package/_src/internal/util.ts +94 -0
- package/demo.d.ts +1 -0
- package/global.d.ts +125 -0
- package/index.d.ts +14 -0
- package/internal/animationFrameProvider.d.ts +12 -0
- package/internal/args.d.ts +3 -0
- package/internal/intervalProvider.d.ts +12 -0
- package/internal/performanceTimestampProvider.d.ts +6 -0
- package/internal/timeoutProvider.d.ts +12 -0
- package/internal/timestampProvider.d.ts +7 -0
- package/internal/util.d.ts +28 -0
- package/package.json +16 -0
|
@@ -0,0 +1,2291 @@
|
|
|
1
|
+
const fileName_1 = "(@fncts/observable) src/Observable/api.ts";
|
|
2
|
+
import * as tsplus_module_1 from "@fncts/observable/Observable";
|
|
3
|
+
import * as tsplus_module_2 from "@fncts/base/data/Cause/api";
|
|
4
|
+
import * as tsplus_module_3 from "@fncts/observable/internal/util";
|
|
5
|
+
import * as tsplus_module_4 from "@fncts/base/util/predicates";
|
|
6
|
+
import * as tsplus_module_5 from "@fncts/io/IO";
|
|
7
|
+
import * as tsplus_module_6 from "@fncts/observable/AsyncScheduler";
|
|
8
|
+
import * as tsplus_module_7 from "@fncts/observable/Subscription";
|
|
9
|
+
import * as tsplus_module_8 from "@fncts/observable/Scheduler";
|
|
10
|
+
import * as tsplus_module_9 from "@fncts/observable/Operator";
|
|
11
|
+
import * as tsplus_module_10 from "@fncts/io/IO/runtime";
|
|
12
|
+
import * as tsplus_module_11 from "@fncts/base/data/Exit/api";
|
|
13
|
+
import * as tsplus_module_12 from "@fncts/io/Fiber/api/interrupt";
|
|
14
|
+
import * as tsplus_module_13 from "@fncts/base/data/function/api";
|
|
15
|
+
import * as tsplus_module_14 from "@fncts/base/data/Either/destructors";
|
|
16
|
+
import * as tsplus_module_15 from "@fncts/base/data/Maybe/destructors";
|
|
17
|
+
import * as tsplus_module_16 from "@fncts/base/data/Maybe/constructors";
|
|
18
|
+
import * as tsplus_module_17 from "@fncts/base/data/Maybe/definition";
|
|
19
|
+
import * as tsplus_module_18 from "@fncts/base/data/Either/constructors";
|
|
20
|
+
import * as tsplus_module_19 from "@fncts/observable/Notification";
|
|
21
|
+
import * as tsplus_module_20 from "@fncts/base/collection/immutable/HashSet/api";
|
|
22
|
+
export const defer = defer_1;
|
|
23
|
+
export const empty = empty_1;
|
|
24
|
+
export const fail = fail_1;
|
|
25
|
+
export const from = from_1;
|
|
26
|
+
export const fromSubscribable = fromSubscribable_1;
|
|
27
|
+
export const interval = interval_1;
|
|
28
|
+
export const single = single_1;
|
|
29
|
+
export const scheduled = scheduled_1;
|
|
30
|
+
export const timer = timer_1;
|
|
31
|
+
export const fromIO = fromIO_1;
|
|
32
|
+
export const zipWith = zipWith_1;
|
|
33
|
+
export const mapWithIndex = mapWithIndex_1;
|
|
34
|
+
export const map_ = map_1;
|
|
35
|
+
export const as_ = as_1;
|
|
36
|
+
export const filterWithIndex_ = filterWithIndex_1;
|
|
37
|
+
export const filterMapWithIndex = filterMapWithIndex_1;
|
|
38
|
+
export const partitionWithIndex = partitionWithIndex_1;
|
|
39
|
+
export const partitionMapWithIndex_ = partitionMapWithIndex_1;
|
|
40
|
+
export const mergeMapWithIndex = mergeMapWithIndex_1;
|
|
41
|
+
export const mergeMap_ = mergeMap_1;
|
|
42
|
+
export const foldLeftWithIndex = foldLeftWithIndex_1;
|
|
43
|
+
export const foldLeft = foldLeft_1;
|
|
44
|
+
export const audit_ = audit_1;
|
|
45
|
+
export const bufferWhen_ = bufferWhen_1;
|
|
46
|
+
export const catchAllCause = catchAllCause_1;
|
|
47
|
+
export const concatAll = concatAll_1;
|
|
48
|
+
export const concat_ = concat_1;
|
|
49
|
+
export const countWithIndex = countWithIndex_1;
|
|
50
|
+
export const combineLatest_ = combineLatest_1;
|
|
51
|
+
export const delayWithIndex = delayWithIndex_1;
|
|
52
|
+
export const delayWith_ = delayWith_1;
|
|
53
|
+
export const exhaustMapWithIndex = exhaustMapWithIndex_1;
|
|
54
|
+
export const expandWithIndex = expandWithIndex_1;
|
|
55
|
+
export const findWithIndex = findWithIndex_1;
|
|
56
|
+
export const findIndexWithIndex = findIndexWithIndex_1;
|
|
57
|
+
export const mergeAll_ = mergeAll_1;
|
|
58
|
+
export const mergeScanWithIndex = mergeScanWithIndex_1;
|
|
59
|
+
export const onEmpty_ = onEmpty_1;
|
|
60
|
+
export const sample_ = sample_1;
|
|
61
|
+
export const scanLeftWithIndex = scanLeftWithIndex_1;
|
|
62
|
+
export const switchMapWithIndex = switchMapWithIndex_1;
|
|
63
|
+
export const switchMap_ = switchMap_1;
|
|
64
|
+
export const switchScanWithIndex = switchScanWithIndex_1;
|
|
65
|
+
export const take_ = take_1;
|
|
66
|
+
export const takeWhileWithIndex = takeWhileWithIndex_1;
|
|
67
|
+
export const throttle_ = throttle_1;
|
|
68
|
+
export const toArray = toArray_1;
|
|
69
|
+
export const uniqueUntilChanged_ = uniqueUntilChanged_1;
|
|
70
|
+
import { popNumber } from "@fncts/observable/internal/args";
|
|
71
|
+
import { arrayOrObject, arrayRemove, readableStreamToAsyncGenerator } from "@fncts/observable/internal/util";
|
|
72
|
+
import { EMPTY } from "@fncts/observable/Observable/definition";
|
|
73
|
+
import { caughtSchedule } from "@fncts/observable/Scheduler";
|
|
74
|
+
/*
|
|
75
|
+
* -------------------------------------------------------------------------------------------------
|
|
76
|
+
* constructors
|
|
77
|
+
* -------------------------------------------------------------------------------------------------
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @tsplus static fncts.observable.ObservableOps halt
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
export function halt(defect) {
|
|
85
|
+
return new tsplus_module_1.Observable(s => s.error(tsplus_module_2.halt(defect)));
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* @tsplus static fncts.observable.ObservableOps defer
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
function defer_1(observable) {
|
|
92
|
+
return new tsplus_module_1.Observable(s => {
|
|
93
|
+
from_1(observable()).subscribe(s);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* @tsplus static fncts.observable.ObservableOps empty
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
function empty_1() {
|
|
102
|
+
return EMPTY;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* @tsplus static fncts.observable.ObservableOps failCause
|
|
106
|
+
*/
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
export function failCause(cause) {
|
|
110
|
+
return new tsplus_module_1.Observable(s => s.error(cause));
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* @tsplus static fncts.observable.ObservableOps fail
|
|
114
|
+
*/
|
|
115
|
+
|
|
116
|
+
function fail_1(e) {
|
|
117
|
+
return new tsplus_module_1.Observable(s => s.error(tsplus_module_2.fail(e)));
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* @tsplus static fncts.observable.ObservableOps from
|
|
121
|
+
*/
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
function from_1(input) {
|
|
125
|
+
if (input instanceof tsplus_module_1.Observable) {
|
|
126
|
+
return input;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (tsplus_module_3.isArrayLike(input)) {
|
|
130
|
+
return fromArrayLike(input);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (tsplus_module_3.isPromiseLike(input)) {
|
|
134
|
+
return fromPromise(input);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (tsplus_module_3.isAsyncIterable(input)) {
|
|
138
|
+
return fromAsyncIterable(input);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (tsplus_module_4.isIterable(input)) {
|
|
142
|
+
return fromIterable(input);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (tsplus_module_3.isReadableStream(input)) {
|
|
146
|
+
return fromReadableStreamLike(input);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (tsplus_module_5.isIO(input)) {
|
|
150
|
+
return fromIO_1(input);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if ("subscribe" in input) {
|
|
154
|
+
return fromSubscribable_1(input);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
throw new TypeError("Invalid Observable input");
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export function fromArrayLike(input) {
|
|
161
|
+
return new tsplus_module_1.Observable(s => {
|
|
162
|
+
for (let i = 0; i < input.length && !s.closed; i++) {
|
|
163
|
+
s.next(input[i]);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
s.complete();
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
export function fromAsyncIterable(asyncIterable) {
|
|
170
|
+
return new tsplus_module_1.Observable(s => {
|
|
171
|
+
process(asyncIterable, s).catch(err => s.error(tsplus_module_2.halt(err)));
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
export function fromIterable(iterable) {
|
|
175
|
+
return new tsplus_module_1.Observable(s => {
|
|
176
|
+
for (const value of iterable) {
|
|
177
|
+
s.next(value);
|
|
178
|
+
|
|
179
|
+
if (s.closed) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
s.complete();
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
export function fromPromise(promise) {
|
|
188
|
+
return new tsplus_module_1.Observable(s => {
|
|
189
|
+
promise.then(value => {
|
|
190
|
+
if (!s.closed) {
|
|
191
|
+
s.next(value);
|
|
192
|
+
s.complete();
|
|
193
|
+
}
|
|
194
|
+
}, err => s.error(tsplus_module_2.halt(err))).then(null, tsplus_module_3.reportUnhandledError);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
export function fromReadableStreamLike(readableStream) {
|
|
198
|
+
return fromAsyncIterable(readableStreamToAsyncGenerator(readableStream));
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* @tsplus static fncts.observable.ObservableOps fromSubscribable
|
|
202
|
+
*/
|
|
203
|
+
|
|
204
|
+
function fromSubscribable_1(subscribable) {
|
|
205
|
+
return new tsplus_module_1.Observable(subscriber => subscribable.subscribe(subscriber));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export function fromInterop(subscribable) {
|
|
209
|
+
return new tsplus_module_1.Observable(subscriber => subscribable.subscribe({
|
|
210
|
+
next: value => subscriber.next(value),
|
|
211
|
+
error: err => subscriber.error(tsplus_module_2.halt(err)),
|
|
212
|
+
complete: () => subscriber.complete()
|
|
213
|
+
}));
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function _if(condition, onTrue, onFalse) {
|
|
217
|
+
return defer_1(() => condition() ? onTrue : onFalse);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export { _if as if };
|
|
221
|
+
export function iterate(options) {
|
|
222
|
+
const {
|
|
223
|
+
initialState,
|
|
224
|
+
cont,
|
|
225
|
+
iterate,
|
|
226
|
+
scheduler
|
|
227
|
+
} = options;
|
|
228
|
+
|
|
229
|
+
function* gen() {
|
|
230
|
+
for (let state = initialState; !cont || cont(state); state = iterate(state)) {
|
|
231
|
+
yield state;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return defer_1(scheduler ? () => scheduleIterable(gen(), scheduler) : gen);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
async function process(asyncIterable, subscriber) {
|
|
239
|
+
for await (const value of asyncIterable) {
|
|
240
|
+
subscriber.next(value);
|
|
241
|
+
|
|
242
|
+
if (subscriber.closed) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
subscriber.complete();
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* @tsplus static fncts.obervable.ObservableOps interval
|
|
251
|
+
*/
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
function interval_1(period = 0, scheduler = tsplus_module_6.asyncScheduler) {
|
|
255
|
+
if (period < 0) {
|
|
256
|
+
// eslint-disable-next-line no-param-reassign
|
|
257
|
+
period = 0;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
return timer_1(period, period, scheduler);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export function merge(...sources) {
|
|
264
|
+
const concurrency = popNumber(sources, Infinity);
|
|
265
|
+
return !sources.length ? empty_1() : sources.length === 1 ? from_1(sources[0]) : mergeAll_1(fromArrayLike(sources), concurrency);
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* @tsplus static fncts.observable.ObservableOps of
|
|
269
|
+
*/
|
|
270
|
+
|
|
271
|
+
export function of(...items) {
|
|
272
|
+
return fromArrayLike(items);
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* @tsplus static fncts.observable.ObservableOps single
|
|
276
|
+
*/
|
|
277
|
+
|
|
278
|
+
function single_1(a) {
|
|
279
|
+
return new tsplus_module_1.Observable(s => {
|
|
280
|
+
s.next(a);
|
|
281
|
+
s.complete();
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* @tsplus fluent fncts.observable.Observable scheduled
|
|
286
|
+
* @tsplus static fncts.observable.ObservableOps scheduled
|
|
287
|
+
*/
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
function scheduled_1(input, scheduler) {
|
|
291
|
+
if (tsplus_module_3.isArrayLike(input)) {
|
|
292
|
+
return scheduleArray(input, scheduler);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if (tsplus_module_3.isPromiseLike(input)) {
|
|
296
|
+
return schedulePromise(input, scheduler);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (tsplus_module_4.isIterable(input)) {
|
|
300
|
+
return scheduleIterable(input, scheduler);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if (tsplus_module_3.isAsyncIterable(input)) {
|
|
304
|
+
return scheduleAsyncIterable(input, scheduler);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (tsplus_module_3.isReadableStream(input)) {
|
|
308
|
+
return scheduleReadableStreamLike(input, scheduler);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return scheduleObservable(from_1(input), scheduler);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export function scheduleArray(input, scheduler) {
|
|
315
|
+
return new tsplus_module_1.Observable(s => {
|
|
316
|
+
let i = 0;
|
|
317
|
+
return scheduler.schedule(function () {
|
|
318
|
+
if (i === input.length) {
|
|
319
|
+
s.complete();
|
|
320
|
+
} else {
|
|
321
|
+
s.next(input[i++]);
|
|
322
|
+
|
|
323
|
+
if (!s.closed) {
|
|
324
|
+
this.schedule();
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
export function scheduleAsyncIterable(input, scheduler) {
|
|
331
|
+
return new tsplus_module_1.Observable(subscriber => {
|
|
332
|
+
const sub = new tsplus_module_7.Subscription();
|
|
333
|
+
sub.add(scheduler.schedule(() => {
|
|
334
|
+
const iterator = input[Symbol.asyncIterator]();
|
|
335
|
+
sub.add(scheduler.schedule(function () {
|
|
336
|
+
iterator.next().then(result => {
|
|
337
|
+
if (result.done) {
|
|
338
|
+
subscriber.complete();
|
|
339
|
+
} else {
|
|
340
|
+
subscriber.next(result.value);
|
|
341
|
+
this.schedule();
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
}));
|
|
345
|
+
}));
|
|
346
|
+
return sub;
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
export function scheduleIterable(input, scheduler) {
|
|
350
|
+
return new tsplus_module_1.Observable(s => {
|
|
351
|
+
let iterator;
|
|
352
|
+
s.add(scheduler.schedule(() => {
|
|
353
|
+
iterator = input[Symbol.iterator]();
|
|
354
|
+
caughtSchedule(s, scheduler, function () {
|
|
355
|
+
const {
|
|
356
|
+
value,
|
|
357
|
+
done
|
|
358
|
+
} = iterator.next();
|
|
359
|
+
|
|
360
|
+
if (done) {
|
|
361
|
+
s.complete();
|
|
362
|
+
} else {
|
|
363
|
+
s.next(value);
|
|
364
|
+
this.schedule();
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
}));
|
|
368
|
+
return () => tsplus_module_4.isFunction(iterator?.return) && iterator.return();
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
export function scheduleObservable(input, scheduler) {
|
|
372
|
+
return new tsplus_module_1.Observable(subscriber => {
|
|
373
|
+
const sub = new tsplus_module_7.Subscription();
|
|
374
|
+
sub.add(scheduler.schedule(() => {
|
|
375
|
+
sub.add(input.subscribe({
|
|
376
|
+
next: value => {
|
|
377
|
+
sub.add(scheduler.schedule(() => subscriber.next(value)));
|
|
378
|
+
},
|
|
379
|
+
error: err => {
|
|
380
|
+
sub.add(scheduler.schedule(() => subscriber.error(err)));
|
|
381
|
+
},
|
|
382
|
+
complete: () => {
|
|
383
|
+
sub.add(scheduler.schedule(() => subscriber.complete()));
|
|
384
|
+
}
|
|
385
|
+
}));
|
|
386
|
+
}));
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
export function schedulePromise(input, scheduler) {
|
|
390
|
+
return new tsplus_module_1.Observable(subscriber => {
|
|
391
|
+
return scheduler.schedule(() => {
|
|
392
|
+
input.then(value => {
|
|
393
|
+
subscriber.add(scheduler.schedule(() => {
|
|
394
|
+
subscriber.next(value);
|
|
395
|
+
subscriber.add(scheduler.schedule(() => subscriber.complete()));
|
|
396
|
+
}));
|
|
397
|
+
}, err => {
|
|
398
|
+
subscriber.add(scheduler.schedule(() => subscriber.error(tsplus_module_2.halt(err))));
|
|
399
|
+
});
|
|
400
|
+
});
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
export function scheduleReadableStreamLike(input, scheduler) {
|
|
404
|
+
return scheduleAsyncIterable(readableStreamToAsyncGenerator(input), scheduler);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function timer_1(time = 0, intervalOrScheduler, scheduler = tsplus_module_6.asyncScheduler) {
|
|
408
|
+
let intervalDuration = -1;
|
|
409
|
+
|
|
410
|
+
if (intervalOrScheduler != null) {
|
|
411
|
+
if (tsplus_module_8.isScheduler(intervalOrScheduler)) {
|
|
412
|
+
// eslint-disable-next-line no-param-reassign
|
|
413
|
+
scheduler = intervalOrScheduler;
|
|
414
|
+
} else {
|
|
415
|
+
intervalDuration = intervalOrScheduler;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
return new tsplus_module_1.Observable(s => {
|
|
420
|
+
let due = tsplus_module_3.isValidDate(time) ? +time - scheduler.now() : time;
|
|
421
|
+
|
|
422
|
+
if (due < 0) {
|
|
423
|
+
due = 0;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
let n = 0;
|
|
427
|
+
return scheduler.schedule(function () {
|
|
428
|
+
if (!s.closed) {
|
|
429
|
+
s.next(n++);
|
|
430
|
+
|
|
431
|
+
if (0 <= intervalDuration) {
|
|
432
|
+
this.schedule(undefined, intervalDuration);
|
|
433
|
+
} else {
|
|
434
|
+
s.complete();
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}, due);
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* @tsplus static fncts.observable.ObservableOps zip
|
|
442
|
+
*/
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
export function makeZip(...sources) {
|
|
446
|
+
return sources.length ? new tsplus_module_1.Observable(subscriber => {
|
|
447
|
+
let buffers = sources.map(() => []);
|
|
448
|
+
let completed = sources.map(() => false);
|
|
449
|
+
subscriber.add(() => {
|
|
450
|
+
buffers = completed = null;
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
for (let sourceIndex = 0; !subscriber.closed && sourceIndex < sources.length; sourceIndex++) {
|
|
454
|
+
from_1(sources[sourceIndex]).subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
455
|
+
next: value => {
|
|
456
|
+
buffers[sourceIndex].push(value);
|
|
457
|
+
|
|
458
|
+
if (buffers.every(buffer => buffer.length)) {
|
|
459
|
+
const result = buffers.map(buffer => buffer.shift());
|
|
460
|
+
subscriber.next(result);
|
|
461
|
+
|
|
462
|
+
if (buffers.some((buffer, i) => !buffer.length && completed[i])) {
|
|
463
|
+
subscriber.complete();
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
},
|
|
467
|
+
complete: () => {
|
|
468
|
+
completed[sourceIndex] = true;
|
|
469
|
+
!buffers[sourceIndex].length && subscriber.complete();
|
|
470
|
+
}
|
|
471
|
+
}));
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
return () => {
|
|
475
|
+
buffers = completed = null;
|
|
476
|
+
};
|
|
477
|
+
}) : empty_1();
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* @tsplus static fncts.observable.ObservableOps fromIO
|
|
481
|
+
*/
|
|
482
|
+
|
|
483
|
+
function fromIO_1(io, scheduler = tsplus_module_6.asyncScheduler) {
|
|
484
|
+
return new tsplus_module_1.Observable(s => {
|
|
485
|
+
let fiber;
|
|
486
|
+
const scheduled = scheduler.schedule(() => {
|
|
487
|
+
fiber = tsplus_module_10.unsafeRunFiber(io, fileName_1 + ":473:32");
|
|
488
|
+
fiber.unsafeOnDone(exit => {
|
|
489
|
+
if (!s.closed) {
|
|
490
|
+
tsplus_module_11.match_(tsplus_module_11.flatten(exit), cause => s.error(cause), a => s.next(a));
|
|
491
|
+
s.complete();
|
|
492
|
+
}
|
|
493
|
+
});
|
|
494
|
+
});
|
|
495
|
+
return () => {
|
|
496
|
+
scheduled.unsubscribe();
|
|
497
|
+
fiber && tsplus_module_10.unsafeRunAsync(tsplus_module_12.interrupt(fiber), fileName_1 + ":486:46");
|
|
498
|
+
};
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
/*
|
|
502
|
+
* -------------------------------------------------------------------------------------------------
|
|
503
|
+
* Applicative
|
|
504
|
+
* -------------------------------------------------------------------------------------------------
|
|
505
|
+
*/
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* @tsplus static fncts.observable.ObservableOps unit
|
|
509
|
+
*/
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
export const unit = /*#__PURE__*/single_1(undefined);
|
|
513
|
+
/*
|
|
514
|
+
* -------------------------------------------------------------------------------------------------
|
|
515
|
+
* Apply
|
|
516
|
+
* -------------------------------------------------------------------------------------------------
|
|
517
|
+
*/
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* @tsplus fluent fncts.observable.Observable zipWith
|
|
521
|
+
*/
|
|
522
|
+
|
|
523
|
+
function zipWith_1(fa, fb, f) {
|
|
524
|
+
return mergeMap_1(fa, a => map_1(fb, b => f(a, b)));
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* @tsplus fluent fncts.observable.Observable zip
|
|
528
|
+
*/
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
export function zip(fa, fb) {
|
|
532
|
+
return zipWith_1(fa, fb, tsplus_module_13.tuple);
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* @tsplus fluent fncts.observable.Observable ap
|
|
536
|
+
*/
|
|
537
|
+
|
|
538
|
+
export function ap(fab, fa) {
|
|
539
|
+
return zipWith_1(fab, fa, (f, a) => f(a));
|
|
540
|
+
}
|
|
541
|
+
/*
|
|
542
|
+
* -------------------------------------------------------------------------------------------------
|
|
543
|
+
* Functor
|
|
544
|
+
* -------------------------------------------------------------------------------------------------
|
|
545
|
+
*/
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* @tsplus fluent fncts.observable.Observable mapWithIndex
|
|
549
|
+
*/
|
|
550
|
+
|
|
551
|
+
function mapWithIndex_1(fa, f) {
|
|
552
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
553
|
+
let i = 0;
|
|
554
|
+
source.subscribe(new tsplus_module_9.OperatorSubscriber(subscriber, {
|
|
555
|
+
next: value => {
|
|
556
|
+
subscriber.next(f(i++, value));
|
|
557
|
+
}
|
|
558
|
+
}));
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* @tsplus fluent fncts.observable.Observable map
|
|
563
|
+
*/
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
function map_1(fa, f) {
|
|
567
|
+
return mapWithIndex_1(fa, (_, a) => f(a));
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* @tsplus fluent fncts.observable.Observable as
|
|
571
|
+
*/
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
function as_1(fa, b) {
|
|
575
|
+
return map_1(fa, b);
|
|
576
|
+
}
|
|
577
|
+
/*
|
|
578
|
+
* -------------------------------------------------------------------------------------------------
|
|
579
|
+
* Bifunctor
|
|
580
|
+
* -------------------------------------------------------------------------------------------------
|
|
581
|
+
*/
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* @tsplus fluent fncts.observable.Observable mapError
|
|
585
|
+
*/
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
export function mapError_(fa, f) {
|
|
589
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
590
|
+
source.subscribe(new tsplus_module_9.OperatorSubscriber(subscriber, {
|
|
591
|
+
error: err => {
|
|
592
|
+
subscriber.error(tsplus_module_2.map_(err, f));
|
|
593
|
+
}
|
|
594
|
+
}));
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* @tsplus getter fncts.observable.Observable swap
|
|
599
|
+
*/
|
|
600
|
+
|
|
601
|
+
export function swap(fa) {
|
|
602
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
603
|
+
source.subscribe(new tsplus_module_9.OperatorSubscriber(subscriber, {
|
|
604
|
+
next: value => {
|
|
605
|
+
subscriber.error(tsplus_module_2.fail(value));
|
|
606
|
+
},
|
|
607
|
+
error: err => {
|
|
608
|
+
tsplus_module_14.match_(tsplus_module_2.failureOrCause(err), e => {
|
|
609
|
+
subscriber.next(e);
|
|
610
|
+
}, cause => {
|
|
611
|
+
subscriber.error(cause);
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
}));
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
function filterWithIndex_1(fa, predicate) {
|
|
619
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
620
|
+
let index = 0;
|
|
621
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
622
|
+
next: value => predicate(index++, value) && subscriber.next(value)
|
|
623
|
+
}));
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
export function filter_(fa, predicate) {
|
|
628
|
+
return filterWithIndex_1(fa, (_, a) => predicate(a));
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* @tsplus fluent fncts.observable.Observable filterMapWithIndex
|
|
632
|
+
*/
|
|
633
|
+
|
|
634
|
+
function filterMapWithIndex_1(fa, f) {
|
|
635
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
636
|
+
let index = 0;
|
|
637
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
638
|
+
next: value => tsplus_module_15.match_(f(index++, value), () => tsplus_module_3.noop, b => subscriber.next(b))
|
|
639
|
+
}));
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* @tsplus fluent fncts.observable.Observable filterMap
|
|
644
|
+
*/
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
export function filterMap_(fa, f) {
|
|
648
|
+
return filterMapWithIndex_1(fa, (_, a) => f(a));
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
function partitionWithIndex_1(fa, predicate) {
|
|
652
|
+
return [filterWithIndex_1(fa, (i, a) => !predicate(i, a)), filterWithIndex_1(fa, predicate)];
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
export function partition_(fa, predicate) {
|
|
656
|
+
return partitionWithIndex_1(fa, (_, a) => predicate(a));
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* @tsplus fluent fncts.observable.Observable partitionMapWithIndex
|
|
660
|
+
*/
|
|
661
|
+
|
|
662
|
+
function partitionMapWithIndex_1(fa, f) {
|
|
663
|
+
return [tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
664
|
+
let index = 0;
|
|
665
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
666
|
+
next: value => {
|
|
667
|
+
tsplus_module_14.match_(f(index++, value), b => subscriber.next(b), tsplus_module_3.noop);
|
|
668
|
+
}
|
|
669
|
+
}));
|
|
670
|
+
}), tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
671
|
+
let index = 0;
|
|
672
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
673
|
+
next: value => {
|
|
674
|
+
tsplus_module_14.match_(f(index++, value), tsplus_module_3.noop, c => subscriber.next(c));
|
|
675
|
+
}
|
|
676
|
+
}));
|
|
677
|
+
})];
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* @tsplus fluent fncts.observable.Observable partitionMap
|
|
681
|
+
*/
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
export function partitionMap_(fa, f) {
|
|
685
|
+
return partitionMapWithIndex_1(fa, (_, a) => f(a));
|
|
686
|
+
}
|
|
687
|
+
/*
|
|
688
|
+
* -------------------------------------------------------------------------------------------------
|
|
689
|
+
* Monad
|
|
690
|
+
* -------------------------------------------------------------------------------------------------
|
|
691
|
+
*/
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* @tsplus fluent fncts.observable.Observable mergeMapWithIndex
|
|
695
|
+
*/
|
|
696
|
+
|
|
697
|
+
function mergeMapWithIndex_1(ma, f, concurrent = Infinity) {
|
|
698
|
+
return tsplus_module_9.operate_(ma, (source, sub) => mergeInternal(source, sub, f, concurrent));
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* @tsplus fluent fncts.observable.Observable mergeMap
|
|
702
|
+
*/
|
|
703
|
+
|
|
704
|
+
|
|
705
|
+
function mergeMap_1(ma, f, concurrent = Infinity) {
|
|
706
|
+
return mergeMapWithIndex_1(ma, (_, a) => f(a), concurrent);
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* @tsplus fluent fncts.observable.Observable concatMapWithIndex
|
|
710
|
+
*/
|
|
711
|
+
|
|
712
|
+
|
|
713
|
+
export function concatMapWithIndex(ma, f) {
|
|
714
|
+
return mergeMapWithIndex_1(ma, f, 1);
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* @tsplus fluent fncts.observable.Observable concatMap
|
|
718
|
+
*/
|
|
719
|
+
|
|
720
|
+
export function concatMap_(ma, f) {
|
|
721
|
+
return mergeMapWithIndex_1(ma, (_, a) => f(a), 1);
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* @tsplus getter fncts.observable.Observable flatten
|
|
725
|
+
*/
|
|
726
|
+
|
|
727
|
+
export function flatten(mma) {
|
|
728
|
+
return concatAll_1(mma);
|
|
729
|
+
}
|
|
730
|
+
/*
|
|
731
|
+
* -------------------------------------------------------------------------------------------------
|
|
732
|
+
* Foldable
|
|
733
|
+
* -------------------------------------------------------------------------------------------------
|
|
734
|
+
*/
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* @tsplus fluent fncts.observable.Observable foldLeftWithIndex
|
|
738
|
+
*/
|
|
739
|
+
|
|
740
|
+
function foldLeftWithIndex_1(fa, initial, f) {
|
|
741
|
+
return tsplus_module_9.operate_(fa, scanInternal(f, initial, true, false, true));
|
|
742
|
+
}
|
|
743
|
+
/**
|
|
744
|
+
* @tsplus fluent fncts.observable.Observable foldLeft
|
|
745
|
+
*/
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
function foldLeft_1(fa, initial, f) {
|
|
749
|
+
return foldLeftWithIndex_1(fa, initial, (_, b, a) => f(b, a));
|
|
750
|
+
}
|
|
751
|
+
/*
|
|
752
|
+
* -------------------------------------------------------------------------------------------------
|
|
753
|
+
* combinators
|
|
754
|
+
* -------------------------------------------------------------------------------------------------
|
|
755
|
+
*/
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* @tsplus fluent fncts.observable.Observable at
|
|
759
|
+
*/
|
|
760
|
+
|
|
761
|
+
|
|
762
|
+
export function at_(fa, index) {
|
|
763
|
+
return onEmpty_1(map_1(take_1(filterWithIndex_1(fa, i => i === index), 1), tsplus_module_16.just), () => tsplus_module_16.nothing());
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* @tsplus fluent fncts.observable.Observable audit
|
|
767
|
+
*/
|
|
768
|
+
|
|
769
|
+
function audit_1(fa, durationSelector) {
|
|
770
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
771
|
+
let lastValue = tsplus_module_16.nothing();
|
|
772
|
+
let durationSubscriber = null;
|
|
773
|
+
let isComplete = false;
|
|
774
|
+
|
|
775
|
+
const endDuration = () => {
|
|
776
|
+
durationSubscriber?.unsubscribe();
|
|
777
|
+
durationSubscriber = null;
|
|
778
|
+
|
|
779
|
+
if (tsplus_module_17.isJust(lastValue)) {
|
|
780
|
+
const {
|
|
781
|
+
value
|
|
782
|
+
} = lastValue;
|
|
783
|
+
lastValue = tsplus_module_16.nothing();
|
|
784
|
+
subscriber.next(value);
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
isComplete && subscriber.complete();
|
|
788
|
+
};
|
|
789
|
+
|
|
790
|
+
const cleanupDuration = () => {
|
|
791
|
+
durationSubscriber = null;
|
|
792
|
+
isComplete && subscriber.complete();
|
|
793
|
+
};
|
|
794
|
+
|
|
795
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
796
|
+
next: value => {
|
|
797
|
+
lastValue = tsplus_module_16.just(value);
|
|
798
|
+
|
|
799
|
+
if (!durationSubscriber) {
|
|
800
|
+
from_1(durationSelector(value)).subscribe(durationSubscriber = tsplus_module_9.operatorSubscriber(subscriber, {
|
|
801
|
+
next: endDuration,
|
|
802
|
+
complete: cleanupDuration
|
|
803
|
+
}));
|
|
804
|
+
}
|
|
805
|
+
},
|
|
806
|
+
complete: () => {
|
|
807
|
+
isComplete = true;
|
|
808
|
+
(tsplus_module_17.isNothing(lastValue) || !durationSubscriber || durationSubscriber.closed) && subscriber.complete();
|
|
809
|
+
}
|
|
810
|
+
}));
|
|
811
|
+
});
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* @tsplus fluent fncts.observable.Observable auditTime
|
|
815
|
+
*/
|
|
816
|
+
|
|
817
|
+
|
|
818
|
+
export function auditTime_(fa, duration, scheduler = tsplus_module_6.asyncScheduler) {
|
|
819
|
+
return audit_1(fa, () => timer_1(duration, scheduler));
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* @tsplus fluent fncts.observable.Observable buffer
|
|
823
|
+
*/
|
|
824
|
+
|
|
825
|
+
export function buffer_(fa, closingNotifier) {
|
|
826
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
827
|
+
let buffer = [];
|
|
828
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
829
|
+
next: value => buffer.push(value),
|
|
830
|
+
complete: () => {
|
|
831
|
+
subscriber.next(buffer);
|
|
832
|
+
subscriber.complete();
|
|
833
|
+
}
|
|
834
|
+
}));
|
|
835
|
+
closingNotifier.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
836
|
+
next: () => {
|
|
837
|
+
const b = buffer;
|
|
838
|
+
buffer = [];
|
|
839
|
+
subscriber.next(b);
|
|
840
|
+
},
|
|
841
|
+
complete: tsplus_module_3.noop
|
|
842
|
+
}));
|
|
843
|
+
return () => {
|
|
844
|
+
buffer = null;
|
|
845
|
+
};
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* @tsplus fluent fncts.observable.Observable bufferCount
|
|
850
|
+
*/
|
|
851
|
+
|
|
852
|
+
export function bufferCount_(fa, bufferSize, startBufferEvery) {
|
|
853
|
+
// eslint-disable-next-line no-param-reassign
|
|
854
|
+
startBufferEvery = startBufferEvery ?? bufferSize;
|
|
855
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
856
|
+
let buffers = [];
|
|
857
|
+
let count = 0;
|
|
858
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
859
|
+
next: value => {
|
|
860
|
+
let toEmit = null;
|
|
861
|
+
|
|
862
|
+
if (count++ % startBufferEvery === 0) {
|
|
863
|
+
buffers.push([]);
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
for (const buffer of buffers) {
|
|
867
|
+
buffer.push(value);
|
|
868
|
+
|
|
869
|
+
if (bufferSize <= buffer.length) {
|
|
870
|
+
toEmit = toEmit ?? [];
|
|
871
|
+
toEmit.push(buffer);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
if (toEmit) {
|
|
876
|
+
for (const buffer of toEmit) {
|
|
877
|
+
arrayRemove(buffers, buffer);
|
|
878
|
+
subscriber.next(buffer);
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
},
|
|
882
|
+
complete: () => {
|
|
883
|
+
for (const buffer of buffers) {
|
|
884
|
+
subscriber.next(buffer);
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
subscriber.complete();
|
|
888
|
+
}
|
|
889
|
+
}, () => {
|
|
890
|
+
buffers = null;
|
|
891
|
+
}));
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
/**
|
|
895
|
+
* @tsplus fluent fncts.observable.Observable bufferTime
|
|
896
|
+
*/
|
|
897
|
+
|
|
898
|
+
export function bufferTime_(fa, config) {
|
|
899
|
+
const {
|
|
900
|
+
bufferTimeSpan,
|
|
901
|
+
bufferCreationInterval = null,
|
|
902
|
+
maxBufferSize = Infinity,
|
|
903
|
+
scheduler = tsplus_module_6.asyncScheduler
|
|
904
|
+
} = config;
|
|
905
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
906
|
+
let bufferRecords = [];
|
|
907
|
+
let restartOnEmit = true;
|
|
908
|
+
|
|
909
|
+
const emit = record => {
|
|
910
|
+
const {
|
|
911
|
+
buffer,
|
|
912
|
+
subs
|
|
913
|
+
} = record;
|
|
914
|
+
subs.unsubscribe();
|
|
915
|
+
arrayRemove(bufferRecords, record);
|
|
916
|
+
subscriber.next(buffer);
|
|
917
|
+
restartOnEmit && startBuffer();
|
|
918
|
+
};
|
|
919
|
+
|
|
920
|
+
const startBuffer = () => {
|
|
921
|
+
if (bufferRecords) {
|
|
922
|
+
const subs = new tsplus_module_7.Subscription();
|
|
923
|
+
subscriber.add(subs);
|
|
924
|
+
const buffer = [];
|
|
925
|
+
const record = {
|
|
926
|
+
buffer,
|
|
927
|
+
subs
|
|
928
|
+
};
|
|
929
|
+
bufferRecords.push(record);
|
|
930
|
+
subs.add(scheduler.schedule(() => emit(record), bufferTimeSpan));
|
|
931
|
+
}
|
|
932
|
+
};
|
|
933
|
+
|
|
934
|
+
bufferCreationInterval !== null && bufferCreationInterval >= 0 ? subscriber.add(scheduler.schedule(function () {
|
|
935
|
+
startBuffer();
|
|
936
|
+
!this.closed && subscriber.add(this.schedule(null, bufferCreationInterval));
|
|
937
|
+
}, bufferCreationInterval)) : restartOnEmit = true;
|
|
938
|
+
startBuffer();
|
|
939
|
+
const bufferTimeSubscriber = tsplus_module_9.operatorSubscriber(subscriber, {
|
|
940
|
+
next: value => {
|
|
941
|
+
const recordsCopy = bufferRecords.slice();
|
|
942
|
+
|
|
943
|
+
for (const record of recordsCopy) {
|
|
944
|
+
const {
|
|
945
|
+
buffer
|
|
946
|
+
} = record;
|
|
947
|
+
buffer.push(value);
|
|
948
|
+
maxBufferSize <= buffer.length && emit(record);
|
|
949
|
+
}
|
|
950
|
+
},
|
|
951
|
+
complete: () => {
|
|
952
|
+
while (bufferRecords?.length) {
|
|
953
|
+
subscriber.next(bufferRecords.shift().buffer);
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
bufferTimeSubscriber?.unsubscribe();
|
|
957
|
+
subscriber.complete();
|
|
958
|
+
subscriber.unsubscribe();
|
|
959
|
+
}
|
|
960
|
+
}, () => bufferRecords = null);
|
|
961
|
+
source.subscribe(bufferTimeSubscriber);
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
/**
|
|
965
|
+
* @tsplus fluent fncts.observable.Observable bufferToggle
|
|
966
|
+
*/
|
|
967
|
+
|
|
968
|
+
export function bufferToggle_(fa, openings, closingSelector) {
|
|
969
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
970
|
+
const buffers = [];
|
|
971
|
+
from_1(openings).subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
972
|
+
next: openValue => {
|
|
973
|
+
const buffer = [];
|
|
974
|
+
buffers.push(buffer);
|
|
975
|
+
const closingSubscription = new tsplus_module_7.Subscription();
|
|
976
|
+
|
|
977
|
+
const emitBuffer = () => {
|
|
978
|
+
arrayRemove(buffers, buffer);
|
|
979
|
+
subscriber.next(buffer);
|
|
980
|
+
closingSubscription.unsubscribe();
|
|
981
|
+
};
|
|
982
|
+
|
|
983
|
+
closingSubscription.add(from_1(closingSelector(openValue)).subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
984
|
+
next: emitBuffer,
|
|
985
|
+
complete: tsplus_module_3.noop
|
|
986
|
+
})));
|
|
987
|
+
},
|
|
988
|
+
complete: tsplus_module_3.noop
|
|
989
|
+
}));
|
|
990
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
991
|
+
next: value => {
|
|
992
|
+
for (const buffer of buffers) {
|
|
993
|
+
buffer.push(value);
|
|
994
|
+
}
|
|
995
|
+
},
|
|
996
|
+
complete: () => {
|
|
997
|
+
while (buffers.length > 0) {
|
|
998
|
+
subscriber.next(buffers.shift());
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
subscriber.complete();
|
|
1002
|
+
}
|
|
1003
|
+
}));
|
|
1004
|
+
});
|
|
1005
|
+
}
|
|
1006
|
+
/**
|
|
1007
|
+
* @tsplus fluent fncts.observable.Observable bufferWhen
|
|
1008
|
+
*/
|
|
1009
|
+
|
|
1010
|
+
function bufferWhen_1(fa, closingSelector) {
|
|
1011
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
1012
|
+
let buffer = null;
|
|
1013
|
+
let closingSubscriber = null;
|
|
1014
|
+
|
|
1015
|
+
const openBuffer = () => {
|
|
1016
|
+
closingSubscriber?.unsubscribe();
|
|
1017
|
+
const b = buffer;
|
|
1018
|
+
buffer = [];
|
|
1019
|
+
b && subscriber.next(b);
|
|
1020
|
+
from_1(closingSelector()).subscribe(closingSubscriber = tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1021
|
+
next: openBuffer,
|
|
1022
|
+
complete: tsplus_module_3.noop
|
|
1023
|
+
}));
|
|
1024
|
+
};
|
|
1025
|
+
|
|
1026
|
+
openBuffer();
|
|
1027
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1028
|
+
next: value => buffer?.push(value),
|
|
1029
|
+
complete: () => {
|
|
1030
|
+
buffer && subscriber.next(buffer);
|
|
1031
|
+
subscriber.complete();
|
|
1032
|
+
}
|
|
1033
|
+
}, () => buffer = closingSubscriber = null));
|
|
1034
|
+
});
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
export function bufferWhen(closingSelector) {
|
|
1038
|
+
return fa => bufferWhen_1(fa, closingSelector);
|
|
1039
|
+
}
|
|
1040
|
+
/**
|
|
1041
|
+
* @tsplus fluent fncts.observable.Observable catchAllCause
|
|
1042
|
+
*/
|
|
1043
|
+
|
|
1044
|
+
function catchAllCause_1(self, f) {
|
|
1045
|
+
return tsplus_module_9.operate_(self, (source, subscriber) => {
|
|
1046
|
+
let innerSub = null;
|
|
1047
|
+
let syncUnsub = false;
|
|
1048
|
+
let handledResult;
|
|
1049
|
+
innerSub = source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1050
|
+
error: cause => {
|
|
1051
|
+
handledResult = from_1(f(cause, catchAllCause_1(source, f)));
|
|
1052
|
+
|
|
1053
|
+
if (innerSub) {
|
|
1054
|
+
innerSub.unsubscribe();
|
|
1055
|
+
innerSub = null;
|
|
1056
|
+
handledResult.subscribe(subscriber);
|
|
1057
|
+
} else {
|
|
1058
|
+
syncUnsub = true;
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
}));
|
|
1062
|
+
|
|
1063
|
+
if (syncUnsub) {
|
|
1064
|
+
innerSub.unsubscribe();
|
|
1065
|
+
innerSub = null;
|
|
1066
|
+
handledResult.subscribe(subscriber);
|
|
1067
|
+
}
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
/**
|
|
1071
|
+
* @tsplus getter fncts.observable.Observable concatAll
|
|
1072
|
+
*/
|
|
1073
|
+
|
|
1074
|
+
|
|
1075
|
+
function concatAll_1(ffa) {
|
|
1076
|
+
return mergeAll_1(ffa, 1);
|
|
1077
|
+
}
|
|
1078
|
+
/**
|
|
1079
|
+
* @tsplus fluent fncts.observable.Observable concat
|
|
1080
|
+
*/
|
|
1081
|
+
|
|
1082
|
+
|
|
1083
|
+
function concat_1(fa, ...sources) {
|
|
1084
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
1085
|
+
concatAll_1(fromArrayLike([source, ...sources])).subscribe(subscriber);
|
|
1086
|
+
});
|
|
1087
|
+
}
|
|
1088
|
+
/**
|
|
1089
|
+
* @tsplus getter fncts.observable.Observable count
|
|
1090
|
+
*/
|
|
1091
|
+
|
|
1092
|
+
|
|
1093
|
+
export function count(fa) {
|
|
1094
|
+
return foldLeft_1(fa, 0, (total, _) => total + 1);
|
|
1095
|
+
}
|
|
1096
|
+
/**
|
|
1097
|
+
* @tsplus fluent fncts.observable.Observable countWithIndex
|
|
1098
|
+
*/
|
|
1099
|
+
|
|
1100
|
+
function countWithIndex_1(fa, predicate) {
|
|
1101
|
+
return foldLeftWithIndex_1(fa, 0, (i, total, v) => predicate(i, v) ? total + 1 : total);
|
|
1102
|
+
}
|
|
1103
|
+
/**
|
|
1104
|
+
* @tsplus fluent fncts.observable.Observable countWith
|
|
1105
|
+
*/
|
|
1106
|
+
|
|
1107
|
+
|
|
1108
|
+
export function countWith_(fa, predicate) {
|
|
1109
|
+
return countWithIndex_1(fa, (_, a) => predicate(a));
|
|
1110
|
+
}
|
|
1111
|
+
/**
|
|
1112
|
+
* @tsplus getter fncts.observable.Observable combineLatestAll
|
|
1113
|
+
*/
|
|
1114
|
+
|
|
1115
|
+
export function combineLatestAll(fa) {
|
|
1116
|
+
return joinAllInternal(fa, sources => !sources.length ? empty_1() : combineLatest_1(sources[0], ...sources.slice(1)));
|
|
1117
|
+
}
|
|
1118
|
+
/**
|
|
1119
|
+
* @tsplus fluent fncts.observable.Observable combineLatest
|
|
1120
|
+
*/
|
|
1121
|
+
|
|
1122
|
+
function combineLatest_1(self, ...sources) {
|
|
1123
|
+
if (!sources.length) {
|
|
1124
|
+
return from_1(self);
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
return tsplus_module_9.operate_(from_1(self), (source, subscriber) => {
|
|
1128
|
+
combineLatestInternal(subscriber, [source, ...sources]);
|
|
1129
|
+
});
|
|
1130
|
+
}
|
|
1131
|
+
/**
|
|
1132
|
+
* @tsplus fluent fncts.observable.Observable debounceWith
|
|
1133
|
+
*/
|
|
1134
|
+
|
|
1135
|
+
|
|
1136
|
+
export function debounceWith_(fa, durationSelector) {
|
|
1137
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
1138
|
+
let lastValue = tsplus_module_16.nothing();
|
|
1139
|
+
let durationSubscriber = null;
|
|
1140
|
+
|
|
1141
|
+
const emit = () => {
|
|
1142
|
+
durationSubscriber?.unsubscribe();
|
|
1143
|
+
durationSubscriber = null;
|
|
1144
|
+
|
|
1145
|
+
if (tsplus_module_17.isJust(lastValue)) {
|
|
1146
|
+
const {
|
|
1147
|
+
value
|
|
1148
|
+
} = lastValue;
|
|
1149
|
+
lastValue = tsplus_module_16.nothing();
|
|
1150
|
+
subscriber.next(value);
|
|
1151
|
+
}
|
|
1152
|
+
};
|
|
1153
|
+
|
|
1154
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1155
|
+
next: value => {
|
|
1156
|
+
durationSubscriber?.unsubscribe();
|
|
1157
|
+
lastValue = tsplus_module_16.just(value);
|
|
1158
|
+
durationSubscriber = tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1159
|
+
next: emit,
|
|
1160
|
+
complete: tsplus_module_3.noop
|
|
1161
|
+
});
|
|
1162
|
+
from_1(durationSelector(value)).subscribe(durationSubscriber);
|
|
1163
|
+
},
|
|
1164
|
+
complete: () => {
|
|
1165
|
+
emit();
|
|
1166
|
+
subscriber.complete();
|
|
1167
|
+
}
|
|
1168
|
+
}, () => {
|
|
1169
|
+
lastValue = durationSubscriber = null;
|
|
1170
|
+
}));
|
|
1171
|
+
});
|
|
1172
|
+
}
|
|
1173
|
+
/**
|
|
1174
|
+
* @tsplus fluent fncts.observable.Observable debounce
|
|
1175
|
+
*/
|
|
1176
|
+
|
|
1177
|
+
export function debounce_(fa, dueTime, scheduler = tsplus_module_6.asyncScheduler) {
|
|
1178
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
1179
|
+
let activeTask = null;
|
|
1180
|
+
let lastValue = null;
|
|
1181
|
+
let lastTime = null;
|
|
1182
|
+
|
|
1183
|
+
const emit = () => {
|
|
1184
|
+
if (activeTask) {
|
|
1185
|
+
activeTask.unsubscribe();
|
|
1186
|
+
activeTask = null;
|
|
1187
|
+
const value = lastValue;
|
|
1188
|
+
lastValue = null;
|
|
1189
|
+
subscriber.next(value);
|
|
1190
|
+
}
|
|
1191
|
+
};
|
|
1192
|
+
|
|
1193
|
+
function emitWhenIdle() {
|
|
1194
|
+
const targetTime = lastTime + dueTime;
|
|
1195
|
+
const now = scheduler.now();
|
|
1196
|
+
|
|
1197
|
+
if (now < targetTime) {
|
|
1198
|
+
activeTask = this.schedule(undefined, targetTime - now);
|
|
1199
|
+
subscriber.add(activeTask);
|
|
1200
|
+
return;
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
emit();
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1207
|
+
next: value => {
|
|
1208
|
+
lastValue = value;
|
|
1209
|
+
lastTime = scheduler.now();
|
|
1210
|
+
|
|
1211
|
+
if (!activeTask) {
|
|
1212
|
+
activeTask = scheduler.schedule(emitWhenIdle, dueTime);
|
|
1213
|
+
subscriber.add(activeTask);
|
|
1214
|
+
}
|
|
1215
|
+
},
|
|
1216
|
+
complete: () => {
|
|
1217
|
+
emit();
|
|
1218
|
+
subscriber.complete();
|
|
1219
|
+
}
|
|
1220
|
+
}, () => {
|
|
1221
|
+
lastValue = activeTask = null;
|
|
1222
|
+
}));
|
|
1223
|
+
});
|
|
1224
|
+
}
|
|
1225
|
+
/**
|
|
1226
|
+
* @tsplus getter fncts.observable.Observable either
|
|
1227
|
+
*/
|
|
1228
|
+
|
|
1229
|
+
export function either(fa) {
|
|
1230
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
1231
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1232
|
+
next: value => {
|
|
1233
|
+
subscriber.next(tsplus_module_18.right(value));
|
|
1234
|
+
},
|
|
1235
|
+
error: error => {
|
|
1236
|
+
tsplus_module_14.match_(tsplus_module_2.failureOrCause(error), e => subscriber.next(tsplus_module_18.left(e)), cause => subscriber.error(cause));
|
|
1237
|
+
}
|
|
1238
|
+
}));
|
|
1239
|
+
});
|
|
1240
|
+
}
|
|
1241
|
+
/**
|
|
1242
|
+
* @tsplus fluent fncts.observable.Observable delayWithIndex
|
|
1243
|
+
*/
|
|
1244
|
+
|
|
1245
|
+
function delayWithIndex_1(fa, f) {
|
|
1246
|
+
return mergeMapWithIndex_1(fa, (i, a) => as_1(take_1(f(i, a), 1), () => a));
|
|
1247
|
+
}
|
|
1248
|
+
/**
|
|
1249
|
+
* @tsplus fluent fncts.observable.Observable delayWith
|
|
1250
|
+
*/
|
|
1251
|
+
|
|
1252
|
+
|
|
1253
|
+
function delayWith_1(fa, f) {
|
|
1254
|
+
return delayWithIndex_1(fa, (_, a) => f(a));
|
|
1255
|
+
}
|
|
1256
|
+
/**
|
|
1257
|
+
* @tsplus fluent fncts.observable.Observable delay
|
|
1258
|
+
*/
|
|
1259
|
+
|
|
1260
|
+
|
|
1261
|
+
export function delay_(fa, due, scheduler = tsplus_module_6.asyncScheduler) {
|
|
1262
|
+
const duration = timer_1(due, scheduler);
|
|
1263
|
+
return delayWith_1(fa, () => duration);
|
|
1264
|
+
}
|
|
1265
|
+
/**
|
|
1266
|
+
* @tsplus getter fncts.observable.Observable dematerialize
|
|
1267
|
+
*/
|
|
1268
|
+
|
|
1269
|
+
export function dematerialize(fa) {
|
|
1270
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
1271
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1272
|
+
next: notification => tsplus_module_19.observe_(notification, subscriber)
|
|
1273
|
+
}));
|
|
1274
|
+
});
|
|
1275
|
+
}
|
|
1276
|
+
/**
|
|
1277
|
+
* @tsplus fluent fncts.observable.Observable ensuring
|
|
1278
|
+
*/
|
|
1279
|
+
|
|
1280
|
+
export function ensuring_(fa, finalizer) {
|
|
1281
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
1282
|
+
source.subscribe(subscriber);
|
|
1283
|
+
subscriber.add(finalizer);
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1286
|
+
/**
|
|
1287
|
+
* @tsplus getter fncts.observable.Observable exhaustAll
|
|
1288
|
+
*/
|
|
1289
|
+
|
|
1290
|
+
export function exhaustAll(ffa) {
|
|
1291
|
+
return tsplus_module_9.operate_(ffa, (source, subscriber) => {
|
|
1292
|
+
let isComplete = false;
|
|
1293
|
+
let innerSub = null;
|
|
1294
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1295
|
+
next: inner => {
|
|
1296
|
+
if (!innerSub) {
|
|
1297
|
+
innerSub = from_1(inner).subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1298
|
+
complete: () => {
|
|
1299
|
+
innerSub = null;
|
|
1300
|
+
isComplete && subscriber.complete();
|
|
1301
|
+
}
|
|
1302
|
+
}));
|
|
1303
|
+
}
|
|
1304
|
+
},
|
|
1305
|
+
complete: () => {
|
|
1306
|
+
isComplete = true;
|
|
1307
|
+
!innerSub && subscriber.complete();
|
|
1308
|
+
}
|
|
1309
|
+
}));
|
|
1310
|
+
});
|
|
1311
|
+
}
|
|
1312
|
+
/**
|
|
1313
|
+
* @tsplus fluent fncts.observable.Observable exhaustMapWithIndex
|
|
1314
|
+
*/
|
|
1315
|
+
|
|
1316
|
+
function exhaustMapWithIndex_1(self, f) {
|
|
1317
|
+
return tsplus_module_9.operate_(self, (source, subscriber) => {
|
|
1318
|
+
let index = 0;
|
|
1319
|
+
let innerSub = null;
|
|
1320
|
+
let isComplete = false;
|
|
1321
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1322
|
+
next: outerValue => {
|
|
1323
|
+
if (!innerSub) {
|
|
1324
|
+
innerSub = tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1325
|
+
complete: () => {
|
|
1326
|
+
innerSub = null;
|
|
1327
|
+
isComplete && subscriber.complete();
|
|
1328
|
+
}
|
|
1329
|
+
});
|
|
1330
|
+
from_1(f(index++, outerValue)).subscribe(innerSub);
|
|
1331
|
+
}
|
|
1332
|
+
},
|
|
1333
|
+
complete: () => {
|
|
1334
|
+
isComplete = true;
|
|
1335
|
+
!innerSub && subscriber.complete();
|
|
1336
|
+
}
|
|
1337
|
+
}));
|
|
1338
|
+
});
|
|
1339
|
+
}
|
|
1340
|
+
/**
|
|
1341
|
+
* @tsplus fluent fncts.observable.Observable exhaustMap
|
|
1342
|
+
*/
|
|
1343
|
+
|
|
1344
|
+
|
|
1345
|
+
export function exhaustMap_(self, f) {
|
|
1346
|
+
return exhaustMapWithIndex_1(self, (_, a) => f(a));
|
|
1347
|
+
}
|
|
1348
|
+
/**
|
|
1349
|
+
* @tsplus fluent fncts.observable.Observable expandWithIndex
|
|
1350
|
+
*/
|
|
1351
|
+
|
|
1352
|
+
function expandWithIndex_1(fa, f, concurrent = Infinity) {
|
|
1353
|
+
// eslint-disable-next-line no-param-reassign
|
|
1354
|
+
concurrent = (concurrent || 0) < 1 ? Infinity : concurrent;
|
|
1355
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => mergeInternal(source, subscriber, f, concurrent, undefined, true));
|
|
1356
|
+
}
|
|
1357
|
+
/**
|
|
1358
|
+
* @tsplus fluent fncts.observable.Observable expand
|
|
1359
|
+
*/
|
|
1360
|
+
|
|
1361
|
+
|
|
1362
|
+
export function expand_(fa, f, concurrent = Infinity) {
|
|
1363
|
+
return expandWithIndex_1(fa, (_, a) => f(a), concurrent);
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
function findWithIndex_1(fa, predicate) {
|
|
1367
|
+
return tsplus_module_9.operate_(fa, findInternal(predicate, "value"));
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
export function find_(fa, predicate) {
|
|
1371
|
+
return findWithIndex_1(fa, (_, a) => predicate(a));
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
function findIndexWithIndex_1(fa, predicate) {
|
|
1375
|
+
return tsplus_module_9.operate_(fa, findInternal(predicate, "index"));
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
export function findIndex_(fa, predicate) {
|
|
1379
|
+
return findIndexWithIndex_1(fa, (_, a) => predicate(a));
|
|
1380
|
+
}
|
|
1381
|
+
export function forkJoin(...args) {
|
|
1382
|
+
const {
|
|
1383
|
+
args: sources,
|
|
1384
|
+
keys
|
|
1385
|
+
} = arrayOrObject(args);
|
|
1386
|
+
return new tsplus_module_1.Observable(s => {
|
|
1387
|
+
const length = sources.length;
|
|
1388
|
+
|
|
1389
|
+
if (!length) {
|
|
1390
|
+
s.complete();
|
|
1391
|
+
return;
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
const values = new Array(length);
|
|
1395
|
+
let remainingCompletions = length;
|
|
1396
|
+
let remainingEmissions = length;
|
|
1397
|
+
|
|
1398
|
+
for (let sourceIndex = 0; sourceIndex < length; sourceIndex++) {
|
|
1399
|
+
let hasValue = false;
|
|
1400
|
+
from_1(sources[sourceIndex]).subscribe(tsplus_module_9.operatorSubscriber(s, {
|
|
1401
|
+
next: value => {
|
|
1402
|
+
if (!hasValue) {
|
|
1403
|
+
hasValue = true;
|
|
1404
|
+
remainingEmissions--;
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
values[sourceIndex] = value;
|
|
1408
|
+
},
|
|
1409
|
+
complete: () => {
|
|
1410
|
+
if (! --remainingCompletions || !hasValue) {
|
|
1411
|
+
if (!remainingEmissions) {
|
|
1412
|
+
s.next(keys ? keys.reduce((b, k, i) => {
|
|
1413
|
+
b[k] = values[i];
|
|
1414
|
+
return b;
|
|
1415
|
+
}, {}) : values);
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
s.complete();
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
}));
|
|
1422
|
+
}
|
|
1423
|
+
});
|
|
1424
|
+
}
|
|
1425
|
+
/**
|
|
1426
|
+
* @tsplus getter fncts.observable.Observable ignore
|
|
1427
|
+
*/
|
|
1428
|
+
|
|
1429
|
+
export function ignore(fa) {
|
|
1430
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
1431
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1432
|
+
next: tsplus_module_3.noop
|
|
1433
|
+
}));
|
|
1434
|
+
});
|
|
1435
|
+
}
|
|
1436
|
+
/**
|
|
1437
|
+
* @tsplus getter fncts.observable.Observable isEmpty
|
|
1438
|
+
*/
|
|
1439
|
+
|
|
1440
|
+
export function isEmpty(fa) {
|
|
1441
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
1442
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1443
|
+
next: () => {
|
|
1444
|
+
subscriber.next(false);
|
|
1445
|
+
subscriber.complete();
|
|
1446
|
+
},
|
|
1447
|
+
complete: () => {
|
|
1448
|
+
subscriber.next(true);
|
|
1449
|
+
subscriber.complete();
|
|
1450
|
+
}
|
|
1451
|
+
}));
|
|
1452
|
+
});
|
|
1453
|
+
}
|
|
1454
|
+
/**
|
|
1455
|
+
* @tsplus getter fncts.observable.Observable materialize
|
|
1456
|
+
*/
|
|
1457
|
+
|
|
1458
|
+
export function materialize(fa) {
|
|
1459
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
1460
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1461
|
+
next: value => {
|
|
1462
|
+
subscriber.next(tsplus_module_19.next(value));
|
|
1463
|
+
},
|
|
1464
|
+
error: error => {
|
|
1465
|
+
subscriber.next(tsplus_module_19.error(error));
|
|
1466
|
+
},
|
|
1467
|
+
complete: () => {
|
|
1468
|
+
subscriber.next(tsplus_module_19.complete());
|
|
1469
|
+
}
|
|
1470
|
+
}));
|
|
1471
|
+
});
|
|
1472
|
+
}
|
|
1473
|
+
/**
|
|
1474
|
+
* @tsplus fluent fncts.observable.Observable mergeAll
|
|
1475
|
+
*/
|
|
1476
|
+
|
|
1477
|
+
function mergeAll_1(self, concurrent = Infinity) {
|
|
1478
|
+
return mergeMap_1(self, tsplus_module_13.identity, concurrent);
|
|
1479
|
+
}
|
|
1480
|
+
/**
|
|
1481
|
+
* @tsplus fluent fncts.observable.Observable mergeScanWithIndex
|
|
1482
|
+
*/
|
|
1483
|
+
|
|
1484
|
+
|
|
1485
|
+
function mergeScanWithIndex_1(fa, initial, f, concurrent = Infinity) {
|
|
1486
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
1487
|
+
let state = initial;
|
|
1488
|
+
return mergeInternal(source, subscriber, (index, value) => f(index, state, value), concurrent, value => {
|
|
1489
|
+
state = value;
|
|
1490
|
+
}, false, undefined, () => state = null);
|
|
1491
|
+
});
|
|
1492
|
+
}
|
|
1493
|
+
/**
|
|
1494
|
+
* @tsplus fluent fncts.observable.Observable mergeScan
|
|
1495
|
+
*/
|
|
1496
|
+
|
|
1497
|
+
|
|
1498
|
+
export function mergeScan_(fa, initial, f, concurrent = Infinity) {
|
|
1499
|
+
return mergeScanWithIndex_1(fa, initial, (_, b, a) => f(b, a), concurrent);
|
|
1500
|
+
}
|
|
1501
|
+
export function onErrorResumeNext(fa, ...sources) {
|
|
1502
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
1503
|
+
const remaining = [source, ...sources];
|
|
1504
|
+
|
|
1505
|
+
const subscribeNext = () => {
|
|
1506
|
+
if (!subscriber.closed) {
|
|
1507
|
+
if (remaining.length > 0) {
|
|
1508
|
+
let nextSource;
|
|
1509
|
+
|
|
1510
|
+
try {
|
|
1511
|
+
nextSource = from_1(remaining.shift());
|
|
1512
|
+
} catch (err) {
|
|
1513
|
+
subscribeNext();
|
|
1514
|
+
return;
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
const innerSub = tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1518
|
+
error: tsplus_module_3.noop,
|
|
1519
|
+
complete: tsplus_module_3.noop
|
|
1520
|
+
});
|
|
1521
|
+
subscriber.add(nextSource.subscribe(innerSub));
|
|
1522
|
+
innerSub.add(subscribeNext);
|
|
1523
|
+
} else {
|
|
1524
|
+
subscriber.complete();
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
};
|
|
1528
|
+
|
|
1529
|
+
subscribeNext();
|
|
1530
|
+
});
|
|
1531
|
+
}
|
|
1532
|
+
/**
|
|
1533
|
+
* @tsplus fluent fncts.observable.Observable onEmpty
|
|
1534
|
+
*/
|
|
1535
|
+
|
|
1536
|
+
function onEmpty_1(fa, f) {
|
|
1537
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
1538
|
+
let hasValue = false;
|
|
1539
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1540
|
+
next: value => {
|
|
1541
|
+
hasValue = true;
|
|
1542
|
+
subscriber.next(value);
|
|
1543
|
+
},
|
|
1544
|
+
complete: () => {
|
|
1545
|
+
if (!hasValue) {
|
|
1546
|
+
subscriber.next(f());
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
subscriber.complete();
|
|
1550
|
+
}
|
|
1551
|
+
}));
|
|
1552
|
+
});
|
|
1553
|
+
}
|
|
1554
|
+
/**
|
|
1555
|
+
* @tsplus fluent fncts.observable.Observable repeat
|
|
1556
|
+
*/
|
|
1557
|
+
|
|
1558
|
+
|
|
1559
|
+
export function repeat_(fa, count = Infinity) {
|
|
1560
|
+
return count <= 0 ? empty_1() : tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
1561
|
+
let repeats = 0;
|
|
1562
|
+
let innerSub;
|
|
1563
|
+
|
|
1564
|
+
const loop = () => {
|
|
1565
|
+
let syncUnsub = false;
|
|
1566
|
+
innerSub = source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1567
|
+
complete: () => {
|
|
1568
|
+
if (++repeats < count) {
|
|
1569
|
+
if (innerSub) {
|
|
1570
|
+
innerSub.unsubscribe();
|
|
1571
|
+
innerSub = null;
|
|
1572
|
+
loop();
|
|
1573
|
+
} else {
|
|
1574
|
+
syncUnsub = true;
|
|
1575
|
+
}
|
|
1576
|
+
} else {
|
|
1577
|
+
subscriber.complete;
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
}));
|
|
1581
|
+
|
|
1582
|
+
if (syncUnsub) {
|
|
1583
|
+
innerSub.unsubscribe();
|
|
1584
|
+
innerSub = null;
|
|
1585
|
+
loop();
|
|
1586
|
+
}
|
|
1587
|
+
};
|
|
1588
|
+
|
|
1589
|
+
loop();
|
|
1590
|
+
});
|
|
1591
|
+
}
|
|
1592
|
+
export function retry_(fa, configOrCount = Infinity) {
|
|
1593
|
+
let config;
|
|
1594
|
+
|
|
1595
|
+
if (configOrCount && typeof configOrCount === "object") {
|
|
1596
|
+
config = configOrCount;
|
|
1597
|
+
} else {
|
|
1598
|
+
config = {
|
|
1599
|
+
count: configOrCount
|
|
1600
|
+
};
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
const {
|
|
1604
|
+
count,
|
|
1605
|
+
resetOnSuccess = false
|
|
1606
|
+
} = config;
|
|
1607
|
+
return count <= 0 ? fa : tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
1608
|
+
let retries = 0;
|
|
1609
|
+
let innerSub;
|
|
1610
|
+
|
|
1611
|
+
const loop = () => {
|
|
1612
|
+
let syncUnsub = false;
|
|
1613
|
+
innerSub = source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1614
|
+
next: value => {
|
|
1615
|
+
if (resetOnSuccess) {
|
|
1616
|
+
retries = 0;
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1619
|
+
subscriber.next(value);
|
|
1620
|
+
},
|
|
1621
|
+
error: err => {
|
|
1622
|
+
if (retries++ < count) {
|
|
1623
|
+
if (innerSub) {
|
|
1624
|
+
innerSub.unsubscribe();
|
|
1625
|
+
innerSub = null;
|
|
1626
|
+
loop();
|
|
1627
|
+
} else {
|
|
1628
|
+
syncUnsub = true;
|
|
1629
|
+
}
|
|
1630
|
+
} else {
|
|
1631
|
+
subscriber.error(err);
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
}));
|
|
1635
|
+
|
|
1636
|
+
if (syncUnsub) {
|
|
1637
|
+
innerSub.unsubscribe();
|
|
1638
|
+
innerSub = null;
|
|
1639
|
+
loop();
|
|
1640
|
+
}
|
|
1641
|
+
};
|
|
1642
|
+
|
|
1643
|
+
loop();
|
|
1644
|
+
});
|
|
1645
|
+
}
|
|
1646
|
+
/**
|
|
1647
|
+
* @tsplus fluent fncts.observable.Observable sample
|
|
1648
|
+
*/
|
|
1649
|
+
|
|
1650
|
+
function sample_1(fa, notifier) {
|
|
1651
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
1652
|
+
let hasValue = false;
|
|
1653
|
+
let lastValue = null;
|
|
1654
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1655
|
+
next: value => {
|
|
1656
|
+
hasValue = true;
|
|
1657
|
+
lastValue = value;
|
|
1658
|
+
}
|
|
1659
|
+
}));
|
|
1660
|
+
|
|
1661
|
+
const emit = () => {
|
|
1662
|
+
if (hasValue) {
|
|
1663
|
+
hasValue = false;
|
|
1664
|
+
const value = lastValue;
|
|
1665
|
+
lastValue = null;
|
|
1666
|
+
subscriber.next(value);
|
|
1667
|
+
}
|
|
1668
|
+
};
|
|
1669
|
+
|
|
1670
|
+
notifier.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1671
|
+
next: emit,
|
|
1672
|
+
complete: tsplus_module_3.noop
|
|
1673
|
+
}));
|
|
1674
|
+
});
|
|
1675
|
+
}
|
|
1676
|
+
/**
|
|
1677
|
+
* @tsplus fluent fncts.observable.Observable sampleTime
|
|
1678
|
+
*/
|
|
1679
|
+
|
|
1680
|
+
|
|
1681
|
+
export function sampleTime_(fa, period, scheduler = tsplus_module_6.asyncScheduler) {
|
|
1682
|
+
return sample_1(fa, interval_1(period, scheduler));
|
|
1683
|
+
}
|
|
1684
|
+
/**
|
|
1685
|
+
* @tsplus fluent fncts.observable.Observable scanLeftWithIndex
|
|
1686
|
+
*/
|
|
1687
|
+
|
|
1688
|
+
function scanLeftWithIndex_1(fa, initial, f) {
|
|
1689
|
+
return tsplus_module_9.operate_(fa, scanInternal(f, initial, true, true));
|
|
1690
|
+
}
|
|
1691
|
+
/**
|
|
1692
|
+
* @tsplus fluent fncts.observable.Observable scanLeft
|
|
1693
|
+
*/
|
|
1694
|
+
|
|
1695
|
+
|
|
1696
|
+
export function scanLeft(fa, initial, f) {
|
|
1697
|
+
return scanLeftWithIndex_1(fa, initial, (_, b, a) => f(b, a));
|
|
1698
|
+
}
|
|
1699
|
+
/**
|
|
1700
|
+
* @tsplus fluent fncts.observable.Observable skip
|
|
1701
|
+
*/
|
|
1702
|
+
|
|
1703
|
+
export function skip_(fa, count) {
|
|
1704
|
+
return filterWithIndex_1(fa, (index, _) => count <= index);
|
|
1705
|
+
}
|
|
1706
|
+
/**
|
|
1707
|
+
* @tsplus fluent fncts.observable.Observable skipLast
|
|
1708
|
+
*/
|
|
1709
|
+
|
|
1710
|
+
export function skipLast_(fa, skipCount) {
|
|
1711
|
+
return skipCount <= 0 ? fa : tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
1712
|
+
let ring = new Array(skipCount);
|
|
1713
|
+
let seen = 0;
|
|
1714
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1715
|
+
next: value => {
|
|
1716
|
+
const valueIndex = seen++;
|
|
1717
|
+
|
|
1718
|
+
if (valueIndex < skipCount) {
|
|
1719
|
+
ring[valueIndex] = value;
|
|
1720
|
+
} else {
|
|
1721
|
+
const index = valueIndex % skipCount;
|
|
1722
|
+
const oldValue = ring[index];
|
|
1723
|
+
ring[index] = value;
|
|
1724
|
+
subscriber.next(oldValue);
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
}));
|
|
1728
|
+
return () => {
|
|
1729
|
+
ring = null;
|
|
1730
|
+
};
|
|
1731
|
+
});
|
|
1732
|
+
}
|
|
1733
|
+
/**
|
|
1734
|
+
* @tsplus fluent fncts.observable.Observable skipUntil
|
|
1735
|
+
*/
|
|
1736
|
+
|
|
1737
|
+
export function skipUntil_(fa, notifier) {
|
|
1738
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
1739
|
+
let taking = false;
|
|
1740
|
+
const skipSubscriber = tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1741
|
+
next: () => {
|
|
1742
|
+
skipSubscriber?.unsubscribe();
|
|
1743
|
+
taking = true;
|
|
1744
|
+
},
|
|
1745
|
+
complete: tsplus_module_3.noop
|
|
1746
|
+
});
|
|
1747
|
+
from_1(notifier).subscribe(skipSubscriber);
|
|
1748
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1749
|
+
next: value => taking && subscriber.next(value)
|
|
1750
|
+
}));
|
|
1751
|
+
});
|
|
1752
|
+
}
|
|
1753
|
+
/**
|
|
1754
|
+
* @tsplus fluent fncts.observable.Observable skipWhile
|
|
1755
|
+
*/
|
|
1756
|
+
|
|
1757
|
+
export function skipWhile_(fa, predicate) {
|
|
1758
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
1759
|
+
let taking = false;
|
|
1760
|
+
let index = 0;
|
|
1761
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1762
|
+
next: value => (taking || (taking = !predicate(index++, value))) && subscriber.next(value)
|
|
1763
|
+
}));
|
|
1764
|
+
});
|
|
1765
|
+
}
|
|
1766
|
+
/**
|
|
1767
|
+
* @tsplus fluent fncts.observable.Observable startWith
|
|
1768
|
+
*/
|
|
1769
|
+
|
|
1770
|
+
export function startWith_(fa, ...values) {
|
|
1771
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
1772
|
+
// @ts-expect-error
|
|
1773
|
+
concat_1(source, values).subscribe(subscriber);
|
|
1774
|
+
});
|
|
1775
|
+
}
|
|
1776
|
+
/**
|
|
1777
|
+
* @tsplus fluent fncts.observable.Observable subscribeOn
|
|
1778
|
+
*/
|
|
1779
|
+
|
|
1780
|
+
export function subscribeOn_(fa, scheduler, delay = 0) {
|
|
1781
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
1782
|
+
subscriber.add(scheduler.schedule(() => source.subscribe(subscriber), delay));
|
|
1783
|
+
});
|
|
1784
|
+
}
|
|
1785
|
+
/**
|
|
1786
|
+
* @tsplus getter fncts.observable.Observable switchAll
|
|
1787
|
+
*/
|
|
1788
|
+
|
|
1789
|
+
export function switchAll(ffa) {
|
|
1790
|
+
return switchMap_1(ffa, tsplus_module_13.identity);
|
|
1791
|
+
}
|
|
1792
|
+
/**
|
|
1793
|
+
* @tsplus fluent fncts.observable.Observable switchMapWithIndex
|
|
1794
|
+
*/
|
|
1795
|
+
|
|
1796
|
+
function switchMapWithIndex_1(fa, f) {
|
|
1797
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
1798
|
+
let innerSubscriber = null;
|
|
1799
|
+
let index = 0;
|
|
1800
|
+
let isComplete = false;
|
|
1801
|
+
|
|
1802
|
+
const checkComplete = () => isComplete && !innerSubscriber && subscriber.complete();
|
|
1803
|
+
|
|
1804
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1805
|
+
next: value => {
|
|
1806
|
+
innerSubscriber?.unsubscribe();
|
|
1807
|
+
const outerIndex = index++;
|
|
1808
|
+
from_1(f(outerIndex, value)).subscribe(innerSubscriber = tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1809
|
+
next: innerValue => subscriber.next(innerValue),
|
|
1810
|
+
complete: () => {
|
|
1811
|
+
innerSubscriber = null;
|
|
1812
|
+
checkComplete();
|
|
1813
|
+
}
|
|
1814
|
+
}));
|
|
1815
|
+
}
|
|
1816
|
+
}, () => {
|
|
1817
|
+
isComplete = true;
|
|
1818
|
+
checkComplete();
|
|
1819
|
+
}));
|
|
1820
|
+
});
|
|
1821
|
+
}
|
|
1822
|
+
/**
|
|
1823
|
+
* @tsplus fluent fncts.observable.Observable switchMap
|
|
1824
|
+
*/
|
|
1825
|
+
|
|
1826
|
+
|
|
1827
|
+
function switchMap_1(fa, f) {
|
|
1828
|
+
return switchMapWithIndex_1(fa, (_, a) => f(a));
|
|
1829
|
+
}
|
|
1830
|
+
/**
|
|
1831
|
+
* @tsplus fluent fncts.observable.Observable switchScanWithIndex
|
|
1832
|
+
*/
|
|
1833
|
+
|
|
1834
|
+
|
|
1835
|
+
function switchScanWithIndex_1(fa, initial, f) {
|
|
1836
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
1837
|
+
let state = initial;
|
|
1838
|
+
switchMapWithIndex_1(source, (index, value) => map_1(from_1(f(index, state, value)), b => (state = b, b))).subscribe(subscriber);
|
|
1839
|
+
return () => {
|
|
1840
|
+
state = null;
|
|
1841
|
+
};
|
|
1842
|
+
});
|
|
1843
|
+
}
|
|
1844
|
+
/**
|
|
1845
|
+
* @tsplus fluent fncts.observable.Observable switchScan
|
|
1846
|
+
*/
|
|
1847
|
+
|
|
1848
|
+
|
|
1849
|
+
export function switchScan_(fa, initial, f) {
|
|
1850
|
+
return switchScanWithIndex_1(fa, initial, (_, b, a) => f(b, a));
|
|
1851
|
+
}
|
|
1852
|
+
/**
|
|
1853
|
+
* @tsplus fluent fncts.observable.Observable take
|
|
1854
|
+
*/
|
|
1855
|
+
|
|
1856
|
+
function take_1(fa, count) {
|
|
1857
|
+
return count <= 0 ? empty_1() : tsplus_module_9.operate_(fa, (source, sub) => {
|
|
1858
|
+
let seen = 0;
|
|
1859
|
+
source.subscribe(new tsplus_module_9.OperatorSubscriber(sub, {
|
|
1860
|
+
next: value => {
|
|
1861
|
+
if (++seen <= count) {
|
|
1862
|
+
sub.next(value);
|
|
1863
|
+
|
|
1864
|
+
if (count <= seen) {
|
|
1865
|
+
sub.complete();
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
}));
|
|
1870
|
+
});
|
|
1871
|
+
}
|
|
1872
|
+
/**
|
|
1873
|
+
* @tsplus fluent fncts.observable.Observable takeLast
|
|
1874
|
+
*/
|
|
1875
|
+
|
|
1876
|
+
|
|
1877
|
+
export function takeLast_(fa, count) {
|
|
1878
|
+
return count <= 0 ? empty_1() : tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
1879
|
+
let buffer = [];
|
|
1880
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1881
|
+
next: value => {
|
|
1882
|
+
buffer.push(value);
|
|
1883
|
+
count < buffer.length && buffer.shift();
|
|
1884
|
+
},
|
|
1885
|
+
complete: () => {
|
|
1886
|
+
for (const value of buffer) {
|
|
1887
|
+
subscriber.next(value);
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1890
|
+
subscriber.complete();
|
|
1891
|
+
}
|
|
1892
|
+
}, () => {
|
|
1893
|
+
buffer = null;
|
|
1894
|
+
}));
|
|
1895
|
+
});
|
|
1896
|
+
}
|
|
1897
|
+
/**
|
|
1898
|
+
* @tsplus fluent fncts.observable.Observable takeUntil
|
|
1899
|
+
*/
|
|
1900
|
+
|
|
1901
|
+
export function takeUntil_(fa, notifier) {
|
|
1902
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
1903
|
+
from_1(notifier).subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1904
|
+
next: () => subscriber.complete(),
|
|
1905
|
+
complete: tsplus_module_3.noop
|
|
1906
|
+
}));
|
|
1907
|
+
!subscriber.closed && source.subscribe(subscriber);
|
|
1908
|
+
});
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1911
|
+
function takeWhileWithIndex_1(fa, predicate, inclusive) {
|
|
1912
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
1913
|
+
let index = 0;
|
|
1914
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1915
|
+
next: value => {
|
|
1916
|
+
const result = predicate(index++, value);
|
|
1917
|
+
(result || inclusive) && subscriber.next(value);
|
|
1918
|
+
!result && subscriber.complete();
|
|
1919
|
+
}
|
|
1920
|
+
}));
|
|
1921
|
+
});
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
export function takeWhile_(fa, predicate, inclusive) {
|
|
1925
|
+
return takeWhileWithIndex_1(fa, (_, a) => predicate(a), inclusive);
|
|
1926
|
+
}
|
|
1927
|
+
/**
|
|
1928
|
+
* @tsplus fluent fncts.observable.Observable tap
|
|
1929
|
+
*/
|
|
1930
|
+
|
|
1931
|
+
export function tap_(fa, observer) {
|
|
1932
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
1933
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1934
|
+
next: value => {
|
|
1935
|
+
observer.next?.(value);
|
|
1936
|
+
subscriber.next(value);
|
|
1937
|
+
},
|
|
1938
|
+
error: err => {
|
|
1939
|
+
observer.error?.(err);
|
|
1940
|
+
subscriber.error(err);
|
|
1941
|
+
},
|
|
1942
|
+
complete: () => {
|
|
1943
|
+
observer.complete?.();
|
|
1944
|
+
subscriber.complete();
|
|
1945
|
+
}
|
|
1946
|
+
}));
|
|
1947
|
+
});
|
|
1948
|
+
}
|
|
1949
|
+
export const defaultThrottleConfig = {
|
|
1950
|
+
leading: true,
|
|
1951
|
+
trailing: false
|
|
1952
|
+
};
|
|
1953
|
+
/**
|
|
1954
|
+
* @tsplus fluent fncts.observable.Observable throttle
|
|
1955
|
+
*/
|
|
1956
|
+
|
|
1957
|
+
function throttle_1(fa, durationSelector, {
|
|
1958
|
+
leading,
|
|
1959
|
+
trailing
|
|
1960
|
+
} = defaultThrottleConfig) {
|
|
1961
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
1962
|
+
let sendValue = tsplus_module_16.nothing();
|
|
1963
|
+
let throttled = null;
|
|
1964
|
+
let isComplete = false;
|
|
1965
|
+
|
|
1966
|
+
const endThrottling = () => {
|
|
1967
|
+
throttled?.unsubscribe();
|
|
1968
|
+
throttled = null;
|
|
1969
|
+
|
|
1970
|
+
if (trailing) {
|
|
1971
|
+
send();
|
|
1972
|
+
isComplete && subscriber.complete();
|
|
1973
|
+
}
|
|
1974
|
+
};
|
|
1975
|
+
|
|
1976
|
+
const cleanupThrottling = () => {
|
|
1977
|
+
throttled = null;
|
|
1978
|
+
isComplete && subscriber.complete();
|
|
1979
|
+
};
|
|
1980
|
+
|
|
1981
|
+
const startThrottling = value => throttled = from_1(durationSelector(value)).subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1982
|
+
next: endThrottling,
|
|
1983
|
+
complete: cleanupThrottling
|
|
1984
|
+
}));
|
|
1985
|
+
|
|
1986
|
+
const send = () => {
|
|
1987
|
+
if (tsplus_module_17.isJust(sendValue)) {
|
|
1988
|
+
const {
|
|
1989
|
+
value
|
|
1990
|
+
} = sendValue;
|
|
1991
|
+
sendValue = tsplus_module_16.nothing();
|
|
1992
|
+
subscriber.next(value);
|
|
1993
|
+
!isComplete && startThrottling(value);
|
|
1994
|
+
}
|
|
1995
|
+
};
|
|
1996
|
+
|
|
1997
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
1998
|
+
next: value => {
|
|
1999
|
+
sendValue = tsplus_module_16.just(value);
|
|
2000
|
+
!(throttled && !throttled.closed) && (leading ? send() : startThrottling(value));
|
|
2001
|
+
},
|
|
2002
|
+
complete: () => {
|
|
2003
|
+
isComplete = true;
|
|
2004
|
+
!(trailing && tsplus_module_17.isJust(sendValue) && throttled && !throttled.closed) && subscriber.complete();
|
|
2005
|
+
}
|
|
2006
|
+
}));
|
|
2007
|
+
});
|
|
2008
|
+
}
|
|
2009
|
+
/**
|
|
2010
|
+
* @tsplus fluent fncts.observable.Observable throttleTime
|
|
2011
|
+
*/
|
|
2012
|
+
|
|
2013
|
+
|
|
2014
|
+
export function throttleTime_(fa, duration, scheduler = tsplus_module_6.asyncScheduler, config = defaultThrottleConfig) {
|
|
2015
|
+
const duration$ = timer_1(duration, scheduler);
|
|
2016
|
+
return throttle_1(fa, () => duration$, config);
|
|
2017
|
+
}
|
|
2018
|
+
export class TimeoutError extends Error {
|
|
2019
|
+
constructor(info) {
|
|
2020
|
+
super("Timeout has occurred");
|
|
2021
|
+
this.info = info;
|
|
2022
|
+
this.name = "TimeoutError";
|
|
2023
|
+
}
|
|
2024
|
+
|
|
2025
|
+
}
|
|
2026
|
+
export function timeout_(fa, config) {
|
|
2027
|
+
const {
|
|
2028
|
+
first,
|
|
2029
|
+
each,
|
|
2030
|
+
with: _with = timeoutError,
|
|
2031
|
+
scheduler = tsplus_module_6.asyncScheduler,
|
|
2032
|
+
meta = null
|
|
2033
|
+
} = config;
|
|
2034
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
2035
|
+
// eslint-disable-next-line prefer-const
|
|
2036
|
+
let originalSourceSubscription;
|
|
2037
|
+
let timerSubscription;
|
|
2038
|
+
let lastValue = tsplus_module_16.nothing();
|
|
2039
|
+
let seen = 0;
|
|
2040
|
+
|
|
2041
|
+
const startTimer = delay => {
|
|
2042
|
+
timerSubscription = caughtSchedule(subscriber, scheduler, () => {
|
|
2043
|
+
originalSourceSubscription.unsubscribe();
|
|
2044
|
+
from_1(_with({
|
|
2045
|
+
meta,
|
|
2046
|
+
lastValue,
|
|
2047
|
+
seen
|
|
2048
|
+
})).subscribe(subscriber);
|
|
2049
|
+
}, delay);
|
|
2050
|
+
};
|
|
2051
|
+
|
|
2052
|
+
originalSourceSubscription = source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
2053
|
+
next: value => {
|
|
2054
|
+
timerSubscription?.unsubscribe();
|
|
2055
|
+
seen++;
|
|
2056
|
+
lastValue = tsplus_module_16.just(value);
|
|
2057
|
+
subscriber.next(value);
|
|
2058
|
+
each > 0 && startTimer(each);
|
|
2059
|
+
}
|
|
2060
|
+
}, () => {
|
|
2061
|
+
if (!timerSubscription?.closed) {
|
|
2062
|
+
timerSubscription?.unsubscribe();
|
|
2063
|
+
}
|
|
2064
|
+
|
|
2065
|
+
lastValue = tsplus_module_16.nothing();
|
|
2066
|
+
}));
|
|
2067
|
+
startTimer(first != null ? typeof first === "number" ? first : +first - scheduler.now() : each);
|
|
2068
|
+
});
|
|
2069
|
+
}
|
|
2070
|
+
|
|
2071
|
+
function timeoutError(info) {
|
|
2072
|
+
return fail_1(new TimeoutError(info));
|
|
2073
|
+
}
|
|
2074
|
+
|
|
2075
|
+
function toArrayAccumulator(arr, value) {
|
|
2076
|
+
return arr.push(value), arr;
|
|
2077
|
+
}
|
|
2078
|
+
/**
|
|
2079
|
+
* @tsplus getter fncts.observable.Observable toArray
|
|
2080
|
+
*/
|
|
2081
|
+
|
|
2082
|
+
|
|
2083
|
+
function toArray_1(fa) {
|
|
2084
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
2085
|
+
foldLeft_1(source, [], toArrayAccumulator).subscribe(subscriber);
|
|
2086
|
+
});
|
|
2087
|
+
}
|
|
2088
|
+
/**
|
|
2089
|
+
* @tsplus fluent fncts.observable.Observable unique
|
|
2090
|
+
*/
|
|
2091
|
+
|
|
2092
|
+
|
|
2093
|
+
export function unique_(fa, toKey, flushes) {
|
|
2094
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
2095
|
+
let distinctKeys = tsplus_module_20.makeDefault();
|
|
2096
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
2097
|
+
next: value => {
|
|
2098
|
+
const key = toKey ? toKey(value) : value;
|
|
2099
|
+
|
|
2100
|
+
if (!tsplus_module_20.has_(distinctKeys, key)) {
|
|
2101
|
+
tsplus_module_20.add_(distinctKeys, key);
|
|
2102
|
+
subscriber.next(value);
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
}));
|
|
2106
|
+
flushes?.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
2107
|
+
next: () => distinctKeys = tsplus_module_20.makeDefault(),
|
|
2108
|
+
complete: tsplus_module_3.noop
|
|
2109
|
+
}));
|
|
2110
|
+
});
|
|
2111
|
+
}
|
|
2112
|
+
|
|
2113
|
+
function uniqueUntilChanged_1(fa, E, keySelector = tsplus_module_13.identity) {
|
|
2114
|
+
const compare = "equals" in E ? E.equals : E;
|
|
2115
|
+
return tsplus_module_9.operate_(fa, (source, subscriber) => {
|
|
2116
|
+
let previousKey;
|
|
2117
|
+
let first = true;
|
|
2118
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
2119
|
+
next: value => {
|
|
2120
|
+
const currentKey = keySelector(value);
|
|
2121
|
+
|
|
2122
|
+
if (first || !compare(previousKey, currentKey)) {
|
|
2123
|
+
first = false;
|
|
2124
|
+
previousKey = currentKey;
|
|
2125
|
+
subscriber.next(value);
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
}));
|
|
2129
|
+
});
|
|
2130
|
+
}
|
|
2131
|
+
|
|
2132
|
+
export function uniqueUntilKeyChanged_(fa, key, equals) {
|
|
2133
|
+
const compare = "equals" in equals ? equals.equals : equals;
|
|
2134
|
+
return uniqueUntilChanged_1(fa, (x, y) => compare(x[key], y[key]));
|
|
2135
|
+
}
|
|
2136
|
+
/*
|
|
2137
|
+
* -------------------------------------------------------------------------------------------------
|
|
2138
|
+
* internal
|
|
2139
|
+
* -------------------------------------------------------------------------------------------------
|
|
2140
|
+
*/
|
|
2141
|
+
|
|
2142
|
+
function combineLatestInternal(subscriber, observables, scheduler, valueTransform = tsplus_module_13.identity) {
|
|
2143
|
+
return maybeSchedule(subscriber, scheduler, () => {
|
|
2144
|
+
const {
|
|
2145
|
+
length
|
|
2146
|
+
} = observables;
|
|
2147
|
+
const values = new Array(length);
|
|
2148
|
+
let active = length;
|
|
2149
|
+
let remainingFirstValues = length;
|
|
2150
|
+
|
|
2151
|
+
for (let i = 0; i < length; i++) {
|
|
2152
|
+
maybeSchedule(subscriber, scheduler, () => {
|
|
2153
|
+
const source = scheduler ? scheduled_1(observables[i], scheduler) : from_1(observables[i]);
|
|
2154
|
+
let hasFirstValue = false;
|
|
2155
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
2156
|
+
next: value => {
|
|
2157
|
+
values[i] = value;
|
|
2158
|
+
|
|
2159
|
+
if (!hasFirstValue) {
|
|
2160
|
+
hasFirstValue = true;
|
|
2161
|
+
remainingFirstValues--;
|
|
2162
|
+
}
|
|
2163
|
+
|
|
2164
|
+
if (!remainingFirstValues) {
|
|
2165
|
+
subscriber.next(valueTransform(values.slice()));
|
|
2166
|
+
}
|
|
2167
|
+
},
|
|
2168
|
+
complete: () => {
|
|
2169
|
+
if (! --active) {
|
|
2170
|
+
subscriber.complete();
|
|
2171
|
+
}
|
|
2172
|
+
}
|
|
2173
|
+
}));
|
|
2174
|
+
});
|
|
2175
|
+
}
|
|
2176
|
+
});
|
|
2177
|
+
}
|
|
2178
|
+
|
|
2179
|
+
function findInternal(predicate, emit) {
|
|
2180
|
+
const findIndex = emit === "index";
|
|
2181
|
+
return (source, subscriber) => {
|
|
2182
|
+
let index = 0;
|
|
2183
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
2184
|
+
next: value => {
|
|
2185
|
+
const i = index++;
|
|
2186
|
+
|
|
2187
|
+
if (predicate(index++, value)) {
|
|
2188
|
+
subscriber.next(findIndex ? i : tsplus_module_16.just(value));
|
|
2189
|
+
subscriber.complete();
|
|
2190
|
+
}
|
|
2191
|
+
},
|
|
2192
|
+
complete: () => {
|
|
2193
|
+
subscriber.next(findIndex ? -1 : tsplus_module_16.nothing());
|
|
2194
|
+
subscriber.complete();
|
|
2195
|
+
}
|
|
2196
|
+
}));
|
|
2197
|
+
};
|
|
2198
|
+
}
|
|
2199
|
+
|
|
2200
|
+
export function joinAllInternal(fa, joiner) {
|
|
2201
|
+
return mergeMap_1(toArray_1(fa), joiner);
|
|
2202
|
+
}
|
|
2203
|
+
|
|
2204
|
+
function maybeSchedule(subscription, scheduler, execute) {
|
|
2205
|
+
if (scheduler) {
|
|
2206
|
+
subscription.add(scheduler.schedule(execute));
|
|
2207
|
+
} else {
|
|
2208
|
+
execute();
|
|
2209
|
+
}
|
|
2210
|
+
}
|
|
2211
|
+
|
|
2212
|
+
function mergeInternal(source, subscriber, f, concurrent, onBeforeNext, expand, innerSubScheduler, additionalTeardown) {
|
|
2213
|
+
const buffer = [];
|
|
2214
|
+
let active = 0;
|
|
2215
|
+
let index = 0;
|
|
2216
|
+
let isComplete = false;
|
|
2217
|
+
|
|
2218
|
+
const checkComplete = () => {
|
|
2219
|
+
if (isComplete && !buffer.length && !active) {
|
|
2220
|
+
subscriber.complete();
|
|
2221
|
+
}
|
|
2222
|
+
};
|
|
2223
|
+
|
|
2224
|
+
const outerNext = a => active < concurrent ? doInnerSub(a) : buffer.push(a);
|
|
2225
|
+
|
|
2226
|
+
const doInnerSub = a => {
|
|
2227
|
+
expand && subscriber.next(a);
|
|
2228
|
+
active++;
|
|
2229
|
+
let innerComplete = false;
|
|
2230
|
+
from_1(f(index++, a)).subscribe(new tsplus_module_9.OperatorSubscriber(subscriber, {
|
|
2231
|
+
next: b => {
|
|
2232
|
+
onBeforeNext?.(b);
|
|
2233
|
+
|
|
2234
|
+
if (expand) {
|
|
2235
|
+
outerNext(b);
|
|
2236
|
+
} else {
|
|
2237
|
+
subscriber.next(b);
|
|
2238
|
+
}
|
|
2239
|
+
},
|
|
2240
|
+
complete: () => {
|
|
2241
|
+
innerComplete = true;
|
|
2242
|
+
}
|
|
2243
|
+
}, () => {
|
|
2244
|
+
if (innerComplete) {
|
|
2245
|
+
try {
|
|
2246
|
+
active--;
|
|
2247
|
+
|
|
2248
|
+
while (buffer.length && active < concurrent) {
|
|
2249
|
+
const bufferedValue = buffer.shift();
|
|
2250
|
+
innerSubScheduler ? subscriber.add(innerSubScheduler.schedule(() => doInnerSub(bufferedValue))) : doInnerSub(bufferedValue);
|
|
2251
|
+
}
|
|
2252
|
+
|
|
2253
|
+
checkComplete();
|
|
2254
|
+
} catch (err) {
|
|
2255
|
+
subscriber.error(tsplus_module_2.halt(err));
|
|
2256
|
+
}
|
|
2257
|
+
}
|
|
2258
|
+
}));
|
|
2259
|
+
};
|
|
2260
|
+
|
|
2261
|
+
source.subscribe(new tsplus_module_9.OperatorSubscriber(subscriber, {
|
|
2262
|
+
next: outerNext,
|
|
2263
|
+
complete: () => {
|
|
2264
|
+
isComplete = true;
|
|
2265
|
+
checkComplete();
|
|
2266
|
+
}
|
|
2267
|
+
}));
|
|
2268
|
+
return () => {
|
|
2269
|
+
additionalTeardown?.();
|
|
2270
|
+
};
|
|
2271
|
+
}
|
|
2272
|
+
|
|
2273
|
+
export function scanInternal(f, initial, hasInitial, emitOnNext, emitBeforeComplete) {
|
|
2274
|
+
return (source, subscriber) => {
|
|
2275
|
+
let hasState = hasInitial;
|
|
2276
|
+
let state = initial;
|
|
2277
|
+
let index = 0;
|
|
2278
|
+
source.subscribe(tsplus_module_9.operatorSubscriber(subscriber, {
|
|
2279
|
+
next: value => {
|
|
2280
|
+
const i = index++;
|
|
2281
|
+
state = hasState ? f(i, state, value) : (hasState = true, value);
|
|
2282
|
+
emitOnNext && subscriber.next(state);
|
|
2283
|
+
},
|
|
2284
|
+
complete: emitBeforeComplete && (() => {
|
|
2285
|
+
hasState && subscriber.next(state);
|
|
2286
|
+
subscriber.complete();
|
|
2287
|
+
})
|
|
2288
|
+
}));
|
|
2289
|
+
};
|
|
2290
|
+
}
|
|
2291
|
+
//# sourceMappingURL=api.mjs.map
|