1 | "use strict";
|
2 | var __extends = (this && this.__extends) || function (d, b) {
|
3 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
4 | function __() { this.constructor = d; }
|
5 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
6 | };
|
7 | var symbol_observable_1 = require("symbol-observable");
|
8 | var NO = {};
|
9 | exports.NO = NO;
|
10 | function noop() { }
|
11 | function cp(a) {
|
12 | var l = a.length;
|
13 | var b = Array(l);
|
14 | for (var i = 0; i < l; ++i)
|
15 | b[i] = a[i];
|
16 | return b;
|
17 | }
|
18 | function and(f1, f2) {
|
19 | return function andFn(t) {
|
20 | return f1(t) && f2(t);
|
21 | };
|
22 | }
|
23 | function _try(c, t, u) {
|
24 | try {
|
25 | return c.f(t);
|
26 | }
|
27 | catch (e) {
|
28 | u._e(e);
|
29 | return NO;
|
30 | }
|
31 | }
|
32 | var NO_IL = {
|
33 | _n: noop,
|
34 | _e: noop,
|
35 | _c: noop,
|
36 | };
|
37 | exports.NO_IL = NO_IL;
|
38 |
|
39 | function internalizeProducer(producer) {
|
40 | producer._start = function _start(il) {
|
41 | il.next = il._n;
|
42 | il.error = il._e;
|
43 | il.complete = il._c;
|
44 | this.start(il);
|
45 | };
|
46 | producer._stop = producer.stop;
|
47 | }
|
48 | var StreamSub = (function () {
|
49 | function StreamSub(_stream, _listener) {
|
50 | this._stream = _stream;
|
51 | this._listener = _listener;
|
52 | }
|
53 | StreamSub.prototype.unsubscribe = function () {
|
54 | this._stream.removeListener(this._listener);
|
55 | };
|
56 | return StreamSub;
|
57 | }());
|
58 | var Observer = (function () {
|
59 | function Observer(_listener) {
|
60 | this._listener = _listener;
|
61 | }
|
62 | Observer.prototype.next = function (value) {
|
63 | this._listener._n(value);
|
64 | };
|
65 | Observer.prototype.error = function (err) {
|
66 | this._listener._e(err);
|
67 | };
|
68 | Observer.prototype.complete = function () {
|
69 | this._listener._c();
|
70 | };
|
71 | return Observer;
|
72 | }());
|
73 | var FromObservable = (function () {
|
74 | function FromObservable(observable) {
|
75 | this.type = 'fromObservable';
|
76 | this.ins = observable;
|
77 | this.active = false;
|
78 | }
|
79 | FromObservable.prototype._start = function (out) {
|
80 | this.out = out;
|
81 | this.active = true;
|
82 | this._sub = this.ins.subscribe(new Observer(out));
|
83 | if (!this.active)
|
84 | this._sub.unsubscribe();
|
85 | };
|
86 | FromObservable.prototype._stop = function () {
|
87 | if (this._sub)
|
88 | this._sub.unsubscribe();
|
89 | this.active = false;
|
90 | };
|
91 | return FromObservable;
|
92 | }());
|
93 | var Merge = (function () {
|
94 | function Merge(insArr) {
|
95 | this.type = 'merge';
|
96 | this.insArr = insArr;
|
97 | this.out = NO;
|
98 | this.ac = 0;
|
99 | }
|
100 | Merge.prototype._start = function (out) {
|
101 | this.out = out;
|
102 | var s = this.insArr;
|
103 | var L = s.length;
|
104 | this.ac = L;
|
105 | for (var i = 0; i < L; i++)
|
106 | s[i]._add(this);
|
107 | };
|
108 | Merge.prototype._stop = function () {
|
109 | var s = this.insArr;
|
110 | var L = s.length;
|
111 | for (var i = 0; i < L; i++)
|
112 | s[i]._remove(this);
|
113 | this.out = NO;
|
114 | };
|
115 | Merge.prototype._n = function (t) {
|
116 | var u = this.out;
|
117 | if (u === NO)
|
118 | return;
|
119 | u._n(t);
|
120 | };
|
121 | Merge.prototype._e = function (err) {
|
122 | var u = this.out;
|
123 | if (u === NO)
|
124 | return;
|
125 | u._e(err);
|
126 | };
|
127 | Merge.prototype._c = function () {
|
128 | if (--this.ac <= 0) {
|
129 | var u = this.out;
|
130 | if (u === NO)
|
131 | return;
|
132 | u._c();
|
133 | }
|
134 | };
|
135 | return Merge;
|
136 | }());
|
137 | var CombineListener = (function () {
|
138 | function CombineListener(i, out, p) {
|
139 | this.i = i;
|
140 | this.out = out;
|
141 | this.p = p;
|
142 | p.ils.push(this);
|
143 | }
|
144 | CombineListener.prototype._n = function (t) {
|
145 | var p = this.p, out = this.out;
|
146 | if (out === NO)
|
147 | return;
|
148 | if (p.up(t, this.i)) {
|
149 | var a = p.vals;
|
150 | var l = a.length;
|
151 | var b = Array(l);
|
152 | for (var i = 0; i < l; ++i)
|
153 | b[i] = a[i];
|
154 | out._n(b);
|
155 | }
|
156 | };
|
157 | CombineListener.prototype._e = function (err) {
|
158 | var out = this.out;
|
159 | if (out === NO)
|
160 | return;
|
161 | out._e(err);
|
162 | };
|
163 | CombineListener.prototype._c = function () {
|
164 | var p = this.p;
|
165 | if (p.out === NO)
|
166 | return;
|
167 | if (--p.Nc === 0)
|
168 | p.out._c();
|
169 | };
|
170 | return CombineListener;
|
171 | }());
|
172 | var Combine = (function () {
|
173 | function Combine(insArr) {
|
174 | this.type = 'combine';
|
175 | this.insArr = insArr;
|
176 | this.out = NO;
|
177 | this.ils = [];
|
178 | this.Nc = this.Nn = 0;
|
179 | this.vals = [];
|
180 | }
|
181 | Combine.prototype.up = function (t, i) {
|
182 | var v = this.vals[i];
|
183 | var Nn = !this.Nn ? 0 : v === NO ? --this.Nn : this.Nn;
|
184 | this.vals[i] = t;
|
185 | return Nn === 0;
|
186 | };
|
187 | Combine.prototype._start = function (out) {
|
188 | this.out = out;
|
189 | var s = this.insArr;
|
190 | var n = this.Nc = this.Nn = s.length;
|
191 | var vals = this.vals = new Array(n);
|
192 | if (n === 0) {
|
193 | out._n([]);
|
194 | out._c();
|
195 | }
|
196 | else {
|
197 | for (var i = 0; i < n; i++) {
|
198 | vals[i] = NO;
|
199 | s[i]._add(new CombineListener(i, out, this));
|
200 | }
|
201 | }
|
202 | };
|
203 | Combine.prototype._stop = function () {
|
204 | var s = this.insArr;
|
205 | var n = s.length;
|
206 | var ils = this.ils;
|
207 | for (var i = 0; i < n; i++)
|
208 | s[i]._remove(ils[i]);
|
209 | this.out = NO;
|
210 | this.ils = [];
|
211 | this.vals = [];
|
212 | };
|
213 | return Combine;
|
214 | }());
|
215 | var FromArray = (function () {
|
216 | function FromArray(a) {
|
217 | this.type = 'fromArray';
|
218 | this.a = a;
|
219 | }
|
220 | FromArray.prototype._start = function (out) {
|
221 | var a = this.a;
|
222 | for (var i = 0, n = a.length; i < n; i++)
|
223 | out._n(a[i]);
|
224 | out._c();
|
225 | };
|
226 | FromArray.prototype._stop = function () {
|
227 | };
|
228 | return FromArray;
|
229 | }());
|
230 | var FromPromise = (function () {
|
231 | function FromPromise(p) {
|
232 | this.type = 'fromPromise';
|
233 | this.on = false;
|
234 | this.p = p;
|
235 | }
|
236 | FromPromise.prototype._start = function (out) {
|
237 | var prod = this;
|
238 | this.on = true;
|
239 | this.p.then(function (v) {
|
240 | if (prod.on) {
|
241 | out._n(v);
|
242 | out._c();
|
243 | }
|
244 | }, function (e) {
|
245 | out._e(e);
|
246 | }).then(noop, function (err) {
|
247 | setTimeout(function () { throw err; });
|
248 | });
|
249 | };
|
250 | FromPromise.prototype._stop = function () {
|
251 | this.on = false;
|
252 | };
|
253 | return FromPromise;
|
254 | }());
|
255 | var Periodic = (function () {
|
256 | function Periodic(period) {
|
257 | this.type = 'periodic';
|
258 | this.period = period;
|
259 | this.intervalID = -1;
|
260 | this.i = 0;
|
261 | }
|
262 | Periodic.prototype._start = function (out) {
|
263 | var self = this;
|
264 | function intervalHandler() { out._n(self.i++); }
|
265 | this.intervalID = setInterval(intervalHandler, this.period);
|
266 | };
|
267 | Periodic.prototype._stop = function () {
|
268 | if (this.intervalID !== -1)
|
269 | clearInterval(this.intervalID);
|
270 | this.intervalID = -1;
|
271 | this.i = 0;
|
272 | };
|
273 | return Periodic;
|
274 | }());
|
275 | var Debug = (function () {
|
276 | function Debug(ins, arg) {
|
277 | this.type = 'debug';
|
278 | this.ins = ins;
|
279 | this.out = NO;
|
280 | this.s = noop;
|
281 | this.l = '';
|
282 | if (typeof arg === 'string')
|
283 | this.l = arg;
|
284 | else if (typeof arg === 'function')
|
285 | this.s = arg;
|
286 | }
|
287 | Debug.prototype._start = function (out) {
|
288 | this.out = out;
|
289 | this.ins._add(this);
|
290 | };
|
291 | Debug.prototype._stop = function () {
|
292 | this.ins._remove(this);
|
293 | this.out = NO;
|
294 | };
|
295 | Debug.prototype._n = function (t) {
|
296 | var u = this.out;
|
297 | if (u === NO)
|
298 | return;
|
299 | var s = this.s, l = this.l;
|
300 | if (s !== noop) {
|
301 | try {
|
302 | s(t);
|
303 | }
|
304 | catch (e) {
|
305 | u._e(e);
|
306 | }
|
307 | }
|
308 | else if (l)
|
309 | console.log(l + ':', t);
|
310 | else
|
311 | console.log(t);
|
312 | u._n(t);
|
313 | };
|
314 | Debug.prototype._e = function (err) {
|
315 | var u = this.out;
|
316 | if (u === NO)
|
317 | return;
|
318 | u._e(err);
|
319 | };
|
320 | Debug.prototype._c = function () {
|
321 | var u = this.out;
|
322 | if (u === NO)
|
323 | return;
|
324 | u._c();
|
325 | };
|
326 | return Debug;
|
327 | }());
|
328 | var Drop = (function () {
|
329 | function Drop(max, ins) {
|
330 | this.type = 'drop';
|
331 | this.ins = ins;
|
332 | this.out = NO;
|
333 | this.max = max;
|
334 | this.dropped = 0;
|
335 | }
|
336 | Drop.prototype._start = function (out) {
|
337 | this.out = out;
|
338 | this.dropped = 0;
|
339 | this.ins._add(this);
|
340 | };
|
341 | Drop.prototype._stop = function () {
|
342 | this.ins._remove(this);
|
343 | this.out = NO;
|
344 | };
|
345 | Drop.prototype._n = function (t) {
|
346 | var u = this.out;
|
347 | if (u === NO)
|
348 | return;
|
349 | if (this.dropped++ >= this.max)
|
350 | u._n(t);
|
351 | };
|
352 | Drop.prototype._e = function (err) {
|
353 | var u = this.out;
|
354 | if (u === NO)
|
355 | return;
|
356 | u._e(err);
|
357 | };
|
358 | Drop.prototype._c = function () {
|
359 | var u = this.out;
|
360 | if (u === NO)
|
361 | return;
|
362 | u._c();
|
363 | };
|
364 | return Drop;
|
365 | }());
|
366 | var EndWhenListener = (function () {
|
367 | function EndWhenListener(out, op) {
|
368 | this.out = out;
|
369 | this.op = op;
|
370 | }
|
371 | EndWhenListener.prototype._n = function () {
|
372 | this.op.end();
|
373 | };
|
374 | EndWhenListener.prototype._e = function (err) {
|
375 | this.out._e(err);
|
376 | };
|
377 | EndWhenListener.prototype._c = function () {
|
378 | this.op.end();
|
379 | };
|
380 | return EndWhenListener;
|
381 | }());
|
382 | var EndWhen = (function () {
|
383 | function EndWhen(o, ins) {
|
384 | this.type = 'endWhen';
|
385 | this.ins = ins;
|
386 | this.out = NO;
|
387 | this.o = o;
|
388 | this.oil = NO_IL;
|
389 | }
|
390 | EndWhen.prototype._start = function (out) {
|
391 | this.out = out;
|
392 | this.o._add(this.oil = new EndWhenListener(out, this));
|
393 | this.ins._add(this);
|
394 | };
|
395 | EndWhen.prototype._stop = function () {
|
396 | this.ins._remove(this);
|
397 | this.o._remove(this.oil);
|
398 | this.out = NO;
|
399 | this.oil = NO_IL;
|
400 | };
|
401 | EndWhen.prototype.end = function () {
|
402 | var u = this.out;
|
403 | if (u === NO)
|
404 | return;
|
405 | u._c();
|
406 | };
|
407 | EndWhen.prototype._n = function (t) {
|
408 | var u = this.out;
|
409 | if (u === NO)
|
410 | return;
|
411 | u._n(t);
|
412 | };
|
413 | EndWhen.prototype._e = function (err) {
|
414 | var u = this.out;
|
415 | if (u === NO)
|
416 | return;
|
417 | u._e(err);
|
418 | };
|
419 | EndWhen.prototype._c = function () {
|
420 | this.end();
|
421 | };
|
422 | return EndWhen;
|
423 | }());
|
424 | var Filter = (function () {
|
425 | function Filter(passes, ins) {
|
426 | this.type = 'filter';
|
427 | this.ins = ins;
|
428 | this.out = NO;
|
429 | this.f = passes;
|
430 | }
|
431 | Filter.prototype._start = function (out) {
|
432 | this.out = out;
|
433 | this.ins._add(this);
|
434 | };
|
435 | Filter.prototype._stop = function () {
|
436 | this.ins._remove(this);
|
437 | this.out = NO;
|
438 | };
|
439 | Filter.prototype._n = function (t) {
|
440 | var u = this.out;
|
441 | if (u === NO)
|
442 | return;
|
443 | var r = _try(this, t, u);
|
444 | if (r === NO || !r)
|
445 | return;
|
446 | u._n(t);
|
447 | };
|
448 | Filter.prototype._e = function (err) {
|
449 | var u = this.out;
|
450 | if (u === NO)
|
451 | return;
|
452 | u._e(err);
|
453 | };
|
454 | Filter.prototype._c = function () {
|
455 | var u = this.out;
|
456 | if (u === NO)
|
457 | return;
|
458 | u._c();
|
459 | };
|
460 | return Filter;
|
461 | }());
|
462 | var FlattenListener = (function () {
|
463 | function FlattenListener(out, op) {
|
464 | this.out = out;
|
465 | this.op = op;
|
466 | }
|
467 | FlattenListener.prototype._n = function (t) {
|
468 | this.out._n(t);
|
469 | };
|
470 | FlattenListener.prototype._e = function (err) {
|
471 | this.out._e(err);
|
472 | };
|
473 | FlattenListener.prototype._c = function () {
|
474 | this.op.inner = NO;
|
475 | this.op.less();
|
476 | };
|
477 | return FlattenListener;
|
478 | }());
|
479 | var Flatten = (function () {
|
480 | function Flatten(ins) {
|
481 | this.type = 'flatten';
|
482 | this.ins = ins;
|
483 | this.out = NO;
|
484 | this.open = true;
|
485 | this.inner = NO;
|
486 | this.il = NO_IL;
|
487 | }
|
488 | Flatten.prototype._start = function (out) {
|
489 | this.out = out;
|
490 | this.open = true;
|
491 | this.inner = NO;
|
492 | this.il = NO_IL;
|
493 | this.ins._add(this);
|
494 | };
|
495 | Flatten.prototype._stop = function () {
|
496 | this.ins._remove(this);
|
497 | if (this.inner !== NO)
|
498 | this.inner._remove(this.il);
|
499 | this.out = NO;
|
500 | this.open = true;
|
501 | this.inner = NO;
|
502 | this.il = NO_IL;
|
503 | };
|
504 | Flatten.prototype.less = function () {
|
505 | var u = this.out;
|
506 | if (u === NO)
|
507 | return;
|
508 | if (!this.open && this.inner === NO)
|
509 | u._c();
|
510 | };
|
511 | Flatten.prototype._n = function (s) {
|
512 | var u = this.out;
|
513 | if (u === NO)
|
514 | return;
|
515 | var _a = this, inner = _a.inner, il = _a.il;
|
516 | if (inner !== NO && il !== NO_IL)
|
517 | inner._remove(il);
|
518 | (this.inner = s)._add(this.il = new FlattenListener(u, this));
|
519 | };
|
520 | Flatten.prototype._e = function (err) {
|
521 | var u = this.out;
|
522 | if (u === NO)
|
523 | return;
|
524 | u._e(err);
|
525 | };
|
526 | Flatten.prototype._c = function () {
|
527 | this.open = false;
|
528 | this.less();
|
529 | };
|
530 | return Flatten;
|
531 | }());
|
532 | var Fold = (function () {
|
533 | function Fold(f, seed, ins) {
|
534 | var _this = this;
|
535 | this.type = 'fold';
|
536 | this.ins = ins;
|
537 | this.out = NO;
|
538 | this.f = function (t) { return f(_this.acc, t); };
|
539 | this.acc = this.seed = seed;
|
540 | }
|
541 | Fold.prototype._start = function (out) {
|
542 | this.out = out;
|
543 | this.acc = this.seed;
|
544 | out._n(this.acc);
|
545 | this.ins._add(this);
|
546 | };
|
547 | Fold.prototype._stop = function () {
|
548 | this.ins._remove(this);
|
549 | this.out = NO;
|
550 | this.acc = this.seed;
|
551 | };
|
552 | Fold.prototype._n = function (t) {
|
553 | var u = this.out;
|
554 | if (u === NO)
|
555 | return;
|
556 | var r = _try(this, t, u);
|
557 | if (r === NO)
|
558 | return;
|
559 | u._n(this.acc = r);
|
560 | };
|
561 | Fold.prototype._e = function (err) {
|
562 | var u = this.out;
|
563 | if (u === NO)
|
564 | return;
|
565 | u._e(err);
|
566 | };
|
567 | Fold.prototype._c = function () {
|
568 | var u = this.out;
|
569 | if (u === NO)
|
570 | return;
|
571 | u._c();
|
572 | };
|
573 | return Fold;
|
574 | }());
|
575 | var Last = (function () {
|
576 | function Last(ins) {
|
577 | this.type = 'last';
|
578 | this.ins = ins;
|
579 | this.out = NO;
|
580 | this.has = false;
|
581 | this.val = NO;
|
582 | }
|
583 | Last.prototype._start = function (out) {
|
584 | this.out = out;
|
585 | this.has = false;
|
586 | this.ins._add(this);
|
587 | };
|
588 | Last.prototype._stop = function () {
|
589 | this.ins._remove(this);
|
590 | this.out = NO;
|
591 | this.val = NO;
|
592 | };
|
593 | Last.prototype._n = function (t) {
|
594 | this.has = true;
|
595 | this.val = t;
|
596 | };
|
597 | Last.prototype._e = function (err) {
|
598 | var u = this.out;
|
599 | if (u === NO)
|
600 | return;
|
601 | u._e(err);
|
602 | };
|
603 | Last.prototype._c = function () {
|
604 | var u = this.out;
|
605 | if (u === NO)
|
606 | return;
|
607 | if (this.has) {
|
608 | u._n(this.val);
|
609 | u._c();
|
610 | }
|
611 | else
|
612 | u._e(new Error('last() failed because input stream completed'));
|
613 | };
|
614 | return Last;
|
615 | }());
|
616 | var MapFlattenListener = (function () {
|
617 | function MapFlattenListener(out, op) {
|
618 | this.out = out;
|
619 | this.op = op;
|
620 | }
|
621 | MapFlattenListener.prototype._n = function (r) {
|
622 | this.out._n(r);
|
623 | };
|
624 | MapFlattenListener.prototype._e = function (err) {
|
625 | this.out._e(err);
|
626 | };
|
627 | MapFlattenListener.prototype._c = function () {
|
628 | this.op.inner = NO;
|
629 | this.op.less();
|
630 | };
|
631 | return MapFlattenListener;
|
632 | }());
|
633 | var MapFlatten = (function () {
|
634 | function MapFlatten(mapOp) {
|
635 | this.type = mapOp.type + "+flatten";
|
636 | this.ins = mapOp.ins;
|
637 | this.out = NO;
|
638 | this.mapOp = mapOp;
|
639 | this.inner = NO;
|
640 | this.il = NO_IL;
|
641 | this.open = true;
|
642 | }
|
643 | MapFlatten.prototype._start = function (out) {
|
644 | this.out = out;
|
645 | this.inner = NO;
|
646 | this.il = NO_IL;
|
647 | this.open = true;
|
648 | this.mapOp.ins._add(this);
|
649 | };
|
650 | MapFlatten.prototype._stop = function () {
|
651 | this.mapOp.ins._remove(this);
|
652 | if (this.inner !== NO)
|
653 | this.inner._remove(this.il);
|
654 | this.out = NO;
|
655 | this.inner = NO;
|
656 | this.il = NO_IL;
|
657 | };
|
658 | MapFlatten.prototype.less = function () {
|
659 | if (!this.open && this.inner === NO) {
|
660 | var u = this.out;
|
661 | if (u === NO)
|
662 | return;
|
663 | u._c();
|
664 | }
|
665 | };
|
666 | MapFlatten.prototype._n = function (v) {
|
667 | var u = this.out;
|
668 | if (u === NO)
|
669 | return;
|
670 | var _a = this, inner = _a.inner, il = _a.il;
|
671 | var s = _try(this.mapOp, v, u);
|
672 | if (s === NO)
|
673 | return;
|
674 | if (inner !== NO && il !== NO_IL)
|
675 | inner._remove(il);
|
676 | (this.inner = s)._add(this.il = new MapFlattenListener(u, this));
|
677 | };
|
678 | MapFlatten.prototype._e = function (err) {
|
679 | var u = this.out;
|
680 | if (u === NO)
|
681 | return;
|
682 | u._e(err);
|
683 | };
|
684 | MapFlatten.prototype._c = function () {
|
685 | this.open = false;
|
686 | this.less();
|
687 | };
|
688 | return MapFlatten;
|
689 | }());
|
690 | var MapOp = (function () {
|
691 | function MapOp(project, ins) {
|
692 | this.type = 'map';
|
693 | this.ins = ins;
|
694 | this.out = NO;
|
695 | this.f = project;
|
696 | }
|
697 | MapOp.prototype._start = function (out) {
|
698 | this.out = out;
|
699 | this.ins._add(this);
|
700 | };
|
701 | MapOp.prototype._stop = function () {
|
702 | this.ins._remove(this);
|
703 | this.out = NO;
|
704 | };
|
705 | MapOp.prototype._n = function (t) {
|
706 | var u = this.out;
|
707 | if (u === NO)
|
708 | return;
|
709 | var r = _try(this, t, u);
|
710 | if (r === NO)
|
711 | return;
|
712 | u._n(r);
|
713 | };
|
714 | MapOp.prototype._e = function (err) {
|
715 | var u = this.out;
|
716 | if (u === NO)
|
717 | return;
|
718 | u._e(err);
|
719 | };
|
720 | MapOp.prototype._c = function () {
|
721 | var u = this.out;
|
722 | if (u === NO)
|
723 | return;
|
724 | u._c();
|
725 | };
|
726 | return MapOp;
|
727 | }());
|
728 | var FilterMapFusion = (function (_super) {
|
729 | __extends(FilterMapFusion, _super);
|
730 | function FilterMapFusion(passes, project, ins) {
|
731 | var _this = _super.call(this, project, ins) || this;
|
732 | _this.type = 'filter+map';
|
733 | _this.passes = passes;
|
734 | return _this;
|
735 | }
|
736 | FilterMapFusion.prototype._n = function (t) {
|
737 | if (!this.passes(t))
|
738 | return;
|
739 | var u = this.out;
|
740 | if (u === NO)
|
741 | return;
|
742 | var r = _try(this, t, u);
|
743 | if (r === NO)
|
744 | return;
|
745 | u._n(r);
|
746 | };
|
747 | return FilterMapFusion;
|
748 | }(MapOp));
|
749 | var Remember = (function () {
|
750 | function Remember(ins) {
|
751 | this.type = 'remember';
|
752 | this.ins = ins;
|
753 | this.out = NO;
|
754 | }
|
755 | Remember.prototype._start = function (out) {
|
756 | this.out = out;
|
757 | this.ins._add(out);
|
758 | };
|
759 | Remember.prototype._stop = function () {
|
760 | this.ins._remove(this.out);
|
761 | this.out = NO;
|
762 | };
|
763 | return Remember;
|
764 | }());
|
765 | var ReplaceError = (function () {
|
766 | function ReplaceError(replacer, ins) {
|
767 | this.type = 'replaceError';
|
768 | this.ins = ins;
|
769 | this.out = NO;
|
770 | this.f = replacer;
|
771 | }
|
772 | ReplaceError.prototype._start = function (out) {
|
773 | this.out = out;
|
774 | this.ins._add(this);
|
775 | };
|
776 | ReplaceError.prototype._stop = function () {
|
777 | this.ins._remove(this);
|
778 | this.out = NO;
|
779 | };
|
780 | ReplaceError.prototype._n = function (t) {
|
781 | var u = this.out;
|
782 | if (u === NO)
|
783 | return;
|
784 | u._n(t);
|
785 | };
|
786 | ReplaceError.prototype._e = function (err) {
|
787 | var u = this.out;
|
788 | if (u === NO)
|
789 | return;
|
790 | try {
|
791 | this.ins._remove(this);
|
792 | (this.ins = this.f(err))._add(this);
|
793 | }
|
794 | catch (e) {
|
795 | u._e(e);
|
796 | }
|
797 | };
|
798 | ReplaceError.prototype._c = function () {
|
799 | var u = this.out;
|
800 | if (u === NO)
|
801 | return;
|
802 | u._c();
|
803 | };
|
804 | return ReplaceError;
|
805 | }());
|
806 | var StartWith = (function () {
|
807 | function StartWith(ins, val) {
|
808 | this.type = 'startWith';
|
809 | this.ins = ins;
|
810 | this.out = NO;
|
811 | this.val = val;
|
812 | }
|
813 | StartWith.prototype._start = function (out) {
|
814 | this.out = out;
|
815 | this.out._n(this.val);
|
816 | this.ins._add(out);
|
817 | };
|
818 | StartWith.prototype._stop = function () {
|
819 | this.ins._remove(this.out);
|
820 | this.out = NO;
|
821 | };
|
822 | return StartWith;
|
823 | }());
|
824 | var Take = (function () {
|
825 | function Take(max, ins) {
|
826 | this.type = 'take';
|
827 | this.ins = ins;
|
828 | this.out = NO;
|
829 | this.max = max;
|
830 | this.taken = 0;
|
831 | }
|
832 | Take.prototype._start = function (out) {
|
833 | this.out = out;
|
834 | this.taken = 0;
|
835 | if (this.max <= 0)
|
836 | out._c();
|
837 | else
|
838 | this.ins._add(this);
|
839 | };
|
840 | Take.prototype._stop = function () {
|
841 | this.ins._remove(this);
|
842 | this.out = NO;
|
843 | };
|
844 | Take.prototype._n = function (t) {
|
845 | var u = this.out;
|
846 | if (u === NO)
|
847 | return;
|
848 | var m = ++this.taken;
|
849 | if (m < this.max)
|
850 | u._n(t);
|
851 | else if (m === this.max) {
|
852 | u._n(t);
|
853 | u._c();
|
854 | }
|
855 | };
|
856 | Take.prototype._e = function (err) {
|
857 | var u = this.out;
|
858 | if (u === NO)
|
859 | return;
|
860 | u._e(err);
|
861 | };
|
862 | Take.prototype._c = function () {
|
863 | var u = this.out;
|
864 | if (u === NO)
|
865 | return;
|
866 | u._c();
|
867 | };
|
868 | return Take;
|
869 | }());
|
870 | var Stream = (function () {
|
871 | function Stream(producer) {
|
872 | this._prod = producer || NO;
|
873 | this._ils = [];
|
874 | this._stopID = NO;
|
875 | this._dl = NO;
|
876 | this._d = false;
|
877 | this._target = NO;
|
878 | this._err = NO;
|
879 | }
|
880 | Stream.prototype._n = function (t) {
|
881 | var a = this._ils;
|
882 | var L = a.length;
|
883 | if (this._d)
|
884 | this._dl._n(t);
|
885 | if (L == 1)
|
886 | a[0]._n(t);
|
887 | else if (L == 0)
|
888 | return;
|
889 | else {
|
890 | var b = cp(a);
|
891 | for (var i = 0; i < L; i++)
|
892 | b[i]._n(t);
|
893 | }
|
894 | };
|
895 | Stream.prototype._e = function (err) {
|
896 | if (this._err !== NO)
|
897 | return;
|
898 | this._err = err;
|
899 | var a = this._ils;
|
900 | var L = a.length;
|
901 | this._x();
|
902 | if (this._d)
|
903 | this._dl._e(err);
|
904 | if (L == 1)
|
905 | a[0]._e(err);
|
906 | else if (L == 0)
|
907 | return;
|
908 | else {
|
909 | var b = cp(a);
|
910 | for (var i = 0; i < L; i++)
|
911 | b[i]._e(err);
|
912 | }
|
913 | if (!this._d && L == 0)
|
914 | throw this._err;
|
915 | };
|
916 | Stream.prototype._c = function () {
|
917 | var a = this._ils;
|
918 | var L = a.length;
|
919 | this._x();
|
920 | if (this._d)
|
921 | this._dl._c();
|
922 | if (L == 1)
|
923 | a[0]._c();
|
924 | else if (L == 0)
|
925 | return;
|
926 | else {
|
927 | var b = cp(a);
|
928 | for (var i = 0; i < L; i++)
|
929 | b[i]._c();
|
930 | }
|
931 | };
|
932 | Stream.prototype._x = function () {
|
933 | if (this._ils.length === 0)
|
934 | return;
|
935 | if (this._prod !== NO)
|
936 | this._prod._stop();
|
937 | this._err = NO;
|
938 | this._ils = [];
|
939 | };
|
940 | Stream.prototype._stopNow = function () {
|
941 |
|
942 |
|
943 | this._prod._stop();
|
944 | this._err = NO;
|
945 | this._stopID = NO;
|
946 | };
|
947 | Stream.prototype._add = function (il) {
|
948 | var ta = this._target;
|
949 | if (ta !== NO)
|
950 | return ta._add(il);
|
951 | var a = this._ils;
|
952 | a.push(il);
|
953 | if (a.length > 1)
|
954 | return;
|
955 | if (this._stopID !== NO) {
|
956 | clearTimeout(this._stopID);
|
957 | this._stopID = NO;
|
958 | }
|
959 | else {
|
960 | var p = this._prod;
|
961 | if (p !== NO)
|
962 | p._start(this);
|
963 | }
|
964 | };
|
965 | Stream.prototype._remove = function (il) {
|
966 | var _this = this;
|
967 | var ta = this._target;
|
968 | if (ta !== NO)
|
969 | return ta._remove(il);
|
970 | var a = this._ils;
|
971 | var i = a.indexOf(il);
|
972 | if (i > -1) {
|
973 | a.splice(i, 1);
|
974 | if (this._prod !== NO && a.length <= 0) {
|
975 | this._err = NO;
|
976 | this._stopID = setTimeout(function () { return _this._stopNow(); });
|
977 | }
|
978 | else if (a.length === 1) {
|
979 | this._pruneCycles();
|
980 | }
|
981 | }
|
982 | };
|
983 |
|
984 |
|
985 |
|
986 |
|
987 | Stream.prototype._pruneCycles = function () {
|
988 | if (this._hasNoSinks(this, []))
|
989 | this._remove(this._ils[0]);
|
990 | };
|
991 |
|
992 |
|
993 |
|
994 |
|
995 | Stream.prototype._hasNoSinks = function (x, trace) {
|
996 | if (trace.indexOf(x) !== -1)
|
997 | return true;
|
998 | else if (x.out === this)
|
999 | return true;
|
1000 | else if (x.out && x.out !== NO)
|
1001 | return this._hasNoSinks(x.out, trace.concat(x));
|
1002 | else if (x._ils) {
|
1003 | for (var i = 0, N = x._ils.length; i < N; i++)
|
1004 | if (!this._hasNoSinks(x._ils[i], trace.concat(x)))
|
1005 | return false;
|
1006 | return true;
|
1007 | }
|
1008 | else
|
1009 | return false;
|
1010 | };
|
1011 | Stream.prototype.ctor = function () {
|
1012 | return this instanceof MemoryStream ? MemoryStream : Stream;
|
1013 | };
|
1014 | |
1015 |
|
1016 |
|
1017 |
|
1018 |
|
1019 | Stream.prototype.addListener = function (listener) {
|
1020 | listener._n = listener.next || noop;
|
1021 | listener._e = listener.error || noop;
|
1022 | listener._c = listener.complete || noop;
|
1023 | this._add(listener);
|
1024 | };
|
1025 | |
1026 |
|
1027 |
|
1028 |
|
1029 |
|
1030 | Stream.prototype.removeListener = function (listener) {
|
1031 | this._remove(listener);
|
1032 | };
|
1033 | |
1034 |
|
1035 |
|
1036 |
|
1037 |
|
1038 |
|
1039 |
|
1040 | Stream.prototype.subscribe = function (listener) {
|
1041 | this.addListener(listener);
|
1042 | return new StreamSub(this, listener);
|
1043 | };
|
1044 | |
1045 |
|
1046 |
|
1047 |
|
1048 |
|
1049 | Stream.prototype[symbol_observable_1.default] = function () {
|
1050 | return this;
|
1051 | };
|
1052 | |
1053 |
|
1054 |
|
1055 |
|
1056 |
|
1057 |
|
1058 |
|
1059 |
|
1060 | Stream.create = function (producer) {
|
1061 | if (producer) {
|
1062 | if (typeof producer.start !== 'function'
|
1063 | || typeof producer.stop !== 'function')
|
1064 | throw new Error('producer requires both start and stop functions');
|
1065 | internalizeProducer(producer);
|
1066 | }
|
1067 | return new Stream(producer);
|
1068 | };
|
1069 | |
1070 |
|
1071 |
|
1072 |
|
1073 |
|
1074 |
|
1075 |
|
1076 |
|
1077 | Stream.createWithMemory = function (producer) {
|
1078 | if (producer)
|
1079 | internalizeProducer(producer);
|
1080 | return new MemoryStream(producer);
|
1081 | };
|
1082 | |
1083 |
|
1084 |
|
1085 |
|
1086 |
|
1087 |
|
1088 |
|
1089 |
|
1090 |
|
1091 |
|
1092 |
|
1093 |
|
1094 |
|
1095 | Stream.never = function () {
|
1096 | return new Stream({ _start: noop, _stop: noop });
|
1097 | };
|
1098 | |
1099 |
|
1100 |
|
1101 |
|
1102 |
|
1103 |
|
1104 |
|
1105 |
|
1106 |
|
1107 |
|
1108 |
|
1109 |
|
1110 |
|
1111 |
|
1112 | Stream.empty = function () {
|
1113 | return new Stream({
|
1114 | _start: function (il) { il._c(); },
|
1115 | _stop: noop,
|
1116 | });
|
1117 | };
|
1118 | |
1119 |
|
1120 |
|
1121 |
|
1122 |
|
1123 |
|
1124 |
|
1125 |
|
1126 |
|
1127 |
|
1128 |
|
1129 |
|
1130 |
|
1131 |
|
1132 |
|
1133 |
|
1134 | Stream.throw = function (error) {
|
1135 | return new Stream({
|
1136 | _start: function (il) { il._e(error); },
|
1137 | _stop: noop,
|
1138 | });
|
1139 | };
|
1140 | |
1141 |
|
1142 |
|
1143 |
|
1144 |
|
1145 |
|
1146 |
|
1147 | Stream.from = function (input) {
|
1148 | if (typeof input[symbol_observable_1.default] === 'function')
|
1149 | return Stream.fromObservable(input);
|
1150 | else if (typeof input.then === 'function')
|
1151 | return Stream.fromPromise(input);
|
1152 | else if (Array.isArray(input))
|
1153 | return Stream.fromArray(input);
|
1154 | throw new TypeError("Type of input to from() must be an Array, Promise, or Observable");
|
1155 | };
|
1156 | |
1157 |
|
1158 |
|
1159 |
|
1160 |
|
1161 |
|
1162 |
|
1163 |
|
1164 |
|
1165 |
|
1166 |
|
1167 |
|
1168 |
|
1169 |
|
1170 |
|
1171 |
|
1172 |
|
1173 | Stream.of = function () {
|
1174 | var items = [];
|
1175 | for (var _i = 0; _i < arguments.length; _i++) {
|
1176 | items[_i] = arguments[_i];
|
1177 | }
|
1178 | return Stream.fromArray(items);
|
1179 | };
|
1180 | |
1181 |
|
1182 |
|
1183 |
|
1184 |
|
1185 |
|
1186 |
|
1187 |
|
1188 |
|
1189 |
|
1190 |
|
1191 |
|
1192 |
|
1193 |
|
1194 |
|
1195 | Stream.fromArray = function (array) {
|
1196 | return new Stream(new FromArray(array));
|
1197 | };
|
1198 | |
1199 |
|
1200 |
|
1201 |
|
1202 |
|
1203 |
|
1204 |
|
1205 |
|
1206 |
|
1207 |
|
1208 |
|
1209 |
|
1210 |
|
1211 |
|
1212 |
|
1213 |
|
1214 | Stream.fromPromise = function (promise) {
|
1215 | return new Stream(new FromPromise(promise));
|
1216 | };
|
1217 | |
1218 |
|
1219 |
|
1220 |
|
1221 |
|
1222 |
|
1223 |
|
1224 | Stream.fromObservable = function (obs) {
|
1225 | if (obs.endWhen)
|
1226 | return obs;
|
1227 | return new Stream(new FromObservable(obs));
|
1228 | };
|
1229 | |
1230 |
|
1231 |
|
1232 |
|
1233 |
|
1234 |
|
1235 |
|
1236 |
|
1237 |
|
1238 |
|
1239 |
|
1240 |
|
1241 |
|
1242 |
|
1243 |
|
1244 |
|
1245 | Stream.periodic = function (period) {
|
1246 | return new Stream(new Periodic(period));
|
1247 | };
|
1248 | Stream.prototype._map = function (project) {
|
1249 | var p = this._prod;
|
1250 | var ctor = this.ctor();
|
1251 | if (p instanceof Filter)
|
1252 | return new ctor(new FilterMapFusion(p.f, project, p.ins));
|
1253 | return new ctor(new MapOp(project, this));
|
1254 | };
|
1255 | |
1256 |
|
1257 |
|
1258 |
|
1259 |
|
1260 |
|
1261 |
|
1262 |
|
1263 |
|
1264 |
|
1265 |
|
1266 |
|
1267 |
|
1268 |
|
1269 |
|
1270 |
|
1271 |
|
1272 | Stream.prototype.map = function (project) {
|
1273 | return this._map(project);
|
1274 | };
|
1275 | |
1276 |
|
1277 |
|
1278 |
|
1279 |
|
1280 |
|
1281 |
|
1282 |
|
1283 |
|
1284 |
|
1285 |
|
1286 |
|
1287 |
|
1288 |
|
1289 |
|
1290 |
|
1291 | Stream.prototype.mapTo = function (projectedValue) {
|
1292 | var s = this.map(function () { return projectedValue; });
|
1293 | var op = s._prod;
|
1294 | op.type = op.type.replace('map', 'mapTo');
|
1295 | return s;
|
1296 | };
|
1297 | |
1298 |
|
1299 |
|
1300 |
|
1301 |
|
1302 |
|
1303 |
|
1304 |
|
1305 |
|
1306 |
|
1307 |
|
1308 |
|
1309 |
|
1310 |
|
1311 |
|
1312 |
|
1313 |
|
1314 |
|
1315 |
|
1316 |
|
1317 | Stream.prototype.filter = function (passes) {
|
1318 | var p = this._prod;
|
1319 | if (p instanceof Filter)
|
1320 | return new Stream(new Filter(and(p.f, passes), p.ins));
|
1321 | return new Stream(new Filter(passes, this));
|
1322 | };
|
1323 | |
1324 |
|
1325 |
|
1326 |
|
1327 |
|
1328 |
|
1329 |
|
1330 |
|
1331 |
|
1332 |
|
1333 |
|
1334 |
|
1335 |
|
1336 |
|
1337 |
|
1338 |
|
1339 | Stream.prototype.take = function (amount) {
|
1340 | return new (this.ctor())(new Take(amount, this));
|
1341 | };
|
1342 | |
1343 |
|
1344 |
|
1345 |
|
1346 |
|
1347 |
|
1348 |
|
1349 |
|
1350 |
|
1351 |
|
1352 |
|
1353 |
|
1354 |
|
1355 |
|
1356 |
|
1357 |
|
1358 |
|
1359 | Stream.prototype.drop = function (amount) {
|
1360 | return new Stream(new Drop(amount, this));
|
1361 | };
|
1362 | |
1363 |
|
1364 |
|
1365 |
|
1366 |
|
1367 |
|
1368 |
|
1369 |
|
1370 |
|
1371 |
|
1372 |
|
1373 |
|
1374 |
|
1375 |
|
1376 | Stream.prototype.last = function () {
|
1377 | return new Stream(new Last(this));
|
1378 | };
|
1379 | |
1380 |
|
1381 |
|
1382 |
|
1383 |
|
1384 |
|
1385 |
|
1386 |
|
1387 |
|
1388 |
|
1389 |
|
1390 |
|
1391 |
|
1392 |
|
1393 |
|
1394 |
|
1395 | Stream.prototype.startWith = function (initial) {
|
1396 | return new MemoryStream(new StartWith(this, initial));
|
1397 | };
|
1398 | |
1399 |
|
1400 |
|
1401 |
|
1402 |
|
1403 |
|
1404 |
|
1405 |
|
1406 |
|
1407 |
|
1408 |
|
1409 |
|
1410 |
|
1411 |
|
1412 |
|
1413 |
|
1414 |
|
1415 |
|
1416 |
|
1417 | Stream.prototype.endWhen = function (other) {
|
1418 | return new (this.ctor())(new EndWhen(other, this));
|
1419 | };
|
1420 | |
1421 |
|
1422 |
|
1423 |
|
1424 |
|
1425 |
|
1426 |
|
1427 |
|
1428 |
|
1429 |
|
1430 |
|
1431 |
|
1432 |
|
1433 |
|
1434 |
|
1435 |
|
1436 |
|
1437 |
|
1438 |
|
1439 |
|
1440 |
|
1441 |
|
1442 |
|
1443 |
|
1444 |
|
1445 |
|
1446 |
|
1447 |
|
1448 |
|
1449 | Stream.prototype.fold = function (accumulate, seed) {
|
1450 | return new MemoryStream(new Fold(accumulate, seed, this));
|
1451 | };
|
1452 | |
1453 |
|
1454 |
|
1455 |
|
1456 |
|
1457 |
|
1458 |
|
1459 |
|
1460 |
|
1461 |
|
1462 |
|
1463 |
|
1464 |
|
1465 |
|
1466 |
|
1467 |
|
1468 |
|
1469 |
|
1470 |
|
1471 |
|
1472 |
|
1473 |
|
1474 |
|
1475 | Stream.prototype.replaceError = function (replace) {
|
1476 | return new (this.ctor())(new ReplaceError(replace, this));
|
1477 | };
|
1478 | |
1479 |
|
1480 |
|
1481 |
|
1482 |
|
1483 |
|
1484 |
|
1485 |
|
1486 |
|
1487 |
|
1488 |
|
1489 |
|
1490 |
|
1491 |
|
1492 |
|
1493 |
|
1494 |
|
1495 |
|
1496 |
|
1497 |
|
1498 |
|
1499 |
|
1500 |
|
1501 |
|
1502 |
|
1503 | Stream.prototype.flatten = function () {
|
1504 | var p = this._prod;
|
1505 | return new Stream(p instanceof MapOp && !(p instanceof FilterMapFusion) ?
|
1506 | new MapFlatten(p) :
|
1507 | new Flatten(this));
|
1508 | };
|
1509 | |
1510 |
|
1511 |
|
1512 |
|
1513 |
|
1514 |
|
1515 |
|
1516 |
|
1517 |
|
1518 |
|
1519 |
|
1520 | Stream.prototype.compose = function (operator) {
|
1521 | return operator(this);
|
1522 | };
|
1523 | |
1524 |
|
1525 |
|
1526 |
|
1527 |
|
1528 |
|
1529 |
|
1530 | Stream.prototype.remember = function () {
|
1531 | return new MemoryStream(new Remember(this));
|
1532 | };
|
1533 | |
1534 |
|
1535 |
|
1536 |
|
1537 |
|
1538 |
|
1539 |
|
1540 |
|
1541 |
|
1542 |
|
1543 |
|
1544 |
|
1545 |
|
1546 |
|
1547 |
|
1548 |
|
1549 |
|
1550 |
|
1551 |
|
1552 |
|
1553 |
|
1554 |
|
1555 |
|
1556 |
|
1557 |
|
1558 |
|
1559 | Stream.prototype.debug = function (labelOrSpy) {
|
1560 | return new (this.ctor())(new Debug(this, labelOrSpy));
|
1561 | };
|
1562 | |
1563 |
|
1564 |
|
1565 |
|
1566 |
|
1567 |
|
1568 |
|
1569 |
|
1570 |
|
1571 |
|
1572 |
|
1573 |
|
1574 |
|
1575 |
|
1576 |
|
1577 |
|
1578 |
|
1579 |
|
1580 |
|
1581 |
|
1582 |
|
1583 |
|
1584 |
|
1585 |
|
1586 |
|
1587 |
|
1588 |
|
1589 |
|
1590 |
|
1591 |
|
1592 |
|
1593 |
|
1594 |
|
1595 |
|
1596 |
|
1597 |
|
1598 |
|
1599 |
|
1600 |
|
1601 |
|
1602 |
|
1603 |
|
1604 |
|
1605 |
|
1606 |
|
1607 |
|
1608 |
|
1609 |
|
1610 |
|
1611 |
|
1612 |
|
1613 |
|
1614 |
|
1615 |
|
1616 |
|
1617 |
|
1618 |
|
1619 |
|
1620 |
|
1621 |
|
1622 |
|
1623 |
|
1624 |
|
1625 |
|
1626 | Stream.prototype.imitate = function (target) {
|
1627 | if (target instanceof MemoryStream)
|
1628 | throw new Error('A MemoryStream was given to imitate(), but it only ' +
|
1629 | 'supports a Stream. Read more about this restriction here: ' +
|
1630 | 'https://github.com/staltz/xstream#faq');
|
1631 | this._target = target;
|
1632 | for (var ils = this._ils, N = ils.length, i = 0; i < N; i++)
|
1633 | target._add(ils[i]);
|
1634 | this._ils = [];
|
1635 | };
|
1636 | |
1637 |
|
1638 |
|
1639 |
|
1640 |
|
1641 |
|
1642 |
|
1643 |
|
1644 |
|
1645 |
|
1646 | Stream.prototype.shamefullySendNext = function (value) {
|
1647 | this._n(value);
|
1648 | };
|
1649 | |
1650 |
|
1651 |
|
1652 |
|
1653 |
|
1654 |
|
1655 |
|
1656 |
|
1657 |
|
1658 |
|
1659 | Stream.prototype.shamefullySendError = function (error) {
|
1660 | this._e(error);
|
1661 | };
|
1662 | |
1663 |
|
1664 |
|
1665 |
|
1666 |
|
1667 |
|
1668 |
|
1669 | Stream.prototype.shamefullySendComplete = function () {
|
1670 | this._c();
|
1671 | };
|
1672 | |
1673 |
|
1674 |
|
1675 |
|
1676 |
|
1677 |
|
1678 |
|
1679 |
|
1680 |
|
1681 |
|
1682 |
|
1683 |
|
1684 |
|
1685 |
|
1686 |
|
1687 |
|
1688 |
|
1689 |
|
1690 |
|
1691 |
|
1692 | Stream.prototype.setDebugListener = function (listener) {
|
1693 | if (!listener) {
|
1694 | this._d = false;
|
1695 | this._dl = NO;
|
1696 | }
|
1697 | else {
|
1698 | this._d = true;
|
1699 | listener._n = listener.next || noop;
|
1700 | listener._e = listener.error || noop;
|
1701 | listener._c = listener.complete || noop;
|
1702 | this._dl = listener;
|
1703 | }
|
1704 | };
|
1705 | return Stream;
|
1706 | }());
|
1707 |
|
1708 |
|
1709 |
|
1710 |
|
1711 |
|
1712 |
|
1713 |
|
1714 |
|
1715 |
|
1716 |
|
1717 |
|
1718 |
|
1719 |
|
1720 |
|
1721 |
|
1722 |
|
1723 |
|
1724 |
|
1725 |
|
1726 |
|
1727 |
|
1728 |
|
1729 | Stream.merge = function merge() {
|
1730 | var streams = [];
|
1731 | for (var _i = 0; _i < arguments.length; _i++) {
|
1732 | streams[_i] = arguments[_i];
|
1733 | }
|
1734 | return new Stream(new Merge(streams));
|
1735 | };
|
1736 |
|
1737 |
|
1738 |
|
1739 |
|
1740 |
|
1741 |
|
1742 |
|
1743 |
|
1744 |
|
1745 |
|
1746 |
|
1747 |
|
1748 |
|
1749 |
|
1750 |
|
1751 |
|
1752 |
|
1753 |
|
1754 |
|
1755 |
|
1756 |
|
1757 |
|
1758 |
|
1759 |
|
1760 |
|
1761 |
|
1762 |
|
1763 |
|
1764 |
|
1765 |
|
1766 |
|
1767 |
|
1768 |
|
1769 |
|
1770 |
|
1771 |
|
1772 |
|
1773 |
|
1774 |
|
1775 |
|
1776 | Stream.combine = function combine() {
|
1777 | var streams = [];
|
1778 | for (var _i = 0; _i < arguments.length; _i++) {
|
1779 | streams[_i] = arguments[_i];
|
1780 | }
|
1781 | return new Stream(new Combine(streams));
|
1782 | };
|
1783 | exports.Stream = Stream;
|
1784 | var MemoryStream = (function (_super) {
|
1785 | __extends(MemoryStream, _super);
|
1786 | function MemoryStream(producer) {
|
1787 | var _this = _super.call(this, producer) || this;
|
1788 | _this._has = false;
|
1789 | return _this;
|
1790 | }
|
1791 | MemoryStream.prototype._n = function (x) {
|
1792 | this._v = x;
|
1793 | this._has = true;
|
1794 | _super.prototype._n.call(this, x);
|
1795 | };
|
1796 | MemoryStream.prototype._add = function (il) {
|
1797 | var ta = this._target;
|
1798 | if (ta !== NO)
|
1799 | return ta._add(il);
|
1800 | var a = this._ils;
|
1801 | a.push(il);
|
1802 | if (a.length > 1) {
|
1803 | if (this._has)
|
1804 | il._n(this._v);
|
1805 | return;
|
1806 | }
|
1807 | if (this._stopID !== NO) {
|
1808 | if (this._has)
|
1809 | il._n(this._v);
|
1810 | clearTimeout(this._stopID);
|
1811 | this._stopID = NO;
|
1812 | }
|
1813 | else if (this._has)
|
1814 | il._n(this._v);
|
1815 | else {
|
1816 | var p = this._prod;
|
1817 | if (p !== NO)
|
1818 | p._start(this);
|
1819 | }
|
1820 | };
|
1821 | MemoryStream.prototype._stopNow = function () {
|
1822 | this._has = false;
|
1823 | _super.prototype._stopNow.call(this);
|
1824 | };
|
1825 | MemoryStream.prototype._x = function () {
|
1826 | this._has = false;
|
1827 | _super.prototype._x.call(this);
|
1828 | };
|
1829 | MemoryStream.prototype.map = function (project) {
|
1830 | return this._map(project);
|
1831 | };
|
1832 | MemoryStream.prototype.mapTo = function (projectedValue) {
|
1833 | return _super.prototype.mapTo.call(this, projectedValue);
|
1834 | };
|
1835 | MemoryStream.prototype.take = function (amount) {
|
1836 | return _super.prototype.take.call(this, amount);
|
1837 | };
|
1838 | MemoryStream.prototype.endWhen = function (other) {
|
1839 | return _super.prototype.endWhen.call(this, other);
|
1840 | };
|
1841 | MemoryStream.prototype.replaceError = function (replace) {
|
1842 | return _super.prototype.replaceError.call(this, replace);
|
1843 | };
|
1844 | MemoryStream.prototype.remember = function () {
|
1845 | return this;
|
1846 | };
|
1847 | MemoryStream.prototype.debug = function (labelOrSpy) {
|
1848 | return _super.prototype.debug.call(this, labelOrSpy);
|
1849 | };
|
1850 | return MemoryStream;
|
1851 | }(Stream));
|
1852 | exports.MemoryStream = MemoryStream;
|
1853 | Object.defineProperty(exports, "__esModule", { value: true });
|
1854 | exports.default = Stream;
|
1855 |
|
\ | No newline at end of file |