@fncts/observable 0.0.31 → 0.0.33

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