@fncts/observable 0.0.1

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