@fncts/observable 0.0.9 → 0.0.11

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