@@ -1,1384 +0,0 @@
3−Object.defineProperty(exports, '__esModule', { value: true });
5−/** @license MIT License (c) copyright 2010-2016 original author or authors */
7−// Non-mutating array operations
9−// cons :: a -> [a] -> [a]
13−// append :: a -> [a] -> [a]
15−function append (x, a) {
17− var b = new Array(l + 1);
18− for (var i = 0; i < l; ++i) {
26−// drop :: Int -> [a] -> [a]
27−// drop first n elements
28−function drop (n, a) { // eslint-disable-line complexity
30− throw new TypeError('n must be >= 0')
34− if (n === 0 || l === 0) {
42− return unsafeDrop(n, a, l - n)
45−// unsafeDrop :: Int -> [a] -> Int -> [a]
46−// Internal helper for drop
47−function unsafeDrop (n, a, l) {
48− var b = new Array(l);
49− for (var i = 0; i < l; ++i) {
62−// duplicate a (shallow duplication)
65−// map :: (a -> b) -> [a] -> [b]
66−// transform each element with f
69− var b = new Array(l);
70− for (var i = 0; i < l; ++i) {
76−// reduce :: (a -> b -> a) -> a -> [b] -> a
77−// accumulate via left-fold
78−function reduce (f, z, a) {
80− for (var i = 0, l = a.length; i < l; ++i) {
86−// replace :: a -> Int -> [a]
87−// replace element at index
90−// remove :: Int -> [a] -> [a]
91−// remove element at index
92−function remove (i, a) { // eslint-disable-line complexity
94− throw new TypeError('i must be >= 0')
98− if (l === 0 || i >= l) { // exit early if index beyond end of array
102− if (l === 1) { // exit early if index in bounds and length === 1
106− return unsafeRemove(i, a, l - 1)
109−// unsafeRemove :: Int -> [a] -> Int -> [a]
110−// Internal helper to remove element at index
111−function unsafeRemove (i, a, l) {
112− var b = new Array(l);
114− for (j = 0; j < i; ++j) {
117− for (j = i; j < l; ++j) {
124−// removeAll :: (a -> boolean) -> [a] -> [a]
125−// remove all elements matching a predicate
126−function removeAll (f, a) {
128− var b = new Array(l);
130− for (var x = (void 0), i = 0; i < l; ++i) {
142−// findIndex :: a -> [a] -> Int
143−// find index of x in a, from the left
144−function findIndex (x, a) {
145− for (var i = 0, l = a.length; i < l; ++i) {
153−// isArrayLike :: * -> boolean
154−// Return true iff x is array-like
156−/** @license MIT License (c) copyright 2010-2016 original author or authors */
159−var id = function (x) { return x; };
161−// compose :: (b -> c) -> (a -> b) -> (a -> c)
164−// apply :: (a -> b) -> a -> b
167−// curry2 :: ((a, b) -> c) -> (a -> b -> c)
168−function curry2 (f) {
169− function curried (a, b) {
170− switch (arguments.length) {
171− case 0: return curried
172− case 1: return function (b) { return f(a, b); }
173− default: return f(a, b)
179−// curry3 :: ((a, b, c) -> d) -> (a -> b -> c -> d)
180−function curry3 (f) {
181− function curried (a, b, c) { // eslint-disable-line complexity
182− switch (arguments.length) {
183− case 0: return curried
184− case 1: return curry2(function (b, c) { return f(a, b, c); })
185− case 2: return function (c) { return f(a, b, c); }
186− default:return f(a, b, c)
192−// curry4 :: ((a, b, c, d) -> e) -> (a -> b -> c -> d -> e)
194−/** @license MIT License (c) copyright 2016 original author or authors */
196−var Disposable = function Disposable (dispose, data) {
197− this._dispose = dispose;
200− this.dispose = function () { return dispose(data); };
203−var MemoizedDisposable = function MemoizedDisposable (disposable) {
204− this.disposed = false;
205− this.value = undefined;
206− this.disposable = disposable;
209−MemoizedDisposable.prototype.dispose = function dispose () {
210− if (!this.disposed) {
211− this.disposed = true;
212− this.value = this.disposable.dispose();
213− this.disposable = undefined;
219−function disposeSafely (disposable) {
220− disposable.dispose();
223−var createDisposable = curry2(function (dispose, data) { return new MemoizedDisposable(new Disposable(dispose, data)); });
225−var emptyDisposable = new Disposable(id, undefined);
227−var disposeAll = function (disposables) { return createDisposable(curry2(map)(disposeSafely), disposables); };
229−/** @license MIT License (c) copyright 2010-2016 original author or authors */
230−/** @author Brian Cavalier */
231−/** @author John Hann */
233−/*global setTimeout, clearTimeout*/
235−function defer (task) {
236− return Promise.resolve(task).then(runTask)
239−function runTask (task) {
243−var ClockTimer = function ClockTimer () {
244− this.now = Date.now;
247−ClockTimer.prototype.setTimer = function setTimer (f, dt) {
248− return dt <= 0 ? runAsap(f) : setTimeout(f, dt)
251−ClockTimer.prototype.clearTimer = function clearTimer (t) {
252− return t instanceof Asap ? t.cancel() : clearTimeout(t)
255−var Asap = function Asap (f) {
260−Asap.prototype.run = function run () {
261− return this.active && this.f()
264−Asap.prototype.cancel = function cancel () {
265− this.active = false;
268−function runAsap (f) {
269− var task = new Asap(f);
275−var ScheduledTask = function ScheduledTask (delay, period, task, scheduler) {
277− this.period = period;
279− this.scheduler = scheduler;
283−ScheduledTask.prototype.run = function run () {
284− this.task.run(this.time);
287−ScheduledTask.prototype.dispose = function dispose () {
288− this.scheduler.cancel(this);
289− this.task.dispose();
293−function runTask$1 (task) {
301−var Scheduler = function Scheduler (timer, timeline) {
305− this.timeline = timeline;
308− this._nextArrival = Infinity;
310− this._runReadyTasksBound = function () { return this$1._runReadyTasks(this$1.now()); };
313−Scheduler.prototype.now = function now () {
314− return this.timer.now()
317−Scheduler.prototype.asap = function asap (task) {
318− return this.schedule(0)(-1)(task)
321−Scheduler.prototype.delay = function delay (delay$1) {
324− return function (task) { return this$1.schedule(delay$1)(-1)(task); }
327−Scheduler.prototype.periodic = function periodic (period) {
330− return function (task) { return this$1.schedule(0)(period)(task); }
333−Scheduler.prototype.schedule = function schedule (delay) {
336− return function (period) { return function (task) {
337− var now = this$1.now();
338− var st = new ScheduledTask(now + Math.max(0, delay), period, task, this$1);
340− this$1.timeline.add(st);
341− this$1._scheduleNextRun(now);
346−Scheduler.prototype.cancel = function cancel (task) {
347− task.active = false;
348− if (this.timeline.remove(task)) {
353−Scheduler.prototype.cancelAll = function cancelAll (f) {
354− this.timeline.removeAll(f);
358−Scheduler.prototype._reschedule = function _reschedule () {
359− if (this.timeline.isEmpty()) {
362− this._scheduleNextRun(this.now());
366−Scheduler.prototype._unschedule = function _unschedule () {
367− this.timer.clearTimer(this._timer);
371−Scheduler.prototype._scheduleNextRun = function _scheduleNextRun (now) { // eslint-disable-line complexity
372− if (this.timeline.isEmpty()) {
376− var nextArrival = this.timeline.nextArrival();
378− if (this._timer === null) {
379− this._scheduleNextArrival(nextArrival, now);
380− } else if (nextArrival < this._nextArrival) {
382− this._scheduleNextArrival(nextArrival, now);
386−Scheduler.prototype._scheduleNextArrival = function _scheduleNextArrival (nextArrival, now) {
387− this._nextArrival = nextArrival;
388− var delay = Math.max(0, nextArrival - now);
389− this._timer = this.timer.setTimer(this._runReadyTasksBound, delay);
392−Scheduler.prototype._runReadyTasks = function _runReadyTasks (now) {
394− this.timeline.runTasks(now, runTask$1);
395− this._scheduleNextRun(this.now());
398−/** @license MIT License (c) copyright 2010-2016 original author or authors */
399−/** @author Brian Cavalier */
400−/** @author John Hann */
402−var Timeline = function Timeline () {
406−Timeline.prototype.nextArrival = function nextArrival () {
407− return this.isEmpty() ? Infinity : this.tasks[0].time
410−Timeline.prototype.isEmpty = function isEmpty () {
411− return this.tasks.length === 0
414−Timeline.prototype.add = function add (st) {
415− insertByTime(st, this.tasks);
418−Timeline.prototype.remove = function remove$$1 (st) {
419− var i = binarySearch(st.time, this.tasks);
421− if (i >= 0 && i < this.tasks.length) {
422− var at = findIndex(st, this.tasks[i].events);
424− this.tasks[i].events.splice(at, 1);
432−Timeline.prototype.removeAll = function removeAll$$1 (f) {
435− for (var i = 0; i < this.tasks.length; ++i) {
436− removeAllFrom(f, this$1.tasks[i]);
440−Timeline.prototype.runTasks = function runTasks (t, runTask) {
443− var tasks = this.tasks;
444− var l = tasks.length;
447− while (i < l && tasks[i].time <= t) {
451− this.tasks = tasks.slice(i);
453− // Run all ready tasks
454− for (var j = 0; j < i; ++j) {
455− this$1.tasks = runReadyTasks(runTask, tasks[j].events, this$1.tasks);
459−function runReadyTasks (runTask, events, tasks) { // eslint-disable-line complexity
460− for (var i = 0; i < events.length; ++i) {
461− var task = events[i];
466− // Reschedule periodic repeating tasks
467− // Check active again, since a task may have canceled itself
468− if (task.period >= 0 && task.active) {
469− task.time = task.time + task.period;
470− insertByTime(task, tasks);
478−function insertByTime (task, timeslots) { // eslint-disable-line complexity
479− var l = timeslots.length;
482− timeslots.push(newTimeslot(task.time, [task]));
486− var i = binarySearch(task.time, timeslots);
489− timeslots.push(newTimeslot(task.time, [task]));
490− } else if (task.time === timeslots[i].time) {
491− timeslots[i].events.push(task);
493− timeslots.splice(i, 0, newTimeslot(task.time, [task]));
497−function removeAllFrom (f, timeslot) {
498− timeslot.events = removeAll(f, timeslot.events);
501−function binarySearch (t, sortedArray) { // eslint-disable-line complexity
503− var hi = sortedArray.length;
507− mid = Math.floor((lo + hi) / 2);
508− y = sortedArray[mid];
512− } else if (t < y.time) {
521−var newTimeslot = function (t, events) { return ({ time: t, events: events }); };
524− curry3(function (run, value, sink) { return new PropagateTask(run, value, sink); });
527− curry2(function (value, sink) { return propagateTask(runEvent, value, sink); });
529−var endTask = function (sink) { return propagateTask(runEnd, void 0, sink); };
531−var PropagateTask = function PropagateTask (run, value, sink) {
535− this.dispose = function () { active = false; };
536− this.run = function (t) {
537− if (!active) { return }
539− run(t, value, sink);
543−function runEvent (time, value, sink) {
544− sink.event(time)(value);
547−function runEnd (time, value, sink) {
548− sink.end(time, value);
551−var defaultScheduler = new Scheduler(new ClockTimer(), new Timeline());
553−var scheduleTasks = curry2(function (tasks, scheduler) {
554− var scheduledTasks = tasks.map(function (task) { return scheduler.asap(task); });
557− dispose: function () { return scheduledTasks.forEach(function (task) { return task.dispose(); }); }
561−var SettableDisposable = function SettableDisposable () {
562− this.disposable = void 0;
563− this.disposed = false;
564− this.result = void 0;
567−SettableDisposable.prototype.setDisposable = function setDisposable (disposable) {
568− this.disposable = disposable;
570− if (this.disposed) {
571− this.result = disposable.dispose();
575−SettableDisposable.prototype.dispose = function dispose () {
576− if (this.disposed) {
580− this.disposed = true;
582− if (this.disposable !== void 0) {
583− this.result = this.disposable.dispose();
589−function runEffects (stream, scheduler) {
590− return runSourceEffects(stream.source, scheduler)
593−var runSourceEffects = function (source, scheduler) { return runSource(source, scheduler); };
595−function runSource (source, scheduler) {
596− var disposable = new SettableDisposable();
597− var observer = new RunEffectsSink(disposable);
599− disposable.setDisposable(source.run(observer)(scheduler));
604−var RunEffectsSink = function RunEffectsSink (disposable) {
605− this._disposable = disposable;
609−RunEffectsSink.prototype.event = function event (t) {
610− return function (x) {}
613−RunEffectsSink.prototype.end = function end (t) {
614− this.active = false;
615− Promise.resolve(this._disposable).then(function (d) { return d.dispose(); });
618−var drain = function (stream) { return function () { return runEffects(stream, defaultScheduler); }; };
620−var LinkedList = function LinkedList () {
625−LinkedList.prototype.add = function add (x) {
626− if (this.head !== null) {
634−LinkedList.prototype.remove = function remove (x) { // eslint-disable-linecomplexity
636− if (x === this.head) {
637− this.head = this.head.next;
639− if (x.next !== null) {
640− x.next.prev = x.prev;
643− if (x.prev !== null) {
644− x.prev.next = x.next;
649−LinkedList.prototype.isEmpty = function isEmpty () {
650− return this.length === 0
653−LinkedList.prototype.dispose = function dispose () {
654− if (this.isEmpty()) { return }
660− while (x !== null) {
666−var Stream = function Stream (source) {
667− this.source = source;
670−/** @license MIT License (c) copyright 2010-2016 original author or authors */
671−/** @author Brian Cavalier */
672−/** @author John Hann */
675− curry2(function (stream, f) { return mergeMapConcurrently(f, Infinity, stream); });
677−var mergeConcurrently = curry2(function (concurrency, stream) { return mergeMapConcurrently(id, concurrency, stream); });
680− mergeConcurrently(Infinity);
682−var mergeMapConcurrently = curry3(function (f, concurrency, stream) { return new Stream(new MergeConcurrently(f, concurrency, stream.source)); });
684−var MergeConcurrently = function MergeConcurrently (f, concurrency, source) {
686− this.concurrency = concurrency;
687− this.source = source;
690−MergeConcurrently.prototype.run = function run (sink) {
693− return function (scheduler) { return new Outer(this$1.f, this$1.concurrency, this$1.source, sink, scheduler); }
696−var Outer = function Outer (f, concurrency, source, sink, scheduler) {
698− this.concurrency = concurrency;
700− this.scheduler = scheduler;
702− this.current = new LinkedList();
703− this.disposable = new MemoizedDisposable(source.run(this)(scheduler));
707−Outer.prototype.event = function event (t) {
710− return function (x) { return this$1._addInner(t, x); }
713−Outer.prototype._addInner = function _addInner (t, x) {
714− if (this.current.length < this.concurrency) {
715− this._startInner(t, x);
717− this.pending.push(x);
721−Outer.prototype._startInner = function _startInner (t, x) {
723− this._initInner(t, x);
729−Outer.prototype._initInner = function _initInner (t, x) {
730− var innerSink = new Inner(t, this, this.sink);
731− innerSink.disposable = mapAndRun(this.f, x, innerSink, this.scheduler);
732− this.current.add(innerSink);
735−Outer.prototype.end = function end (t) {
736− this.active = false;
737− this.disposable.dispose();
741−Outer.prototype.dispose = function dispose () {
742− this.active = false;
743− this.pending.length = 0;
744− this.disposable.dispose();
745− this.current.dispose();
748−Outer.prototype._endInner = function _endInner (t, inner) {
749− this.current.remove(inner);
752− if (this.pending.length === 0) {
755− this._startInner(t, this.pending.shift());
759−Outer.prototype._checkEnd = function _checkEnd (t) {
760− if (!this.active && this.current.isEmpty()) {
765−var mapAndRun = function (f, x, sink, scheduler) { return f(x).source.run(sink)(scheduler); };
767−var Inner = function Inner (time, outer, sink) {
768− this.prev = this.next = null;
772− this.disposable = void 0;
775−Inner.prototype.event = function event (t) {
778− return function (x) { return this$1.sink.event(Math.max(t, this$1.time))(x); }
781−Inner.prototype.end = function end (t) {
782− this.outer._endInner(Math.max(t, this.time), this);
785−Inner.prototype.dispose = function dispose () {
786− return this.disposable.dispose()
789−var IndexSink = function IndexSink (i, sink) {
793− this.value = void 0;
796−IndexSink.prototype.event = function event (t) {
799− return function (x) {
800− if (!this$1.active) { return }
803− this$1.sink.event(t)(this$1);
807−IndexSink.prototype.end = function end (t) {
808− if (!this.active) { return }
810− this.active = false;
811− this.sink.end(t, { index: this.index });
814−/** @license MIT License (c) copyright 2010-2016 original author or authors */
815−/** @author Brian Cavalier */
816−/** @author John Hann */
818−var combine2 = function (f) { return function (s1) { return function (s2) { return combineArray(f, [s1, s2]); }; }; };
819−var combine3 = function (f) { return function (s1) { return function (s2) { return function (s3) { return combineArray(f, [s1, s2, s3]); }; }; }; };
820−var combine4 = function (f) { return function (s1) { return function (s2) { return function (s3) { return function (s4) { return combineArray(f, [s1, s2, s3, s4]); }; }; }; }; };
821−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]); }; }; }; }; }; };
823−function combineArray (f, streams) {
824− return new Stream(combineSources(f, streams))
827−function combineSources (f, streams) {
828− return new Combine(f, map(getSource, streams))
831−function getSource (stream) {
832− return stream.source
835−function Combine (f, sources) {
837− this.sources = sources;
840−Combine.prototype.run = function (sink) {
843− return function (scheduler) {
844− var l = this$1.sources.length;
845− var disposables = new Array(l);
846− var sinks = new Array(l);
848− var mergeSink = new CombineSink(disposables, sinks, sink, this$1.f);
850− for (var indexSink, i = 0; i < l; ++i) {
851− indexSink = sinks[i] = new IndexSink(i, mergeSink);
852− disposables[i] = this$1.sources[i].run(indexSink)(scheduler);
855− return disposeAll(disposables)
859−function CombineSink (disposables, sinks, sink, f) {
863− this.disposables = disposables;
867− var l = sinks.length;
869− this.values = new Array(l);
870− this.hasValue = new Array(l);
872− for (var i = 0; i < l; ++i) {
873− this$1.hasValue[i] = false;
876− this.activeCount = sinks.length;
879−CombineSink.prototype.event = function (t) {
882− return function (indexedValue) {
883− var i = indexedValue.index;
884− var awaiting = this$1._updateReady(i);
886− this$1.values[i] = indexedValue.value;
887− if (awaiting === 0) {
888− var value = tail(this$1.values).reduce(function (f, x) { return f(x); }, this$1.f(this$1.values[0]));
889− this$1.sink.event(t)(value);
894−CombineSink.prototype._updateReady = function (index) {
895− if (this.awaiting > 0) {
896− if (!this.hasValue[index]) {
897− this.hasValue[index] = true;
901− return this.awaiting
904−CombineSink.prototype.end = function (t, indexedValue) {
905− this.disposables[indexedValue.index].dispose();
907− if (--this.activeCount === 0) {
912−/** @license MIT License (c) copyright 2010-2016 original author or authors */
913−/** @author Brian Cavalier */
914−/** @author John Hann */
917− * @param {Array} streams array of stream to merge
918− * @returns {Stream} stream containing events from all input observables
919− * in time order. If two events are simultaneous they will be merged in
922−function merge (streams) {
923− return new Stream(mergeSources(streams))
927− * This implements fusion/flattening for merge. It will
928− * fuse adjacent merge operations. For example:
929− * - a.merge(b).merge(c) effectively becomes merge(a, b, c)
930− * - merge(a, merge(b, c)) effectively becomes merge(a, b, c)
931− * It does this by concatenating the sources arrays of
932− * any nested Merge sources, in effect "flattening" nested
933− * merge operations into a single merge.
935−function mergeSources (streams) {
936− return new Merge(reduce(appendSources, [], streams))
939−function appendSources (sources, stream) {
940− var source = stream.source;
941− return source instanceof Merge
942− ? sources.concat(source.sources)
943− : sources.concat(source)
946−function Merge (sources) {
947− this.sources = sources;
950−Merge.prototype.run = function (sink, scheduler) {
953− var l = this.sources.length;
954− var disposables = new Array(l);
955− var sinks = new Array(l);
957− var mergeSink = new MergeSink(disposables, sinks, sink);
959− for (var indexSink, i = 0; i < l; ++i) {
960− indexSink = sinks[i] = new IndexSink(i, mergeSink);
961− disposables[i] = this$1.sources[i].run(indexSink, scheduler);
964− return disposeAll(disposables)
967−function MergeSink (disposables, sinks, sink) {
969− this.disposables = disposables;
970− this.activeCount = sinks.length;
973−MergeSink.prototype.event = function (t, indexValue) {
974− this.sink.event(t, indexValue.value);
977−MergeSink.prototype.end = function (t, indexedValue) {
978− dispose.tryDispose(t, this.disposables[indexedValue.index], this.sink);
979− if (--this.activeCount === 0) {
980− this.sink.end(t, indexedValue.value);
984−var concat = function (s1) { return function (s2) { return continueWith(function () { return s2; })(s1); }; };
986−var continueWith = function (f) { return function (stream) { return new Stream(new ContinueWith(f, stream.source)); }; };
988−function ContinueWith (f, source) {
990− this.source = source;
993−ContinueWith.prototype.run = function (sink) {
996− return function (scheduler) {
997− return new ContinueWithSink(this$1.f, this$1.source, sink, scheduler)
1001−function ContinueWithSink (f, source, sink, scheduler) {
1004− this.scheduler = scheduler;
1005− this.active = true;
1006− this.disposable = new MemoizedDisposable(source.run(this)(scheduler));
1009−ContinueWithSink.prototype.event = function (t) {
1012− return function (x) {
1013− if (!this$1.active) {
1016− this$1.sink.event(t)(x);
1020−ContinueWithSink.prototype.end = function (t, x) {
1021− if (!this.active) {
1025− this.disposable.dispose();
1026− this._startNext(t, x, this.sink);
1029−ContinueWithSink.prototype._startNext = function (t, x, sink) {
1030− this._continue(this.f, x, sink);
1033−ContinueWithSink.prototype._continue = function (f, x, sink) {
1034− return f(x).source.run(sink)(this.scheduler)
1037−ContinueWithSink.prototype.dispose = function () {
1038− this.active = false;
1039− return this.disposable.dispose()
1043− * Given a stream of streams, return a new stream that adopts the behavior
1044− * of the most recent inner stream.
1045− * @param {Stream} stream of streams on which to switch
1046− * @returns {Stream} switching stream
1048−function switchLatest (stream) {
1049− return new Stream(new Switch(stream.source))
1052−function Switch (source) {
1053− this.source = source;
1056−Switch.prototype.run = function (sink) {
1059− return function (scheduler) {
1060− var switchSink = new SwitchSink(sink, scheduler);
1061− return disposeAll([switchSink, this$1.source.run(switchSink)(scheduler)])
1065−function SwitchSink (sink, scheduler) {
1067− this.scheduler = scheduler;
1068− this.current = null;
1069− this.ended = false;
1072−SwitchSink.prototype.event = function (t) {
1075− return function (stream) {
1076− this$1._disposeCurrent(t); // TODO: capture the result of this dispose
1077− this$1.current = new Segment(t, Infinity, this$1, this$1.sink);
1078− this$1.current.disposable = stream.source.run(this$1.current)(this$1.scheduler);
1082−SwitchSink.prototype.end = function (t, x) {
1084− this._checkEnd(t, x);
1087−SwitchSink.prototype.dispose = function () {
1088− return this._disposeCurrent(this.scheduler.now())
1091−SwitchSink.prototype._disposeCurrent = function (t) {
1092− if (this.current !== null) {
1093− return this.current._dispose(t)
1097−SwitchSink.prototype._disposeInner = function (t, inner) {
1098− inner._dispose(t); // TODO: capture the result of this dispose
1099− if (inner === this.current) {
1100− this.current = null;
1104−SwitchSink.prototype._checkEnd = function (t, x) {
1105− if (this.ended && this.current === null) {
1106− this.sink.end(t, x);
1110−SwitchSink.prototype._endInner = function (t, x, inner) {
1111− this._disposeInner(t, inner);
1112− this._checkEnd(t, x);
1115−function Segment (min, max, outer, sink) {
1118− this.outer = outer;
1120− this.disposable = emptyDisposable;
1123−Segment.prototype.event = function (t) {
1126− return function (x) {
1127− if (t < this$1.max) {
1128− this$1.sink.event(Math.max(t, this$1.min))(x);
1133−Segment.prototype.end = function (t, x) {
1134− this.outer._endInner(Math.max(t, this.min), x, this);
1137−Segment.prototype._dispose = function (t) {
1139− this.disposable.dispose();
1142−var skipRepeatsWith = function (equals) { return function (stream) { return new Stream(new SkipRepeats(equals, stream)); }; };
1144−var SkipRepeats = function SkipRepeats (equals, source) {
1145− this.equals = equals;
1146− this.source = source;
1149−SkipRepeats.prototype.run = function run (sink) {
1152− return function (scheduler) { return this$1.source.run(new SkipRepeatsSink(this$1.equals, sink), scheduler); }
1155−var SkipRepeatsSink = function SkipRepeatsSink (equals, sink) {
1156− this.equals = equals;
1157− this.value = void 0;
1161−SkipRepeatsSink.prototype.event = function event (t) {
1164− return function (x) {
1166− this$1.init = false;
1168− this$1.sink.event(t, x);
1169− } else if (!this$1.equals(this$1.value)(x)) {
1171− this$1.sink.event(t)(x);
1176−SkipRepeatsSink.prototype.end = function end (t) {
1180−var delay = function (delayTime) { return function (stream) { return delayTime <= 0 ? stream : new Stream(new Delay(delayTime, stream.source)); }; };
1182−var Delay = function Delay (dt, source) {
1184− this.source = source;
1187−Delay.prototype.run = function run (sink) {
1190− return function (scheduler) {
1191− var delaySink = new DelaySink(this$1.dt, sink, scheduler);
1192− return disposeAll([delaySink, this$1.source.run(delaySink)(scheduler)])
1196−var DelaySink = function DelaySink (dt, sink, scheduler) {
1199− this.scheduler = scheduler;
1202−DelaySink.prototype.dispose = function dispose () {
1205− this.scheduler.cancelAll(function (task) { return task.sink === this$1.sink; });
1208−DelaySink.prototype.event = function event (t) {
1211− return function (x) { return this$1.scheduler.delay(this$1.dt)(eventTask(x)(this$1.sink)); }
1214−DelaySink.prototype.end = function end (t) {
1215− this.scheduler.delay(this.dt)(endTask(this.sink));
1218−var dispose$1 = function (disposable) { return disposable.dispose(); };
1220−var emptyDisposable$1 = {
1221− dispose: function dispose () {}
1224−var MulticastDisposable = function MulticastDisposable (source, sink) {
1225− this.source = source;
1227− this.disposed = false;
1230−MulticastDisposable.prototype.dispose = function dispose () {
1231− if (this.disposed) {
1234− this.disposed = true;
1235− var remaining = this.source.remove(this.sink);
1236− return remaining === 0 && this.source._dispose()
1239−var MulticastSource = function MulticastSource (source) {
1240− this.source = source;
1242− this._disposable = emptyDisposable$1;
1245−MulticastSource.prototype.run = function run (sink) {
1248− return function (scheduler) {
1249− var n = this$1.add(sink, scheduler);
1251− this$1._disposable = this$1.source.run(this$1)(scheduler);
1253− return new MulticastDisposable(this$1, sink)
1257−MulticastSource.prototype._dispose = function _dispose () {
1258− var disposable = this._disposable;
1259− this._disposable = emptyDisposable$1;
1260− return Promise.resolve(disposable).then(dispose$1)
1263−MulticastSource.prototype.add = function add (sink) {
1264− this.sinks = append(sink, this.sinks);
1265− return this.sinks.length
1268−MulticastSource.prototype.remove = function remove$1 (sink) {
1269− var i = findIndex(sink, this.sinks);
1270− // istanbul ignore next
1272− this.sinks = remove(i, this.sinks);
1275− return this.sinks.length
1278−MulticastSource.prototype.event = function event (time) {
1281− return function (value) {
1282− var s = this$1.sinks;
1283− if (s.length === 1) {
1284− return s[0].event(time)(value)
1286− for (var i = 0; i < s.length; ++i) {
1287− s[i].event(time)(value);
1292−MulticastSource.prototype.end = function end (time) {
1293− var s = this.sinks;
1294− for (var i = 0; i < s.length; ++i) {
1299−var HoldSource = (function (MulticastSource$$1) {
1300− function HoldSource (source, bufferSize) {
1301− MulticastSource$$1.call(this, source);
1302− this.bufferSize = bufferSize;
1307− if ( MulticastSource$$1 ) HoldSource.__proto__ = MulticastSource$$1;
1308− HoldSource.prototype = Object.create( MulticastSource$$1 && MulticastSource$$1.prototype );
1309− HoldSource.prototype.constructor = HoldSource;
1311− HoldSource.prototype.add = function add (sink, scheduler) {
1313− pushEvents(this.buffer, sink, scheduler);
1316− return MulticastSource$$1.prototype.add.call(this, sink, scheduler)
1319− HoldSource.prototype.event = function event (time) {
1322− return function (value) {
1324− this$1.buffer = dropAndAppend(value, this$1.buffer, this$1.bufferSize);
1326− return MulticastSource$$1.prototype.event.call(this$1, time)(value)
1331−}(MulticastSource));
1333−function pushEvents (buffer, sink, scheduler) {
1334− var length = buffer.length;
1336− for (var i = 0; i < length; ++i) {
1337− sink.event(scheduler.now(), buffer[i]);
1341−function dropAndAppend (value, buffer, bufferSize) {
1342− if (buffer.length === bufferSize) {
1343− return append(value, drop(1, buffer))
1346− return append(value, buffer)
1349−function multicast (stream) {
1350− var source = stream.source;
1352− return source instanceof MulticastSource
1354− : new Stream(new MulticastSource(source))
1357−var hold = function (bufferSize) { return function (stream) { return new Stream(new HoldSource(stream.source, bufferSize)); }; };
1361−exports.createDisposable = createDisposable;
1362−exports.emptyDisposable = emptyDisposable;
1363−exports.disposeAll = disposeAll;
1364−exports.defaultScheduler = defaultScheduler;
1365−exports.scheduleTasks = scheduleTasks;
1366−exports.endTask = endTask;
1367−exports.eventTask = eventTask;
1368−exports.drain = drain;
1369−exports.flatMap = flatMap;
1370−exports.mergeConcurrently = mergeConcurrently;
1371−exports.join = join;
1372−exports.mergeMapConcurrently = mergeMapConcurrently;
1373−exports.combine2 = combine2;
1374−exports.combine3 = combine3;
1375−exports.combine4 = combine4;
1376−exports.combine5 = combine5;
1377−exports.merge = merge;
1378−exports.concat = concat;
1379−exports.continueWith = continueWith;
1380−exports.switch = switchLatest;
1381−exports.skipRepeatsWith = skipRepeatsWith;
1382−exports.delay = delay;
1383−exports.multicast = multicast;
1384−exports.hold = hold;