@@ -16,11 +16,38 @@ Object.defineProperty(exports, '__esModule', { value: true });
1616
1717// drop :: Int -> [a] -> [a]
1818// drop first n elements
19+function drop (n, a) { // eslint-disable-line complexity
20+ if (n < 0) {
21+ throw new TypeError('n must be >= 0')
22+ }
23+
24+ var l = a.length;
25+ if (n === 0 || l === 0) {
26+ return a
27+ }
28+
29+ if (n >= l) {
30+ return []
31+ }
1932
33+ return unsafeDrop(n, a, l - n)
34+}
35+
36+// unsafeDrop :: Int -> [a] -> Int -> [a]
37+// Internal helper for drop
38+function unsafeDrop (n, a, l) {
39+ var b = new Array(l);
40+ for (var i = 0; i < l; ++i) {
41+ b[i] = a[n + i];
42+ }
43+ return b
44+}
2045
2146// tail :: [a] -> [a]
2247// drop head element
23−
48+function tail (a) {
49+ return drop(1, a)
50+}
2451
2552// copy :: [a] -> [a]
2653// duplicate a (shallow duplication)
@@ -39,7 +66,13 @@ function map (f, a) {
3966
4067// reduce :: (a -> b -> a) -> a -> [b] -> a
4168// accumulate via left-fold
42−
69+function reduce (f, z, a) {
70+ var r = z;
71+ for (var i = 0, l = a.length; i < l; ++i) {
72+ r = f(r, a[i], i);
73+ }
74+ return r
75+}
4376
4477// replace :: a -> Int -> [a]
4578// replace element at index
@@ -124,10 +157,8 @@ function curry3 (f) {
124157var Disposable = function Disposable (dispose, data) {
125158 this._dispose = dispose;
126159 this._data = data;
127−};
128160
129−Disposable.prototype.dispose = function dispose () {
130− return this._dispose(this._data)
161+ this.dispose = function () { return dispose(data); };
131162};
132163
133164var MemoizedDisposable = function MemoizedDisposable (disposable) {
@@ -139,14 +170,14 @@ var MemoizedDisposable = function MemoizedDisposable (disposable) {
139170MemoizedDisposable.prototype.dispose = function dispose () {
140171 if (!this.disposed) {
141172 this.disposed = true;
142− this.value = disposeSafely(this.disposable);
173+ this.value = this.disposable.dispose();
143174 this.disposable = undefined;
144175 }
145176
146177 return this.value
147178};
148179
149−function disposeSafely$1 (disposable) {
180+function disposeSafely (disposable) {
150181 disposable.dispose();
151182}
152183
@@ -154,7 +185,7 @@ var createDisposable = curry2(function (dispose, data) { return new MemoizedDisp
154185
155186var emptyDisposable = new Disposable(id, undefined);
156187
157−var disposeAll = function (disposables) { return createDisposable(map(disposeSafely$1, disposables), disposables); };
188+var disposeAll = function (disposables) { return createDisposable(curry2(map)(disposeSafely), disposables); };
158189
159190/** @license MIT License (c) copyright 2010-2016 original author or authors */
160191/** @author Brian Cavalier */
@@ -202,21 +233,22 @@ function runAsap (f) {
202233}
203234
204235/* */
205−function ScheduledTask (delay, period, task, scheduler) {
206− var this$1 = this;
207−
236+var ScheduledTask = function ScheduledTask (delay, period, task, scheduler) {
208237 this.time = delay;
209238 this.period = period;
210239 this.task = task;
211240 this.scheduler = scheduler;
212241 this.active = true;
242+};
213243
214− this.run = function () { return task.run(this$1.time); };
215− this.dispose = function () {
216− scheduler.cancel(this$1);
217− task.dispose();
218− };
219−}
244+ScheduledTask.prototype.run = function run () {
245+ this.task.run(this.time);
246+};
247+
248+ScheduledTask.prototype.dispose = function dispose () {
249+ this.scheduler.cancel(this);
250+ this.task.dispose();
251+};
220252
221253/* */
222254function runTask$1 (task) {
@@ -244,24 +276,32 @@ Scheduler.prototype.now = function now () {
244276};
245277
246278Scheduler.prototype.asap = function asap (task) {
247− return this.schedule(0, -1, task)
279+ return this.schedule(0)(-1)(task)
248280};
249281
250−Scheduler.prototype.delay = function delay (delay$1, task) {
251− return this.schedule(delay$1, -1, task)
282+Scheduler.prototype.delay = function delay (delay$1) {
283+ var this$1 = this;
284+
285+ return function (task) { return this$1.schedule(delay$1)(-1)(task); }
252286};
253287
254−Scheduler.prototype.periodic = function periodic (period, task) {
255− return this.schedule(0, period, task)
288+Scheduler.prototype.periodic = function periodic (period) {
289+ var this$1 = this;
290+
291+ return function (task) { return this$1.schedule(0)(period)(task); }
256292};
257293
258−Scheduler.prototype.schedule = function schedule (delay, period, task) {
259− var now = this.now();
260− var st = new ScheduledTask(now + Math.max(0, delay), period, task, this);
294+Scheduler.prototype.schedule = function schedule (delay) {
295+ var this$1 = this;
261296
262− this.timeline.add(st);
263− this._scheduleNextRun(now);
264− return st
297+ return function (period) { return function (task) {
298+ var now = this$1.now();
299+ var st = new ScheduledTask(now + Math.max(0, delay), period, task, this$1);
300+
301+ this$1.timeline.add(st);
302+ this$1._scheduleNextRun(now);
303+ return st
304+ }; }
265305};
266306
267307Scheduler.prototype.cancel = function cancel (task) {
@@ -478,48 +518,6 @@ var scheduleTasks = curry2(function (tasks, scheduler) {
478518 }
479519});
480520
481−var Stream = function Stream (source) {
482− this.source = source;
483−};
484−
485−var tapEnd = curry2(function (f, stream) { return new Stream(new TapEnd(f, stream.source)); });
486−
487−var tapEvent = curry2(function (f, stream) { return new Stream(new TapEvent(f, stream.source)); });
488−
489−var TapEvent = function TapEvent (f, source) {
490− this.source = source;
491− this.f = f;
492−
493− this.run = function (sink) { return function (scheduler) { return source.run(new TapSink(f, sink))(scheduler); }; };
494−};
495−
496−var TapSink = function TapSink (f, sink) {
497− this.event = function (t) { return function (x) {
498− f(x)();
499− sink.event(t)(x);
500− }; };
501−
502− this.end = function (t) {
503− sink.end(t);
504− };
505−};
506−
507−var TapEnd = function TapEnd (f, source) {
508− this.source = source;
509− this.f = f;
510−
511− this.run = function (sink) { return function (scheduler) { return source.run(new TapEndSink(f, sink))(scheduler); }; };
512−};
513−
514−var TapEndSink = function TapEndSink (f, sink) {
515− this.event = function (t) { return function (x) { return sink.event(t)(x); }; };
516−
517− this.end = function (t) {
518− f();
519− sink.end(t);
520− };
521−};
522−
523521var SettableDisposable = function SettableDisposable () {
524522 this.disposable = void 0;
525523 this.disposed = false;
@@ -559,6 +557,8 @@ function runSource (source, scheduler) {
559557 var observer = new RunEffectsSink(disposable);
560558
561559 disposable.setDisposable(source.run(observer)(scheduler));
560+
561+ return {}
562562}
563563
564564var RunEffectsSink = function RunEffectsSink (disposable) {
@@ -577,100 +577,526 @@ RunEffectsSink.prototype.end = function end (t) {
577577
578578var drain = function (stream) { return function () { return runEffects(stream, defaultScheduler); }; };
579579
580−var combine =
581− curry3(function (f, stream1, stream2) { return new Stream(new Combine(f, stream1.source, stream2.source)); });
580+var LinkedList = function LinkedList () {
581+ this.head = null;
582+ this.length = 0;
583+};
584+
585+LinkedList.prototype.add = function add (x) {
586+ if (this.head !== null) {
587+ this.head.prev = x;
588+ x.next = this.head;
589+ }
590+ this.head = x;
591+ ++this.length;
592+};
593+
594+LinkedList.prototype.remove = function remove (x) { // eslint-disable-linecomplexity
595+ --this.length;
596+ if (x === this.head) {
597+ this.head = this.head.next;
598+ }
599+ if (x.next !== null) {
600+ x.next.prev = x.prev;
601+ x.next = null;
602+ }
603+ if (x.prev !== null) {
604+ x.prev.next = x.next;
605+ x.prev = null;
606+ }
607+};
608+
609+LinkedList.prototype.isEmpty = function isEmpty () {
610+ return this.length === 0
611+};
612+
613+LinkedList.prototype.dispose = function dispose () {
614+ if (this.isEmpty()) { return }
615+
616+ var x = this.head;
617+ this.head = null;
618+ this.length = 0;
619+
620+ while (x !== null) {
621+ x.dispose();
622+ x = x.next;
623+ }
624+};
625+
626+var Stream = function Stream (source) {
627+ this.source = source;
628+};
629+
630+/** @license MIT License (c) copyright 2010-2016 original author or authors */
631+/** @author Brian Cavalier */
632+/** @author John Hann */
582633
583−var Combine = function Combine (f, source1, source2) {
634+var flatMap =
635+ curry2(function (stream, f) { return mergeMapConcurrently(f, Infinity, stream); });
636+
637+var mergeConcurrently = curry2(function (concurrency, stream) { return mergeMapConcurrently(id, concurrency, stream); });
638+
639+var join =
640+ mergeConcurrently(Infinity);
641+
642+var mergeMapConcurrently = curry3(function (f, concurrency, stream) { return new Stream(new MergeConcurrently(f, concurrency, stream.source)); });
643+
644+var MergeConcurrently = function MergeConcurrently (f, concurrency, source) {
584645 this.f = f;
585− this.source1 = source1;
586− this.source2 = source2;
646+ this.concurrency = concurrency;
647+ this.source = source;
587648};
588649
589−Combine.prototype.run = function run (sink) {
650+MergeConcurrently.prototype.run = function run (sink) {
590651 var this$1 = this;
591652
592− return function (scheduler) {
593− var disposables = Array(2);
594− var sinks = Array(2);
653+ return function (scheduler) { return new Outer(this$1.f, this$1.concurrency, this$1.source, sink, scheduler); }
654+};
595655
596− var mergeSink = new CombineSink(disposables, sinks, sink, this$1.f);
656+var Outer = function Outer (f, concurrency, source, sink, scheduler) {
657+ this.f = f;
658+ this.concurrency = concurrency;
659+ this.sink = sink;
660+ this.scheduler = scheduler;
661+ this.pending = [];
662+ this.current = new LinkedList();
663+ this.disposable = new MemoizedDisposable(source.run(this)(scheduler));
664+ this.active = true;
665+};
597666
598− sinks[0] = new IndexSink(0, mergeSink);
599− sinks[1] = new IndexSink(1, mergeSink);
600− disposables[0] = this$1.source1.run(sinks[0])(scheduler);
601− disposables[1] = this$1.source2.run(sinks[1])(scheduler);
667+Outer.prototype.event = function event (t) {
668+ var this$1 = this;
602669
603− return disposeAll(disposables)
670+ return function (x) { return this$1._addInner(t, x); }
671+};
672+
673+Outer.prototype._addInner = function _addInner (t, x) {
674+ if (this.current.length < this.concurrency) {
675+ this._startInner(t, x);
676+ } else {
677+ this.pending.push(x);
604678 }
605679};
606680
607−var IndexSink = function IndexSink () {};
681+Outer.prototype._startInner = function _startInner (t, x) {
682+ try {
683+ this._initInner(t, x);
684+ } catch (e) {
685+ this.error(t, e);
686+ }
687+};
688+
689+Outer.prototype._initInner = function _initInner (t, x) {
690+ var innerSink = new Inner(t, this, this.sink);
691+ innerSink.disposable = mapAndRun(this.f, x, innerSink, this.scheduler);
692+ this.current.add(innerSink);
693+};
694+
695+Outer.prototype.end = function end (t) {
696+ this.active = false;
697+ this.disposable.dispose();
698+ this._checkEnd(t);
699+};
608700
609−IndexSink.prototype.cosntructor = function cosntructor (i, sink) {
610− this.i = i;
701+Outer.prototype.dispose = function dispose () {
702+ this.active = false;
703+ this.pending.length = 0;
704+ this.disposable.dispose();
705+ this.current.dispose();
706+};
707+
708+Outer.prototype._endInner = function _endInner (t, inner) {
709+ this.current.remove(inner);
710+ inner.dispose();
711+
712+ if (this.pending.length === 0) {
713+ this._checkEnd(t);
714+ } else {
715+ this._startInner(t, this.pending.shift());
716+ }
717+};
718+
719+Outer.prototype._checkEnd = function _checkEnd (t) {
720+ if (!this.active && this.current.isEmpty()) {
721+ this.sink.end(t);
722+ }
723+};
724+
725+var mapAndRun = function (f, x, sink, scheduler) { return f(x).source.run(sink)(scheduler); };
726+
727+var Inner = function Inner (time, outer, sink) {
728+ this.prev = this.next = null;
729+ this.time = time;
730+ this.outer = outer;
731+ this.sink = sink;
732+ this.disposable = void 0;
733+};
734+
735+Inner.prototype.event = function event (t) {
736+ var this$1 = this;
737+
738+ return function (x) { return this$1.sink.event(Math.max(t, this$1.time))(x); }
739+};
740+
741+Inner.prototype.end = function end (t) {
742+ this.outer._endInner(Math.max(t, this.time), this);
743+};
744+
745+Inner.prototype.dispose = function dispose () {
746+ return this.disposable.dispose()
747+};
748+
749+var IndexSink = function IndexSink (i, sink) {
611750 this.sink = sink;
751+ this.index = i;
752+ this.active = true;
753+ this.value = void 0;
612754};
613755
614756IndexSink.prototype.event = function event (t) {
615757 var this$1 = this;
616758
617759 return function (x) {
618− this$1.sink.event(t)({ index: this$1.i, value: x });
760+ if (!this$1.active) { return }
761+
762+ this$1.value = x;
763+ this$1.sink.event(t)(this$1);
619764 }
620765};
621766
622767IndexSink.prototype.end = function end (t) {
623− this.sink.end(t, this.i);
768+ if (!this.active) { return }
769+
770+ this.active = false;
771+ this.sink.end(t, { index: this.index });
624772};
625773
626−var CombineSink = function CombineSink (disposables, sinks, sink, f) {
774+/** @license MIT License (c) copyright 2010-2016 original author or authors */
775+/** @author Brian Cavalier */
776+/** @author John Hann */
777+
778+var combine2 = function (f) { return function (s1) { return function (s2) { return combineArray(f, [s1, s2]); }; }; };
779+var combine3 = function (f) { return function (s1) { return function (s2) { return function (s3) { return combineArray(f, [s1, s2, s3]); }; }; }; };
780+var combine4 = function (f) { return function (s1) { return function (s2) { return function (s3) { return function (s4) { return combineArray(f, [s1, s2, s3, s4]); }; }; }; }; };
781+var combine5 = function (f) { return function (s1) { return function (s2) { return function (s3) { return function (s4) { return function (s5) { return combineArray(f, [s1, s2, s3, s4, s5]); }; }; }; }; }; };
782+
783+function combineArray (f, streams) {
784+ return new Stream(combineSources(f, streams))
785+}
786+
787+function combineSources (f, streams) {
788+ return new Combine(f, map(getSource, streams))
789+}
790+
791+function getSource (stream) {
792+ return stream.source
793+}
794+
795+function Combine (f, sources) {
796+ this.f = f;
797+ this.sources = sources;
798+}
799+
800+Combine.prototype.run = function (sink) {
801+ var this$1 = this;
802+
803+ return function (scheduler) {
804+ var l = this$1.sources.length;
805+ var disposables = new Array(l);
806+ var sinks = new Array(l);
807+
808+ var mergeSink = new CombineSink(disposables, sinks, sink, this$1.f);
809+
810+ for (var indexSink, i = 0; i < l; ++i) {
811+ indexSink = sinks[i] = new IndexSink(i, mergeSink);
812+ disposables[i] = this$1.sources[i].run(indexSink)(scheduler);
813+ }
814+
815+ return disposeAll(disposables)
816+ }
817+};
818+
819+function CombineSink (disposables, sinks, sink, f) {
820+ var this$1 = this;
821+
822+ this.sink = sink;
627823 this.disposables = disposables;
628824 this.sinks = sinks;
629− this.sink = sink;
630825 this.f = f;
631826
632− this.awaiting = 2;
633− this.values = Array(2);
634− this.hasValue = [false, false];
635− this.activeCount = 2;
636−};
827+ var l = sinks.length;
828+ this.awaiting = l;
829+ this.values = new Array(l);
830+ this.hasValue = new Array(l);
637831
638−CombineSink.prototype.event = function event (t) {
639− var this$1 = this;
832+ for (var i = 0; i < l; ++i) {
833+ this$1.hasValue[i] = false;
834+ }
835+
836+ this.activeCount = sinks.length;
837+}
640838
641− return function (ref) {
642− var index = ref.index;
643− var value = ref.value;
839+CombineSink.prototype.event = function (t) {
840+ var this$1 = this;
644841
645− var f = this$1.f;
646− var awaiting = this$1._updateReady(index);
647− this$1.values[index] = value;
842+ return function (indexedValue) {
843+ var i = indexedValue.index;
844+ var awaiting = this$1._updateReady(i);
648845
846+ this$1.values[i] = indexedValue.value;
649847 if (awaiting === 0) {
650− var result = f(this$1.values[0])(this$1.values[1]);
651− this$1.sink.event(t)(result);
848+ var value = tail(this$1.values).reduce(function (f, x) { return f(x); }, this$1.f(this$1.values[0]));
849+ this$1.sink.event(t)(value);
652850 }
653851 }
654852};
655853
656−CombineSink.prototype._updateReady = function _updateReady (index) {
854+CombineSink.prototype._updateReady = function (index) {
657855 if (this.awaiting > 0) {
658856 if (!this.hasValue[index]) {
659857 this.hasValue[index] = true;
660858 this.awaiting -= 1;
661859 }
662860 }
663−
664861 return this.awaiting
665862};
666863
667−CombineSink.prototype.end = function end (t, ref) {
668− var index = ref.index;
669− var value = ref.value;
864+CombineSink.prototype.end = function (t, indexedValue) {
865+ this.disposables[indexedValue.index].dispose();
866+
867+ if (--this.activeCount === 0) {
868+ this.sink.end(t);
869+ }
870+};
871+
872+/** @license MIT License (c) copyright 2010-2016 original author or authors */
873+/** @author Brian Cavalier */
874+/** @author John Hann */
670875
671− this.disposables[index].dispose();
876+/**
877+ * @param {Array} streams array of stream to merge
878+ * @returns {Stream} stream containing events from all input observables
879+ * in time order. If two events are simultaneous they will be merged in
880+ * arbitrary order.
881+ */
882+function merge (streams) {
883+ return new Stream(mergeSources(streams))
884+}
885+
886+/**
887+ * This implements fusion/flattening for merge. It will
888+ * fuse adjacent merge operations. For example:
889+ * - a.merge(b).merge(c) effectively becomes merge(a, b, c)
890+ * - merge(a, merge(b, c)) effectively becomes merge(a, b, c)
891+ * It does this by concatenating the sources arrays of
892+ * any nested Merge sources, in effect "flattening" nested
893+ * merge operations into a single merge.
894+ */
895+function mergeSources (streams) {
896+ return new Merge(reduce(appendSources, [], streams))
897+}
898+
899+function appendSources (sources, stream) {
900+ var source = stream.source;
901+ return source instanceof Merge
902+ ? sources.concat(source.sources)
903+ : sources.concat(source)
904+}
905+
906+function Merge (sources) {
907+ this.sources = sources;
908+}
909+
910+Merge.prototype.run = function (sink, scheduler) {
911+ var this$1 = this;
912+
913+ var l = this.sources.length;
914+ var disposables = new Array(l);
915+ var sinks = new Array(l);
916+
917+ var mergeSink = new MergeSink(disposables, sinks, sink);
918+
919+ for (var indexSink, i = 0; i < l; ++i) {
920+ indexSink = sinks[i] = new IndexSink(i, mergeSink);
921+ disposables[i] = this$1.sources[i].run(indexSink, scheduler);
922+ }
923+
924+ return disposeAll(disposables)
925+};
926+
927+function MergeSink (disposables, sinks, sink) {
928+ this.sink = sink;
929+ this.disposables = disposables;
930+ this.activeCount = sinks.length;
931+}
932+
933+MergeSink.prototype.event = function (t, indexValue) {
934+ this.sink.event(t, indexValue.value);
935+};
936+
937+MergeSink.prototype.end = function (t, indexedValue) {
938+ dispose.tryDispose(t, this.disposables[indexedValue.index], this.sink);
939+ if (--this.activeCount === 0) {
940+ this.sink.end(t, indexedValue.value);
941+ }
942+};
943+
944+var concat = function (s1) { return function (s2) { return continueWith(function () { return s2; })(s1); }; };
945+
946+var continueWith = function (f) { return function (stream) { return new Stream(new ContinueWith(f, stream.source)); }; };
947+
948+function ContinueWith (f, source) {
949+ this.f = f;
950+ this.source = source;
951+}
952+
953+ContinueWith.prototype.run = function (sink) {
954+ var this$1 = this;
955+
956+ return function (scheduler) {
957+ return new ContinueWithSink(this$1.f, this$1.source, sink, scheduler)
958+ }
959+};
960+
961+function ContinueWithSink (f, source, sink, scheduler) {
962+ this.f = f;
963+ this.sink = sink;
964+ this.scheduler = scheduler;
965+ this.active = true;
966+ this.disposable = new MemoizedDisposable(source.run(this)(scheduler));
967+}
968+
969+ContinueWithSink.prototype.event = function (t) {
970+ var this$1 = this;
971+
972+ return function (x) {
973+ if (!this$1.active) {
974+ return
975+ }
976+ this$1.sink.event(t)(x);
977+ }
978+};
979+
980+ContinueWithSink.prototype.end = function (t, x) {
981+ if (!this.active) {
982+ return
983+ }
984+
985+ this.disposable.dispose();
986+ this._startNext(t, x, this.sink);
987+};
988+
989+ContinueWithSink.prototype._startNext = function (t, x, sink) {
990+ this._continue(this.f, x, sink);
991+};
992+
993+ContinueWithSink.prototype._continue = function (f, x, sink) {
994+ return f(x).source.run(sink)(this.scheduler)
995+};
996+
997+ContinueWithSink.prototype.dispose = function () {
998+ this.active = false;
999+ return this.disposable.dispose()
1000+};
1001+
1002+/**
1003+ * Given a stream of streams, return a new stream that adopts the behavior
1004+ * of the most recent inner stream.
1005+ * @param {Stream} stream of streams on which to switch
1006+ * @returns {Stream} switching stream
1007+ */
1008+function switchLatest (stream) {
1009+ return new Stream(new Switch(stream.source))
1010+}
1011+
1012+function Switch (source) {
1013+ this.source = source;
1014+}
1015+
1016+Switch.prototype.run = function (sink) {
1017+ var this$1 = this;
1018+
1019+ return function (scheduler) {
1020+ var switchSink = new SwitchSink(sink, scheduler);
1021+ return disposeAll([switchSink, this$1.source.run(switchSink)(scheduler)])
1022+ }
1023+};
1024+
1025+function SwitchSink (sink, scheduler) {
1026+ this.sink = sink;
1027+ this.scheduler = scheduler;
1028+ this.current = null;
1029+ this.ended = false;
1030+}
1031+
1032+SwitchSink.prototype.event = function (t) {
1033+ var this$1 = this;
1034+
1035+ return function (stream) {
1036+ this$1._disposeCurrent(t); // TODO: capture the result of this dispose
1037+ this$1.current = new Segment(t, Infinity, this$1, this$1.sink);
1038+ this$1.current.disposable = stream.source.run(this$1.current)(this$1.scheduler);
1039+ }
1040+};
1041+
1042+SwitchSink.prototype.end = function (t, x) {
1043+ this.ended = true;
1044+ this._checkEnd(t, x);
1045+};
1046+
1047+SwitchSink.prototype.dispose = function () {
1048+ return this._disposeCurrent(this.scheduler.now())
1049+};
1050+
1051+SwitchSink.prototype._disposeCurrent = function (t) {
1052+ if (this.current !== null) {
1053+ return this.current._dispose(t)
1054+ }
1055+};
1056+
1057+SwitchSink.prototype._disposeInner = function (t, inner) {
1058+ inner._dispose(t); // TODO: capture the result of this dispose
1059+ if (inner === this.current) {
1060+ this.current = null;
1061+ }
1062+};
1063+
1064+SwitchSink.prototype._checkEnd = function (t, x) {
1065+ if (this.ended && this.current === null) {
1066+ this.sink.end(t, x);
1067+ }
1068+};
1069+
1070+SwitchSink.prototype._endInner = function (t, x, inner) {
1071+ this._disposeInner(t, inner);
1072+ this._checkEnd(t, x);
1073+};
1074+
1075+function Segment (min, max, outer, sink) {
1076+ this.min = min;
1077+ this.max = max;
1078+ this.outer = outer;
1079+ this.sink = sink;
1080+ this.disposable = emptyDisposable;
1081+}
1082+
1083+Segment.prototype.event = function (t) {
1084+ var this$1 = this;
1085+
1086+ return function (x) {
1087+ if (t < this$1.max) {
1088+ this$1.sink.event(Math.max(t, this$1.min))(x);
1089+ }
1090+ }
1091+};
1092+
1093+Segment.prototype.end = function (t, x) {
1094+ this.outer._endInner(Math.max(t, this.min), x, this);
1095+};
6721096
673− if (--this.activeCount === 0) { this.sink.end(t); }
1097+Segment.prototype._dispose = function (t) {
1098+ this.max = t;
1099+ this.disposable.dispose();
6741100};
6751101
6761102/* */
@@ -682,7 +1108,16 @@ exports.defaultScheduler = defaultScheduler;
6821108exports.scheduleTasks = scheduleTasks;
6831109exports.endTask = endTask;
6841110exports.eventTask = eventTask;
685−exports.tapEnd = tapEnd;
686−exports.tapEvent = tapEvent;
6871111exports.drain = drain;
688−exports.combine = combine;
1112+exports.flatMap = flatMap;
1113+exports.mergeConcurrently = mergeConcurrently;
1114+exports.join = join;
1115+exports.mergeMapConcurrently = mergeMapConcurrently;
1116+exports.combine2 = combine2;
1117+exports.combine3 = combine3;
1118+exports.combine4 = combine4;
1119+exports.combine5 = combine5;
1120+exports.merge = merge;
1121+exports.concat = concat;
1122+exports.continueWith = continueWith;
1123+exports.switch = switchLatest;