@fncts/observable 0.0.8 → 0.0.10

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