UNPKG

17.1 kBJavaScriptView Raw
1(function(e){"object"===typeof exports&&"undefined"!==typeof module?module.exports=e():"function"===typeof define&&define.amd?define([],e):("undefined"!==typeof window?window:"undefined"!==typeof global?global:"undefined"!==typeof self?self:this).xstream=e()})(function(){return function(){function e(k,h,d){function q(l,m){if(!h[l]){if(!k[l]){var n="function"==typeof require&&require;if(!m&&n)return n(l,!0);if(u)return u(l,!0);m=Error("Cannot find module '"+l+"'");throw m.code="MODULE_NOT_FOUND",m;
2}m=h[l]={exports:{}};k[l][0].call(m.exports,function(c){return q(k[l][1][c]||c)},m,m.exports,e,k,h,d)}return h[l].exports}for(var u="function"==typeof require&&require,n=0;n<d.length;n++)q(d[n]);return q}return e}()({1:[function(e,k,h){function d(){}function q(a){for(var b=a.length,f=Array(b),c=0;c<b;++c)f[c]=a[c];return f}function u(a,b){return function(f){return a(f)&&b(f)}}function n(a,b,f){try{return a.f(b)}catch(g){return f._e(g),c}}function l(a){a._start=function(b){b.next=b._n;b.error=b._e;
3b.complete=b._c;this.start(b)};a._stop=a.stop}var m=this&&this.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(b,f){b.__proto__=f}||function(b,f){for(var a in f)f.hasOwnProperty(a)&&(b[a]=f[a])};return function(b,f){function c(){this.constructor=b}a(b,f);b.prototype=null===f?Object.create(f):(c.prototype=f.prototype,new c)}}();Object.defineProperty(h,"__esModule",{value:!0});var t=e("symbol-observable"),c={};h.NO=c;var r={_n:d,_e:d,_c:d};h.NO_IL=r;var x=
4function(){function a(b,f){this._stream=b;this._listener=f}a.prototype.unsubscribe=function(){this._stream._remove(this._listener)};return a}(),y=function(){function a(b){this._listener=b}a.prototype.next=function(b){this._listener._n(b)};a.prototype.error=function(b){this._listener._e(b)};a.prototype.complete=function(){this._listener._c()};return a}(),z=function(){function a(b){this.type="fromObservable";this.ins=b;this.active=!1}a.prototype._start=function(b){this.out=b;this.active=!0;this._sub=
5this.ins.subscribe(new y(b));this.active||this._sub.unsubscribe()};a.prototype._stop=function(){this._sub&&this._sub.unsubscribe();this.active=!1};return a}(),A=function(){function a(b){this.type="merge";this.insArr=b;this.out=c;this.ac=0}a.prototype._start=function(b){this.out=b;b=this.insArr;var f=b.length;this.ac=f;for(var a=0;a<f;a++)b[a]._add(this)};a.prototype._stop=function(){for(var b=this.insArr,a=b.length,g=0;g<a;g++)b[g]._remove(this);this.out=c};a.prototype._n=function(b){var a=this.out;
6a!==c&&a._n(b)};a.prototype._e=function(b){var a=this.out;a!==c&&a._e(b)};a.prototype._c=function(){if(0>=--this.ac){var b=this.out;b!==c&&b._c()}};return a}(),C=function(){function a(b,a,c){this.i=b;this.out=a;this.p=c;c.ils.push(this)}a.prototype._n=function(b){var a=this.p,g=this.out;if(g!==c&&a.up(b,this.i)){b=a.vals;a=b.length;for(var w=Array(a),d=0;d<a;++d)w[d]=b[d];g._n(w)}};a.prototype._e=function(b){var a=this.out;a!==c&&a._e(b)};a.prototype._c=function(){var b=this.p;b.out!==c&&0===--b.Nc&&
7b.out._c()};return a}(),D=function(){function a(b){this.type="combine";this.insArr=b;this.out=c;this.ils=[];this.Nc=this.Nn=0;this.vals=[]}a.prototype.up=function(b,a){var f=this.vals[a];f=this.Nn?f===c?--this.Nn:this.Nn:0;this.vals[a]=b;return 0===f};a.prototype._start=function(b){this.out=b;var a=this.insArr,g=this.Nc=this.Nn=a.length,d=this.vals=Array(g);if(0===g)b._n([]),b._c();else for(var e=0;e<g;e++)d[e]=c,a[e]._add(new C(e,b,this))};a.prototype._stop=function(){for(var b=this.insArr,a=b.length,
8g=this.ils,d=0;d<a;d++)b[d]._remove(g[d]);this.out=c;this.ils=[];this.vals=[]};return a}(),E=function(){function a(b){this.type="fromArray";this.a=b}a.prototype._start=function(b){for(var a=this.a,c=0,d=a.length;c<d;c++)b._n(a[c]);b._c()};a.prototype._stop=function(){};return a}(),F=function(){function a(b){this.type="fromPromise";this.on=!1;this.p=b}a.prototype._start=function(b){var a=this;this.on=!0;this.p.then(function(f){a.on&&(b._n(f),b._c())},function(a){b._e(a)}).then(d,function(b){setTimeout(function(){throw b;
9})})};a.prototype._stop=function(){this.on=!1};return a}(),G=function(){function a(b){this.type="periodic";this.period=b;this.intervalID=-1;this.i=0}a.prototype._start=function(b){var a=this;this.intervalID=setInterval(function(){b._n(a.i++)},this.period)};a.prototype._stop=function(){-1!==this.intervalID&&clearInterval(this.intervalID);this.intervalID=-1;this.i=0};return a}(),H=function(){function a(b,a){this.type="debug";this.ins=b;this.out=c;this.s=d;this.l="";"string"===typeof a?this.l=a:"function"===
10typeof a&&(this.s=a)}a.prototype._start=function(b){this.out=b;this.ins._add(this)};a.prototype._stop=function(){this.ins._remove(this);this.out=c};a.prototype._n=function(b){var a=this.out;if(a!==c){var g=this.s,e=this.l;if(g!==d)try{g(b)}catch(B){a._e(B)}else e?console.log(e+":",b):console.log(b);a._n(b)}};a.prototype._e=function(b){var a=this.out;a!==c&&a._e(b)};a.prototype._c=function(){var b=this.out;b!==c&&b._c()};return a}(),I=function(){function a(b,a){this.type="drop";this.ins=a;this.out=
11c;this.max=b;this.dropped=0}a.prototype._start=function(b){this.out=b;this.dropped=0;this.ins._add(this)};a.prototype._stop=function(){this.ins._remove(this);this.out=c};a.prototype._n=function(b){var a=this.out;a!==c&&this.dropped++>=this.max&&a._n(b)};a.prototype._e=function(b){var a=this.out;a!==c&&a._e(b)};a.prototype._c=function(){var b=this.out;b!==c&&b._c()};return a}(),J=function(){function a(b,a){this.out=b;this.op=a}a.prototype._n=function(){this.op.end()};a.prototype._e=function(b){this.out._e(b)};
12a.prototype._c=function(){this.op.end()};return a}(),K=function(){function a(b,a){this.type="endWhen";this.ins=a;this.out=c;this.o=b;this.oil=r}a.prototype._start=function(b){this.out=b;this.o._add(this.oil=new J(b,this));this.ins._add(this)};a.prototype._stop=function(){this.ins._remove(this);this.o._remove(this.oil);this.out=c;this.oil=r};a.prototype.end=function(){var b=this.out;b!==c&&b._c()};a.prototype._n=function(b){var a=this.out;a!==c&&a._n(b)};a.prototype._e=function(b){var a=this.out;a!==
13c&&a._e(b)};a.prototype._c=function(){this.end()};return a}(),v=function(){function a(b,a){this.type="filter";this.ins=a;this.out=c;this.f=b}a.prototype._start=function(b){this.out=b;this.ins._add(this)};a.prototype._stop=function(){this.ins._remove(this);this.out=c};a.prototype._n=function(b){var a=this.out;if(a!==c){var g=n(this,b,a);g!==c&&g&&a._n(b)}};a.prototype._e=function(b){var a=this.out;a!==c&&a._e(b)};a.prototype._c=function(){var b=this.out;b!==c&&b._c()};return a}(),L=function(){function a(b,
14a){this.out=b;this.op=a}a.prototype._n=function(b){this.out._n(b)};a.prototype._e=function(b){this.out._e(b)};a.prototype._c=function(){this.op.inner=c;this.op.less()};return a}(),M=function(){function a(b){this.type="flatten";this.ins=b;this.out=c;this.open=!0;this.inner=c;this.il=r}a.prototype._start=function(b){this.out=b;this.open=!0;this.inner=c;this.il=r;this.ins._add(this)};a.prototype._stop=function(){this.ins._remove(this);this.inner!==c&&this.inner._remove(this.il);this.out=c;this.open=
15!0;this.inner=c;this.il=r};a.prototype.less=function(){var b=this.out;b!==c&&(this.open||this.inner!==c||b._c())};a.prototype._n=function(b){var a=this.out;if(a!==c){var g=this.inner,d=this.il;g!==c&&d!==r&&g._remove(d);(this.inner=b)._add(this.il=new L(a,this))}};a.prototype._e=function(b){var a=this.out;a!==c&&a._e(b)};a.prototype._c=function(){this.open=!1;this.less()};return a}(),N=function(){function a(b,a,g){var f=this;this.type="fold";this.ins=g;this.out=c;this.f=function(a){return b(f.acc,
16a)};this.acc=this.seed=a}a.prototype._start=function(b){this.out=b;this.acc=this.seed;b._n(this.acc);this.ins._add(this)};a.prototype._stop=function(){this.ins._remove(this);this.out=c;this.acc=this.seed};a.prototype._n=function(b){var a=this.out;a!==c&&(b=n(this,b,a),b!==c&&a._n(this.acc=b))};a.prototype._e=function(b){var a=this.out;a!==c&&a._e(b)};a.prototype._c=function(){var b=this.out;b!==c&&b._c()};return a}(),O=function(){function a(b){this.type="last";this.ins=b;this.out=c;this.has=!1;this.val=
17c}a.prototype._start=function(b){this.out=b;this.has=!1;this.ins._add(this)};a.prototype._stop=function(){this.ins._remove(this);this.val=this.out=c};a.prototype._n=function(b){this.has=!0;this.val=b};a.prototype._e=function(b){var a=this.out;a!==c&&a._e(b)};a.prototype._c=function(){var b=this.out;b!==c&&(this.has?(b._n(this.val),b._c()):b._e(Error("last() failed because input stream completed")))};return a}(),P=function(){function a(b,a){this.type="map";this.ins=a;this.out=c;this.f=b}a.prototype._start=
18function(b){this.out=b;this.ins._add(this)};a.prototype._stop=function(){this.ins._remove(this);this.out=c};a.prototype._n=function(b){var a=this.out;a!==c&&(b=n(this,b,a),b!==c&&a._n(b))};a.prototype._e=function(b){var a=this.out;a!==c&&a._e(b)};a.prototype._c=function(){var b=this.out;b!==c&&b._c()};return a}(),Q=function(){function a(b){this.type="remember";this.ins=b;this.out=c}a.prototype._start=function(b){this.out=b;this.ins._add(b)};a.prototype._stop=function(){this.ins._remove(this.out);
19this.out=c};return a}(),R=function(){function a(b,a){this.type="replaceError";this.ins=a;this.out=c;this.f=b}a.prototype._start=function(b){this.out=b;this.ins._add(this)};a.prototype._stop=function(){this.ins._remove(this);this.out=c};a.prototype._n=function(b){var a=this.out;a!==c&&a._n(b)};a.prototype._e=function(b){var a=this.out;if(a!==c)try{this.ins._remove(this),(this.ins=this.f(b))._add(this)}catch(g){a._e(g)}};a.prototype._c=function(){var b=this.out;b!==c&&b._c()};return a}(),S=function(){function a(b,
20a){this.type="startWith";this.ins=b;this.out=c;this.val=a}a.prototype._start=function(b){this.out=b;this.out._n(this.val);this.ins._add(b)};a.prototype._stop=function(){this.ins._remove(this.out);this.out=c};return a}(),T=function(){function a(b,a){this.type="take";this.ins=a;this.out=c;this.max=b;this.taken=0}a.prototype._start=function(b){this.out=b;this.taken=0;0>=this.max?b._c():this.ins._add(this)};a.prototype._stop=function(){this.ins._remove(this);this.out=c};a.prototype._n=function(b){var a=
21this.out;if(a!==c){var g=++this.taken;g<this.max?a._n(b):g===this.max&&(a._n(b),a._c())}};a.prototype._e=function(b){var a=this.out;a!==c&&a._e(b)};a.prototype._c=function(){var b=this.out;b!==c&&b._c()};return a}();e=function(){function a(b){this._prod=b||c;this._ils=[];this._dl=this._stopID=c;this._d=!1;this._err=this._target=c}a.prototype._n=function(b){var a=this._ils,c=a.length;this._d&&this._dl._n(b);if(1==c)a[0]._n(b);else if(0!=c){a=q(a);for(var d=0;d<c;d++)a[d]._n(b)}};a.prototype._e=function(b){if(this._err===
22c){this._err=b;var a=this._ils,g=a.length;this._x();this._d&&this._dl._e(b);if(1==g)a[0]._e(b);else{if(0==g)return;a=q(a);for(var d=0;d<g;d++)a[d]._e(b)}if(!this._d&&0==g)throw this._err;}};a.prototype._c=function(){var b=this._ils,a=b.length;this._x();this._d&&this._dl._c();if(1==a)b[0]._c();else if(0!=a){b=q(b);for(var c=0;c<a;c++)b[c]._c()}};a.prototype._x=function(){0!==this._ils.length&&(this._prod!==c&&this._prod._stop(),this._err=c,this._ils=[])};a.prototype._stopNow=function(){this._prod._stop();
23this._stopID=this._err=c};a.prototype._add=function(b){var a=this._target;if(a!==c)return a._add(b);a=this._ils;a.push(b);1<a.length||(this._stopID!==c?(clearTimeout(this._stopID),this._stopID=c):(b=this._prod,b!==c&&b._start(this)))};a.prototype._remove=function(b){var a=this,d=this._target;if(d!==c)return d._remove(b);d=this._ils;b=d.indexOf(b);-1<b&&(d.splice(b,1),this._prod!==c&&0>=d.length?(this._err=c,this._stopID=setTimeout(function(){return a._stopNow()})):1===d.length&&this._pruneCycles())};
24a.prototype._pruneCycles=function(){this._hasNoSinks(this,[])&&this._remove(this._ils[0])};a.prototype._hasNoSinks=function(b,a){if(-1!==a.indexOf(b)||b.out===this)return!0;if(b.out&&b.out!==c)return this._hasNoSinks(b.out,a.concat(b));if(b._ils){for(var f=0,d=b._ils.length;f<d;f++)if(!this._hasNoSinks(b._ils[f],a.concat(b)))return!1;return!0}return!1};a.prototype.ctor=function(){return this instanceof p?p:a};a.prototype.addListener=function(b){b._n=b.next||d;b._e=b.error||d;b._c=b.complete||d;this._add(b)};
25a.prototype.removeListener=function(b){this._remove(b)};a.prototype.subscribe=function(b){this.addListener(b);return new x(this,b)};a.prototype[t.default]=function(){return this};a.create=function(b){if(b){if("function"!==typeof b.start||"function"!==typeof b.stop)throw Error("producer requires both start and stop functions");l(b)}return new a(b)};a.createWithMemory=function(b){b&&l(b);return new p(b)};a.never=function(){return new a({_start:d,_stop:d})};a.empty=function(){return new a({_start:function(b){b._c()},
26_stop:d})};a.throw=function(b){return new a({_start:function(a){a._e(b)},_stop:d})};a.from=function(b){if("function"===typeof b[t.default])return a.fromObservable(b);if("function"===typeof b.then)return a.fromPromise(b);if(Array.isArray(b))return a.fromArray(b);throw new TypeError("Type of input to from() must be an Array, Promise, or Observable");};a.of=function(){for(var b=[],c=0;c<arguments.length;c++)b[c]=arguments[c];return a.fromArray(b)};a.fromArray=function(b){return new a(new E(b))};a.fromPromise=
27function(b){return new a(new F(b))};a.fromObservable=function(b){if(b.endWhen)return b;b="function"===typeof b[t.default]?b[t.default]():b;return new a(new z(b))};a.periodic=function(b){return new a(new G(b))};a.prototype._map=function(b){return new (this.ctor())(new P(b,this))};a.prototype.map=function(b){return this._map(b)};a.prototype.mapTo=function(b){var a=this.map(function(){return b});a._prod.type="mapTo";return a};a.prototype.filter=function(b){var c=this._prod;return c instanceof v?new a(new v(u(c.f,
28b),c.ins)):new a(new v(b,this))};a.prototype.take=function(b){return new (this.ctor())(new T(b,this))};a.prototype.drop=function(b){return new a(new I(b,this))};a.prototype.last=function(){return new a(new O(this))};a.prototype.startWith=function(b){return new p(new S(this,b))};a.prototype.endWhen=function(b){return new (this.ctor())(new K(b,this))};a.prototype.fold=function(b,a){return new p(new N(b,a,this))};a.prototype.replaceError=function(b){return new (this.ctor())(new R(b,this))};a.prototype.flatten=
29function(){return new a(new M(this))};a.prototype.compose=function(b){return b(this)};a.prototype.remember=function(){return new p(new Q(this))};a.prototype.debug=function(b){return new (this.ctor())(new H(this,b))};a.prototype.imitate=function(b){if(b instanceof p)throw Error("A MemoryStream was given to imitate(), but it only supports a Stream. Read more about this restriction here: https://github.com/staltz/xstream#faq");this._target=b;for(var a=this._ils,c=a.length,d=0;d<c;d++)b._add(a[d]);this._ils=
30[]};a.prototype.shamefullySendNext=function(a){this._n(a)};a.prototype.shamefullySendError=function(a){this._e(a)};a.prototype.shamefullySendComplete=function(){this._c()};a.prototype.setDebugListener=function(a){a?(this._d=!0,a._n=a.next||d,a._e=a.error||d,a._c=a.complete||d,this._dl=a):(this._d=!1,this._dl=c)};a.merge=function(){for(var b=[],c=0;c<arguments.length;c++)b[c]=arguments[c];return new a(new A(b))};a.combine=function(){for(var b=[],c=0;c<arguments.length;c++)b[c]=arguments[c];return new a(new D(b))};
31return a}();h.Stream=e;var p=function(a){function b(b){b=a.call(this,b)||this;b._has=!1;return b}m(b,a);b.prototype._n=function(b){this._v=b;this._has=!0;a.prototype._n.call(this,b)};b.prototype._add=function(a){var b=this._target;if(b!==c)return b._add(a);b=this._ils;b.push(a);1<b.length?this._has&&a._n(this._v):this._stopID!==c?(this._has&&a._n(this._v),clearTimeout(this._stopID),this._stopID=c):this._has?a._n(this._v):(a=this._prod,a!==c&&a._start(this))};b.prototype._stopNow=function(){this._has=
32!1;a.prototype._stopNow.call(this)};b.prototype._x=function(){this._has=!1;a.prototype._x.call(this)};b.prototype.map=function(a){return this._map(a)};b.prototype.mapTo=function(b){return a.prototype.mapTo.call(this,b)};b.prototype.take=function(b){return a.prototype.take.call(this,b)};b.prototype.endWhen=function(b){return a.prototype.endWhen.call(this,b)};b.prototype.replaceError=function(b){return a.prototype.replaceError.call(this,b)};b.prototype.remember=function(){return this};b.prototype.debug=
33function(b){return a.prototype.debug.call(this,b)};return b}(e);h.MemoryStream=p;h.default=e},{"symbol-observable":2}],2:[function(e,k,h){var d="undefined"!==typeof global?global:"undefined"!==typeof self?self:"undefined"!==typeof window?window:{};Object.defineProperty(h,"__esModule",{value:!0});e=(e=e("./ponyfill.js"))&&e.__esModule?e:{"default":e};k="undefined"!==typeof self?self:"undefined"!==typeof window?window:"undefined"!==typeof d?d:"undefined"!==typeof k?k:Function("return this")();k=(0,
34e["default"])(k);h["default"]=k},{"./ponyfill.js":3}],3:[function(e,k,h){Object.defineProperty(h,"__esModule",{value:!0});h["default"]=function(d){var e=d.Symbol;"function"===typeof e?e.observable?d=e.observable:(d=e("observable"),e.observable=d):d="@@observable";return d}},{}]},{},[1])(1)});
\No newline at end of file