1 |
|
2 |
|
3 |
|
4 |
|
5 | function createObj(proto) {
|
6 | var F = function () {};
|
7 | F.prototype = proto;
|
8 | return new F();
|
9 | }
|
10 |
|
11 | function extend(target /*, mixin1, mixin2...*/) {
|
12 | var length = arguments.length,
|
13 | i = void 0,
|
14 | prop = void 0;
|
15 | for (i = 1; i < length; i++) {
|
16 | for (prop in arguments[i]) {
|
17 | target[prop] = arguments[i][prop];
|
18 | }
|
19 | }
|
20 | return target;
|
21 | }
|
22 |
|
23 | function inherit(Child, Parent /*, mixin1, mixin2...*/) {
|
24 | var length = arguments.length,
|
25 | i = void 0;
|
26 | Child.prototype = createObj(Parent.prototype);
|
27 | Child.prototype.constructor = Child;
|
28 | for (i = 2; i < length; i++) {
|
29 | extend(Child.prototype, arguments[i]);
|
30 | }
|
31 | return Child;
|
32 | }
|
33 |
|
34 | var NOTHING = ['<nothing>'];
|
35 | var END = 'end';
|
36 | var VALUE = 'value';
|
37 | var ERROR = 'error';
|
38 | var ANY = 'any';
|
39 |
|
40 | function concat(a, b) {
|
41 | var result = void 0,
|
42 | length = void 0,
|
43 | i = void 0,
|
44 | j = void 0;
|
45 | if (a.length === 0) {
|
46 | return b;
|
47 | }
|
48 | if (b.length === 0) {
|
49 | return a;
|
50 | }
|
51 | j = 0;
|
52 | result = new Array(a.length + b.length);
|
53 | length = a.length;
|
54 | for (i = 0; i < length; i++, j++) {
|
55 | result[j] = a[i];
|
56 | }
|
57 | length = b.length;
|
58 | for (i = 0; i < length; i++, j++) {
|
59 | result[j] = b[i];
|
60 | }
|
61 | return result;
|
62 | }
|
63 |
|
64 | function find(arr, value) {
|
65 | var length = arr.length,
|
66 | i = void 0;
|
67 | for (i = 0; i < length; i++) {
|
68 | if (arr[i] === value) {
|
69 | return i;
|
70 | }
|
71 | }
|
72 | return -1;
|
73 | }
|
74 |
|
75 | function findByPred(arr, pred) {
|
76 | var length = arr.length,
|
77 | i = void 0;
|
78 | for (i = 0; i < length; i++) {
|
79 | if (pred(arr[i])) {
|
80 | return i;
|
81 | }
|
82 | }
|
83 | return -1;
|
84 | }
|
85 |
|
86 | function cloneArray(input) {
|
87 | var length = input.length,
|
88 | result = new Array(length),
|
89 | i = void 0;
|
90 | for (i = 0; i < length; i++) {
|
91 | result[i] = input[i];
|
92 | }
|
93 | return result;
|
94 | }
|
95 |
|
96 | function remove(input, index) {
|
97 | var length = input.length,
|
98 | result = void 0,
|
99 | i = void 0,
|
100 | j = void 0;
|
101 | if (index >= 0 && index < length) {
|
102 | if (length === 1) {
|
103 | return [];
|
104 | } else {
|
105 | result = new Array(length - 1);
|
106 | for (i = 0, j = 0; i < length; i++) {
|
107 | if (i !== index) {
|
108 | result[j] = input[i];
|
109 | j++;
|
110 | }
|
111 | }
|
112 | return result;
|
113 | }
|
114 | } else {
|
115 | return input;
|
116 | }
|
117 | }
|
118 |
|
119 | function map(input, fn) {
|
120 | var length = input.length,
|
121 | result = new Array(length),
|
122 | i = void 0;
|
123 | for (i = 0; i < length; i++) {
|
124 | result[i] = fn(input[i]);
|
125 | }
|
126 | return result;
|
127 | }
|
128 |
|
129 | function forEach(arr, fn) {
|
130 | var length = arr.length,
|
131 | i = void 0;
|
132 | for (i = 0; i < length; i++) {
|
133 | fn(arr[i]);
|
134 | }
|
135 | }
|
136 |
|
137 | function fillArray(arr, value) {
|
138 | var length = arr.length,
|
139 | i = void 0;
|
140 | for (i = 0; i < length; i++) {
|
141 | arr[i] = value;
|
142 | }
|
143 | }
|
144 |
|
145 | function contains(arr, value) {
|
146 | return find(arr, value) !== -1;
|
147 | }
|
148 |
|
149 | function slide(cur, next, max) {
|
150 | var length = Math.min(max, cur.length + 1),
|
151 | offset = cur.length - length + 1,
|
152 | result = new Array(length),
|
153 | i = void 0;
|
154 | for (i = offset; i < length; i++) {
|
155 | result[i - offset] = cur[i];
|
156 | }
|
157 | result[length - 1] = next;
|
158 | return result;
|
159 | }
|
160 |
|
161 | function callSubscriber(type, fn, event) {
|
162 | if (type === ANY) {
|
163 | fn(event);
|
164 | } else if (type === event.type) {
|
165 | if (type === VALUE || type === ERROR) {
|
166 | fn(event.value);
|
167 | } else {
|
168 | fn();
|
169 | }
|
170 | }
|
171 | }
|
172 |
|
173 | function Dispatcher() {
|
174 | this._items = [];
|
175 | this._spies = [];
|
176 | this._inLoop = 0;
|
177 | this._removedItems = null;
|
178 | }
|
179 |
|
180 | extend(Dispatcher.prototype, {
|
181 | add: function (type, fn) {
|
182 | this._items = concat(this._items, [{ type: type, fn: fn }]);
|
183 | return this._items.length;
|
184 | },
|
185 | remove: function (type, fn) {
|
186 | var index = findByPred(this._items, function (x) {
|
187 | return x.type === type && x.fn === fn;
|
188 | });
|
189 |
|
190 |
|
191 |
|
192 | if (this._inLoop !== 0 && index !== -1) {
|
193 | if (this._removedItems === null) {
|
194 | this._removedItems = [];
|
195 | }
|
196 | this._removedItems.push(this._items[index]);
|
197 | }
|
198 |
|
199 | this._items = remove(this._items, index);
|
200 | return this._items.length;
|
201 | },
|
202 | addSpy: function (fn) {
|
203 | this._spies = concat(this._spies, [fn]);
|
204 | return this._spies.length;
|
205 | },
|
206 |
|
207 |
|
208 |
|
209 |
|
210 |
|
211 | removeSpy: function (fn) {
|
212 | this._spies = remove(this._spies, this._spies.indexOf(fn));
|
213 | return this._spies.length;
|
214 | },
|
215 | dispatch: function (event) {
|
216 | this._inLoop++;
|
217 | for (var i = 0, spies = this._spies; this._spies !== null && i < spies.length; i++) {
|
218 | spies[i](event);
|
219 | }
|
220 |
|
221 | for (var _i = 0, items = this._items; _i < items.length; _i++) {
|
222 |
|
223 | if (this._items === null) {
|
224 | break;
|
225 | }
|
226 |
|
227 |
|
228 | if (this._removedItems !== null && contains(this._removedItems, items[_i])) {
|
229 | continue;
|
230 | }
|
231 |
|
232 | callSubscriber(items[_i].type, items[_i].fn, event);
|
233 | }
|
234 | this._inLoop--;
|
235 | if (this._inLoop === 0) {
|
236 | this._removedItems = null;
|
237 | }
|
238 | },
|
239 | cleanup: function () {
|
240 | this._items = null;
|
241 | this._spies = null;
|
242 | }
|
243 | });
|
244 |
|
245 | function Observable() {
|
246 | this._dispatcher = new Dispatcher();
|
247 | this._active = false;
|
248 | this._alive = true;
|
249 | this._activating = false;
|
250 | this._logHandlers = null;
|
251 | this._spyHandlers = null;
|
252 | }
|
253 |
|
254 | extend(Observable.prototype, {
|
255 | _name: 'observable',
|
256 |
|
257 | _onActivation: function () {},
|
258 | _onDeactivation: function () {},
|
259 | _setActive: function (active) {
|
260 | if (this._active !== active) {
|
261 | this._active = active;
|
262 | if (active) {
|
263 | this._activating = true;
|
264 | this._onActivation();
|
265 | this._activating = false;
|
266 | } else {
|
267 | this._onDeactivation();
|
268 | }
|
269 | }
|
270 | },
|
271 | _clear: function () {
|
272 | this._setActive(false);
|
273 | this._dispatcher.cleanup();
|
274 | this._dispatcher = null;
|
275 | this._logHandlers = null;
|
276 | },
|
277 | _emit: function (type, x) {
|
278 | switch (type) {
|
279 | case VALUE:
|
280 | return this._emitValue(x);
|
281 | case ERROR:
|
282 | return this._emitError(x);
|
283 | case END:
|
284 | return this._emitEnd();
|
285 | }
|
286 | },
|
287 | _emitValue: function (value) {
|
288 | if (this._alive) {
|
289 | this._dispatcher.dispatch({ type: VALUE, value: value });
|
290 | }
|
291 | },
|
292 | _emitError: function (value) {
|
293 | if (this._alive) {
|
294 | this._dispatcher.dispatch({ type: ERROR, value: value });
|
295 | }
|
296 | },
|
297 | _emitEnd: function () {
|
298 | if (this._alive) {
|
299 | this._alive = false;
|
300 | this._dispatcher.dispatch({ type: END });
|
301 | this._clear();
|
302 | }
|
303 | },
|
304 | _on: function (type, fn) {
|
305 | if (this._alive) {
|
306 | this._dispatcher.add(type, fn);
|
307 | this._setActive(true);
|
308 | } else {
|
309 | callSubscriber(type, fn, { type: END });
|
310 | }
|
311 | return this;
|
312 | },
|
313 | _off: function (type, fn) {
|
314 | if (this._alive) {
|
315 | var count = this._dispatcher.remove(type, fn);
|
316 | if (count === 0) {
|
317 | this._setActive(false);
|
318 | }
|
319 | }
|
320 | return this;
|
321 | },
|
322 | onValue: function (fn) {
|
323 | return this._on(VALUE, fn);
|
324 | },
|
325 | onError: function (fn) {
|
326 | return this._on(ERROR, fn);
|
327 | },
|
328 | onEnd: function (fn) {
|
329 | return this._on(END, fn);
|
330 | },
|
331 | onAny: function (fn) {
|
332 | return this._on(ANY, fn);
|
333 | },
|
334 | offValue: function (fn) {
|
335 | return this._off(VALUE, fn);
|
336 | },
|
337 | offError: function (fn) {
|
338 | return this._off(ERROR, fn);
|
339 | },
|
340 | offEnd: function (fn) {
|
341 | return this._off(END, fn);
|
342 | },
|
343 | offAny: function (fn) {
|
344 | return this._off(ANY, fn);
|
345 | },
|
346 | observe: function (observerOrOnValue, onError, onEnd) {
|
347 | var _this = this;
|
348 | var closed = false;
|
349 |
|
350 | var observer = !observerOrOnValue || typeof observerOrOnValue === 'function' ? { value: observerOrOnValue, error: onError, end: onEnd } : observerOrOnValue;
|
351 |
|
352 | var handler = function (event) {
|
353 | if (event.type === END) {
|
354 | closed = true;
|
355 | }
|
356 | if (event.type === VALUE && observer.value) {
|
357 | observer.value(event.value);
|
358 | } else if (event.type === ERROR && observer.error) {
|
359 | observer.error(event.value);
|
360 | } else if (event.type === END && observer.end) {
|
361 | observer.end(event.value);
|
362 | }
|
363 | };
|
364 |
|
365 | this.onAny(handler);
|
366 |
|
367 | return {
|
368 | unsubscribe: function () {
|
369 | if (!closed) {
|
370 | _this.offAny(handler);
|
371 | closed = true;
|
372 | }
|
373 | },
|
374 |
|
375 | get closed() {
|
376 | return closed;
|
377 | }
|
378 | };
|
379 | },
|
380 |
|
381 |
|
382 |
|
383 | _ofSameType: function (A, B) {
|
384 | return A.prototype.getType() === this.getType() ? A : B;
|
385 | },
|
386 | setName: function (sourceObs /* optional */, selfName) {
|
387 | this._name = selfName ? sourceObs._name + '.' + selfName : sourceObs;
|
388 | return this;
|
389 | },
|
390 | log: function () {
|
391 | var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.toString();
|
392 |
|
393 | var isCurrent = void 0;
|
394 | var handler = function (event) {
|
395 | var type = '<' + event.type + (isCurrent ? ':current' : '') + '>';
|
396 | if (event.type === END) {
|
397 | console.log(name, type);
|
398 | } else {
|
399 | console.log(name, type, event.value);
|
400 | }
|
401 | };
|
402 |
|
403 | if (this._alive) {
|
404 | if (!this._logHandlers) {
|
405 | this._logHandlers = [];
|
406 | }
|
407 | this._logHandlers.push({ name: name, handler: handler });
|
408 | }
|
409 |
|
410 | isCurrent = true;
|
411 | this.onAny(handler);
|
412 | isCurrent = false;
|
413 |
|
414 | return this;
|
415 | },
|
416 | offLog: function () {
|
417 | var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.toString();
|
418 |
|
419 | if (this._logHandlers) {
|
420 | var handlerIndex = findByPred(this._logHandlers, function (obj) {
|
421 | return obj.name === name;
|
422 | });
|
423 | if (handlerIndex !== -1) {
|
424 | this.offAny(this._logHandlers[handlerIndex].handler);
|
425 | this._logHandlers.splice(handlerIndex, 1);
|
426 | }
|
427 | }
|
428 |
|
429 | return this;
|
430 | },
|
431 | spy: function () {
|
432 | var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.toString();
|
433 |
|
434 | var handler = function (event) {
|
435 | var type = '<' + event.type + '>';
|
436 | if (event.type === END) {
|
437 | console.log(name, type);
|
438 | } else {
|
439 | console.log(name, type, event.value);
|
440 | }
|
441 | };
|
442 | if (this._alive) {
|
443 | if (!this._spyHandlers) {
|
444 | this._spyHandlers = [];
|
445 | }
|
446 | this._spyHandlers.push({ name: name, handler: handler });
|
447 | this._dispatcher.addSpy(handler);
|
448 | }
|
449 | return this;
|
450 | },
|
451 | offSpy: function () {
|
452 | var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.toString();
|
453 |
|
454 | if (this._spyHandlers) {
|
455 | var handlerIndex = findByPred(this._spyHandlers, function (obj) {
|
456 | return obj.name === name;
|
457 | });
|
458 | if (handlerIndex !== -1) {
|
459 | this._dispatcher.removeSpy(this._spyHandlers[handlerIndex].handler);
|
460 | this._spyHandlers.splice(handlerIndex, 1);
|
461 | }
|
462 | }
|
463 | return this;
|
464 | }
|
465 | });
|
466 |
|
467 |
|
468 | Observable.prototype.toString = function () {
|
469 | return '[' + this._name + ']';
|
470 | };
|
471 |
|
472 | function Stream() {
|
473 | Observable.call(this);
|
474 | }
|
475 |
|
476 | inherit(Stream, Observable, {
|
477 | _name: 'stream',
|
478 |
|
479 | getType: function () {
|
480 | return 'stream';
|
481 | }
|
482 | });
|
483 |
|
484 | function Property() {
|
485 | Observable.call(this);
|
486 | this._currentEvent = null;
|
487 | }
|
488 |
|
489 | inherit(Property, Observable, {
|
490 | _name: 'property',
|
491 |
|
492 | _emitValue: function (value) {
|
493 | if (this._alive) {
|
494 | this._currentEvent = { type: VALUE, value: value };
|
495 | if (!this._activating) {
|
496 | this._dispatcher.dispatch({ type: VALUE, value: value });
|
497 | }
|
498 | }
|
499 | },
|
500 | _emitError: function (value) {
|
501 | if (this._alive) {
|
502 | this._currentEvent = { type: ERROR, value: value };
|
503 | if (!this._activating) {
|
504 | this._dispatcher.dispatch({ type: ERROR, value: value });
|
505 | }
|
506 | }
|
507 | },
|
508 | _emitEnd: function () {
|
509 | if (this._alive) {
|
510 | this._alive = false;
|
511 | if (!this._activating) {
|
512 | this._dispatcher.dispatch({ type: END });
|
513 | }
|
514 | this._clear();
|
515 | }
|
516 | },
|
517 | _on: function (type, fn) {
|
518 | if (this._alive) {
|
519 | this._dispatcher.add(type, fn);
|
520 | this._setActive(true);
|
521 | }
|
522 | if (this._currentEvent !== null) {
|
523 | callSubscriber(type, fn, this._currentEvent);
|
524 | }
|
525 | if (!this._alive) {
|
526 | callSubscriber(type, fn, { type: END });
|
527 | }
|
528 | return this;
|
529 | },
|
530 | getType: function () {
|
531 | return 'property';
|
532 | }
|
533 | });
|
534 |
|
535 | var neverS = new Stream();
|
536 | neverS._emitEnd();
|
537 | neverS._name = 'never';
|
538 |
|
539 | function never() {
|
540 | return neverS;
|
541 | }
|
542 |
|
543 | function timeBased(mixin) {
|
544 | function AnonymousStream(wait, options) {
|
545 | var _this = this;
|
546 |
|
547 | Stream.call(this);
|
548 | this._wait = wait;
|
549 | this._intervalId = null;
|
550 | this._$onTick = function () {
|
551 | return _this._onTick();
|
552 | };
|
553 | this._init(options);
|
554 | }
|
555 |
|
556 | inherit(AnonymousStream, Stream, {
|
557 | _init: function () {},
|
558 | _free: function () {},
|
559 | _onTick: function () {},
|
560 | _onActivation: function () {
|
561 | this._intervalId = setInterval(this._$onTick, this._wait);
|
562 | },
|
563 | _onDeactivation: function () {
|
564 | if (this._intervalId !== null) {
|
565 | clearInterval(this._intervalId);
|
566 | this._intervalId = null;
|
567 | }
|
568 | },
|
569 | _clear: function () {
|
570 | Stream.prototype._clear.call(this);
|
571 | this._$onTick = null;
|
572 | this._free();
|
573 | }
|
574 | }, mixin);
|
575 |
|
576 | return AnonymousStream;
|
577 | }
|
578 |
|
579 | var S = timeBased({
|
580 | _name: 'later',
|
581 |
|
582 | _init: function (_ref) {
|
583 | var x = _ref.x;
|
584 |
|
585 | this._x = x;
|
586 | },
|
587 | _free: function () {
|
588 | this._x = null;
|
589 | },
|
590 | _onTick: function () {
|
591 | this._emitValue(this._x);
|
592 | this._emitEnd();
|
593 | }
|
594 | });
|
595 |
|
596 | function later(wait, x) {
|
597 | return new S(wait, { x: x });
|
598 | }
|
599 |
|
600 | var S$1 = timeBased({
|
601 | _name: 'interval',
|
602 |
|
603 | _init: function (_ref) {
|
604 | var x = _ref.x;
|
605 |
|
606 | this._x = x;
|
607 | },
|
608 | _free: function () {
|
609 | this._x = null;
|
610 | },
|
611 | _onTick: function () {
|
612 | this._emitValue(this._x);
|
613 | }
|
614 | });
|
615 |
|
616 | function interval(wait, x) {
|
617 | return new S$1(wait, { x: x });
|
618 | }
|
619 |
|
620 | var S$2 = timeBased({
|
621 | _name: 'sequentially',
|
622 |
|
623 | _init: function (_ref) {
|
624 | var xs = _ref.xs;
|
625 |
|
626 | this._xs = cloneArray(xs);
|
627 | },
|
628 | _free: function () {
|
629 | this._xs = null;
|
630 | },
|
631 | _onTick: function () {
|
632 | if (this._xs.length === 1) {
|
633 | this._emitValue(this._xs[0]);
|
634 | this._emitEnd();
|
635 | } else {
|
636 | this._emitValue(this._xs.shift());
|
637 | }
|
638 | }
|
639 | });
|
640 |
|
641 | function sequentially(wait, xs) {
|
642 | return xs.length === 0 ? never() : new S$2(wait, { xs: xs });
|
643 | }
|
644 |
|
645 | var S$3 = timeBased({
|
646 | _name: 'fromPoll',
|
647 |
|
648 | _init: function (_ref) {
|
649 | var fn = _ref.fn;
|
650 |
|
651 | this._fn = fn;
|
652 | },
|
653 | _free: function () {
|
654 | this._fn = null;
|
655 | },
|
656 | _onTick: function () {
|
657 | var fn = this._fn;
|
658 | this._emitValue(fn());
|
659 | }
|
660 | });
|
661 |
|
662 | function fromPoll(wait, fn) {
|
663 | return new S$3(wait, { fn: fn });
|
664 | }
|
665 |
|
666 | function emitter(obs) {
|
667 | function value(x) {
|
668 | obs._emitValue(x);
|
669 | return obs._active;
|
670 | }
|
671 |
|
672 | function error(x) {
|
673 | obs._emitError(x);
|
674 | return obs._active;
|
675 | }
|
676 |
|
677 | function end() {
|
678 | obs._emitEnd();
|
679 | return obs._active;
|
680 | }
|
681 |
|
682 | function event(e) {
|
683 | obs._emit(e.type, e.value);
|
684 | return obs._active;
|
685 | }
|
686 |
|
687 | return {
|
688 | value: value,
|
689 | error: error,
|
690 | end: end,
|
691 | event: event,
|
692 |
|
693 |
|
694 | emit: value,
|
695 | emitEvent: event
|
696 | };
|
697 | }
|
698 |
|
699 | var S$4 = timeBased({
|
700 | _name: 'withInterval',
|
701 |
|
702 | _init: function (_ref) {
|
703 | var fn = _ref.fn;
|
704 |
|
705 | this._fn = fn;
|
706 | this._emitter = emitter(this);
|
707 | },
|
708 | _free: function () {
|
709 | this._fn = null;
|
710 | this._emitter = null;
|
711 | },
|
712 | _onTick: function () {
|
713 | var fn = this._fn;
|
714 | fn(this._emitter);
|
715 | }
|
716 | });
|
717 |
|
718 | function withInterval(wait, fn) {
|
719 | return new S$4(wait, { fn: fn });
|
720 | }
|
721 |
|
722 | function S$5(fn) {
|
723 | Stream.call(this);
|
724 | this._fn = fn;
|
725 | this._unsubscribe = null;
|
726 | }
|
727 |
|
728 | inherit(S$5, Stream, {
|
729 | _name: 'stream',
|
730 |
|
731 | _onActivation: function () {
|
732 | var fn = this._fn;
|
733 | var unsubscribe = fn(emitter(this));
|
734 | this._unsubscribe = typeof unsubscribe === 'function' ? unsubscribe : null;
|
735 |
|
736 |
|
737 | if (!this._active) {
|
738 | this._callUnsubscribe();
|
739 | }
|
740 | },
|
741 | _callUnsubscribe: function () {
|
742 | if (this._unsubscribe !== null) {
|
743 | this._unsubscribe();
|
744 | this._unsubscribe = null;
|
745 | }
|
746 | },
|
747 | _onDeactivation: function () {
|
748 | this._callUnsubscribe();
|
749 | },
|
750 | _clear: function () {
|
751 | Stream.prototype._clear.call(this);
|
752 | this._fn = null;
|
753 | }
|
754 | });
|
755 |
|
756 | function stream(fn) {
|
757 | return new S$5(fn);
|
758 | }
|
759 |
|
760 | function fromCallback(callbackConsumer) {
|
761 | var called = false;
|
762 |
|
763 | return stream(function (emitter) {
|
764 | if (!called) {
|
765 | callbackConsumer(function (x) {
|
766 | emitter.emit(x);
|
767 | emitter.end();
|
768 | });
|
769 | called = true;
|
770 | }
|
771 | }).setName('fromCallback');
|
772 | }
|
773 |
|
774 | function fromNodeCallback(callbackConsumer) {
|
775 | var called = false;
|
776 |
|
777 | return stream(function (emitter) {
|
778 | if (!called) {
|
779 | callbackConsumer(function (error, x) {
|
780 | if (error) {
|
781 | emitter.error(error);
|
782 | } else {
|
783 | emitter.emit(x);
|
784 | }
|
785 | emitter.end();
|
786 | });
|
787 | called = true;
|
788 | }
|
789 | }).setName('fromNodeCallback');
|
790 | }
|
791 |
|
792 | function spread(fn, length) {
|
793 | switch (length) {
|
794 | case 0:
|
795 | return function () {
|
796 | return fn();
|
797 | };
|
798 | case 1:
|
799 | return function (a) {
|
800 | return fn(a[0]);
|
801 | };
|
802 | case 2:
|
803 | return function (a) {
|
804 | return fn(a[0], a[1]);
|
805 | };
|
806 | case 3:
|
807 | return function (a) {
|
808 | return fn(a[0], a[1], a[2]);
|
809 | };
|
810 | case 4:
|
811 | return function (a) {
|
812 | return fn(a[0], a[1], a[2], a[3]);
|
813 | };
|
814 | default:
|
815 | return function (a) {
|
816 | return fn.apply(null, a);
|
817 | };
|
818 | }
|
819 | }
|
820 |
|
821 | function apply(fn, c, a) {
|
822 | var aLength = a ? a.length : 0;
|
823 | if (c == null) {
|
824 | switch (aLength) {
|
825 | case 0:
|
826 | return fn();
|
827 | case 1:
|
828 | return fn(a[0]);
|
829 | case 2:
|
830 | return fn(a[0], a[1]);
|
831 | case 3:
|
832 | return fn(a[0], a[1], a[2]);
|
833 | case 4:
|
834 | return fn(a[0], a[1], a[2], a[3]);
|
835 | default:
|
836 | return fn.apply(null, a);
|
837 | }
|
838 | } else {
|
839 | switch (aLength) {
|
840 | case 0:
|
841 | return fn.call(c);
|
842 | default:
|
843 | return fn.apply(c, a);
|
844 | }
|
845 | }
|
846 | }
|
847 |
|
848 | function fromSubUnsub(sub, unsub, transformer /* Function | falsey */) {
|
849 | return stream(function (emitter) {
|
850 | var handler = transformer ? function () {
|
851 | emitter.emit(apply(transformer, this, arguments));
|
852 | } : function (x) {
|
853 | emitter.emit(x);
|
854 | };
|
855 |
|
856 | sub(handler);
|
857 | return function () {
|
858 | return unsub(handler);
|
859 | };
|
860 | }).setName('fromSubUnsub');
|
861 | }
|
862 |
|
863 | var pairs = [['addEventListener', 'removeEventListener'], ['addListener', 'removeListener'], ['on', 'off']];
|
864 |
|
865 | function fromEvents(target, eventName, transformer) {
|
866 | var sub = void 0,
|
867 | unsub = void 0;
|
868 |
|
869 | for (var i = 0; i < pairs.length; i++) {
|
870 | if (typeof target[pairs[i][0]] === 'function' && typeof target[pairs[i][1]] === 'function') {
|
871 | sub = pairs[i][0];
|
872 | unsub = pairs[i][1];
|
873 | break;
|
874 | }
|
875 | }
|
876 |
|
877 | if (sub === undefined) {
|
878 | throw new Error("target don't support any of " + 'addEventListener/removeEventListener, addListener/removeListener, on/off method pair');
|
879 | }
|
880 |
|
881 | return fromSubUnsub(function (handler) {
|
882 | return target[sub](eventName, handler);
|
883 | }, function (handler) {
|
884 | return target[unsub](eventName, handler);
|
885 | }, transformer).setName('fromEvents');
|
886 | }
|
887 |
|
888 |
|
889 |
|
890 |
|
891 |
|
892 |
|
893 | function P(value) {
|
894 | this._currentEvent = { type: 'value', value: value, current: true };
|
895 | }
|
896 |
|
897 | inherit(P, Property, {
|
898 | _name: 'constant',
|
899 | _active: false,
|
900 | _activating: false,
|
901 | _alive: false,
|
902 | _dispatcher: null,
|
903 | _logHandlers: null
|
904 | });
|
905 |
|
906 | function constant(x) {
|
907 | return new P(x);
|
908 | }
|
909 |
|
910 |
|
911 |
|
912 |
|
913 |
|
914 |
|
915 | function P$1(value) {
|
916 | this._currentEvent = { type: 'error', value: value, current: true };
|
917 | }
|
918 |
|
919 | inherit(P$1, Property, {
|
920 | _name: 'constantError',
|
921 | _active: false,
|
922 | _activating: false,
|
923 | _alive: false,
|
924 | _dispatcher: null,
|
925 | _logHandlers: null
|
926 | });
|
927 |
|
928 | function constantError(x) {
|
929 | return new P$1(x);
|
930 | }
|
931 |
|
932 | function createConstructor(BaseClass, name) {
|
933 | return function AnonymousObservable(source, options) {
|
934 | var _this = this;
|
935 |
|
936 | BaseClass.call(this);
|
937 | this._source = source;
|
938 | this._name = source._name + '.' + name;
|
939 | this._init(options);
|
940 | this._$handleAny = function (event) {
|
941 | return _this._handleAny(event);
|
942 | };
|
943 | };
|
944 | }
|
945 |
|
946 | function createClassMethods(BaseClass) {
|
947 | return {
|
948 | _init: function () {},
|
949 | _free: function () {},
|
950 | _handleValue: function (x) {
|
951 | this._emitValue(x);
|
952 | },
|
953 | _handleError: function (x) {
|
954 | this._emitError(x);
|
955 | },
|
956 | _handleEnd: function () {
|
957 | this._emitEnd();
|
958 | },
|
959 | _handleAny: function (event) {
|
960 | switch (event.type) {
|
961 | case VALUE:
|
962 | return this._handleValue(event.value);
|
963 | case ERROR:
|
964 | return this._handleError(event.value);
|
965 | case END:
|
966 | return this._handleEnd();
|
967 | }
|
968 | },
|
969 | _onActivation: function () {
|
970 | this._source.onAny(this._$handleAny);
|
971 | },
|
972 | _onDeactivation: function () {
|
973 | this._source.offAny(this._$handleAny);
|
974 | },
|
975 | _clear: function () {
|
976 | BaseClass.prototype._clear.call(this);
|
977 | this._source = null;
|
978 | this._$handleAny = null;
|
979 | this._free();
|
980 | }
|
981 | };
|
982 | }
|
983 |
|
984 | function createStream(name, mixin) {
|
985 | var S = createConstructor(Stream, name);
|
986 | inherit(S, Stream, createClassMethods(Stream), mixin);
|
987 | return S;
|
988 | }
|
989 |
|
990 | function createProperty(name, mixin) {
|
991 | var P = createConstructor(Property, name);
|
992 | inherit(P, Property, createClassMethods(Property), mixin);
|
993 | return P;
|
994 | }
|
995 |
|
996 | var P$2 = createProperty('toProperty', {
|
997 | _init: function (_ref) {
|
998 | var fn = _ref.fn;
|
999 |
|
1000 | this._getInitialCurrent = fn;
|
1001 | },
|
1002 | _onActivation: function () {
|
1003 | if (this._getInitialCurrent !== null) {
|
1004 | var getInitial = this._getInitialCurrent;
|
1005 | this._emitValue(getInitial());
|
1006 | }
|
1007 | this._source.onAny(this._$handleAny);
|
1008 | }
|
1009 | });
|
1010 |
|
1011 | function toProperty(obs) {
|
1012 | var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
1013 |
|
1014 | if (fn !== null && typeof fn !== 'function') {
|
1015 | throw new Error('You should call toProperty() with a function or no arguments.');
|
1016 | }
|
1017 | return new P$2(obs, { fn: fn });
|
1018 | }
|
1019 |
|
1020 | var S$6 = createStream('changes', {
|
1021 | _handleValue: function (x) {
|
1022 | if (!this._activating) {
|
1023 | this._emitValue(x);
|
1024 | }
|
1025 | },
|
1026 | _handleError: function (x) {
|
1027 | if (!this._activating) {
|
1028 | this._emitError(x);
|
1029 | }
|
1030 | }
|
1031 | });
|
1032 |
|
1033 | function changes(obs) {
|
1034 | return new S$6(obs);
|
1035 | }
|
1036 |
|
1037 | function fromPromise(promise) {
|
1038 | var called = false;
|
1039 |
|
1040 | var result = stream(function (emitter) {
|
1041 | if (!called) {
|
1042 | var onValue = function (x) {
|
1043 | emitter.emit(x);
|
1044 | emitter.end();
|
1045 | };
|
1046 | var onError = function (x) {
|
1047 | emitter.error(x);
|
1048 | emitter.end();
|
1049 | };
|
1050 | var _promise = promise.then(onValue, onError);
|
1051 |
|
1052 |
|
1053 | if (_promise && typeof _promise.done === 'function') {
|
1054 | _promise.done();
|
1055 | }
|
1056 |
|
1057 | called = true;
|
1058 | }
|
1059 | });
|
1060 |
|
1061 | return toProperty(result, null).setName('fromPromise');
|
1062 | }
|
1063 |
|
1064 | function getGlodalPromise() {
|
1065 | if (typeof Promise === 'function') {
|
1066 | return Promise;
|
1067 | } else {
|
1068 | throw new Error("There isn't default Promise, use shim or parameter");
|
1069 | }
|
1070 | }
|
1071 |
|
1072 | var toPromise = function (obs) {
|
1073 | var Promise = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getGlodalPromise();
|
1074 |
|
1075 | var last = null;
|
1076 | return new Promise(function (resolve, reject) {
|
1077 | obs.onAny(function (event) {
|
1078 | if (event.type === END && last !== null) {
|
1079 | (last.type === VALUE ? resolve : reject)(last.value);
|
1080 | last = null;
|
1081 | } else {
|
1082 | last = event;
|
1083 | }
|
1084 | });
|
1085 | });
|
1086 | };
|
1087 |
|
1088 | var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
1089 |
|
1090 |
|
1091 |
|
1092 |
|
1093 |
|
1094 | function createCommonjsModule(fn, module) {
|
1095 | return module = { exports: {} }, fn(module, module.exports), module.exports;
|
1096 | }
|
1097 |
|
1098 | var ponyfill = createCommonjsModule(function (module, exports) {
|
1099 | 'use strict';
|
1100 |
|
1101 | Object.defineProperty(exports, "__esModule", {
|
1102 | value: true
|
1103 | });
|
1104 | exports['default'] = symbolObservablePonyfill;
|
1105 | function symbolObservablePonyfill(root) {
|
1106 | var result;
|
1107 | var _Symbol = root.Symbol;
|
1108 |
|
1109 | if (typeof _Symbol === 'function') {
|
1110 | if (_Symbol.observable) {
|
1111 | result = _Symbol.observable;
|
1112 | } else {
|
1113 | result = _Symbol('observable');
|
1114 | _Symbol.observable = result;
|
1115 | }
|
1116 | } else {
|
1117 | result = '@@observable';
|
1118 | }
|
1119 |
|
1120 | return result;
|
1121 | }
|
1122 | });
|
1123 |
|
1124 | var index$1 = createCommonjsModule(function (module, exports) {
|
1125 | 'use strict';
|
1126 |
|
1127 | Object.defineProperty(exports, "__esModule", {
|
1128 | value: true
|
1129 | });
|
1130 |
|
1131 |
|
1132 |
|
1133 | var _ponyfill2 = _interopRequireDefault(ponyfill);
|
1134 |
|
1135 | function _interopRequireDefault(obj) {
|
1136 | return obj && obj.__esModule ? obj : { 'default': obj };
|
1137 | }
|
1138 |
|
1139 | var root;
|
1140 |
|
1141 | if (typeof self !== 'undefined') {
|
1142 | root = self;
|
1143 | } else if (typeof window !== 'undefined') {
|
1144 | root = window;
|
1145 | } else if (typeof commonjsGlobal !== 'undefined') {
|
1146 | root = commonjsGlobal;
|
1147 | } else {
|
1148 | root = module;
|
1149 | }
|
1150 |
|
1151 | var result = (0, _ponyfill2['default'])(root);
|
1152 | exports['default'] = result;
|
1153 | });
|
1154 |
|
1155 | var index = index$1;
|
1156 |
|
1157 |
|
1158 |
|
1159 | var $$observable = index.default ? index.default : index;
|
1160 |
|
1161 | function fromESObservable(_observable) {
|
1162 | var observable = _observable[$$observable] ? _observable[$$observable]() : _observable;
|
1163 | return stream(function (emitter) {
|
1164 | var unsub = observable.subscribe({
|
1165 | error: function (error) {
|
1166 | emitter.error(error);
|
1167 | emitter.end();
|
1168 | },
|
1169 | next: function (value) {
|
1170 | emitter.emit(value);
|
1171 | },
|
1172 | complete: function () {
|
1173 | emitter.end();
|
1174 | }
|
1175 | });
|
1176 |
|
1177 | if (unsub.unsubscribe) {
|
1178 | return function () {
|
1179 | unsub.unsubscribe();
|
1180 | };
|
1181 | } else {
|
1182 | return unsub;
|
1183 | }
|
1184 | }).setName('fromESObservable');
|
1185 | }
|
1186 |
|
1187 | function ESObservable(observable) {
|
1188 | this._observable = observable.takeErrors(1);
|
1189 | }
|
1190 |
|
1191 | extend(ESObservable.prototype, {
|
1192 | subscribe: function (observerOrOnNext, onError, onComplete) {
|
1193 | var _this = this;
|
1194 |
|
1195 | var observer = typeof observerOrOnNext === 'function' ? { next: observerOrOnNext, error: onError, complete: onComplete } : observerOrOnNext;
|
1196 |
|
1197 | var fn = function (event) {
|
1198 | if (event.type === END) {
|
1199 | closed = true;
|
1200 | }
|
1201 |
|
1202 | if (event.type === VALUE && observer.next) {
|
1203 | observer.next(event.value);
|
1204 | } else if (event.type === ERROR && observer.error) {
|
1205 | observer.error(event.value);
|
1206 | } else if (event.type === END && observer.complete) {
|
1207 | observer.complete(event.value);
|
1208 | }
|
1209 | };
|
1210 |
|
1211 | this._observable.onAny(fn);
|
1212 | var closed = false;
|
1213 |
|
1214 | var subscription = {
|
1215 | unsubscribe: function () {
|
1216 | closed = true;
|
1217 | _this._observable.offAny(fn);
|
1218 | },
|
1219 | get closed() {
|
1220 | return closed;
|
1221 | }
|
1222 | };
|
1223 | return subscription;
|
1224 | }
|
1225 | });
|
1226 |
|
1227 |
|
1228 | ESObservable.prototype[$$observable] = function () {
|
1229 | return this;
|
1230 | };
|
1231 |
|
1232 | function toESObservable() {
|
1233 | return new ESObservable(this);
|
1234 | }
|
1235 |
|
1236 | function collect(source, keys, values) {
|
1237 | for (var prop in source) {
|
1238 | if (source.hasOwnProperty(prop)) {
|
1239 | keys.push(prop);
|
1240 | values.push(source[prop]);
|
1241 | }
|
1242 | }
|
1243 | }
|
1244 |
|
1245 | function defaultErrorsCombinator(errors) {
|
1246 | var latestError = void 0;
|
1247 | for (var i = 0; i < errors.length; i++) {
|
1248 | if (errors[i] !== undefined) {
|
1249 | if (latestError === undefined || latestError.index < errors[i].index) {
|
1250 | latestError = errors[i];
|
1251 | }
|
1252 | }
|
1253 | }
|
1254 | return latestError.error;
|
1255 | }
|
1256 |
|
1257 | function Combine(active, passive, combinator) {
|
1258 | var _this = this;
|
1259 |
|
1260 | Stream.call(this);
|
1261 | this._activeCount = active.length;
|
1262 | this._sources = concat(active, passive);
|
1263 | this._combinator = combinator;
|
1264 | this._aliveCount = 0;
|
1265 | this._latestValues = new Array(this._sources.length);
|
1266 | this._latestErrors = new Array(this._sources.length);
|
1267 | fillArray(this._latestValues, NOTHING);
|
1268 | this._emitAfterActivation = false;
|
1269 | this._endAfterActivation = false;
|
1270 | this._latestErrorIndex = 0;
|
1271 |
|
1272 | this._$handlers = [];
|
1273 |
|
1274 | var _loop = function (i) {
|
1275 | _this._$handlers.push(function (event) {
|
1276 | return _this._handleAny(i, event);
|
1277 | });
|
1278 | };
|
1279 |
|
1280 | for (var i = 0; i < this._sources.length; i++) {
|
1281 | _loop(i);
|
1282 | }
|
1283 | }
|
1284 |
|
1285 | inherit(Combine, Stream, {
|
1286 | _name: 'combine',
|
1287 |
|
1288 | _onActivation: function () {
|
1289 | this._aliveCount = this._activeCount;
|
1290 |
|
1291 |
|
1292 |
|
1293 | for (var i = this._activeCount; i < this._sources.length; i++) {
|
1294 | this._sources[i].onAny(this._$handlers[i]);
|
1295 | }
|
1296 | for (var _i = 0; _i < this._activeCount; _i++) {
|
1297 | this._sources[_i].onAny(this._$handlers[_i]);
|
1298 | }
|
1299 |
|
1300 | if (this._emitAfterActivation) {
|
1301 | this._emitAfterActivation = false;
|
1302 | this._emitIfFull();
|
1303 | }
|
1304 | if (this._endAfterActivation) {
|
1305 | this._emitEnd();
|
1306 | }
|
1307 | },
|
1308 | _onDeactivation: function () {
|
1309 | var length = this._sources.length,
|
1310 | i = void 0;
|
1311 | for (i = 0; i < length; i++) {
|
1312 | this._sources[i].offAny(this._$handlers[i]);
|
1313 | }
|
1314 | },
|
1315 | _emitIfFull: function () {
|
1316 | var hasAllValues = true;
|
1317 | var hasErrors = false;
|
1318 | var length = this._latestValues.length;
|
1319 | var valuesCopy = new Array(length);
|
1320 | var errorsCopy = new Array(length);
|
1321 |
|
1322 | for (var i = 0; i < length; i++) {
|
1323 | valuesCopy[i] = this._latestValues[i];
|
1324 | errorsCopy[i] = this._latestErrors[i];
|
1325 |
|
1326 | if (valuesCopy[i] === NOTHING) {
|
1327 | hasAllValues = false;
|
1328 | }
|
1329 |
|
1330 | if (errorsCopy[i] !== undefined) {
|
1331 | hasErrors = true;
|
1332 | }
|
1333 | }
|
1334 |
|
1335 | if (hasAllValues) {
|
1336 | var combinator = this._combinator;
|
1337 | this._emitValue(combinator(valuesCopy));
|
1338 | }
|
1339 | if (hasErrors) {
|
1340 | this._emitError(defaultErrorsCombinator(errorsCopy));
|
1341 | }
|
1342 | },
|
1343 | _handleAny: function (i, event) {
|
1344 | if (event.type === VALUE || event.type === ERROR) {
|
1345 | if (event.type === VALUE) {
|
1346 | this._latestValues[i] = event.value;
|
1347 | this._latestErrors[i] = undefined;
|
1348 | }
|
1349 | if (event.type === ERROR) {
|
1350 | this._latestValues[i] = NOTHING;
|
1351 | this._latestErrors[i] = {
|
1352 | index: this._latestErrorIndex++,
|
1353 | error: event.value
|
1354 | };
|
1355 | }
|
1356 |
|
1357 | if (i < this._activeCount) {
|
1358 | if (this._activating) {
|
1359 | this._emitAfterActivation = true;
|
1360 | } else {
|
1361 | this._emitIfFull();
|
1362 | }
|
1363 | }
|
1364 | } else {
|
1365 |
|
1366 |
|
1367 | if (i < this._activeCount) {
|
1368 | this._aliveCount--;
|
1369 | if (this._aliveCount === 0) {
|
1370 | if (this._activating) {
|
1371 | this._endAfterActivation = true;
|
1372 | } else {
|
1373 | this._emitEnd();
|
1374 | }
|
1375 | }
|
1376 | }
|
1377 | }
|
1378 | },
|
1379 | _clear: function () {
|
1380 | Stream.prototype._clear.call(this);
|
1381 | this._sources = null;
|
1382 | this._latestValues = null;
|
1383 | this._latestErrors = null;
|
1384 | this._combinator = null;
|
1385 | this._$handlers = null;
|
1386 | }
|
1387 | });
|
1388 |
|
1389 | function combineAsArray(active) {
|
1390 | var passive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
1391 | var combinator = arguments[2];
|
1392 |
|
1393 | if (!Array.isArray(passive)) {
|
1394 | throw new Error('Combine can only combine active and passive collections of the same type.');
|
1395 | }
|
1396 |
|
1397 | combinator = combinator ? spread(combinator, active.length + passive.length) : function (x) {
|
1398 | return x;
|
1399 | };
|
1400 | return active.length === 0 ? never() : new Combine(active, passive, combinator);
|
1401 | }
|
1402 |
|
1403 | function combineAsObject(active) {
|
1404 | var passive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
1405 | var combinator = arguments[2];
|
1406 |
|
1407 | if (typeof passive !== 'object' || Array.isArray(passive)) {
|
1408 | throw new Error('Combine can only combine active and passive collections of the same type.');
|
1409 | }
|
1410 |
|
1411 | var keys = [],
|
1412 | activeObservables = [],
|
1413 | passiveObservables = [];
|
1414 |
|
1415 | collect(active, keys, activeObservables);
|
1416 | collect(passive, keys, passiveObservables);
|
1417 |
|
1418 | var objectify = function (values) {
|
1419 | var event = {};
|
1420 | for (var i = values.length - 1; 0 <= i; i--) {
|
1421 | event[keys[i]] = values[i];
|
1422 | }
|
1423 | return combinator ? combinator(event) : event;
|
1424 | };
|
1425 |
|
1426 | return activeObservables.length === 0 ? never() : new Combine(activeObservables, passiveObservables, objectify);
|
1427 | }
|
1428 |
|
1429 | function combine(active, passive, combinator) {
|
1430 | if (typeof passive === 'function') {
|
1431 | combinator = passive;
|
1432 | passive = undefined;
|
1433 | }
|
1434 |
|
1435 | return Array.isArray(active) ? combineAsArray(active, passive, combinator) : combineAsObject(active, passive, combinator);
|
1436 | }
|
1437 |
|
1438 | var Observable$2 = {
|
1439 | empty: function () {
|
1440 | return never();
|
1441 | },
|
1442 |
|
1443 |
|
1444 |
|
1445 | concat: function (a, b) {
|
1446 | return a.merge(b);
|
1447 | },
|
1448 | of: function (x) {
|
1449 | return constant(x);
|
1450 | },
|
1451 | map: function (fn, obs) {
|
1452 | return obs.map(fn);
|
1453 | },
|
1454 | bimap: function (fnErr, fnVal, obs) {
|
1455 | return obs.mapErrors(fnErr).map(fnVal);
|
1456 | },
|
1457 |
|
1458 |
|
1459 |
|
1460 |
|
1461 |
|
1462 |
|
1463 | ap: function (obsFn, obsVal) {
|
1464 | return combine([obsFn, obsVal], function (fn, val) {
|
1465 | return fn(val);
|
1466 | });
|
1467 | },
|
1468 | chain: function (fn, obs) {
|
1469 | return obs.flatMap(fn);
|
1470 | }
|
1471 | };
|
1472 |
|
1473 |
|
1474 |
|
1475 | var staticLand = Object.freeze({
|
1476 | Observable: Observable$2
|
1477 | });
|
1478 |
|
1479 | var mixin = {
|
1480 | _init: function (_ref) {
|
1481 | var fn = _ref.fn;
|
1482 |
|
1483 | this._fn = fn;
|
1484 | },
|
1485 | _free: function () {
|
1486 | this._fn = null;
|
1487 | },
|
1488 | _handleValue: function (x) {
|
1489 | var fn = this._fn;
|
1490 | this._emitValue(fn(x));
|
1491 | }
|
1492 | };
|
1493 |
|
1494 | var S$7 = createStream('map', mixin);
|
1495 | var P$3 = createProperty('map', mixin);
|
1496 |
|
1497 | var id = function (x) {
|
1498 | return x;
|
1499 | };
|
1500 |
|
1501 | function map$1(obs) {
|
1502 | var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : id;
|
1503 |
|
1504 | return new (obs._ofSameType(S$7, P$3))(obs, { fn: fn });
|
1505 | }
|
1506 |
|
1507 | var mixin$1 = {
|
1508 | _init: function (_ref) {
|
1509 | var fn = _ref.fn;
|
1510 |
|
1511 | this._fn = fn;
|
1512 | },
|
1513 | _free: function () {
|
1514 | this._fn = null;
|
1515 | },
|
1516 | _handleValue: function (x) {
|
1517 | var fn = this._fn;
|
1518 | if (fn(x)) {
|
1519 | this._emitValue(x);
|
1520 | }
|
1521 | }
|
1522 | };
|
1523 |
|
1524 | var S$8 = createStream('filter', mixin$1);
|
1525 | var P$4 = createProperty('filter', mixin$1);
|
1526 |
|
1527 | var id$1 = function (x) {
|
1528 | return x;
|
1529 | };
|
1530 |
|
1531 | function filter(obs) {
|
1532 | var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : id$1;
|
1533 |
|
1534 | return new (obs._ofSameType(S$8, P$4))(obs, { fn: fn });
|
1535 | }
|
1536 |
|
1537 | var mixin$2 = {
|
1538 | _init: function (_ref) {
|
1539 | var n = _ref.n;
|
1540 |
|
1541 | this._n = n;
|
1542 | if (n <= 0) {
|
1543 | this._emitEnd();
|
1544 | }
|
1545 | },
|
1546 | _handleValue: function (x) {
|
1547 | if (this._n === 0) {
|
1548 | return;
|
1549 | }
|
1550 | this._n--;
|
1551 | this._emitValue(x);
|
1552 | if (this._n === 0) {
|
1553 | this._emitEnd();
|
1554 | }
|
1555 | }
|
1556 | };
|
1557 |
|
1558 | var S$9 = createStream('take', mixin$2);
|
1559 | var P$5 = createProperty('take', mixin$2);
|
1560 |
|
1561 | function take(obs, n) {
|
1562 | return new (obs._ofSameType(S$9, P$5))(obs, { n: n });
|
1563 | }
|
1564 |
|
1565 | var mixin$3 = {
|
1566 | _init: function (_ref) {
|
1567 | var n = _ref.n;
|
1568 |
|
1569 | this._n = n;
|
1570 | if (n <= 0) {
|
1571 | this._emitEnd();
|
1572 | }
|
1573 | },
|
1574 | _handleError: function (x) {
|
1575 | if (this._n === 0) {
|
1576 | return;
|
1577 | }
|
1578 | this._n--;
|
1579 | this._emitError(x);
|
1580 | if (this._n === 0) {
|
1581 | this._emitEnd();
|
1582 | }
|
1583 | }
|
1584 | };
|
1585 |
|
1586 | var S$10 = createStream('takeErrors', mixin$3);
|
1587 | var P$6 = createProperty('takeErrors', mixin$3);
|
1588 |
|
1589 | function takeErrors(obs, n) {
|
1590 | return new (obs._ofSameType(S$10, P$6))(obs, { n: n });
|
1591 | }
|
1592 |
|
1593 | var mixin$4 = {
|
1594 | _init: function (_ref) {
|
1595 | var fn = _ref.fn;
|
1596 |
|
1597 | this._fn = fn;
|
1598 | },
|
1599 | _free: function () {
|
1600 | this._fn = null;
|
1601 | },
|
1602 | _handleValue: function (x) {
|
1603 | var fn = this._fn;
|
1604 | if (fn(x)) {
|
1605 | this._emitValue(x);
|
1606 | } else {
|
1607 | this._emitEnd();
|
1608 | }
|
1609 | }
|
1610 | };
|
1611 |
|
1612 | var S$11 = createStream('takeWhile', mixin$4);
|
1613 | var P$7 = createProperty('takeWhile', mixin$4);
|
1614 |
|
1615 | var id$2 = function (x) {
|
1616 | return x;
|
1617 | };
|
1618 |
|
1619 | function takeWhile(obs) {
|
1620 | var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : id$2;
|
1621 |
|
1622 | return new (obs._ofSameType(S$11, P$7))(obs, { fn: fn });
|
1623 | }
|
1624 |
|
1625 | var mixin$5 = {
|
1626 | _init: function () {
|
1627 | this._lastValue = NOTHING;
|
1628 | },
|
1629 | _free: function () {
|
1630 | this._lastValue = null;
|
1631 | },
|
1632 | _handleValue: function (x) {
|
1633 | this._lastValue = x;
|
1634 | },
|
1635 | _handleEnd: function () {
|
1636 | if (this._lastValue !== NOTHING) {
|
1637 | this._emitValue(this._lastValue);
|
1638 | }
|
1639 | this._emitEnd();
|
1640 | }
|
1641 | };
|
1642 |
|
1643 | var S$12 = createStream('last', mixin$5);
|
1644 | var P$8 = createProperty('last', mixin$5);
|
1645 |
|
1646 | function last(obs) {
|
1647 | return new (obs._ofSameType(S$12, P$8))(obs);
|
1648 | }
|
1649 |
|
1650 | var mixin$6 = {
|
1651 | _init: function (_ref) {
|
1652 | var n = _ref.n;
|
1653 |
|
1654 | this._n = Math.max(0, n);
|
1655 | },
|
1656 | _handleValue: function (x) {
|
1657 | if (this._n === 0) {
|
1658 | this._emitValue(x);
|
1659 | } else {
|
1660 | this._n--;
|
1661 | }
|
1662 | }
|
1663 | };
|
1664 |
|
1665 | var S$13 = createStream('skip', mixin$6);
|
1666 | var P$9 = createProperty('skip', mixin$6);
|
1667 |
|
1668 | function skip(obs, n) {
|
1669 | return new (obs._ofSameType(S$13, P$9))(obs, { n: n });
|
1670 | }
|
1671 |
|
1672 | var mixin$7 = {
|
1673 | _init: function (_ref) {
|
1674 | var fn = _ref.fn;
|
1675 |
|
1676 | this._fn = fn;
|
1677 | },
|
1678 | _free: function () {
|
1679 | this._fn = null;
|
1680 | },
|
1681 | _handleValue: function (x) {
|
1682 | var fn = this._fn;
|
1683 | if (this._fn !== null && !fn(x)) {
|
1684 | this._fn = null;
|
1685 | }
|
1686 | if (this._fn === null) {
|
1687 | this._emitValue(x);
|
1688 | }
|
1689 | }
|
1690 | };
|
1691 |
|
1692 | var S$14 = createStream('skipWhile', mixin$7);
|
1693 | var P$10 = createProperty('skipWhile', mixin$7);
|
1694 |
|
1695 | var id$3 = function (x) {
|
1696 | return x;
|
1697 | };
|
1698 |
|
1699 | function skipWhile(obs) {
|
1700 | var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : id$3;
|
1701 |
|
1702 | return new (obs._ofSameType(S$14, P$10))(obs, { fn: fn });
|
1703 | }
|
1704 |
|
1705 | var mixin$8 = {
|
1706 | _init: function (_ref) {
|
1707 | var fn = _ref.fn;
|
1708 |
|
1709 | this._fn = fn;
|
1710 | this._prev = NOTHING;
|
1711 | },
|
1712 | _free: function () {
|
1713 | this._fn = null;
|
1714 | this._prev = null;
|
1715 | },
|
1716 | _handleValue: function (x) {
|
1717 | var fn = this._fn;
|
1718 | if (this._prev === NOTHING || !fn(this._prev, x)) {
|
1719 | this._prev = x;
|
1720 | this._emitValue(x);
|
1721 | }
|
1722 | }
|
1723 | };
|
1724 |
|
1725 | var S$15 = createStream('skipDuplicates', mixin$8);
|
1726 | var P$11 = createProperty('skipDuplicates', mixin$8);
|
1727 |
|
1728 | var eq = function (a, b) {
|
1729 | return a === b;
|
1730 | };
|
1731 |
|
1732 | function skipDuplicates(obs) {
|
1733 | var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : eq;
|
1734 |
|
1735 | return new (obs._ofSameType(S$15, P$11))(obs, { fn: fn });
|
1736 | }
|
1737 |
|
1738 | var mixin$9 = {
|
1739 | _init: function (_ref) {
|
1740 | var fn = _ref.fn,
|
1741 | seed = _ref.seed;
|
1742 |
|
1743 | this._fn = fn;
|
1744 | this._prev = seed;
|
1745 | },
|
1746 | _free: function () {
|
1747 | this._prev = null;
|
1748 | this._fn = null;
|
1749 | },
|
1750 | _handleValue: function (x) {
|
1751 | if (this._prev !== NOTHING) {
|
1752 | var fn = this._fn;
|
1753 | this._emitValue(fn(this._prev, x));
|
1754 | }
|
1755 | this._prev = x;
|
1756 | }
|
1757 | };
|
1758 |
|
1759 | var S$16 = createStream('diff', mixin$9);
|
1760 | var P$12 = createProperty('diff', mixin$9);
|
1761 |
|
1762 | function defaultFn(a, b) {
|
1763 | return [a, b];
|
1764 | }
|
1765 |
|
1766 | function diff(obs, fn) {
|
1767 | var seed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : NOTHING;
|
1768 |
|
1769 | return new (obs._ofSameType(S$16, P$12))(obs, { fn: fn || defaultFn, seed: seed });
|
1770 | }
|
1771 |
|
1772 | var P$13 = createProperty('scan', {
|
1773 | _init: function (_ref) {
|
1774 | var fn = _ref.fn,
|
1775 | seed = _ref.seed;
|
1776 |
|
1777 | this._fn = fn;
|
1778 | this._seed = seed;
|
1779 | if (seed !== NOTHING) {
|
1780 | this._emitValue(seed);
|
1781 | }
|
1782 | },
|
1783 | _free: function () {
|
1784 | this._fn = null;
|
1785 | this._seed = null;
|
1786 | },
|
1787 | _handleValue: function (x) {
|
1788 | var fn = this._fn;
|
1789 | if (this._currentEvent === null || this._currentEvent.type === ERROR) {
|
1790 | this._emitValue(this._seed === NOTHING ? x : fn(this._seed, x));
|
1791 | } else {
|
1792 | this._emitValue(fn(this._currentEvent.value, x));
|
1793 | }
|
1794 | }
|
1795 | });
|
1796 |
|
1797 | function scan(obs, fn) {
|
1798 | var seed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : NOTHING;
|
1799 |
|
1800 | return new P$13(obs, { fn: fn, seed: seed });
|
1801 | }
|
1802 |
|
1803 | var mixin$10 = {
|
1804 | _init: function (_ref) {
|
1805 | var fn = _ref.fn;
|
1806 |
|
1807 | this._fn = fn;
|
1808 | },
|
1809 | _free: function () {
|
1810 | this._fn = null;
|
1811 | },
|
1812 | _handleValue: function (x) {
|
1813 | var fn = this._fn;
|
1814 | var xs = fn(x);
|
1815 | for (var i = 0; i < xs.length; i++) {
|
1816 | this._emitValue(xs[i]);
|
1817 | }
|
1818 | }
|
1819 | };
|
1820 |
|
1821 | var S$17 = createStream('flatten', mixin$10);
|
1822 |
|
1823 | var id$4 = function (x) {
|
1824 | return x;
|
1825 | };
|
1826 |
|
1827 | function flatten(obs) {
|
1828 | var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : id$4;
|
1829 |
|
1830 | return new S$17(obs, { fn: fn });
|
1831 | }
|
1832 |
|
1833 | var END_MARKER = {};
|
1834 |
|
1835 | var mixin$11 = {
|
1836 | _init: function (_ref) {
|
1837 | var _this = this;
|
1838 |
|
1839 | var wait = _ref.wait;
|
1840 |
|
1841 | this._wait = Math.max(0, wait);
|
1842 | this._buff = [];
|
1843 | this._$shiftBuff = function () {
|
1844 | var value = _this._buff.shift();
|
1845 | if (value === END_MARKER) {
|
1846 | _this._emitEnd();
|
1847 | } else {
|
1848 | _this._emitValue(value);
|
1849 | }
|
1850 | };
|
1851 | },
|
1852 | _free: function () {
|
1853 | this._buff = null;
|
1854 | this._$shiftBuff = null;
|
1855 | },
|
1856 | _handleValue: function (x) {
|
1857 | if (this._activating) {
|
1858 | this._emitValue(x);
|
1859 | } else {
|
1860 | this._buff.push(x);
|
1861 | setTimeout(this._$shiftBuff, this._wait);
|
1862 | }
|
1863 | },
|
1864 | _handleEnd: function () {
|
1865 | if (this._activating) {
|
1866 | this._emitEnd();
|
1867 | } else {
|
1868 | this._buff.push(END_MARKER);
|
1869 | setTimeout(this._$shiftBuff, this._wait);
|
1870 | }
|
1871 | }
|
1872 | };
|
1873 |
|
1874 | var S$18 = createStream('delay', mixin$11);
|
1875 | var P$14 = createProperty('delay', mixin$11);
|
1876 |
|
1877 | function delay(obs, wait) {
|
1878 | return new (obs._ofSameType(S$18, P$14))(obs, { wait: wait });
|
1879 | }
|
1880 |
|
1881 | var now = Date.now ? function () {
|
1882 | return Date.now();
|
1883 | } : function () {
|
1884 | return new Date().getTime();
|
1885 | };
|
1886 |
|
1887 | var mixin$12 = {
|
1888 | _init: function (_ref) {
|
1889 | var _this = this;
|
1890 |
|
1891 | var wait = _ref.wait,
|
1892 | leading = _ref.leading,
|
1893 | trailing = _ref.trailing;
|
1894 |
|
1895 | this._wait = Math.max(0, wait);
|
1896 | this._leading = leading;
|
1897 | this._trailing = trailing;
|
1898 | this._trailingValue = null;
|
1899 | this._timeoutId = null;
|
1900 | this._endLater = false;
|
1901 | this._lastCallTime = 0;
|
1902 | this._$trailingCall = function () {
|
1903 | return _this._trailingCall();
|
1904 | };
|
1905 | },
|
1906 | _free: function () {
|
1907 | this._trailingValue = null;
|
1908 | this._$trailingCall = null;
|
1909 | },
|
1910 | _handleValue: function (x) {
|
1911 | if (this._activating) {
|
1912 | this._emitValue(x);
|
1913 | } else {
|
1914 | var curTime = now();
|
1915 | if (this._lastCallTime === 0 && !this._leading) {
|
1916 | this._lastCallTime = curTime;
|
1917 | }
|
1918 | var remaining = this._wait - (curTime - this._lastCallTime);
|
1919 | if (remaining <= 0) {
|
1920 | this._cancelTrailing();
|
1921 | this._lastCallTime = curTime;
|
1922 | this._emitValue(x);
|
1923 | } else if (this._trailing) {
|
1924 | this._cancelTrailing();
|
1925 | this._trailingValue = x;
|
1926 | this._timeoutId = setTimeout(this._$trailingCall, remaining);
|
1927 | }
|
1928 | }
|
1929 | },
|
1930 | _handleEnd: function () {
|
1931 | if (this._activating) {
|
1932 | this._emitEnd();
|
1933 | } else {
|
1934 | if (this._timeoutId) {
|
1935 | this._endLater = true;
|
1936 | } else {
|
1937 | this._emitEnd();
|
1938 | }
|
1939 | }
|
1940 | },
|
1941 | _cancelTrailing: function () {
|
1942 | if (this._timeoutId !== null) {
|
1943 | clearTimeout(this._timeoutId);
|
1944 | this._timeoutId = null;
|
1945 | }
|
1946 | },
|
1947 | _trailingCall: function () {
|
1948 | this._emitValue(this._trailingValue);
|
1949 | this._timeoutId = null;
|
1950 | this._trailingValue = null;
|
1951 | this._lastCallTime = !this._leading ? 0 : now();
|
1952 | if (this._endLater) {
|
1953 | this._emitEnd();
|
1954 | }
|
1955 | }
|
1956 | };
|
1957 |
|
1958 | var S$19 = createStream('throttle', mixin$12);
|
1959 | var P$15 = createProperty('throttle', mixin$12);
|
1960 |
|
1961 | function throttle(obs, wait) {
|
1962 | var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
1963 | _ref2$leading = _ref2.leading,
|
1964 | leading = _ref2$leading === undefined ? true : _ref2$leading,
|
1965 | _ref2$trailing = _ref2.trailing,
|
1966 | trailing = _ref2$trailing === undefined ? true : _ref2$trailing;
|
1967 |
|
1968 | return new (obs._ofSameType(S$19, P$15))(obs, { wait: wait, leading: leading, trailing: trailing });
|
1969 | }
|
1970 |
|
1971 | var mixin$13 = {
|
1972 | _init: function (_ref) {
|
1973 | var _this = this;
|
1974 |
|
1975 | var wait = _ref.wait,
|
1976 | immediate = _ref.immediate;
|
1977 |
|
1978 | this._wait = Math.max(0, wait);
|
1979 | this._immediate = immediate;
|
1980 | this._lastAttempt = 0;
|
1981 | this._timeoutId = null;
|
1982 | this._laterValue = null;
|
1983 | this._endLater = false;
|
1984 | this._$later = function () {
|
1985 | return _this._later();
|
1986 | };
|
1987 | },
|
1988 | _free: function () {
|
1989 | this._laterValue = null;
|
1990 | this._$later = null;
|
1991 | },
|
1992 | _handleValue: function (x) {
|
1993 | if (this._activating) {
|
1994 | this._emitValue(x);
|
1995 | } else {
|
1996 | this._lastAttempt = now();
|
1997 | if (this._immediate && !this._timeoutId) {
|
1998 | this._emitValue(x);
|
1999 | }
|
2000 | if (!this._timeoutId) {
|
2001 | this._timeoutId = setTimeout(this._$later, this._wait);
|
2002 | }
|
2003 | if (!this._immediate) {
|
2004 | this._laterValue = x;
|
2005 | }
|
2006 | }
|
2007 | },
|
2008 | _handleEnd: function () {
|
2009 | if (this._activating) {
|
2010 | this._emitEnd();
|
2011 | } else {
|
2012 | if (this._timeoutId && !this._immediate) {
|
2013 | this._endLater = true;
|
2014 | } else {
|
2015 | this._emitEnd();
|
2016 | }
|
2017 | }
|
2018 | },
|
2019 | _later: function () {
|
2020 | var last = now() - this._lastAttempt;
|
2021 | if (last < this._wait && last >= 0) {
|
2022 | this._timeoutId = setTimeout(this._$later, this._wait - last);
|
2023 | } else {
|
2024 | this._timeoutId = null;
|
2025 | if (!this._immediate) {
|
2026 | this._emitValue(this._laterValue);
|
2027 | this._laterValue = null;
|
2028 | }
|
2029 | if (this._endLater) {
|
2030 | this._emitEnd();
|
2031 | }
|
2032 | }
|
2033 | }
|
2034 | };
|
2035 |
|
2036 | var S$20 = createStream('debounce', mixin$13);
|
2037 | var P$16 = createProperty('debounce', mixin$13);
|
2038 |
|
2039 | function debounce(obs, wait) {
|
2040 | var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
2041 | _ref2$immediate = _ref2.immediate,
|
2042 | immediate = _ref2$immediate === undefined ? false : _ref2$immediate;
|
2043 |
|
2044 | return new (obs._ofSameType(S$20, P$16))(obs, { wait: wait, immediate: immediate });
|
2045 | }
|
2046 |
|
2047 | var mixin$14 = {
|
2048 | _init: function (_ref) {
|
2049 | var fn = _ref.fn;
|
2050 |
|
2051 | this._fn = fn;
|
2052 | },
|
2053 | _free: function () {
|
2054 | this._fn = null;
|
2055 | },
|
2056 | _handleError: function (x) {
|
2057 | var fn = this._fn;
|
2058 | this._emitError(fn(x));
|
2059 | }
|
2060 | };
|
2061 |
|
2062 | var S$21 = createStream('mapErrors', mixin$14);
|
2063 | var P$17 = createProperty('mapErrors', mixin$14);
|
2064 |
|
2065 | var id$5 = function (x) {
|
2066 | return x;
|
2067 | };
|
2068 |
|
2069 | function mapErrors(obs) {
|
2070 | var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : id$5;
|
2071 |
|
2072 | return new (obs._ofSameType(S$21, P$17))(obs, { fn: fn });
|
2073 | }
|
2074 |
|
2075 | var mixin$15 = {
|
2076 | _init: function (_ref) {
|
2077 | var fn = _ref.fn;
|
2078 |
|
2079 | this._fn = fn;
|
2080 | },
|
2081 | _free: function () {
|
2082 | this._fn = null;
|
2083 | },
|
2084 | _handleError: function (x) {
|
2085 | var fn = this._fn;
|
2086 | if (fn(x)) {
|
2087 | this._emitError(x);
|
2088 | }
|
2089 | }
|
2090 | };
|
2091 |
|
2092 | var S$22 = createStream('filterErrors', mixin$15);
|
2093 | var P$18 = createProperty('filterErrors', mixin$15);
|
2094 |
|
2095 | var id$6 = function (x) {
|
2096 | return x;
|
2097 | };
|
2098 |
|
2099 | function filterErrors(obs) {
|
2100 | var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : id$6;
|
2101 |
|
2102 | return new (obs._ofSameType(S$22, P$18))(obs, { fn: fn });
|
2103 | }
|
2104 |
|
2105 | var mixin$16 = {
|
2106 | _handleValue: function () {}
|
2107 | };
|
2108 |
|
2109 | var S$23 = createStream('ignoreValues', mixin$16);
|
2110 | var P$19 = createProperty('ignoreValues', mixin$16);
|
2111 |
|
2112 | function ignoreValues(obs) {
|
2113 | return new (obs._ofSameType(S$23, P$19))(obs);
|
2114 | }
|
2115 |
|
2116 | var mixin$17 = {
|
2117 | _handleError: function () {}
|
2118 | };
|
2119 |
|
2120 | var S$24 = createStream('ignoreErrors', mixin$17);
|
2121 | var P$20 = createProperty('ignoreErrors', mixin$17);
|
2122 |
|
2123 | function ignoreErrors(obs) {
|
2124 | return new (obs._ofSameType(S$24, P$20))(obs);
|
2125 | }
|
2126 |
|
2127 | var mixin$18 = {
|
2128 | _handleEnd: function () {}
|
2129 | };
|
2130 |
|
2131 | var S$25 = createStream('ignoreEnd', mixin$18);
|
2132 | var P$21 = createProperty('ignoreEnd', mixin$18);
|
2133 |
|
2134 | function ignoreEnd(obs) {
|
2135 | return new (obs._ofSameType(S$25, P$21))(obs);
|
2136 | }
|
2137 |
|
2138 | var mixin$19 = {
|
2139 | _init: function (_ref) {
|
2140 | var fn = _ref.fn;
|
2141 |
|
2142 | this._fn = fn;
|
2143 | },
|
2144 | _free: function () {
|
2145 | this._fn = null;
|
2146 | },
|
2147 | _handleEnd: function () {
|
2148 | var fn = this._fn;
|
2149 | this._emitValue(fn());
|
2150 | this._emitEnd();
|
2151 | }
|
2152 | };
|
2153 |
|
2154 | var S$26 = createStream('beforeEnd', mixin$19);
|
2155 | var P$22 = createProperty('beforeEnd', mixin$19);
|
2156 |
|
2157 | function beforeEnd(obs, fn) {
|
2158 | return new (obs._ofSameType(S$26, P$22))(obs, { fn: fn });
|
2159 | }
|
2160 |
|
2161 | var mixin$20 = {
|
2162 | _init: function (_ref) {
|
2163 | var min = _ref.min,
|
2164 | max = _ref.max;
|
2165 |
|
2166 | this._max = max;
|
2167 | this._min = min;
|
2168 | this._buff = [];
|
2169 | },
|
2170 | _free: function () {
|
2171 | this._buff = null;
|
2172 | },
|
2173 | _handleValue: function (x) {
|
2174 | this._buff = slide(this._buff, x, this._max);
|
2175 | if (this._buff.length >= this._min) {
|
2176 | this._emitValue(this._buff);
|
2177 | }
|
2178 | }
|
2179 | };
|
2180 |
|
2181 | var S$27 = createStream('slidingWindow', mixin$20);
|
2182 | var P$23 = createProperty('slidingWindow', mixin$20);
|
2183 |
|
2184 | function slidingWindow(obs, max) {
|
2185 | var min = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
2186 |
|
2187 | return new (obs._ofSameType(S$27, P$23))(obs, { min: min, max: max });
|
2188 | }
|
2189 |
|
2190 | var mixin$21 = {
|
2191 | _init: function (_ref) {
|
2192 | var fn = _ref.fn,
|
2193 | flushOnEnd = _ref.flushOnEnd;
|
2194 |
|
2195 | this._fn = fn;
|
2196 | this._flushOnEnd = flushOnEnd;
|
2197 | this._buff = [];
|
2198 | },
|
2199 | _free: function () {
|
2200 | this._buff = null;
|
2201 | },
|
2202 | _flush: function () {
|
2203 | if (this._buff !== null && this._buff.length !== 0) {
|
2204 | this._emitValue(this._buff);
|
2205 | this._buff = [];
|
2206 | }
|
2207 | },
|
2208 | _handleValue: function (x) {
|
2209 | this._buff.push(x);
|
2210 | var fn = this._fn;
|
2211 | if (!fn(x)) {
|
2212 | this._flush();
|
2213 | }
|
2214 | },
|
2215 | _handleEnd: function () {
|
2216 | if (this._flushOnEnd) {
|
2217 | this._flush();
|
2218 | }
|
2219 | this._emitEnd();
|
2220 | }
|
2221 | };
|
2222 |
|
2223 | var S$28 = createStream('bufferWhile', mixin$21);
|
2224 | var P$24 = createProperty('bufferWhile', mixin$21);
|
2225 |
|
2226 | var id$7 = function (x) {
|
2227 | return x;
|
2228 | };
|
2229 |
|
2230 | function bufferWhile(obs, fn) {
|
2231 | var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
2232 | _ref2$flushOnEnd = _ref2.flushOnEnd,
|
2233 | flushOnEnd = _ref2$flushOnEnd === undefined ? true : _ref2$flushOnEnd;
|
2234 |
|
2235 | return new (obs._ofSameType(S$28, P$24))(obs, { fn: fn || id$7, flushOnEnd: flushOnEnd });
|
2236 | }
|
2237 |
|
2238 | var mixin$22 = {
|
2239 | _init: function (_ref) {
|
2240 | var count = _ref.count,
|
2241 | flushOnEnd = _ref.flushOnEnd;
|
2242 |
|
2243 | this._count = count;
|
2244 | this._flushOnEnd = flushOnEnd;
|
2245 | this._buff = [];
|
2246 | },
|
2247 | _free: function () {
|
2248 | this._buff = null;
|
2249 | },
|
2250 | _flush: function () {
|
2251 | if (this._buff !== null && this._buff.length !== 0) {
|
2252 | this._emitValue(this._buff);
|
2253 | this._buff = [];
|
2254 | }
|
2255 | },
|
2256 | _handleValue: function (x) {
|
2257 | this._buff.push(x);
|
2258 | if (this._buff.length >= this._count) {
|
2259 | this._flush();
|
2260 | }
|
2261 | },
|
2262 | _handleEnd: function () {
|
2263 | if (this._flushOnEnd) {
|
2264 | this._flush();
|
2265 | }
|
2266 | this._emitEnd();
|
2267 | }
|
2268 | };
|
2269 |
|
2270 | var S$29 = createStream('bufferWithCount', mixin$22);
|
2271 | var P$25 = createProperty('bufferWithCount', mixin$22);
|
2272 |
|
2273 | function bufferWhile$1(obs, count) {
|
2274 | var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
2275 | _ref2$flushOnEnd = _ref2.flushOnEnd,
|
2276 | flushOnEnd = _ref2$flushOnEnd === undefined ? true : _ref2$flushOnEnd;
|
2277 |
|
2278 | return new (obs._ofSameType(S$29, P$25))(obs, { count: count, flushOnEnd: flushOnEnd });
|
2279 | }
|
2280 |
|
2281 | var mixin$23 = {
|
2282 | _init: function (_ref) {
|
2283 | var _this = this;
|
2284 |
|
2285 | var wait = _ref.wait,
|
2286 | count = _ref.count,
|
2287 | flushOnEnd = _ref.flushOnEnd;
|
2288 |
|
2289 | this._wait = wait;
|
2290 | this._count = count;
|
2291 | this._flushOnEnd = flushOnEnd;
|
2292 | this._intervalId = null;
|
2293 | this._$onTick = function () {
|
2294 | return _this._flush();
|
2295 | };
|
2296 | this._buff = [];
|
2297 | },
|
2298 | _free: function () {
|
2299 | this._$onTick = null;
|
2300 | this._buff = null;
|
2301 | },
|
2302 | _flush: function () {
|
2303 | if (this._buff !== null) {
|
2304 | this._emitValue(this._buff);
|
2305 | this._buff = [];
|
2306 | }
|
2307 | },
|
2308 | _handleValue: function (x) {
|
2309 | this._buff.push(x);
|
2310 | if (this._buff.length >= this._count) {
|
2311 | clearInterval(this._intervalId);
|
2312 | this._flush();
|
2313 | this._intervalId = setInterval(this._$onTick, this._wait);
|
2314 | }
|
2315 | },
|
2316 | _handleEnd: function () {
|
2317 | if (this._flushOnEnd && this._buff.length !== 0) {
|
2318 | this._flush();
|
2319 | }
|
2320 | this._emitEnd();
|
2321 | },
|
2322 | _onActivation: function () {
|
2323 | this._intervalId = setInterval(this._$onTick, this._wait);
|
2324 | this._source.onAny(this._$handleAny);
|
2325 | },
|
2326 | _onDeactivation: function () {
|
2327 | if (this._intervalId !== null) {
|
2328 | clearInterval(this._intervalId);
|
2329 | this._intervalId = null;
|
2330 | }
|
2331 | this._source.offAny(this._$handleAny);
|
2332 | }
|
2333 | };
|
2334 |
|
2335 | var S$30 = createStream('bufferWithTimeOrCount', mixin$23);
|
2336 | var P$26 = createProperty('bufferWithTimeOrCount', mixin$23);
|
2337 |
|
2338 | function bufferWithTimeOrCount(obs, wait, count) {
|
2339 | var _ref2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
|
2340 | _ref2$flushOnEnd = _ref2.flushOnEnd,
|
2341 | flushOnEnd = _ref2$flushOnEnd === undefined ? true : _ref2$flushOnEnd;
|
2342 |
|
2343 | return new (obs._ofSameType(S$30, P$26))(obs, { wait: wait, count: count, flushOnEnd: flushOnEnd });
|
2344 | }
|
2345 |
|
2346 | function xformForObs(obs) {
|
2347 | return {
|
2348 | '@@transducer/step': function (res, input) {
|
2349 | obs._emitValue(input);
|
2350 | return null;
|
2351 | },
|
2352 | '@@transducer/result': function () {
|
2353 | obs._emitEnd();
|
2354 | return null;
|
2355 | }
|
2356 | };
|
2357 | }
|
2358 |
|
2359 | var mixin$24 = {
|
2360 | _init: function (_ref) {
|
2361 | var transducer = _ref.transducer;
|
2362 |
|
2363 | this._xform = transducer(xformForObs(this));
|
2364 | },
|
2365 | _free: function () {
|
2366 | this._xform = null;
|
2367 | },
|
2368 | _handleValue: function (x) {
|
2369 | if (this._xform['@@transducer/step'](null, x) !== null) {
|
2370 | this._xform['@@transducer/result'](null);
|
2371 | }
|
2372 | },
|
2373 | _handleEnd: function () {
|
2374 | this._xform['@@transducer/result'](null);
|
2375 | }
|
2376 | };
|
2377 |
|
2378 | var S$31 = createStream('transduce', mixin$24);
|
2379 | var P$27 = createProperty('transduce', mixin$24);
|
2380 |
|
2381 | function transduce(obs, transducer) {
|
2382 | return new (obs._ofSameType(S$31, P$27))(obs, { transducer: transducer });
|
2383 | }
|
2384 |
|
2385 | var mixin$25 = {
|
2386 | _init: function (_ref) {
|
2387 | var fn = _ref.fn;
|
2388 |
|
2389 | this._handler = fn;
|
2390 | this._emitter = emitter(this);
|
2391 | },
|
2392 | _free: function () {
|
2393 | this._handler = null;
|
2394 | this._emitter = null;
|
2395 | },
|
2396 | _handleAny: function (event) {
|
2397 | this._handler(this._emitter, event);
|
2398 | }
|
2399 | };
|
2400 |
|
2401 | var S$32 = createStream('withHandler', mixin$25);
|
2402 | var P$28 = createProperty('withHandler', mixin$25);
|
2403 |
|
2404 | function withHandler(obs, fn) {
|
2405 | return new (obs._ofSameType(S$32, P$28))(obs, { fn: fn });
|
2406 | }
|
2407 |
|
2408 | var isArray = Array.isArray || function (xs) {
|
2409 | return Object.prototype.toString.call(xs) === '[object Array]';
|
2410 | };
|
2411 |
|
2412 | function Zip(sources, combinator) {
|
2413 | var _this = this;
|
2414 |
|
2415 | Stream.call(this);
|
2416 |
|
2417 | this._buffers = map(sources, function (source) {
|
2418 | return isArray(source) ? cloneArray(source) : [];
|
2419 | });
|
2420 | this._sources = map(sources, function (source) {
|
2421 | return isArray(source) ? never() : source;
|
2422 | });
|
2423 |
|
2424 | this._combinator = combinator ? spread(combinator, this._sources.length) : function (x) {
|
2425 | return x;
|
2426 | };
|
2427 | this._aliveCount = 0;
|
2428 |
|
2429 | this._$handlers = [];
|
2430 |
|
2431 | var _loop = function (i) {
|
2432 | _this._$handlers.push(function (event) {
|
2433 | return _this._handleAny(i, event);
|
2434 | });
|
2435 | };
|
2436 |
|
2437 | for (var i = 0; i < this._sources.length; i++) {
|
2438 | _loop(i);
|
2439 | }
|
2440 | }
|
2441 |
|
2442 | inherit(Zip, Stream, {
|
2443 | _name: 'zip',
|
2444 |
|
2445 | _onActivation: function () {
|
2446 |
|
2447 | while (this._isFull()) {
|
2448 | this._emit();
|
2449 | }
|
2450 |
|
2451 | var length = this._sources.length;
|
2452 | this._aliveCount = length;
|
2453 | for (var i = 0; i < length && this._active; i++) {
|
2454 | this._sources[i].onAny(this._$handlers[i]);
|
2455 | }
|
2456 | },
|
2457 | _onDeactivation: function () {
|
2458 | for (var i = 0; i < this._sources.length; i++) {
|
2459 | this._sources[i].offAny(this._$handlers[i]);
|
2460 | }
|
2461 | },
|
2462 | _emit: function () {
|
2463 | var values = new Array(this._buffers.length);
|
2464 | for (var i = 0; i < this._buffers.length; i++) {
|
2465 | values[i] = this._buffers[i].shift();
|
2466 | }
|
2467 | var combinator = this._combinator;
|
2468 | this._emitValue(combinator(values));
|
2469 | },
|
2470 | _isFull: function () {
|
2471 | for (var i = 0; i < this._buffers.length; i++) {
|
2472 | if (this._buffers[i].length === 0) {
|
2473 | return false;
|
2474 | }
|
2475 | }
|
2476 | return true;
|
2477 | },
|
2478 | _handleAny: function (i, event) {
|
2479 | if (event.type === VALUE) {
|
2480 | this._buffers[i].push(event.value);
|
2481 | if (this._isFull()) {
|
2482 | this._emit();
|
2483 | }
|
2484 | }
|
2485 | if (event.type === ERROR) {
|
2486 | this._emitError(event.value);
|
2487 | }
|
2488 | if (event.type === END) {
|
2489 | this._aliveCount--;
|
2490 | if (this._aliveCount === 0) {
|
2491 | this._emitEnd();
|
2492 | }
|
2493 | }
|
2494 | },
|
2495 | _clear: function () {
|
2496 | Stream.prototype._clear.call(this);
|
2497 | this._sources = null;
|
2498 | this._buffers = null;
|
2499 | this._combinator = null;
|
2500 | this._$handlers = null;
|
2501 | }
|
2502 | });
|
2503 |
|
2504 | function zip(observables, combinator /* Function | falsey */) {
|
2505 | return observables.length === 0 ? never() : new Zip(observables, combinator);
|
2506 | }
|
2507 |
|
2508 | var id$8 = function (x) {
|
2509 | return x;
|
2510 | };
|
2511 |
|
2512 | function AbstractPool() {
|
2513 | var _this = this;
|
2514 |
|
2515 | var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
2516 | _ref$queueLim = _ref.queueLim,
|
2517 | queueLim = _ref$queueLim === undefined ? 0 : _ref$queueLim,
|
2518 | _ref$concurLim = _ref.concurLim,
|
2519 | concurLim = _ref$concurLim === undefined ? -1 : _ref$concurLim,
|
2520 | _ref$drop = _ref.drop,
|
2521 | drop = _ref$drop === undefined ? 'new' : _ref$drop;
|
2522 |
|
2523 | Stream.call(this);
|
2524 |
|
2525 | this._queueLim = queueLim < 0 ? -1 : queueLim;
|
2526 | this._concurLim = concurLim < 0 ? -1 : concurLim;
|
2527 | this._drop = drop;
|
2528 | this._queue = [];
|
2529 | this._curSources = [];
|
2530 | this._$handleSubAny = function (event) {
|
2531 | return _this._handleSubAny(event);
|
2532 | };
|
2533 | this._$endHandlers = [];
|
2534 | this._currentlyAdding = null;
|
2535 |
|
2536 | if (this._concurLim === 0) {
|
2537 | this._emitEnd();
|
2538 | }
|
2539 | }
|
2540 |
|
2541 | inherit(AbstractPool, Stream, {
|
2542 | _name: 'abstractPool',
|
2543 |
|
2544 | _add: function (obj, toObs /* Function | falsey */) {
|
2545 | toObs = toObs || id$8;
|
2546 | if (this._concurLim === -1 || this._curSources.length < this._concurLim) {
|
2547 | this._addToCur(toObs(obj));
|
2548 | } else {
|
2549 | if (this._queueLim === -1 || this._queue.length < this._queueLim) {
|
2550 | this._addToQueue(toObs(obj));
|
2551 | } else if (this._drop === 'old') {
|
2552 | this._removeOldest();
|
2553 | this._add(obj, toObs);
|
2554 | }
|
2555 | }
|
2556 | },
|
2557 | _addAll: function (obss) {
|
2558 | var _this2 = this;
|
2559 |
|
2560 | forEach(obss, function (obs) {
|
2561 | return _this2._add(obs);
|
2562 | });
|
2563 | },
|
2564 | _remove: function (obs) {
|
2565 | if (this._removeCur(obs) === -1) {
|
2566 | this._removeQueue(obs);
|
2567 | }
|
2568 | },
|
2569 | _addToQueue: function (obs) {
|
2570 | this._queue = concat(this._queue, [obs]);
|
2571 | },
|
2572 | _addToCur: function (obs) {
|
2573 | if (this._active) {
|
2574 |
|
2575 |
|
2576 |
|
2577 |
|
2578 |
|
2579 |
|
2580 |
|
2581 |
|
2582 |
|
2583 |
|
2584 |
|
2585 |
|
2586 |
|
2587 |
|
2588 |
|
2589 |
|
2590 | if (!obs._alive) {
|
2591 | if (obs._currentEvent) {
|
2592 | this._emit(obs._currentEvent.type, obs._currentEvent.value);
|
2593 | }
|
2594 |
|
2595 | if (this._active) {
|
2596 | if (this._queue.length !== 0) {
|
2597 | this._pullQueue();
|
2598 | } else if (this._curSources.length === 0) {
|
2599 | this._onEmpty();
|
2600 | }
|
2601 | }
|
2602 | return;
|
2603 | }
|
2604 |
|
2605 |
|
2606 |
|
2607 |
|
2608 | this._currentlyAdding = obs;
|
2609 | obs.onAny(this._$handleSubAny);
|
2610 | this._currentlyAdding = null;
|
2611 | if (obs._alive) {
|
2612 | this._curSources = concat(this._curSources, [obs]);
|
2613 | if (this._active) {
|
2614 | this._subToEnd(obs);
|
2615 | }
|
2616 | }
|
2617 | } else {
|
2618 | this._curSources = concat(this._curSources, [obs]);
|
2619 | }
|
2620 | },
|
2621 | _subToEnd: function (obs) {
|
2622 | var _this3 = this;
|
2623 |
|
2624 | var onEnd = function () {
|
2625 | return _this3._removeCur(obs);
|
2626 | };
|
2627 | this._$endHandlers.push({ obs: obs, handler: onEnd });
|
2628 | obs.onEnd(onEnd);
|
2629 | },
|
2630 | _subscribe: function (obs) {
|
2631 | obs.onAny(this._$handleSubAny);
|
2632 |
|
2633 |
|
2634 | if (this._active) {
|
2635 | this._subToEnd(obs);
|
2636 | }
|
2637 | },
|
2638 | _unsubscribe: function (obs) {
|
2639 | obs.offAny(this._$handleSubAny);
|
2640 |
|
2641 | var onEndI = findByPred(this._$endHandlers, function (obj) {
|
2642 | return obj.obs === obs;
|
2643 | });
|
2644 | if (onEndI !== -1) {
|
2645 | obs.offEnd(this._$endHandlers[onEndI].handler);
|
2646 | this._$endHandlers.splice(onEndI, 1);
|
2647 | }
|
2648 | },
|
2649 | _handleSubAny: function (event) {
|
2650 | if (event.type === VALUE) {
|
2651 | this._emitValue(event.value);
|
2652 | } else if (event.type === ERROR) {
|
2653 | this._emitError(event.value);
|
2654 | }
|
2655 | },
|
2656 | _removeQueue: function (obs) {
|
2657 | var index = find(this._queue, obs);
|
2658 | this._queue = remove(this._queue, index);
|
2659 | return index;
|
2660 | },
|
2661 | _removeCur: function (obs) {
|
2662 | if (this._active) {
|
2663 | this._unsubscribe(obs);
|
2664 | }
|
2665 | var index = find(this._curSources, obs);
|
2666 | this._curSources = remove(this._curSources, index);
|
2667 | if (index !== -1) {
|
2668 | if (this._queue.length !== 0) {
|
2669 | this._pullQueue();
|
2670 | } else if (this._curSources.length === 0) {
|
2671 | this._onEmpty();
|
2672 | }
|
2673 | }
|
2674 | return index;
|
2675 | },
|
2676 | _removeOldest: function () {
|
2677 | this._removeCur(this._curSources[0]);
|
2678 | },
|
2679 | _pullQueue: function () {
|
2680 | if (this._queue.length !== 0) {
|
2681 | this._queue = cloneArray(this._queue);
|
2682 | this._addToCur(this._queue.shift());
|
2683 | }
|
2684 | },
|
2685 | _onActivation: function () {
|
2686 | for (var i = 0, sources = this._curSources; i < sources.length && this._active; i++) {
|
2687 | this._subscribe(sources[i]);
|
2688 | }
|
2689 | },
|
2690 | _onDeactivation: function () {
|
2691 | for (var i = 0, sources = this._curSources; i < sources.length; i++) {
|
2692 | this._unsubscribe(sources[i]);
|
2693 | }
|
2694 | if (this._currentlyAdding !== null) {
|
2695 | this._unsubscribe(this._currentlyAdding);
|
2696 | }
|
2697 | },
|
2698 | _isEmpty: function () {
|
2699 | return this._curSources.length === 0;
|
2700 | },
|
2701 | _onEmpty: function () {},
|
2702 | _clear: function () {
|
2703 | Stream.prototype._clear.call(this);
|
2704 | this._queue = null;
|
2705 | this._curSources = null;
|
2706 | this._$handleSubAny = null;
|
2707 | this._$endHandlers = null;
|
2708 | }
|
2709 | });
|
2710 |
|
2711 | function Merge(sources) {
|
2712 | AbstractPool.call(this);
|
2713 | this._addAll(sources);
|
2714 | this._initialised = true;
|
2715 | }
|
2716 |
|
2717 | inherit(Merge, AbstractPool, {
|
2718 | _name: 'merge',
|
2719 |
|
2720 | _onEmpty: function () {
|
2721 | if (this._initialised) {
|
2722 | this._emitEnd();
|
2723 | }
|
2724 | }
|
2725 | });
|
2726 |
|
2727 | function merge(observables) {
|
2728 | return observables.length === 0 ? never() : new Merge(observables);
|
2729 | }
|
2730 |
|
2731 | function S$33(generator) {
|
2732 | var _this = this;
|
2733 |
|
2734 | Stream.call(this);
|
2735 | this._generator = generator;
|
2736 | this._source = null;
|
2737 | this._inLoop = false;
|
2738 | this._iteration = 0;
|
2739 | this._$handleAny = function (event) {
|
2740 | return _this._handleAny(event);
|
2741 | };
|
2742 | }
|
2743 |
|
2744 | inherit(S$33, Stream, {
|
2745 | _name: 'repeat',
|
2746 |
|
2747 | _handleAny: function (event) {
|
2748 | if (event.type === END) {
|
2749 | this._source = null;
|
2750 | this._getSource();
|
2751 | } else {
|
2752 | this._emit(event.type, event.value);
|
2753 | }
|
2754 | },
|
2755 | _getSource: function () {
|
2756 | if (!this._inLoop) {
|
2757 | this._inLoop = true;
|
2758 | var generator = this._generator;
|
2759 | while (this._source === null && this._alive && this._active) {
|
2760 | this._source = generator(this._iteration++);
|
2761 | if (this._source) {
|
2762 | this._source.onAny(this._$handleAny);
|
2763 | } else {
|
2764 | this._emitEnd();
|
2765 | }
|
2766 | }
|
2767 | this._inLoop = false;
|
2768 | }
|
2769 | },
|
2770 | _onActivation: function () {
|
2771 | if (this._source) {
|
2772 | this._source.onAny(this._$handleAny);
|
2773 | } else {
|
2774 | this._getSource();
|
2775 | }
|
2776 | },
|
2777 | _onDeactivation: function () {
|
2778 | if (this._source) {
|
2779 | this._source.offAny(this._$handleAny);
|
2780 | }
|
2781 | },
|
2782 | _clear: function () {
|
2783 | Stream.prototype._clear.call(this);
|
2784 | this._generator = null;
|
2785 | this._source = null;
|
2786 | this._$handleAny = null;
|
2787 | }
|
2788 | });
|
2789 |
|
2790 | var repeat = function (generator) {
|
2791 | return new S$33(generator);
|
2792 | };
|
2793 |
|
2794 | function concat$1(observables) {
|
2795 | return repeat(function (index) {
|
2796 | return observables.length > index ? observables[index] : false;
|
2797 | }).setName('concat');
|
2798 | }
|
2799 |
|
2800 | function Pool() {
|
2801 | AbstractPool.call(this);
|
2802 | }
|
2803 |
|
2804 | inherit(Pool, AbstractPool, {
|
2805 | _name: 'pool',
|
2806 |
|
2807 | plug: function (obs) {
|
2808 | this._add(obs);
|
2809 | return this;
|
2810 | },
|
2811 | unplug: function (obs) {
|
2812 | this._remove(obs);
|
2813 | return this;
|
2814 | }
|
2815 | });
|
2816 |
|
2817 | function FlatMap(source, fn, options) {
|
2818 | var _this = this;
|
2819 |
|
2820 | AbstractPool.call(this, options);
|
2821 | this._source = source;
|
2822 | this._fn = fn;
|
2823 | this._mainEnded = false;
|
2824 | this._lastCurrent = null;
|
2825 | this._$handleMain = function (event) {
|
2826 | return _this._handleMain(event);
|
2827 | };
|
2828 | }
|
2829 |
|
2830 | inherit(FlatMap, AbstractPool, {
|
2831 | _onActivation: function () {
|
2832 | AbstractPool.prototype._onActivation.call(this);
|
2833 | if (this._active) {
|
2834 | this._source.onAny(this._$handleMain);
|
2835 | }
|
2836 | },
|
2837 | _onDeactivation: function () {
|
2838 | AbstractPool.prototype._onDeactivation.call(this);
|
2839 | this._source.offAny(this._$handleMain);
|
2840 | this._hadNoEvSinceDeact = true;
|
2841 | },
|
2842 | _handleMain: function (event) {
|
2843 | if (event.type === VALUE) {
|
2844 |
|
2845 |
|
2846 |
|
2847 |
|
2848 | var sameCurr = this._activating && this._hadNoEvSinceDeact && this._lastCurrent === event.value;
|
2849 | if (!sameCurr) {
|
2850 | this._add(event.value, this._fn);
|
2851 | }
|
2852 | this._lastCurrent = event.value;
|
2853 | this._hadNoEvSinceDeact = false;
|
2854 | }
|
2855 |
|
2856 | if (event.type === ERROR) {
|
2857 | this._emitError(event.value);
|
2858 | }
|
2859 |
|
2860 | if (event.type === END) {
|
2861 | if (this._isEmpty()) {
|
2862 | this._emitEnd();
|
2863 | } else {
|
2864 | this._mainEnded = true;
|
2865 | }
|
2866 | }
|
2867 | },
|
2868 | _onEmpty: function () {
|
2869 | if (this._mainEnded) {
|
2870 | this._emitEnd();
|
2871 | }
|
2872 | },
|
2873 | _clear: function () {
|
2874 | AbstractPool.prototype._clear.call(this);
|
2875 | this._source = null;
|
2876 | this._lastCurrent = null;
|
2877 | this._$handleMain = null;
|
2878 | }
|
2879 | });
|
2880 |
|
2881 | function FlatMapErrors(source, fn) {
|
2882 | FlatMap.call(this, source, fn);
|
2883 | }
|
2884 |
|
2885 | inherit(FlatMapErrors, FlatMap, {
|
2886 |
|
2887 | _handleMain: function (event) {
|
2888 | if (event.type === ERROR) {
|
2889 | var sameCurr = this._activating && this._hadNoEvSinceDeact && this._lastCurrent === event.value;
|
2890 | if (!sameCurr) {
|
2891 | this._add(event.value, this._fn);
|
2892 | }
|
2893 | this._lastCurrent = event.value;
|
2894 | this._hadNoEvSinceDeact = false;
|
2895 | }
|
2896 |
|
2897 | if (event.type === VALUE) {
|
2898 | this._emitValue(event.value);
|
2899 | }
|
2900 |
|
2901 | if (event.type === END) {
|
2902 | if (this._isEmpty()) {
|
2903 | this._emitEnd();
|
2904 | } else {
|
2905 | this._mainEnded = true;
|
2906 | }
|
2907 | }
|
2908 | }
|
2909 | });
|
2910 |
|
2911 | function createConstructor$1(BaseClass, name) {
|
2912 | return function AnonymousObservable(primary, secondary, options) {
|
2913 | var _this = this;
|
2914 |
|
2915 | BaseClass.call(this);
|
2916 | this._primary = primary;
|
2917 | this._secondary = secondary;
|
2918 | this._name = primary._name + '.' + name;
|
2919 | this._lastSecondary = NOTHING;
|
2920 | this._$handleSecondaryAny = function (event) {
|
2921 | return _this._handleSecondaryAny(event);
|
2922 | };
|
2923 | this._$handlePrimaryAny = function (event) {
|
2924 | return _this._handlePrimaryAny(event);
|
2925 | };
|
2926 | this._init(options);
|
2927 | };
|
2928 | }
|
2929 |
|
2930 | function createClassMethods$1(BaseClass) {
|
2931 | return {
|
2932 | _init: function () {},
|
2933 | _free: function () {},
|
2934 | _handlePrimaryValue: function (x) {
|
2935 | this._emitValue(x);
|
2936 | },
|
2937 | _handlePrimaryError: function (x) {
|
2938 | this._emitError(x);
|
2939 | },
|
2940 | _handlePrimaryEnd: function () {
|
2941 | this._emitEnd();
|
2942 | },
|
2943 | _handleSecondaryValue: function (x) {
|
2944 | this._lastSecondary = x;
|
2945 | },
|
2946 | _handleSecondaryError: function (x) {
|
2947 | this._emitError(x);
|
2948 | },
|
2949 | _handleSecondaryEnd: function () {},
|
2950 | _handlePrimaryAny: function (event) {
|
2951 | switch (event.type) {
|
2952 | case VALUE:
|
2953 | return this._handlePrimaryValue(event.value);
|
2954 | case ERROR:
|
2955 | return this._handlePrimaryError(event.value);
|
2956 | case END:
|
2957 | return this._handlePrimaryEnd(event.value);
|
2958 | }
|
2959 | },
|
2960 | _handleSecondaryAny: function (event) {
|
2961 | switch (event.type) {
|
2962 | case VALUE:
|
2963 | return this._handleSecondaryValue(event.value);
|
2964 | case ERROR:
|
2965 | return this._handleSecondaryError(event.value);
|
2966 | case END:
|
2967 | this._handleSecondaryEnd(event.value);
|
2968 | this._removeSecondary();
|
2969 | }
|
2970 | },
|
2971 | _removeSecondary: function () {
|
2972 | if (this._secondary !== null) {
|
2973 | this._secondary.offAny(this._$handleSecondaryAny);
|
2974 | this._$handleSecondaryAny = null;
|
2975 | this._secondary = null;
|
2976 | }
|
2977 | },
|
2978 | _onActivation: function () {
|
2979 | if (this._secondary !== null) {
|
2980 | this._secondary.onAny(this._$handleSecondaryAny);
|
2981 | }
|
2982 | if (this._active) {
|
2983 | this._primary.onAny(this._$handlePrimaryAny);
|
2984 | }
|
2985 | },
|
2986 | _onDeactivation: function () {
|
2987 | if (this._secondary !== null) {
|
2988 | this._secondary.offAny(this._$handleSecondaryAny);
|
2989 | }
|
2990 | this._primary.offAny(this._$handlePrimaryAny);
|
2991 | },
|
2992 | _clear: function () {
|
2993 | BaseClass.prototype._clear.call(this);
|
2994 | this._primary = null;
|
2995 | this._secondary = null;
|
2996 | this._lastSecondary = null;
|
2997 | this._$handleSecondaryAny = null;
|
2998 | this._$handlePrimaryAny = null;
|
2999 | this._free();
|
3000 | }
|
3001 | };
|
3002 | }
|
3003 |
|
3004 | function createStream$1(name, mixin) {
|
3005 | var S = createConstructor$1(Stream, name);
|
3006 | inherit(S, Stream, createClassMethods$1(Stream), mixin);
|
3007 | return S;
|
3008 | }
|
3009 |
|
3010 | function createProperty$1(name, mixin) {
|
3011 | var P = createConstructor$1(Property, name);
|
3012 | inherit(P, Property, createClassMethods$1(Property), mixin);
|
3013 | return P;
|
3014 | }
|
3015 |
|
3016 | var mixin$26 = {
|
3017 | _handlePrimaryValue: function (x) {
|
3018 | if (this._lastSecondary !== NOTHING && this._lastSecondary) {
|
3019 | this._emitValue(x);
|
3020 | }
|
3021 | },
|
3022 | _handleSecondaryEnd: function () {
|
3023 | if (this._lastSecondary === NOTHING || !this._lastSecondary) {
|
3024 | this._emitEnd();
|
3025 | }
|
3026 | }
|
3027 | };
|
3028 |
|
3029 | var S$34 = createStream$1('filterBy', mixin$26);
|
3030 | var P$29 = createProperty$1('filterBy', mixin$26);
|
3031 |
|
3032 | function filterBy(primary, secondary) {
|
3033 | return new (primary._ofSameType(S$34, P$29))(primary, secondary);
|
3034 | }
|
3035 |
|
3036 | var id2 = function (_, x) {
|
3037 | return x;
|
3038 | };
|
3039 |
|
3040 | function sampledBy(passive, active, combinator) {
|
3041 | var _combinator = combinator ? function (a, b) {
|
3042 | return combinator(b, a);
|
3043 | } : id2;
|
3044 | return combine([active], [passive], _combinator).setName(passive, 'sampledBy');
|
3045 | }
|
3046 |
|
3047 | var mixin$27 = {
|
3048 | _handlePrimaryValue: function (x) {
|
3049 | if (this._lastSecondary !== NOTHING) {
|
3050 | this._emitValue(x);
|
3051 | }
|
3052 | },
|
3053 | _handleSecondaryEnd: function () {
|
3054 | if (this._lastSecondary === NOTHING) {
|
3055 | this._emitEnd();
|
3056 | }
|
3057 | }
|
3058 | };
|
3059 |
|
3060 | var S$35 = createStream$1('skipUntilBy', mixin$27);
|
3061 | var P$30 = createProperty$1('skipUntilBy', mixin$27);
|
3062 |
|
3063 | function skipUntilBy(primary, secondary) {
|
3064 | return new (primary._ofSameType(S$35, P$30))(primary, secondary);
|
3065 | }
|
3066 |
|
3067 | var mixin$28 = {
|
3068 | _handleSecondaryValue: function () {
|
3069 | this._emitEnd();
|
3070 | }
|
3071 | };
|
3072 |
|
3073 | var S$36 = createStream$1('takeUntilBy', mixin$28);
|
3074 | var P$31 = createProperty$1('takeUntilBy', mixin$28);
|
3075 |
|
3076 | function takeUntilBy(primary, secondary) {
|
3077 | return new (primary._ofSameType(S$36, P$31))(primary, secondary);
|
3078 | }
|
3079 |
|
3080 | var mixin$29 = {
|
3081 | _init: function () {
|
3082 | var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
3083 | _ref$flushOnEnd = _ref.flushOnEnd,
|
3084 | flushOnEnd = _ref$flushOnEnd === undefined ? true : _ref$flushOnEnd;
|
3085 |
|
3086 | this._buff = [];
|
3087 | this._flushOnEnd = flushOnEnd;
|
3088 | },
|
3089 | _free: function () {
|
3090 | this._buff = null;
|
3091 | },
|
3092 | _flush: function () {
|
3093 | if (this._buff !== null) {
|
3094 | this._emitValue(this._buff);
|
3095 | this._buff = [];
|
3096 | }
|
3097 | },
|
3098 | _handlePrimaryEnd: function () {
|
3099 | if (this._flushOnEnd) {
|
3100 | this._flush();
|
3101 | }
|
3102 | this._emitEnd();
|
3103 | },
|
3104 | _onActivation: function () {
|
3105 | this._primary.onAny(this._$handlePrimaryAny);
|
3106 | if (this._alive && this._secondary !== null) {
|
3107 | this._secondary.onAny(this._$handleSecondaryAny);
|
3108 | }
|
3109 | },
|
3110 | _handlePrimaryValue: function (x) {
|
3111 | this._buff.push(x);
|
3112 | },
|
3113 | _handleSecondaryValue: function () {
|
3114 | this._flush();
|
3115 | },
|
3116 | _handleSecondaryEnd: function () {
|
3117 | if (!this._flushOnEnd) {
|
3118 | this._emitEnd();
|
3119 | }
|
3120 | }
|
3121 | };
|
3122 |
|
3123 | var S$37 = createStream$1('bufferBy', mixin$29);
|
3124 | var P$32 = createProperty$1('bufferBy', mixin$29);
|
3125 |
|
3126 | function bufferBy(primary, secondary, options /* optional */) {
|
3127 | return new (primary._ofSameType(S$37, P$32))(primary, secondary, options);
|
3128 | }
|
3129 |
|
3130 | var mixin$30 = {
|
3131 | _init: function () {
|
3132 | var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
3133 | _ref$flushOnEnd = _ref.flushOnEnd,
|
3134 | flushOnEnd = _ref$flushOnEnd === undefined ? true : _ref$flushOnEnd,
|
3135 | _ref$flushOnChange = _ref.flushOnChange,
|
3136 | flushOnChange = _ref$flushOnChange === undefined ? false : _ref$flushOnChange;
|
3137 |
|
3138 | this._buff = [];
|
3139 | this._flushOnEnd = flushOnEnd;
|
3140 | this._flushOnChange = flushOnChange;
|
3141 | },
|
3142 | _free: function () {
|
3143 | this._buff = null;
|
3144 | },
|
3145 | _flush: function () {
|
3146 | if (this._buff !== null) {
|
3147 | this._emitValue(this._buff);
|
3148 | this._buff = [];
|
3149 | }
|
3150 | },
|
3151 | _handlePrimaryEnd: function () {
|
3152 | if (this._flushOnEnd) {
|
3153 | this._flush();
|
3154 | }
|
3155 | this._emitEnd();
|
3156 | },
|
3157 | _handlePrimaryValue: function (x) {
|
3158 | this._buff.push(x);
|
3159 | if (this._lastSecondary !== NOTHING && !this._lastSecondary) {
|
3160 | this._flush();
|
3161 | }
|
3162 | },
|
3163 | _handleSecondaryEnd: function () {
|
3164 | if (!this._flushOnEnd && (this._lastSecondary === NOTHING || this._lastSecondary)) {
|
3165 | this._emitEnd();
|
3166 | }
|
3167 | },
|
3168 | _handleSecondaryValue: function (x) {
|
3169 | if (this._flushOnChange && !x) {
|
3170 | this._flush();
|
3171 | }
|
3172 |
|
3173 |
|
3174 | this._lastSecondary = x;
|
3175 | }
|
3176 | };
|
3177 |
|
3178 | var S$38 = createStream$1('bufferWhileBy', mixin$30);
|
3179 | var P$33 = createProperty$1('bufferWhileBy', mixin$30);
|
3180 |
|
3181 | function bufferWhileBy(primary, secondary, options /* optional */) {
|
3182 | return new (primary._ofSameType(S$38, P$33))(primary, secondary, options);
|
3183 | }
|
3184 |
|
3185 | var f = function () {
|
3186 | return false;
|
3187 | };
|
3188 | var t = function () {
|
3189 | return true;
|
3190 | };
|
3191 |
|
3192 | function awaiting(a, b) {
|
3193 | var result = merge([map$1(a, t), map$1(b, f)]);
|
3194 | result = skipDuplicates(result);
|
3195 | result = toProperty(result, f);
|
3196 | return result.setName(a, 'awaiting');
|
3197 | }
|
3198 |
|
3199 | var mixin$31 = {
|
3200 | _init: function (_ref) {
|
3201 | var fn = _ref.fn;
|
3202 |
|
3203 | this._fn = fn;
|
3204 | },
|
3205 | _free: function () {
|
3206 | this._fn = null;
|
3207 | },
|
3208 | _handleValue: function (x) {
|
3209 | var fn = this._fn;
|
3210 | var result = fn(x);
|
3211 | if (result.convert) {
|
3212 | this._emitError(result.error);
|
3213 | } else {
|
3214 | this._emitValue(x);
|
3215 | }
|
3216 | }
|
3217 | };
|
3218 |
|
3219 | var S$39 = createStream('valuesToErrors', mixin$31);
|
3220 | var P$34 = createProperty('valuesToErrors', mixin$31);
|
3221 |
|
3222 | var defFn = function (x) {
|
3223 | return { convert: true, error: x };
|
3224 | };
|
3225 |
|
3226 | function valuesToErrors(obs) {
|
3227 | var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defFn;
|
3228 |
|
3229 | return new (obs._ofSameType(S$39, P$34))(obs, { fn: fn });
|
3230 | }
|
3231 |
|
3232 | var mixin$32 = {
|
3233 | _init: function (_ref) {
|
3234 | var fn = _ref.fn;
|
3235 |
|
3236 | this._fn = fn;
|
3237 | },
|
3238 | _free: function () {
|
3239 | this._fn = null;
|
3240 | },
|
3241 | _handleError: function (x) {
|
3242 | var fn = this._fn;
|
3243 | var result = fn(x);
|
3244 | if (result.convert) {
|
3245 | this._emitValue(result.value);
|
3246 | } else {
|
3247 | this._emitError(x);
|
3248 | }
|
3249 | }
|
3250 | };
|
3251 |
|
3252 | var S$40 = createStream('errorsToValues', mixin$32);
|
3253 | var P$35 = createProperty('errorsToValues', mixin$32);
|
3254 |
|
3255 | var defFn$1 = function (x) {
|
3256 | return { convert: true, value: x };
|
3257 | };
|
3258 |
|
3259 | function errorsToValues(obs) {
|
3260 | var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defFn$1;
|
3261 |
|
3262 | return new (obs._ofSameType(S$40, P$35))(obs, { fn: fn });
|
3263 | }
|
3264 |
|
3265 | var mixin$33 = {
|
3266 | _handleError: function (x) {
|
3267 | this._emitError(x);
|
3268 | this._emitEnd();
|
3269 | }
|
3270 | };
|
3271 |
|
3272 | var S$41 = createStream('endOnError', mixin$33);
|
3273 | var P$36 = createProperty('endOnError', mixin$33);
|
3274 |
|
3275 | function endOnError(obs) {
|
3276 | return new (obs._ofSameType(S$41, P$36))(obs);
|
3277 | }
|
3278 |
|
3279 |
|
3280 |
|
3281 |
|
3282 |
|
3283 |
|
3284 |
|
3285 |
|
3286 |
|
3287 |
|
3288 |
|
3289 |
|
3290 |
|
3291 |
|
3292 |
|
3293 |
|
3294 |
|
3295 |
|
3296 |
|
3297 |
|
3298 |
|
3299 |
|
3300 |
|
3301 |
|
3302 | Observable.prototype.toProperty = function (fn) {
|
3303 | return toProperty(this, fn);
|
3304 | };
|
3305 |
|
3306 |
|
3307 | Observable.prototype.changes = function () {
|
3308 | return changes(this);
|
3309 | };
|
3310 |
|
3311 |
|
3312 |
|
3313 |
|
3314 |
|
3315 |
|
3316 | Observable.prototype.toPromise = function (Promise) {
|
3317 | return toPromise(this, Promise);
|
3318 | };
|
3319 |
|
3320 |
|
3321 |
|
3322 | Observable.prototype.toESObservable = toESObservable;
|
3323 | Observable.prototype[$$observable] = toESObservable;
|
3324 |
|
3325 |
|
3326 |
|
3327 |
|
3328 |
|
3329 |
|
3330 | Observable.prototype.map = function (fn) {
|
3331 | return map$1(this, fn);
|
3332 | };
|
3333 |
|
3334 |
|
3335 |
|
3336 | Observable.prototype.filter = function (fn) {
|
3337 | return filter(this, fn);
|
3338 | };
|
3339 |
|
3340 |
|
3341 |
|
3342 | Observable.prototype.take = function (n) {
|
3343 | return take(this, n);
|
3344 | };
|
3345 |
|
3346 |
|
3347 |
|
3348 | Observable.prototype.takeErrors = function (n) {
|
3349 | return takeErrors(this, n);
|
3350 | };
|
3351 |
|
3352 |
|
3353 |
|
3354 | Observable.prototype.takeWhile = function (fn) {
|
3355 | return takeWhile(this, fn);
|
3356 | };
|
3357 |
|
3358 |
|
3359 |
|
3360 | Observable.prototype.last = function () {
|
3361 | return last(this);
|
3362 | };
|
3363 |
|
3364 |
|
3365 |
|
3366 | Observable.prototype.skip = function (n) {
|
3367 | return skip(this, n);
|
3368 | };
|
3369 |
|
3370 |
|
3371 |
|
3372 | Observable.prototype.skipWhile = function (fn) {
|
3373 | return skipWhile(this, fn);
|
3374 | };
|
3375 |
|
3376 |
|
3377 |
|
3378 | Observable.prototype.skipDuplicates = function (fn) {
|
3379 | return skipDuplicates(this, fn);
|
3380 | };
|
3381 |
|
3382 |
|
3383 |
|
3384 | Observable.prototype.diff = function (fn, seed) {
|
3385 | return diff(this, fn, seed);
|
3386 | };
|
3387 |
|
3388 |
|
3389 | Observable.prototype.scan = function (fn, seed) {
|
3390 | return scan(this, fn, seed);
|
3391 | };
|
3392 |
|
3393 |
|
3394 |
|
3395 | Observable.prototype.flatten = function (fn) {
|
3396 | return flatten(this, fn);
|
3397 | };
|
3398 |
|
3399 |
|
3400 |
|
3401 | Observable.prototype.delay = function (wait) {
|
3402 | return delay(this, wait);
|
3403 | };
|
3404 |
|
3405 |
|
3406 |
|
3407 |
|
3408 | Observable.prototype.throttle = function (wait, options) {
|
3409 | return throttle(this, wait, options);
|
3410 | };
|
3411 |
|
3412 |
|
3413 |
|
3414 |
|
3415 | Observable.prototype.debounce = function (wait, options) {
|
3416 | return debounce(this, wait, options);
|
3417 | };
|
3418 |
|
3419 |
|
3420 |
|
3421 | Observable.prototype.mapErrors = function (fn) {
|
3422 | return mapErrors(this, fn);
|
3423 | };
|
3424 |
|
3425 |
|
3426 |
|
3427 | Observable.prototype.filterErrors = function (fn) {
|
3428 | return filterErrors(this, fn);
|
3429 | };
|
3430 |
|
3431 |
|
3432 |
|
3433 | Observable.prototype.ignoreValues = function () {
|
3434 | return ignoreValues(this);
|
3435 | };
|
3436 |
|
3437 |
|
3438 |
|
3439 | Observable.prototype.ignoreErrors = function () {
|
3440 | return ignoreErrors(this);
|
3441 | };
|
3442 |
|
3443 |
|
3444 |
|
3445 | Observable.prototype.ignoreEnd = function () {
|
3446 | return ignoreEnd(this);
|
3447 | };
|
3448 |
|
3449 |
|
3450 |
|
3451 | Observable.prototype.beforeEnd = function (fn) {
|
3452 | return beforeEnd(this, fn);
|
3453 | };
|
3454 |
|
3455 |
|
3456 |
|
3457 | Observable.prototype.slidingWindow = function (max, min) {
|
3458 | return slidingWindow(this, max, min);
|
3459 | };
|
3460 |
|
3461 |
|
3462 |
|
3463 |
|
3464 | Observable.prototype.bufferWhile = function (fn, options) {
|
3465 | return bufferWhile(this, fn, options);
|
3466 | };
|
3467 |
|
3468 |
|
3469 |
|
3470 | Observable.prototype.bufferWithCount = function (count, options) {
|
3471 | return bufferWhile$1(this, count, options);
|
3472 | };
|
3473 |
|
3474 |
|
3475 |
|
3476 |
|
3477 | Observable.prototype.bufferWithTimeOrCount = function (wait, count, options) {
|
3478 | return bufferWithTimeOrCount(this, wait, count, options);
|
3479 | };
|
3480 |
|
3481 |
|
3482 |
|
3483 | Observable.prototype.transduce = function (transducer) {
|
3484 | return transduce(this, transducer);
|
3485 | };
|
3486 |
|
3487 |
|
3488 |
|
3489 | Observable.prototype.withHandler = function (fn) {
|
3490 | return withHandler(this, fn);
|
3491 | };
|
3492 |
|
3493 |
|
3494 |
|
3495 | Observable.prototype.thru = function (fn) {
|
3496 | return fn(this);
|
3497 | };
|
3498 |
|
3499 |
|
3500 |
|
3501 |
|
3502 |
|
3503 |
|
3504 | Observable.prototype.combine = function (other, combinator) {
|
3505 | return combine([this, other], combinator);
|
3506 | };
|
3507 |
|
3508 |
|
3509 | Observable.prototype.zip = function (other, combinator) {
|
3510 | return zip([this, other], combinator);
|
3511 | };
|
3512 |
|
3513 |
|
3514 | Observable.prototype.merge = function (other) {
|
3515 | return merge([this, other]);
|
3516 | };
|
3517 |
|
3518 |
|
3519 | Observable.prototype.concat = function (other) {
|
3520 | return concat$1([this, other]);
|
3521 | };
|
3522 |
|
3523 |
|
3524 | var pool = function () {
|
3525 | return new Pool();
|
3526 | };
|
3527 |
|
3528 |
|
3529 |
|
3530 |
|
3531 | Observable.prototype.flatMap = function (fn) {
|
3532 | return new FlatMap(this, fn).setName(this, 'flatMap');
|
3533 | };
|
3534 | Observable.prototype.flatMapLatest = function (fn) {
|
3535 | return new FlatMap(this, fn, { concurLim: 1, drop: 'old' }).setName(this, 'flatMapLatest');
|
3536 | };
|
3537 | Observable.prototype.flatMapFirst = function (fn) {
|
3538 | return new FlatMap(this, fn, { concurLim: 1 }).setName(this, 'flatMapFirst');
|
3539 | };
|
3540 | Observable.prototype.flatMapConcat = function (fn) {
|
3541 | return new FlatMap(this, fn, { queueLim: -1, concurLim: 1 }).setName(this, 'flatMapConcat');
|
3542 | };
|
3543 | Observable.prototype.flatMapConcurLimit = function (fn, limit) {
|
3544 | return new FlatMap(this, fn, { queueLim: -1, concurLim: limit }).setName(this, 'flatMapConcurLimit');
|
3545 | };
|
3546 |
|
3547 |
|
3548 | Observable.prototype.flatMapErrors = function (fn) {
|
3549 | return new FlatMapErrors(this, fn).setName(this, 'flatMapErrors');
|
3550 | };
|
3551 |
|
3552 |
|
3553 |
|
3554 |
|
3555 |
|
3556 |
|
3557 | Observable.prototype.filterBy = function (other) {
|
3558 | return filterBy(this, other);
|
3559 | };
|
3560 |
|
3561 |
|
3562 |
|
3563 | Observable.prototype.sampledBy = function (other, combinator) {
|
3564 | return sampledBy(this, other, combinator);
|
3565 | };
|
3566 |
|
3567 |
|
3568 |
|
3569 | Observable.prototype.skipUntilBy = function (other) {
|
3570 | return skipUntilBy(this, other);
|
3571 | };
|
3572 |
|
3573 |
|
3574 |
|
3575 | Observable.prototype.takeUntilBy = function (other) {
|
3576 | return takeUntilBy(this, other);
|
3577 | };
|
3578 |
|
3579 |
|
3580 |
|
3581 |
|
3582 | Observable.prototype.bufferBy = function (other, options) {
|
3583 | return bufferBy(this, other, options);
|
3584 | };
|
3585 |
|
3586 |
|
3587 |
|
3588 |
|
3589 | Observable.prototype.bufferWhileBy = function (other, options) {
|
3590 | return bufferWhileBy(this, other, options);
|
3591 | };
|
3592 |
|
3593 |
|
3594 |
|
3595 |
|
3596 | var DEPRECATION_WARNINGS = true;
|
3597 | function dissableDeprecationWarnings() {
|
3598 | DEPRECATION_WARNINGS = false;
|
3599 | }
|
3600 |
|
3601 | function warn(msg) {
|
3602 | if (DEPRECATION_WARNINGS && console && typeof console.warn === 'function') {
|
3603 | var msg2 = '\nHere is an Error object for you containing the call stack:';
|
3604 | console.warn(msg, msg2, new Error());
|
3605 | }
|
3606 | }
|
3607 |
|
3608 |
|
3609 | Observable.prototype.awaiting = function (other) {
|
3610 | warn('You are using deprecated .awaiting() method, see https://github.com/kefirjs/kefir/issues/145');
|
3611 | return awaiting(this, other);
|
3612 | };
|
3613 |
|
3614 |
|
3615 |
|
3616 | Observable.prototype.valuesToErrors = function (fn) {
|
3617 | warn('You are using deprecated .valuesToErrors() method, see https://github.com/kefirjs/kefir/issues/149');
|
3618 | return valuesToErrors(this, fn);
|
3619 | };
|
3620 |
|
3621 |
|
3622 |
|
3623 | Observable.prototype.errorsToValues = function (fn) {
|
3624 | warn('You are using deprecated .errorsToValues() method, see https://github.com/kefirjs/kefir/issues/149');
|
3625 | return errorsToValues(this, fn);
|
3626 | };
|
3627 |
|
3628 |
|
3629 |
|
3630 | Observable.prototype.endOnError = function () {
|
3631 | warn('You are using deprecated .endOnError() method, see https://github.com/kefirjs/kefir/issues/150');
|
3632 | return endOnError(this);
|
3633 | };
|
3634 |
|
3635 |
|
3636 |
|
3637 |
|
3638 | var Kefir = {
|
3639 | Observable: Observable,
|
3640 | Stream: Stream,
|
3641 | Property: Property,
|
3642 | never: never,
|
3643 | later: later,
|
3644 | interval: interval,
|
3645 | sequentially: sequentially,
|
3646 | fromPoll: fromPoll,
|
3647 | withInterval: withInterval,
|
3648 | fromCallback: fromCallback,
|
3649 | fromNodeCallback: fromNodeCallback,
|
3650 | fromEvents: fromEvents,
|
3651 | stream: stream,
|
3652 | constant: constant,
|
3653 | constantError: constantError,
|
3654 | fromPromise: fromPromise,
|
3655 | fromESObservable: fromESObservable,
|
3656 | combine: combine,
|
3657 | zip: zip,
|
3658 | merge: merge,
|
3659 | concat: concat$1,
|
3660 | Pool: Pool,
|
3661 | pool: pool,
|
3662 | repeat: repeat,
|
3663 | staticLand: staticLand
|
3664 | };
|
3665 |
|
3666 | Kefir.Kefir = Kefir;
|
3667 |
|
3668 | export { dissableDeprecationWarnings, Kefir, Observable, Stream, Property, never, later, interval, sequentially, fromPoll, withInterval, fromCallback, fromNodeCallback, fromEvents, stream, constant, constantError, fromPromise, fromESObservable, combine, zip, merge, concat$1 as concat, Pool, pool, repeat, staticLand };export default Kefir;
|