Comparing version 10.1.0 to 10.2.0
@@ -0,1 +1,13 @@ | ||
<a name="10.2.0"></a> | ||
# [10.2.0](https://github.com/staltz/xstream/compare/v10.1.0...v10.2.0) (2017-02-03) | ||
### Performance Improvements | ||
* **fromObservable:** avoid converting from xs stream to xs stream ([04031c6](https://github.com/staltz/xstream/commit/04031c6)) | ||
* **index:** drop curly braces wherever possible ([26d0299](https://github.com/staltz/xstream/commit/26d0299)) | ||
* **Stream:** speed up Stream next, error, complete handlers ([b32ffe3](https://github.com/staltz/xstream/commit/b32ffe3)) | ||
<a name="10.1.0"></a> | ||
@@ -2,0 +14,0 @@ # [10.1.0](https://github.com/staltz/xstream/compare/v9.3.0...v10.1.0) (2017-01-31) |
@@ -12,8 +12,7 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.xstream = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
function noop() { } | ||
function copy(a) { | ||
function cp(a) { | ||
var l = a.length; | ||
var b = Array(l); | ||
for (var i = 0; i < l; ++i) { | ||
for (var i = 0; i < l; ++i) | ||
b[i] = a[i]; | ||
} | ||
return b; | ||
@@ -108,5 +107,4 @@ } | ||
this.ac = L; | ||
for (var i = 0; i < L; i++) { | ||
for (var i = 0; i < L; i++) | ||
s[i]._add(this); | ||
} | ||
}; | ||
@@ -116,5 +114,4 @@ Merge.prototype._stop = function () { | ||
var L = s.length; | ||
for (var i = 0; i < L; i++) { | ||
for (var i = 0; i < L; i++) | ||
s[i]._remove(this); | ||
} | ||
this.out = NO; | ||
@@ -155,5 +152,4 @@ }; | ||
return; | ||
if (p.up(t, this.i)) { | ||
if (p.up(t, this.i)) | ||
out._n(p.vals); | ||
} | ||
}; | ||
@@ -170,5 +166,4 @@ CombineListener.prototype._e = function (err) { | ||
return; | ||
if (--p.Nc === 0) { | ||
if (--p.Nc === 0) | ||
p.out._c(); | ||
} | ||
}; | ||
@@ -212,5 +207,4 @@ return CombineListener; | ||
var ils = this.ils; | ||
for (var i = 0; i < n; i++) { | ||
for (var i = 0; i < n; i++) | ||
s[i]._remove(ils[i]); | ||
} | ||
this.out = NO; | ||
@@ -229,5 +223,4 @@ this.ils = []; | ||
var a = this.a; | ||
for (var i = 0, l = a.length; i < l; i++) { | ||
for (var i = 0, n = a.length; i < n; i++) | ||
out._n(a[i]); | ||
} | ||
out._c(); | ||
@@ -291,8 +284,6 @@ }; | ||
this.l = ''; | ||
if (typeof arg === 'string') { | ||
if (typeof arg === 'string') | ||
this.l = arg; | ||
} | ||
else if (typeof arg === 'function') { | ||
else if (typeof arg === 'function') | ||
this.s = arg; | ||
} | ||
} | ||
@@ -320,8 +311,6 @@ Debug.prototype._start = function (out) { | ||
} | ||
else if (l) { | ||
else if (l) | ||
console.log(l + ':', t); | ||
} | ||
else { | ||
else | ||
console.log(t); | ||
} | ||
u._n(t); | ||
@@ -626,5 +615,4 @@ }; | ||
} | ||
else { | ||
u._e('TODO show proper error'); | ||
} | ||
else | ||
u._e(new Error('last() failed because input stream completed')); | ||
}; | ||
@@ -852,8 +840,6 @@ return Last; | ||
this.taken = 0; | ||
if (this.max <= 0) { | ||
if (this.max <= 0) | ||
out._c(); | ||
} | ||
else { | ||
else | ||
this.ins._add(this); | ||
} | ||
}; | ||
@@ -869,5 +855,4 @@ Take.prototype._stop = function () { | ||
var m = ++this.taken; | ||
if (m < this.max) { | ||
if (m < this.max) | ||
u._n(t); | ||
} | ||
else if (m === this.max) { | ||
@@ -909,4 +894,6 @@ u._n(t); | ||
a[0]._n(t); | ||
else if (L == 0) | ||
return; | ||
else { | ||
var b = copy(a); | ||
var b = cp(a); | ||
for (var i = 0; i < L; i++) | ||
@@ -927,4 +914,6 @@ b[i]._n(t); | ||
a[0]._e(err); | ||
else if (L == 0) | ||
return; | ||
else { | ||
var b = copy(a); | ||
var b = cp(a); | ||
for (var i = 0; i < L; i++) | ||
@@ -944,4 +933,6 @@ b[i]._e(err); | ||
a[0]._c(); | ||
else if (L == 0) | ||
return; | ||
else { | ||
var b = copy(a); | ||
var b = cp(a); | ||
for (var i = 0; i < L; i++) | ||
@@ -1007,5 +998,4 @@ b[i]._c(); | ||
Stream.prototype._pruneCycles = function () { | ||
if (this._hasNoSinks(this, [])) { | ||
if (this._hasNoSinks(this, [])) | ||
this._remove(this._ils[0]); | ||
} | ||
}; | ||
@@ -1017,22 +1007,16 @@ | ||
Stream.prototype._hasNoSinks = function (x, trace) { | ||
if (trace.indexOf(x) !== -1) { | ||
if (trace.indexOf(x) !== -1) | ||
return true; | ||
} | ||
else if (x.out === this) { | ||
else if (x.out === this) | ||
return true; | ||
} | ||
else if (x.out && x.out !== NO) { | ||
else if (x.out && x.out !== NO) | ||
return this._hasNoSinks(x.out, trace.concat(x)); | ||
} | ||
else if (x._ils) { | ||
for (var i = 0, N = x._ils.length; i < N; i++) { | ||
if (!this._hasNoSinks(x._ils[i], trace.concat(x))) { | ||
for (var i = 0, N = x._ils.length; i < N; i++) | ||
if (!this._hasNoSinks(x._ils[i], trace.concat(x))) | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
else { | ||
else | ||
return false; | ||
} | ||
}; | ||
@@ -1066,5 +1050,4 @@ Stream.prototype.ctor = function () { | ||
if (typeof producer.start !== 'function' | ||
|| typeof producer.stop !== 'function') { | ||
|| typeof producer.stop !== 'function') | ||
throw new Error('producer requires both start and stop functions'); | ||
} | ||
internalizeProducer(producer); | ||
@@ -1076,5 +1059,4 @@ } | ||
Stream.createWithMemory = function (producer) { | ||
if (producer) { | ||
if (producer) | ||
internalizeProducer(producer); | ||
} | ||
return new MemoryStream(producer); | ||
@@ -1102,11 +1084,8 @@ }; | ||
Stream.from = function (input) { | ||
if (typeof input[symbol_observable_1.default] === 'function') { | ||
if (typeof input[symbol_observable_1.default] === 'function') | ||
return Stream.fromObservable(input); | ||
} | ||
else if (typeof input.then === 'function') { | ||
else if (typeof input.then === 'function') | ||
return Stream.fromPromise(input); | ||
} | ||
else if (Array.isArray(input)) { | ||
else if (Array.isArray(input)) | ||
return Stream.fromArray(input); | ||
} | ||
throw new TypeError("Type of input to from() must be an Array, Promise, or Observable"); | ||
@@ -1131,4 +1110,6 @@ }; | ||
Stream.fromObservable = function (observable) { | ||
return new Stream(new FromObservable(observable)); | ||
Stream.fromObservable = function (obs) { | ||
if (obs.endWhen) | ||
return obs; | ||
return new Stream(new FromObservable(obs)); | ||
}; | ||
@@ -1142,5 +1123,4 @@ | ||
var ctor = this.ctor(); | ||
if (p instanceof Filter) { | ||
if (p instanceof Filter) | ||
return new ctor(new FilterMapFusion(p.f, project, p.ins)); | ||
} | ||
return new ctor(new MapOp(project, this)); | ||
@@ -1162,5 +1142,4 @@ }; | ||
var p = this._prod; | ||
if (p instanceof Filter) { | ||
if (p instanceof Filter) | ||
return new Stream(new Filter(and(p.f, passes), p.ins)); | ||
} | ||
return new Stream(new Filter(passes, this)); | ||
@@ -1217,11 +1196,9 @@ }; | ||
Stream.prototype.imitate = function (target) { | ||
if (target instanceof MemoryStream) { | ||
if (target instanceof MemoryStream) | ||
throw new 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 = target; | ||
for (var ils = this._ils, N = ils.length, i = 0; i < N; i++) { | ||
for (var ils = this._ils, N = ils.length, i = 0; i < N; i++) | ||
target._add(ils[i]); | ||
} | ||
this._ils = []; | ||
@@ -1228,0 +1205,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.xstream=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){"use strict";var __extends=this&&this.__extends||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p];function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)};var symbol_observable_1=require("symbol-observable");var NO={};exports.NO=NO;function noop(){}function copy(a){var l=a.length;var b=Array(l);for(var i=0;i<l;++i){b[i]=a[i]}return b}function and(f1,f2){return function andFn(t){return f1(t)&&f2(t)}}function _try(c,t,u){try{return c.f(t)}catch(e){u._e(e);return NO}}var NO_IL={_n:noop,_e:noop,_c:noop};exports.NO_IL=NO_IL;function internalizeProducer(producer){producer._start=function _start(il){il.next=il._n;il.error=il._e;il.complete=il._c;this.start(il)};producer._stop=producer.stop}var StreamSub=function(){function StreamSub(_stream,_listener){this._stream=_stream;this._listener=_listener}StreamSub.prototype.unsubscribe=function(){this._stream.removeListener(this._listener)};return StreamSub}();var Observer=function(){function Observer(_listener){this._listener=_listener}Observer.prototype.next=function(value){this._listener._n(value)};Observer.prototype.error=function(err){this._listener._e(err)};Observer.prototype.complete=function(){this._listener._c()};return Observer}();var FromObservable=function(){function FromObservable(observable){this.type="fromObservable";this.ins=observable;this.active=false}FromObservable.prototype._start=function(out){this.out=out;this.active=true;this._sub=this.ins.subscribe(new Observer(out));if(!this.active)this._sub.unsubscribe()};FromObservable.prototype._stop=function(){if(this._sub)this._sub.unsubscribe();this.active=false};return FromObservable}();var Merge=function(){function Merge(insArr){this.type="merge";this.insArr=insArr;this.out=NO;this.ac=0}Merge.prototype._start=function(out){this.out=out;var s=this.insArr;var L=s.length;this.ac=L;for(var i=0;i<L;i++){s[i]._add(this)}};Merge.prototype._stop=function(){var s=this.insArr;var L=s.length;for(var i=0;i<L;i++){s[i]._remove(this)}this.out=NO};Merge.prototype._n=function(t){var u=this.out;if(u===NO)return;u._n(t)};Merge.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};Merge.prototype._c=function(){if(--this.ac<=0){var u=this.out;if(u===NO)return;u._c()}};return Merge}();var CombineListener=function(){function CombineListener(i,out,p){this.i=i;this.out=out;this.p=p;p.ils.push(this)}CombineListener.prototype._n=function(t){var p=this.p,out=this.out;if(out===NO)return;if(p.up(t,this.i)){out._n(p.vals)}};CombineListener.prototype._e=function(err){var out=this.out;if(out===NO)return;out._e(err)};CombineListener.prototype._c=function(){var p=this.p;if(p.out===NO)return;if(--p.Nc===0){p.out._c()}};return CombineListener}();var Combine=function(){function Combine(insArr){this.type="combine";this.insArr=insArr;this.out=NO;this.ils=[];this.Nc=this.Nn=0;this.vals=[]}Combine.prototype.up=function(t,i){var v=this.vals[i];var Nn=!this.Nn?0:v===NO?--this.Nn:this.Nn;this.vals[i]=t;return Nn===0};Combine.prototype._start=function(out){this.out=out;var s=this.insArr;var n=this.Nc=this.Nn=s.length;var vals=this.vals=new Array(n);if(n===0){out._n([]);out._c()}else{for(var i=0;i<n;i++){vals[i]=NO;s[i]._add(new CombineListener(i,out,this))}}};Combine.prototype._stop=function(){var s=this.insArr;var n=s.length;var ils=this.ils;for(var i=0;i<n;i++){s[i]._remove(ils[i])}this.out=NO;this.ils=[];this.vals=[]};return Combine}();var FromArray=function(){function FromArray(a){this.type="fromArray";this.a=a}FromArray.prototype._start=function(out){var a=this.a;for(var i=0,l=a.length;i<l;i++){out._n(a[i])}out._c()};FromArray.prototype._stop=function(){};return FromArray}();var FromPromise=function(){function FromPromise(p){this.type="fromPromise";this.on=false;this.p=p}FromPromise.prototype._start=function(out){var prod=this;this.on=true;this.p.then(function(v){if(prod.on){out._n(v);out._c()}},function(e){out._e(e)}).then(noop,function(err){setTimeout(function(){throw err})})};FromPromise.prototype._stop=function(){this.on=false};return FromPromise}();var Periodic=function(){function Periodic(period){this.type="periodic";this.period=period;this.intervalID=-1;this.i=0}Periodic.prototype._start=function(out){var self=this;function intervalHandler(){out._n(self.i++)}this.intervalID=setInterval(intervalHandler,this.period)};Periodic.prototype._stop=function(){if(this.intervalID!==-1)clearInterval(this.intervalID);this.intervalID=-1;this.i=0};return Periodic}();var Debug=function(){function Debug(ins,arg){this.type="debug";this.ins=ins;this.out=NO;this.s=noop;this.l="";if(typeof arg==="string"){this.l=arg}else if(typeof arg==="function"){this.s=arg}}Debug.prototype._start=function(out){this.out=out;this.ins._add(this)};Debug.prototype._stop=function(){this.ins._remove(this);this.out=NO};Debug.prototype._n=function(t){var u=this.out;if(u===NO)return;var s=this.s,l=this.l;if(s!==noop){try{s(t)}catch(e){u._e(e)}}else if(l){console.log(l+":",t)}else{console.log(t)}u._n(t)};Debug.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};Debug.prototype._c=function(){var u=this.out;if(u===NO)return;u._c()};return Debug}();var Drop=function(){function Drop(max,ins){this.type="drop";this.ins=ins;this.out=NO;this.max=max;this.dropped=0}Drop.prototype._start=function(out){this.out=out;this.dropped=0;this.ins._add(this)};Drop.prototype._stop=function(){this.ins._remove(this);this.out=NO};Drop.prototype._n=function(t){var u=this.out;if(u===NO)return;if(this.dropped++>=this.max)u._n(t)};Drop.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};Drop.prototype._c=function(){var u=this.out;if(u===NO)return;u._c()};return Drop}();var EndWhenListener=function(){function EndWhenListener(out,op){this.out=out;this.op=op}EndWhenListener.prototype._n=function(){this.op.end()};EndWhenListener.prototype._e=function(err){this.out._e(err)};EndWhenListener.prototype._c=function(){this.op.end()};return EndWhenListener}();var EndWhen=function(){function EndWhen(o,ins){this.type="endWhen";this.ins=ins;this.out=NO;this.o=o;this.oil=NO_IL}EndWhen.prototype._start=function(out){this.out=out;this.o._add(this.oil=new EndWhenListener(out,this));this.ins._add(this)};EndWhen.prototype._stop=function(){this.ins._remove(this);this.o._remove(this.oil);this.out=NO;this.oil=NO_IL};EndWhen.prototype.end=function(){var u=this.out;if(u===NO)return;u._c()};EndWhen.prototype._n=function(t){var u=this.out;if(u===NO)return;u._n(t)};EndWhen.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};EndWhen.prototype._c=function(){this.end()};return EndWhen}();var Filter=function(){function Filter(passes,ins){this.type="filter";this.ins=ins;this.out=NO;this.f=passes}Filter.prototype._start=function(out){this.out=out;this.ins._add(this)};Filter.prototype._stop=function(){this.ins._remove(this);this.out=NO};Filter.prototype._n=function(t){var u=this.out;if(u===NO)return;var r=_try(this,t,u);if(r===NO||!r)return;u._n(t)};Filter.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};Filter.prototype._c=function(){var u=this.out;if(u===NO)return;u._c()};return Filter}();var FlattenListener=function(){function FlattenListener(out,op){this.out=out;this.op=op}FlattenListener.prototype._n=function(t){this.out._n(t)};FlattenListener.prototype._e=function(err){this.out._e(err)};FlattenListener.prototype._c=function(){this.op.inner=NO;this.op.less()};return FlattenListener}();var Flatten=function(){function Flatten(ins){this.type="flatten";this.ins=ins;this.out=NO;this.open=true;this.inner=NO;this.il=NO_IL}Flatten.prototype._start=function(out){this.out=out;this.open=true;this.inner=NO;this.il=NO_IL;this.ins._add(this)};Flatten.prototype._stop=function(){this.ins._remove(this);if(this.inner!==NO)this.inner._remove(this.il);this.out=NO;this.open=true;this.inner=NO;this.il=NO_IL};Flatten.prototype.less=function(){var u=this.out;if(u===NO)return;if(!this.open&&this.inner===NO)u._c()};Flatten.prototype._n=function(s){var u=this.out;if(u===NO)return;var _a=this,inner=_a.inner,il=_a.il;if(inner!==NO&&il!==NO_IL)inner._remove(il);(this.inner=s)._add(this.il=new FlattenListener(u,this))};Flatten.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};Flatten.prototype._c=function(){this.open=false;this.less()};return Flatten}();var Fold=function(){function Fold(f,seed,ins){var _this=this;this.type="fold";this.ins=ins;this.out=NO;this.f=function(t){return f(_this.acc,t)};this.acc=this.seed=seed}Fold.prototype._start=function(out){this.out=out;this.acc=this.seed;out._n(this.acc);this.ins._add(this)};Fold.prototype._stop=function(){this.ins._remove(this);this.out=NO;this.acc=this.seed};Fold.prototype._n=function(t){var u=this.out;if(u===NO)return;var r=_try(this,t,u);if(r===NO)return;u._n(this.acc=r)};Fold.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};Fold.prototype._c=function(){var u=this.out;if(u===NO)return;u._c()};return Fold}();var Last=function(){function Last(ins){this.type="last";this.ins=ins;this.out=NO;this.has=false;this.val=NO}Last.prototype._start=function(out){this.out=out;this.has=false;this.ins._add(this)};Last.prototype._stop=function(){this.ins._remove(this);this.out=NO;this.val=NO};Last.prototype._n=function(t){this.has=true;this.val=t};Last.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};Last.prototype._c=function(){var u=this.out;if(u===NO)return;if(this.has){u._n(this.val);u._c()}else{u._e("TODO show proper error")}};return Last}();var MapFlattenListener=function(){function MapFlattenListener(out,op){this.out=out;this.op=op}MapFlattenListener.prototype._n=function(r){this.out._n(r)};MapFlattenListener.prototype._e=function(err){this.out._e(err)};MapFlattenListener.prototype._c=function(){this.op.inner=NO;this.op.less()};return MapFlattenListener}();var MapFlatten=function(){function MapFlatten(mapOp){this.type=mapOp.type+"+flatten";this.ins=mapOp.ins;this.out=NO;this.mapOp=mapOp;this.inner=NO;this.il=NO_IL;this.open=true}MapFlatten.prototype._start=function(out){this.out=out;this.inner=NO;this.il=NO_IL;this.open=true;this.mapOp.ins._add(this)};MapFlatten.prototype._stop=function(){this.mapOp.ins._remove(this);if(this.inner!==NO)this.inner._remove(this.il);this.out=NO;this.inner=NO;this.il=NO_IL};MapFlatten.prototype.less=function(){if(!this.open&&this.inner===NO){var u=this.out;if(u===NO)return;u._c()}};MapFlatten.prototype._n=function(v){var u=this.out;if(u===NO)return;var _a=this,inner=_a.inner,il=_a.il;var s=_try(this.mapOp,v,u);if(s===NO)return;if(inner!==NO&&il!==NO_IL)inner._remove(il);(this.inner=s)._add(this.il=new MapFlattenListener(u,this))};MapFlatten.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};MapFlatten.prototype._c=function(){this.open=false;this.less()};return MapFlatten}();var MapOp=function(){function MapOp(project,ins){this.type="map";this.ins=ins;this.out=NO;this.f=project}MapOp.prototype._start=function(out){this.out=out;this.ins._add(this)};MapOp.prototype._stop=function(){this.ins._remove(this);this.out=NO};MapOp.prototype._n=function(t){var u=this.out;if(u===NO)return;var r=_try(this,t,u);if(r===NO)return;u._n(r)};MapOp.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};MapOp.prototype._c=function(){var u=this.out;if(u===NO)return;u._c()};return MapOp}();var FilterMapFusion=function(_super){__extends(FilterMapFusion,_super);function FilterMapFusion(passes,project,ins){var _this=_super.call(this,project,ins)||this;_this.type="filter+map";_this.passes=passes;return _this}FilterMapFusion.prototype._n=function(t){if(!this.passes(t))return;var u=this.out;if(u===NO)return;var r=_try(this,t,u);if(r===NO)return;u._n(r)};return FilterMapFusion}(MapOp);var Remember=function(){function Remember(ins){this.type="remember";this.ins=ins;this.out=NO}Remember.prototype._start=function(out){this.out=out;this.ins._add(out)};Remember.prototype._stop=function(){this.ins._remove(this.out);this.out=NO};return Remember}();var ReplaceError=function(){function ReplaceError(replacer,ins){this.type="replaceError";this.ins=ins;this.out=NO;this.f=replacer}ReplaceError.prototype._start=function(out){this.out=out;this.ins._add(this)};ReplaceError.prototype._stop=function(){this.ins._remove(this);this.out=NO};ReplaceError.prototype._n=function(t){var u=this.out;if(u===NO)return;u._n(t)};ReplaceError.prototype._e=function(err){var u=this.out;if(u===NO)return;try{this.ins._remove(this);(this.ins=this.f(err))._add(this)}catch(e){u._e(e)}};ReplaceError.prototype._c=function(){var u=this.out;if(u===NO)return;u._c()};return ReplaceError}();var StartWith=function(){function StartWith(ins,val){this.type="startWith";this.ins=ins;this.out=NO;this.val=val}StartWith.prototype._start=function(out){this.out=out;this.out._n(this.val);this.ins._add(out)};StartWith.prototype._stop=function(){this.ins._remove(this.out);this.out=NO};return StartWith}();var Take=function(){function Take(max,ins){this.type="take";this.ins=ins;this.out=NO;this.max=max;this.taken=0}Take.prototype._start=function(out){this.out=out;this.taken=0;if(this.max<=0){out._c()}else{this.ins._add(this)}};Take.prototype._stop=function(){this.ins._remove(this);this.out=NO};Take.prototype._n=function(t){var u=this.out;if(u===NO)return;var m=++this.taken;if(m<this.max){u._n(t)}else if(m===this.max){u._n(t);u._c()}};Take.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};Take.prototype._c=function(){var u=this.out;if(u===NO)return;u._c()};return Take}();var Stream=function(){function Stream(producer){this._prod=producer||NO;this._ils=[];this._stopID=NO;this._dl=NO;this._d=false;this._target=NO;this._err=NO}Stream.prototype._n=function(t){var a=this._ils;var L=a.length;if(this._d)this._dl._n(t);if(L==1)a[0]._n(t);else{var b=copy(a);for(var i=0;i<L;i++)b[i]._n(t)}};Stream.prototype._e=function(err){if(this._err!==NO)return;this._err=err;var a=this._ils;var L=a.length;this._x();if(this._d)this._dl._e(err);if(L==1)a[0]._e(err);else{var b=copy(a);for(var i=0;i<L;i++)b[i]._e(err)}if(!this._d&&L==0)throw this._err};Stream.prototype._c=function(){var a=this._ils;var L=a.length;this._x();if(this._d)this._dl._c();if(L==1)a[0]._c();else{var b=copy(a);for(var i=0;i<L;i++)b[i]._c()}};Stream.prototype._x=function(){if(this._ils.length===0)return;if(this._prod!==NO)this._prod._stop();this._err=NO;this._ils=[]};Stream.prototype._stopNow=function(){this._prod._stop();this._err=NO;this._stopID=NO};Stream.prototype._add=function(il){var ta=this._target;if(ta!==NO)return ta._add(il);var a=this._ils;a.push(il);if(a.length>1)return;if(this._stopID!==NO){clearTimeout(this._stopID);this._stopID=NO}else{var p=this._prod;if(p!==NO)p._start(this)}};Stream.prototype._remove=function(il){var _this=this;var ta=this._target;if(ta!==NO)return ta._remove(il);var a=this._ils;var i=a.indexOf(il);if(i>-1){a.splice(i,1);if(this._prod!==NO&&a.length<=0){this._err=NO;this._stopID=setTimeout(function(){return _this._stopNow()})}else if(a.length===1){this._pruneCycles()}}};Stream.prototype._pruneCycles=function(){if(this._hasNoSinks(this,[])){this._remove(this._ils[0])}};Stream.prototype._hasNoSinks=function(x,trace){if(trace.indexOf(x)!==-1){return true}else if(x.out===this){return true}else if(x.out&&x.out!==NO){return this._hasNoSinks(x.out,trace.concat(x))}else if(x._ils){for(var i=0,N=x._ils.length;i<N;i++){if(!this._hasNoSinks(x._ils[i],trace.concat(x))){return false}}return true}else{return false}};Stream.prototype.ctor=function(){return this instanceof MemoryStream?MemoryStream:Stream};Stream.prototype.addListener=function(listener){listener._n=listener.next||noop;listener._e=listener.error||noop;listener._c=listener.complete||noop;this._add(listener)};Stream.prototype.removeListener=function(listener){this._remove(listener)};Stream.prototype.subscribe=function(listener){this.addListener(listener);return new StreamSub(this,listener)};Stream.prototype[symbol_observable_1.default]=function(){return this};Stream.create=function(producer){if(producer){if(typeof producer.start!=="function"||typeof producer.stop!=="function"){throw new Error("producer requires both start and stop functions")}internalizeProducer(producer)}return new Stream(producer)};Stream.createWithMemory=function(producer){if(producer){internalizeProducer(producer)}return new MemoryStream(producer)};Stream.never=function(){return new Stream({_start:noop,_stop:noop})};Stream.empty=function(){return new Stream({_start:function(il){il._c()},_stop:noop})};Stream.throw=function(error){return new Stream({_start:function(il){il._e(error)},_stop:noop})};Stream.from=function(input){if(typeof input[symbol_observable_1.default]==="function"){return Stream.fromObservable(input)}else if(typeof input.then==="function"){return Stream.fromPromise(input)}else if(Array.isArray(input)){return Stream.fromArray(input)}throw new TypeError("Type of input to from() must be an Array, Promise, or Observable")};Stream.of=function(){var items=[];for(var _i=0;_i<arguments.length;_i++){items[_i]=arguments[_i]}return Stream.fromArray(items)};Stream.fromArray=function(array){return new Stream(new FromArray(array))};Stream.fromPromise=function(promise){return new Stream(new FromPromise(promise))};Stream.fromObservable=function(observable){return new Stream(new FromObservable(observable))};Stream.periodic=function(period){return new Stream(new Periodic(period))};Stream.prototype._map=function(project){var p=this._prod;var ctor=this.ctor();if(p instanceof Filter){return new ctor(new FilterMapFusion(p.f,project,p.ins))}return new ctor(new MapOp(project,this))};Stream.prototype.map=function(project){return this._map(project)};Stream.prototype.mapTo=function(projectedValue){var s=this.map(function(){return projectedValue});var op=s._prod;op.type=op.type.replace("map","mapTo");return s};Stream.prototype.filter=function(passes){var p=this._prod;if(p instanceof Filter){return new Stream(new Filter(and(p.f,passes),p.ins))}return new Stream(new Filter(passes,this))};Stream.prototype.take=function(amount){return new(this.ctor())(new Take(amount,this))};Stream.prototype.drop=function(amount){return new Stream(new Drop(amount,this))};Stream.prototype.last=function(){return new Stream(new Last(this))};Stream.prototype.startWith=function(initial){return new MemoryStream(new StartWith(this,initial))};Stream.prototype.endWhen=function(other){return new(this.ctor())(new EndWhen(other,this))};Stream.prototype.fold=function(accumulate,seed){return new MemoryStream(new Fold(accumulate,seed,this))};Stream.prototype.replaceError=function(replace){return new(this.ctor())(new ReplaceError(replace,this))};Stream.prototype.flatten=function(){var p=this._prod;return new Stream(p instanceof MapOp&&!(p instanceof FilterMapFusion)?new MapFlatten(p):new Flatten(this))};Stream.prototype.compose=function(operator){return operator(this)};Stream.prototype.remember=function(){return new MemoryStream(new Remember(this))};Stream.prototype.debug=function(labelOrSpy){return new(this.ctor())(new Debug(this,labelOrSpy))};Stream.prototype.imitate=function(target){if(target instanceof MemoryStream){throw new 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=target;for(var ils=this._ils,N=ils.length,i=0;i<N;i++){target._add(ils[i])}this._ils=[]};Stream.prototype.shamefullySendNext=function(value){this._n(value)};Stream.prototype.shamefullySendError=function(error){this._e(error)};Stream.prototype.shamefullySendComplete=function(){this._c()};Stream.prototype.setDebugListener=function(listener){if(!listener){this._d=false;this._dl=NO}else{this._d=true;listener._n=listener.next||noop;listener._e=listener.error||noop;listener._c=listener.complete||noop;this._dl=listener}};return Stream}();Stream.merge=function merge(){var streams=[];for(var _i=0;_i<arguments.length;_i++){streams[_i]=arguments[_i]}return new Stream(new Merge(streams))};Stream.combine=function combine(){var streams=[];for(var _i=0;_i<arguments.length;_i++){streams[_i]=arguments[_i]}return new Stream(new Combine(streams))};exports.Stream=Stream;var MemoryStream=function(_super){__extends(MemoryStream,_super);function MemoryStream(producer){var _this=_super.call(this,producer)||this;_this._has=false;return _this}MemoryStream.prototype._n=function(x){this._v=x;this._has=true;_super.prototype._n.call(this,x)};MemoryStream.prototype._add=function(il){var ta=this._target;if(ta!==NO)return ta._add(il);var a=this._ils;a.push(il);if(a.length>1){if(this._has)il._n(this._v);return}if(this._stopID!==NO){if(this._has)il._n(this._v);clearTimeout(this._stopID);this._stopID=NO}else if(this._has)il._n(this._v);else{var p=this._prod;if(p!==NO)p._start(this)}};MemoryStream.prototype._stopNow=function(){this._has=false;_super.prototype._stopNow.call(this)};MemoryStream.prototype._x=function(){this._has=false;_super.prototype._x.call(this)};MemoryStream.prototype.map=function(project){return this._map(project)};MemoryStream.prototype.mapTo=function(projectedValue){return _super.prototype.mapTo.call(this,projectedValue)};MemoryStream.prototype.take=function(amount){return _super.prototype.take.call(this,amount)};MemoryStream.prototype.endWhen=function(other){return _super.prototype.endWhen.call(this,other)};MemoryStream.prototype.replaceError=function(replace){return _super.prototype.replaceError.call(this,replace)};MemoryStream.prototype.remember=function(){return this};MemoryStream.prototype.debug=function(labelOrSpy){return _super.prototype.debug.call(this,labelOrSpy)};return MemoryStream}(Stream);exports.MemoryStream=MemoryStream;Object.defineProperty(exports,"__esModule",{value:true});exports.default=Stream},{"symbol-observable":2}],2:[function(require,module,exports){module.exports=require("./lib/index")},{"./lib/index":3}],3:[function(require,module,exports){(function(global){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _ponyfill=require("./ponyfill");var _ponyfill2=_interopRequireDefault(_ponyfill);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var root;if(typeof self!=="undefined"){root=self}else if(typeof window!=="undefined"){root=window}else if(typeof global!=="undefined"){root=global}else if(typeof module!=="undefined"){root=module}else{root=Function("return this")()}var result=(0,_ponyfill2["default"])(root);exports["default"]=result}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./ponyfill":4}],4:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=symbolObservablePonyfill;function symbolObservablePonyfill(root){var result;var _Symbol=root.Symbol;if(typeof _Symbol==="function"){if(_Symbol.observable){result=_Symbol.observable}else{result=_Symbol("observable");_Symbol.observable=result}}else{result="@@observable"}return result}},{}]},{},[1])(1)}); | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.xstream=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){"use strict";var __extends=this&&this.__extends||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p];function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)};var symbol_observable_1=require("symbol-observable");var NO={};exports.NO=NO;function noop(){}function cp(a){var l=a.length;var b=Array(l);for(var i=0;i<l;++i)b[i]=a[i];return b}function and(f1,f2){return function andFn(t){return f1(t)&&f2(t)}}function _try(c,t,u){try{return c.f(t)}catch(e){u._e(e);return NO}}var NO_IL={_n:noop,_e:noop,_c:noop};exports.NO_IL=NO_IL;function internalizeProducer(producer){producer._start=function _start(il){il.next=il._n;il.error=il._e;il.complete=il._c;this.start(il)};producer._stop=producer.stop}var StreamSub=function(){function StreamSub(_stream,_listener){this._stream=_stream;this._listener=_listener}StreamSub.prototype.unsubscribe=function(){this._stream.removeListener(this._listener)};return StreamSub}();var Observer=function(){function Observer(_listener){this._listener=_listener}Observer.prototype.next=function(value){this._listener._n(value)};Observer.prototype.error=function(err){this._listener._e(err)};Observer.prototype.complete=function(){this._listener._c()};return Observer}();var FromObservable=function(){function FromObservable(observable){this.type="fromObservable";this.ins=observable;this.active=false}FromObservable.prototype._start=function(out){this.out=out;this.active=true;this._sub=this.ins.subscribe(new Observer(out));if(!this.active)this._sub.unsubscribe()};FromObservable.prototype._stop=function(){if(this._sub)this._sub.unsubscribe();this.active=false};return FromObservable}();var Merge=function(){function Merge(insArr){this.type="merge";this.insArr=insArr;this.out=NO;this.ac=0}Merge.prototype._start=function(out){this.out=out;var s=this.insArr;var L=s.length;this.ac=L;for(var i=0;i<L;i++)s[i]._add(this)};Merge.prototype._stop=function(){var s=this.insArr;var L=s.length;for(var i=0;i<L;i++)s[i]._remove(this);this.out=NO};Merge.prototype._n=function(t){var u=this.out;if(u===NO)return;u._n(t)};Merge.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};Merge.prototype._c=function(){if(--this.ac<=0){var u=this.out;if(u===NO)return;u._c()}};return Merge}();var CombineListener=function(){function CombineListener(i,out,p){this.i=i;this.out=out;this.p=p;p.ils.push(this)}CombineListener.prototype._n=function(t){var p=this.p,out=this.out;if(out===NO)return;if(p.up(t,this.i))out._n(p.vals)};CombineListener.prototype._e=function(err){var out=this.out;if(out===NO)return;out._e(err)};CombineListener.prototype._c=function(){var p=this.p;if(p.out===NO)return;if(--p.Nc===0)p.out._c()};return CombineListener}();var Combine=function(){function Combine(insArr){this.type="combine";this.insArr=insArr;this.out=NO;this.ils=[];this.Nc=this.Nn=0;this.vals=[]}Combine.prototype.up=function(t,i){var v=this.vals[i];var Nn=!this.Nn?0:v===NO?--this.Nn:this.Nn;this.vals[i]=t;return Nn===0};Combine.prototype._start=function(out){this.out=out;var s=this.insArr;var n=this.Nc=this.Nn=s.length;var vals=this.vals=new Array(n);if(n===0){out._n([]);out._c()}else{for(var i=0;i<n;i++){vals[i]=NO;s[i]._add(new CombineListener(i,out,this))}}};Combine.prototype._stop=function(){var s=this.insArr;var n=s.length;var ils=this.ils;for(var i=0;i<n;i++)s[i]._remove(ils[i]);this.out=NO;this.ils=[];this.vals=[]};return Combine}();var FromArray=function(){function FromArray(a){this.type="fromArray";this.a=a}FromArray.prototype._start=function(out){var a=this.a;for(var i=0,n=a.length;i<n;i++)out._n(a[i]);out._c()};FromArray.prototype._stop=function(){};return FromArray}();var FromPromise=function(){function FromPromise(p){this.type="fromPromise";this.on=false;this.p=p}FromPromise.prototype._start=function(out){var prod=this;this.on=true;this.p.then(function(v){if(prod.on){out._n(v);out._c()}},function(e){out._e(e)}).then(noop,function(err){setTimeout(function(){throw err})})};FromPromise.prototype._stop=function(){this.on=false};return FromPromise}();var Periodic=function(){function Periodic(period){this.type="periodic";this.period=period;this.intervalID=-1;this.i=0}Periodic.prototype._start=function(out){var self=this;function intervalHandler(){out._n(self.i++)}this.intervalID=setInterval(intervalHandler,this.period)};Periodic.prototype._stop=function(){if(this.intervalID!==-1)clearInterval(this.intervalID);this.intervalID=-1;this.i=0};return Periodic}();var Debug=function(){function Debug(ins,arg){this.type="debug";this.ins=ins;this.out=NO;this.s=noop;this.l="";if(typeof arg==="string")this.l=arg;else if(typeof arg==="function")this.s=arg}Debug.prototype._start=function(out){this.out=out;this.ins._add(this)};Debug.prototype._stop=function(){this.ins._remove(this);this.out=NO};Debug.prototype._n=function(t){var u=this.out;if(u===NO)return;var s=this.s,l=this.l;if(s!==noop){try{s(t)}catch(e){u._e(e)}}else if(l)console.log(l+":",t);else console.log(t);u._n(t)};Debug.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};Debug.prototype._c=function(){var u=this.out;if(u===NO)return;u._c()};return Debug}();var Drop=function(){function Drop(max,ins){this.type="drop";this.ins=ins;this.out=NO;this.max=max;this.dropped=0}Drop.prototype._start=function(out){this.out=out;this.dropped=0;this.ins._add(this)};Drop.prototype._stop=function(){this.ins._remove(this);this.out=NO};Drop.prototype._n=function(t){var u=this.out;if(u===NO)return;if(this.dropped++>=this.max)u._n(t)};Drop.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};Drop.prototype._c=function(){var u=this.out;if(u===NO)return;u._c()};return Drop}();var EndWhenListener=function(){function EndWhenListener(out,op){this.out=out;this.op=op}EndWhenListener.prototype._n=function(){this.op.end()};EndWhenListener.prototype._e=function(err){this.out._e(err)};EndWhenListener.prototype._c=function(){this.op.end()};return EndWhenListener}();var EndWhen=function(){function EndWhen(o,ins){this.type="endWhen";this.ins=ins;this.out=NO;this.o=o;this.oil=NO_IL}EndWhen.prototype._start=function(out){this.out=out;this.o._add(this.oil=new EndWhenListener(out,this));this.ins._add(this)};EndWhen.prototype._stop=function(){this.ins._remove(this);this.o._remove(this.oil);this.out=NO;this.oil=NO_IL};EndWhen.prototype.end=function(){var u=this.out;if(u===NO)return;u._c()};EndWhen.prototype._n=function(t){var u=this.out;if(u===NO)return;u._n(t)};EndWhen.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};EndWhen.prototype._c=function(){this.end()};return EndWhen}();var Filter=function(){function Filter(passes,ins){this.type="filter";this.ins=ins;this.out=NO;this.f=passes}Filter.prototype._start=function(out){this.out=out;this.ins._add(this)};Filter.prototype._stop=function(){this.ins._remove(this);this.out=NO};Filter.prototype._n=function(t){var u=this.out;if(u===NO)return;var r=_try(this,t,u);if(r===NO||!r)return;u._n(t)};Filter.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};Filter.prototype._c=function(){var u=this.out;if(u===NO)return;u._c()};return Filter}();var FlattenListener=function(){function FlattenListener(out,op){this.out=out;this.op=op}FlattenListener.prototype._n=function(t){this.out._n(t)};FlattenListener.prototype._e=function(err){this.out._e(err)};FlattenListener.prototype._c=function(){this.op.inner=NO;this.op.less()};return FlattenListener}();var Flatten=function(){function Flatten(ins){this.type="flatten";this.ins=ins;this.out=NO;this.open=true;this.inner=NO;this.il=NO_IL}Flatten.prototype._start=function(out){this.out=out;this.open=true;this.inner=NO;this.il=NO_IL;this.ins._add(this)};Flatten.prototype._stop=function(){this.ins._remove(this);if(this.inner!==NO)this.inner._remove(this.il);this.out=NO;this.open=true;this.inner=NO;this.il=NO_IL};Flatten.prototype.less=function(){var u=this.out;if(u===NO)return;if(!this.open&&this.inner===NO)u._c()};Flatten.prototype._n=function(s){var u=this.out;if(u===NO)return;var _a=this,inner=_a.inner,il=_a.il;if(inner!==NO&&il!==NO_IL)inner._remove(il);(this.inner=s)._add(this.il=new FlattenListener(u,this))};Flatten.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};Flatten.prototype._c=function(){this.open=false;this.less()};return Flatten}();var Fold=function(){function Fold(f,seed,ins){var _this=this;this.type="fold";this.ins=ins;this.out=NO;this.f=function(t){return f(_this.acc,t)};this.acc=this.seed=seed}Fold.prototype._start=function(out){this.out=out;this.acc=this.seed;out._n(this.acc);this.ins._add(this)};Fold.prototype._stop=function(){this.ins._remove(this);this.out=NO;this.acc=this.seed};Fold.prototype._n=function(t){var u=this.out;if(u===NO)return;var r=_try(this,t,u);if(r===NO)return;u._n(this.acc=r)};Fold.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};Fold.prototype._c=function(){var u=this.out;if(u===NO)return;u._c()};return Fold}();var Last=function(){function Last(ins){this.type="last";this.ins=ins;this.out=NO;this.has=false;this.val=NO}Last.prototype._start=function(out){this.out=out;this.has=false;this.ins._add(this)};Last.prototype._stop=function(){this.ins._remove(this);this.out=NO;this.val=NO};Last.prototype._n=function(t){this.has=true;this.val=t};Last.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};Last.prototype._c=function(){var u=this.out;if(u===NO)return;if(this.has){u._n(this.val);u._c()}else u._e(new Error("last() failed because input stream completed"))};return Last}();var MapFlattenListener=function(){function MapFlattenListener(out,op){this.out=out;this.op=op}MapFlattenListener.prototype._n=function(r){this.out._n(r)};MapFlattenListener.prototype._e=function(err){this.out._e(err)};MapFlattenListener.prototype._c=function(){this.op.inner=NO;this.op.less()};return MapFlattenListener}();var MapFlatten=function(){function MapFlatten(mapOp){this.type=mapOp.type+"+flatten";this.ins=mapOp.ins;this.out=NO;this.mapOp=mapOp;this.inner=NO;this.il=NO_IL;this.open=true}MapFlatten.prototype._start=function(out){this.out=out;this.inner=NO;this.il=NO_IL;this.open=true;this.mapOp.ins._add(this)};MapFlatten.prototype._stop=function(){this.mapOp.ins._remove(this);if(this.inner!==NO)this.inner._remove(this.il);this.out=NO;this.inner=NO;this.il=NO_IL};MapFlatten.prototype.less=function(){if(!this.open&&this.inner===NO){var u=this.out;if(u===NO)return;u._c()}};MapFlatten.prototype._n=function(v){var u=this.out;if(u===NO)return;var _a=this,inner=_a.inner,il=_a.il;var s=_try(this.mapOp,v,u);if(s===NO)return;if(inner!==NO&&il!==NO_IL)inner._remove(il);(this.inner=s)._add(this.il=new MapFlattenListener(u,this))};MapFlatten.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};MapFlatten.prototype._c=function(){this.open=false;this.less()};return MapFlatten}();var MapOp=function(){function MapOp(project,ins){this.type="map";this.ins=ins;this.out=NO;this.f=project}MapOp.prototype._start=function(out){this.out=out;this.ins._add(this)};MapOp.prototype._stop=function(){this.ins._remove(this);this.out=NO};MapOp.prototype._n=function(t){var u=this.out;if(u===NO)return;var r=_try(this,t,u);if(r===NO)return;u._n(r)};MapOp.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};MapOp.prototype._c=function(){var u=this.out;if(u===NO)return;u._c()};return MapOp}();var FilterMapFusion=function(_super){__extends(FilterMapFusion,_super);function FilterMapFusion(passes,project,ins){var _this=_super.call(this,project,ins)||this;_this.type="filter+map";_this.passes=passes;return _this}FilterMapFusion.prototype._n=function(t){if(!this.passes(t))return;var u=this.out;if(u===NO)return;var r=_try(this,t,u);if(r===NO)return;u._n(r)};return FilterMapFusion}(MapOp);var Remember=function(){function Remember(ins){this.type="remember";this.ins=ins;this.out=NO}Remember.prototype._start=function(out){this.out=out;this.ins._add(out)};Remember.prototype._stop=function(){this.ins._remove(this.out);this.out=NO};return Remember}();var ReplaceError=function(){function ReplaceError(replacer,ins){this.type="replaceError";this.ins=ins;this.out=NO;this.f=replacer}ReplaceError.prototype._start=function(out){this.out=out;this.ins._add(this)};ReplaceError.prototype._stop=function(){this.ins._remove(this);this.out=NO};ReplaceError.prototype._n=function(t){var u=this.out;if(u===NO)return;u._n(t)};ReplaceError.prototype._e=function(err){var u=this.out;if(u===NO)return;try{this.ins._remove(this);(this.ins=this.f(err))._add(this)}catch(e){u._e(e)}};ReplaceError.prototype._c=function(){var u=this.out;if(u===NO)return;u._c()};return ReplaceError}();var StartWith=function(){function StartWith(ins,val){this.type="startWith";this.ins=ins;this.out=NO;this.val=val}StartWith.prototype._start=function(out){this.out=out;this.out._n(this.val);this.ins._add(out)};StartWith.prototype._stop=function(){this.ins._remove(this.out);this.out=NO};return StartWith}();var Take=function(){function Take(max,ins){this.type="take";this.ins=ins;this.out=NO;this.max=max;this.taken=0}Take.prototype._start=function(out){this.out=out;this.taken=0;if(this.max<=0)out._c();else this.ins._add(this)};Take.prototype._stop=function(){this.ins._remove(this);this.out=NO};Take.prototype._n=function(t){var u=this.out;if(u===NO)return;var m=++this.taken;if(m<this.max)u._n(t);else if(m===this.max){u._n(t);u._c()}};Take.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};Take.prototype._c=function(){var u=this.out;if(u===NO)return;u._c()};return Take}();var Stream=function(){function Stream(producer){this._prod=producer||NO;this._ils=[];this._stopID=NO;this._dl=NO;this._d=false;this._target=NO;this._err=NO}Stream.prototype._n=function(t){var a=this._ils;var L=a.length;if(this._d)this._dl._n(t);if(L==1)a[0]._n(t);else if(L==0)return;else{var b=cp(a);for(var i=0;i<L;i++)b[i]._n(t)}};Stream.prototype._e=function(err){if(this._err!==NO)return;this._err=err;var a=this._ils;var L=a.length;this._x();if(this._d)this._dl._e(err);if(L==1)a[0]._e(err);else if(L==0)return;else{var b=cp(a);for(var i=0;i<L;i++)b[i]._e(err)}if(!this._d&&L==0)throw this._err};Stream.prototype._c=function(){var a=this._ils;var L=a.length;this._x();if(this._d)this._dl._c();if(L==1)a[0]._c();else if(L==0)return;else{var b=cp(a);for(var i=0;i<L;i++)b[i]._c()}};Stream.prototype._x=function(){if(this._ils.length===0)return;if(this._prod!==NO)this._prod._stop();this._err=NO;this._ils=[]};Stream.prototype._stopNow=function(){this._prod._stop();this._err=NO;this._stopID=NO};Stream.prototype._add=function(il){var ta=this._target;if(ta!==NO)return ta._add(il);var a=this._ils;a.push(il);if(a.length>1)return;if(this._stopID!==NO){clearTimeout(this._stopID);this._stopID=NO}else{var p=this._prod;if(p!==NO)p._start(this)}};Stream.prototype._remove=function(il){var _this=this;var ta=this._target;if(ta!==NO)return ta._remove(il);var a=this._ils;var i=a.indexOf(il);if(i>-1){a.splice(i,1);if(this._prod!==NO&&a.length<=0){this._err=NO;this._stopID=setTimeout(function(){return _this._stopNow()})}else if(a.length===1){this._pruneCycles()}}};Stream.prototype._pruneCycles=function(){if(this._hasNoSinks(this,[]))this._remove(this._ils[0])};Stream.prototype._hasNoSinks=function(x,trace){if(trace.indexOf(x)!==-1)return true;else if(x.out===this)return true;else if(x.out&&x.out!==NO)return this._hasNoSinks(x.out,trace.concat(x));else if(x._ils){for(var i=0,N=x._ils.length;i<N;i++)if(!this._hasNoSinks(x._ils[i],trace.concat(x)))return false;return true}else return false};Stream.prototype.ctor=function(){return this instanceof MemoryStream?MemoryStream:Stream};Stream.prototype.addListener=function(listener){listener._n=listener.next||noop;listener._e=listener.error||noop;listener._c=listener.complete||noop;this._add(listener)};Stream.prototype.removeListener=function(listener){this._remove(listener)};Stream.prototype.subscribe=function(listener){this.addListener(listener);return new StreamSub(this,listener)};Stream.prototype[symbol_observable_1.default]=function(){return this};Stream.create=function(producer){if(producer){if(typeof producer.start!=="function"||typeof producer.stop!=="function")throw new Error("producer requires both start and stop functions");internalizeProducer(producer)}return new Stream(producer)};Stream.createWithMemory=function(producer){if(producer)internalizeProducer(producer);return new MemoryStream(producer)};Stream.never=function(){return new Stream({_start:noop,_stop:noop})};Stream.empty=function(){return new Stream({_start:function(il){il._c()},_stop:noop})};Stream.throw=function(error){return new Stream({_start:function(il){il._e(error)},_stop:noop})};Stream.from=function(input){if(typeof input[symbol_observable_1.default]==="function")return Stream.fromObservable(input);else if(typeof input.then==="function")return Stream.fromPromise(input);else if(Array.isArray(input))return Stream.fromArray(input);throw new TypeError("Type of input to from() must be an Array, Promise, or Observable")};Stream.of=function(){var items=[];for(var _i=0;_i<arguments.length;_i++){items[_i]=arguments[_i]}return Stream.fromArray(items)};Stream.fromArray=function(array){return new Stream(new FromArray(array))};Stream.fromPromise=function(promise){return new Stream(new FromPromise(promise))};Stream.fromObservable=function(obs){if(obs.endWhen)return obs;return new Stream(new FromObservable(obs))};Stream.periodic=function(period){return new Stream(new Periodic(period))};Stream.prototype._map=function(project){var p=this._prod;var ctor=this.ctor();if(p instanceof Filter)return new ctor(new FilterMapFusion(p.f,project,p.ins));return new ctor(new MapOp(project,this))};Stream.prototype.map=function(project){return this._map(project)};Stream.prototype.mapTo=function(projectedValue){var s=this.map(function(){return projectedValue});var op=s._prod;op.type=op.type.replace("map","mapTo");return s};Stream.prototype.filter=function(passes){var p=this._prod;if(p instanceof Filter)return new Stream(new Filter(and(p.f,passes),p.ins));return new Stream(new Filter(passes,this))};Stream.prototype.take=function(amount){return new(this.ctor())(new Take(amount,this))};Stream.prototype.drop=function(amount){return new Stream(new Drop(amount,this))};Stream.prototype.last=function(){return new Stream(new Last(this))};Stream.prototype.startWith=function(initial){return new MemoryStream(new StartWith(this,initial))};Stream.prototype.endWhen=function(other){return new(this.ctor())(new EndWhen(other,this))};Stream.prototype.fold=function(accumulate,seed){return new MemoryStream(new Fold(accumulate,seed,this))};Stream.prototype.replaceError=function(replace){return new(this.ctor())(new ReplaceError(replace,this))};Stream.prototype.flatten=function(){var p=this._prod;return new Stream(p instanceof MapOp&&!(p instanceof FilterMapFusion)?new MapFlatten(p):new Flatten(this))};Stream.prototype.compose=function(operator){return operator(this)};Stream.prototype.remember=function(){return new MemoryStream(new Remember(this))};Stream.prototype.debug=function(labelOrSpy){return new(this.ctor())(new Debug(this,labelOrSpy))};Stream.prototype.imitate=function(target){if(target instanceof MemoryStream)throw new 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=target;for(var ils=this._ils,N=ils.length,i=0;i<N;i++)target._add(ils[i]);this._ils=[]};Stream.prototype.shamefullySendNext=function(value){this._n(value)};Stream.prototype.shamefullySendError=function(error){this._e(error)};Stream.prototype.shamefullySendComplete=function(){this._c()};Stream.prototype.setDebugListener=function(listener){if(!listener){this._d=false;this._dl=NO}else{this._d=true;listener._n=listener.next||noop;listener._e=listener.error||noop;listener._c=listener.complete||noop;this._dl=listener}};return Stream}();Stream.merge=function merge(){var streams=[];for(var _i=0;_i<arguments.length;_i++){streams[_i]=arguments[_i]}return new Stream(new Merge(streams))};Stream.combine=function combine(){var streams=[];for(var _i=0;_i<arguments.length;_i++){streams[_i]=arguments[_i]}return new Stream(new Combine(streams))};exports.Stream=Stream;var MemoryStream=function(_super){__extends(MemoryStream,_super);function MemoryStream(producer){var _this=_super.call(this,producer)||this;_this._has=false;return _this}MemoryStream.prototype._n=function(x){this._v=x;this._has=true;_super.prototype._n.call(this,x)};MemoryStream.prototype._add=function(il){var ta=this._target;if(ta!==NO)return ta._add(il);var a=this._ils;a.push(il);if(a.length>1){if(this._has)il._n(this._v);return}if(this._stopID!==NO){if(this._has)il._n(this._v);clearTimeout(this._stopID);this._stopID=NO}else if(this._has)il._n(this._v);else{var p=this._prod;if(p!==NO)p._start(this)}};MemoryStream.prototype._stopNow=function(){this._has=false;_super.prototype._stopNow.call(this)};MemoryStream.prototype._x=function(){this._has=false;_super.prototype._x.call(this)};MemoryStream.prototype.map=function(project){return this._map(project)};MemoryStream.prototype.mapTo=function(projectedValue){return _super.prototype.mapTo.call(this,projectedValue)};MemoryStream.prototype.take=function(amount){return _super.prototype.take.call(this,amount)};MemoryStream.prototype.endWhen=function(other){return _super.prototype.endWhen.call(this,other)};MemoryStream.prototype.replaceError=function(replace){return _super.prototype.replaceError.call(this,replace)};MemoryStream.prototype.remember=function(){return this};MemoryStream.prototype.debug=function(labelOrSpy){return _super.prototype.debug.call(this,labelOrSpy)};return MemoryStream}(Stream);exports.MemoryStream=MemoryStream;Object.defineProperty(exports,"__esModule",{value:true});exports.default=Stream},{"symbol-observable":2}],2:[function(require,module,exports){module.exports=require("./lib/index")},{"./lib/index":3}],3:[function(require,module,exports){(function(global){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _ponyfill=require("./ponyfill");var _ponyfill2=_interopRequireDefault(_ponyfill);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var root;if(typeof self!=="undefined"){root=self}else if(typeof window!=="undefined"){root=window}else if(typeof global!=="undefined"){root=global}else if(typeof module!=="undefined"){root=module}else{root=Function("return this")()}var result=(0,_ponyfill2["default"])(root);exports["default"]=result}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./ponyfill":4}],4:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=symbolObservablePonyfill;function symbolObservablePonyfill(root){var result;var _Symbol=root.Symbol;if(typeof _Symbol==="function"){if(_Symbol.observable){result=_Symbol.observable}else{result=_Symbol("observable");_Symbol.observable=result}}else{result="@@observable"}return result}},{}]},{},[1])(1)}); |
@@ -237,3 +237,5 @@ declare const NO: {}; | ||
*/ | ||
static fromObservable<T>(observable: any): Stream<T>; | ||
static fromObservable<T>(obs: { | ||
subscribe: any; | ||
}): Stream<T>; | ||
/** | ||
@@ -240,0 +242,0 @@ * Creates a stream that periodically emits incremental numbers, every |
115
index.js
@@ -11,8 +11,7 @@ "use strict"; | ||
function noop() { } | ||
function copy(a) { | ||
function cp(a) { | ||
var l = a.length; | ||
var b = Array(l); | ||
for (var i = 0; i < l; ++i) { | ||
for (var i = 0; i < l; ++i) | ||
b[i] = a[i]; | ||
} | ||
return b; | ||
@@ -107,5 +106,4 @@ } | ||
this.ac = L; | ||
for (var i = 0; i < L; i++) { | ||
for (var i = 0; i < L; i++) | ||
s[i]._add(this); | ||
} | ||
}; | ||
@@ -115,5 +113,4 @@ Merge.prototype._stop = function () { | ||
var L = s.length; | ||
for (var i = 0; i < L; i++) { | ||
for (var i = 0; i < L; i++) | ||
s[i]._remove(this); | ||
} | ||
this.out = NO; | ||
@@ -154,5 +151,4 @@ }; | ||
return; | ||
if (p.up(t, this.i)) { | ||
if (p.up(t, this.i)) | ||
out._n(p.vals); | ||
} | ||
}; | ||
@@ -169,5 +165,4 @@ CombineListener.prototype._e = function (err) { | ||
return; | ||
if (--p.Nc === 0) { | ||
if (--p.Nc === 0) | ||
p.out._c(); | ||
} | ||
}; | ||
@@ -211,5 +206,4 @@ return CombineListener; | ||
var ils = this.ils; | ||
for (var i = 0; i < n; i++) { | ||
for (var i = 0; i < n; i++) | ||
s[i]._remove(ils[i]); | ||
} | ||
this.out = NO; | ||
@@ -228,5 +222,4 @@ this.ils = []; | ||
var a = this.a; | ||
for (var i = 0, l = a.length; i < l; i++) { | ||
for (var i = 0, n = a.length; i < n; i++) | ||
out._n(a[i]); | ||
} | ||
out._c(); | ||
@@ -290,8 +283,6 @@ }; | ||
this.l = ''; | ||
if (typeof arg === 'string') { | ||
if (typeof arg === 'string') | ||
this.l = arg; | ||
} | ||
else if (typeof arg === 'function') { | ||
else if (typeof arg === 'function') | ||
this.s = arg; | ||
} | ||
} | ||
@@ -319,8 +310,6 @@ Debug.prototype._start = function (out) { | ||
} | ||
else if (l) { | ||
else if (l) | ||
console.log(l + ':', t); | ||
} | ||
else { | ||
else | ||
console.log(t); | ||
} | ||
u._n(t); | ||
@@ -625,5 +614,4 @@ }; | ||
} | ||
else { | ||
u._e('TODO show proper error'); | ||
} | ||
else | ||
u._e(new Error('last() failed because input stream completed')); | ||
}; | ||
@@ -851,8 +839,6 @@ return Last; | ||
this.taken = 0; | ||
if (this.max <= 0) { | ||
if (this.max <= 0) | ||
out._c(); | ||
} | ||
else { | ||
else | ||
this.ins._add(this); | ||
} | ||
}; | ||
@@ -868,5 +854,4 @@ Take.prototype._stop = function () { | ||
var m = ++this.taken; | ||
if (m < this.max) { | ||
if (m < this.max) | ||
u._n(t); | ||
} | ||
else if (m === this.max) { | ||
@@ -908,4 +893,6 @@ u._n(t); | ||
a[0]._n(t); | ||
else if (L == 0) | ||
return; | ||
else { | ||
var b = copy(a); | ||
var b = cp(a); | ||
for (var i = 0; i < L; i++) | ||
@@ -926,4 +913,6 @@ b[i]._n(t); | ||
a[0]._e(err); | ||
else if (L == 0) | ||
return; | ||
else { | ||
var b = copy(a); | ||
var b = cp(a); | ||
for (var i = 0; i < L; i++) | ||
@@ -943,4 +932,6 @@ b[i]._e(err); | ||
a[0]._c(); | ||
else if (L == 0) | ||
return; | ||
else { | ||
var b = copy(a); | ||
var b = cp(a); | ||
for (var i = 0; i < L; i++) | ||
@@ -1006,5 +997,4 @@ b[i]._c(); | ||
Stream.prototype._pruneCycles = function () { | ||
if (this._hasNoSinks(this, [])) { | ||
if (this._hasNoSinks(this, [])) | ||
this._remove(this._ils[0]); | ||
} | ||
}; | ||
@@ -1016,22 +1006,16 @@ // Checks whether *there is no* path starting from `x` that leads to an end | ||
Stream.prototype._hasNoSinks = function (x, trace) { | ||
if (trace.indexOf(x) !== -1) { | ||
if (trace.indexOf(x) !== -1) | ||
return true; | ||
} | ||
else if (x.out === this) { | ||
else if (x.out === this) | ||
return true; | ||
} | ||
else if (x.out && x.out !== NO) { | ||
else if (x.out && x.out !== NO) | ||
return this._hasNoSinks(x.out, trace.concat(x)); | ||
} | ||
else if (x._ils) { | ||
for (var i = 0, N = x._ils.length; i < N; i++) { | ||
if (!this._hasNoSinks(x._ils[i], trace.concat(x))) { | ||
for (var i = 0, N = x._ils.length; i < N; i++) | ||
if (!this._hasNoSinks(x._ils[i], trace.concat(x))) | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
else { | ||
else | ||
return false; | ||
} | ||
}; | ||
@@ -1090,5 +1074,4 @@ Stream.prototype.ctor = function () { | ||
if (typeof producer.start !== 'function' | ||
|| typeof producer.stop !== 'function') { | ||
|| typeof producer.stop !== 'function') | ||
throw new Error('producer requires both start and stop functions'); | ||
} | ||
internalizeProducer(producer); // mutates the input | ||
@@ -1107,5 +1090,4 @@ } | ||
Stream.createWithMemory = function (producer) { | ||
if (producer) { | ||
if (producer) | ||
internalizeProducer(producer); // mutates the input | ||
} | ||
return new MemoryStream(producer); | ||
@@ -1179,11 +1161,8 @@ }; | ||
Stream.from = function (input) { | ||
if (typeof input[symbol_observable_1.default] === 'function') { | ||
if (typeof input[symbol_observable_1.default] === 'function') | ||
return Stream.fromObservable(input); | ||
} | ||
else if (typeof input.then === 'function') { | ||
else if (typeof input.then === 'function') | ||
return Stream.fromPromise(input); | ||
} | ||
else if (Array.isArray(input)) { | ||
else if (Array.isArray(input)) | ||
return Stream.fromArray(input); | ||
} | ||
throw new TypeError("Type of input to from() must be an Array, Promise, or Observable"); | ||
@@ -1259,4 +1238,6 @@ }; | ||
*/ | ||
Stream.fromObservable = function (observable) { | ||
return new Stream(new FromObservable(observable)); | ||
Stream.fromObservable = function (obs) { | ||
if (obs.endWhen) | ||
return obs; | ||
return new Stream(new FromObservable(obs)); | ||
}; | ||
@@ -1285,5 +1266,4 @@ /** | ||
var ctor = this.ctor(); | ||
if (p instanceof Filter) { | ||
if (p instanceof Filter) | ||
return new ctor(new FilterMapFusion(p.f, project, p.ins)); | ||
} | ||
return new ctor(new MapOp(project, this)); | ||
@@ -1355,5 +1335,4 @@ }; | ||
var p = this._prod; | ||
if (p instanceof Filter) { | ||
if (p instanceof Filter) | ||
return new Stream(new Filter(and(p.f, passes), p.ins)); | ||
} | ||
return new Stream(new Filter(passes, this)); | ||
@@ -1665,11 +1644,9 @@ }; | ||
Stream.prototype.imitate = function (target) { | ||
if (target instanceof MemoryStream) { | ||
if (target instanceof MemoryStream) | ||
throw new 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 = target; | ||
for (var ils = this._ils, N = ils.length, i = 0; i < N; i++) { | ||
for (var ils = this._ils, N = ils.length, i = 0; i < N; i++) | ||
target._add(ils[i]); | ||
} | ||
this._ils = []; | ||
@@ -1676,0 +1653,0 @@ }; |
{ | ||
"name": "xstream", | ||
"version": "10.1.0", | ||
"version": "10.2.0", | ||
"description": "An extremely intuitive, small, and fast functional reactive stream library for JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
136
src/index.ts
@@ -6,8 +6,6 @@ import $$observable from 'symbol-observable'; | ||
function copy<T>(a: Array<T>): Array<T> { | ||
function cp<T>(a: Array<T>): Array<T> { | ||
const l = a.length; | ||
const b = Array(l); | ||
for (let i = 0; i < l; ++i) { | ||
b[i] = a[i]; | ||
} | ||
for (let i = 0; i < l; ++i) b[i] = a[i]; | ||
return b; | ||
@@ -233,5 +231,3 @@ } | ||
this.ac = L; | ||
for (let i = 0; i < L; i++) { | ||
s[i]._add(this); | ||
} | ||
for (let i = 0; i < L; i++) s[i]._add(this); | ||
} | ||
@@ -242,5 +238,3 @@ | ||
const L = s.length; | ||
for (let i = 0; i < L; i++) { | ||
s[i]._remove(this); | ||
} | ||
for (let i = 0; i < L; i++) s[i]._remove(this); | ||
this.out = NO as Stream<T>; | ||
@@ -354,5 +348,3 @@ } | ||
if (out === NO) return; | ||
if (p.up(t, this.i)) { | ||
out._n(p.vals); | ||
} | ||
if (p.up(t, this.i)) out._n(p.vals); | ||
} | ||
@@ -369,5 +361,3 @@ | ||
if (p.out === NO) return; | ||
if (--p.Nc === 0) { | ||
p.out._c(); | ||
} | ||
if (--p.Nc === 0) p.out._c(); | ||
} | ||
@@ -420,5 +410,3 @@ } | ||
const ils = this.ils; | ||
for (let i = 0; i < n; i++) { | ||
s[i]._remove(ils[i]); | ||
} | ||
for (let i = 0; i < n; i++) s[i]._remove(ils[i]); | ||
this.out = NO as Stream<Array<R>>; | ||
@@ -440,5 +428,3 @@ this.ils = []; | ||
const a = this.a; | ||
for (let i = 0, l = a.length; i < l; i++) { | ||
out._n(a[i]); | ||
} | ||
for (let i = 0, n = a.length; i < n; i++) out._n(a[i]); | ||
out._c(); | ||
@@ -473,3 +459,3 @@ } | ||
out._e(e); | ||
} | ||
}, | ||
).then(noop, (err: any) => { | ||
@@ -526,7 +512,3 @@ setTimeout(() => { throw err; }); | ||
this.l = ''; | ||
if (typeof arg === 'string') { | ||
this.l = arg; | ||
} else if (typeof arg === 'function') { | ||
this.s = arg; | ||
} | ||
if (typeof arg === 'string') this.l = arg; else if (typeof arg === 'function') this.s = arg; | ||
} | ||
@@ -554,7 +536,3 @@ | ||
} | ||
} else if (l) { | ||
console.log(l + ':', t); | ||
} else { | ||
console.log(t); | ||
} | ||
} else if (l) console.log(l + ':', t); else console.log(t); | ||
u._n(t); | ||
@@ -909,5 +887,3 @@ } | ||
u._c(); | ||
} else { | ||
u._e('TODO show proper error'); | ||
} | ||
} else u._e(new Error('last() failed because input stream completed')); | ||
} | ||
@@ -1174,7 +1150,3 @@ } | ||
this.taken = 0; | ||
if (this.max <= 0) { | ||
out._c(); | ||
} else { | ||
this.ins._add(this); | ||
} | ||
if (this.max <= 0) out._c(); else this.ins._add(this); | ||
} | ||
@@ -1191,6 +1163,4 @@ | ||
const m = ++this.taken; | ||
if (m < this.max) { | ||
if (m < this.max) u._n(t); else if (m === this.max) { | ||
u._n(t); | ||
} else if (m === this.max) { | ||
u._n(t); | ||
u._c(); | ||
@@ -1236,4 +1206,4 @@ } | ||
if (this._d) this._dl._n(t); | ||
if (L == 1) a[0]._n(t); else { | ||
const b = copy(a); | ||
if (L == 1) a[0]._n(t); else if (L == 0) return; else { | ||
const b = cp(a); | ||
for (let i = 0; i < L; i++) b[i]._n(t); | ||
@@ -1250,4 +1220,4 @@ } | ||
if (this._d) this._dl._e(err); | ||
if (L == 1) a[0]._e(err); else { | ||
const b = copy(a); | ||
if (L == 1) a[0]._e(err); else if (L == 0) return; else { | ||
const b = cp(a); | ||
for (let i = 0; i < L; i++) b[i]._e(err); | ||
@@ -1263,4 +1233,4 @@ } | ||
if (this._d) this._dl._c(); | ||
if (L == 1) a[0]._c(); else { | ||
const b = copy(a); | ||
if (L == 1) a[0]._c(); else if (L == 0) return; else { | ||
const b = cp(a); | ||
for (let i = 0; i < L; i++) b[i]._c(); | ||
@@ -1321,5 +1291,3 @@ } | ||
_pruneCycles() { | ||
if (this._hasNoSinks(this, [])) { | ||
this._remove(this._ils[0]); | ||
} | ||
if (this._hasNoSinks(this, [])) this._remove(this._ils[0]); | ||
} | ||
@@ -1332,18 +1300,14 @@ | ||
_hasNoSinks(x: InternalListener<any>, trace: Array<any>): boolean { | ||
if (trace.indexOf(x) !== -1) { | ||
return true; | ||
} else if ((x as any as OutSender<any>).out === this) { | ||
return true; | ||
} else if ((x as any as OutSender<any>).out && (x as any as OutSender<any>).out !== NO) { | ||
return this._hasNoSinks((x as any as OutSender<any>).out, trace.concat(x)); | ||
} else if ((x as Stream<any>)._ils) { | ||
for (let i = 0, N = (x as Stream<any>)._ils.length; i < N; i++) { | ||
if (!this._hasNoSinks((x as Stream<any>)._ils[i], trace.concat(x))) { | ||
if (trace.indexOf(x) !== -1) | ||
return true; else | ||
if ((x as any as OutSender<any>).out === this) | ||
return true; else | ||
if ((x as any as OutSender<any>).out && (x as any as OutSender<any>).out !== NO) | ||
return this._hasNoSinks((x as any as OutSender<any>).out, trace.concat(x)); else | ||
if ((x as Stream<any>)._ils) { | ||
for (let i = 0, N = (x as Stream<any>)._ils.length; i < N; i++) | ||
if (!this._hasNoSinks((x as Stream<any>)._ils[i], trace.concat(x))) | ||
return false; | ||
} | ||
} | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} else return false; | ||
} | ||
@@ -1385,3 +1349,2 @@ | ||
this.addListener(listener); | ||
return new StreamSub<T>(this, listener); | ||
@@ -1410,5 +1373,4 @@ } | ||
if (typeof producer.start !== 'function' | ||
|| typeof producer.stop !== 'function') { | ||
|| typeof producer.stop !== 'function') | ||
throw new Error('producer requires both start and stop functions'); | ||
} | ||
internalizeProducer(producer); // mutates the input | ||
@@ -1428,5 +1390,3 @@ } | ||
static createWithMemory<T>(producer?: Producer<T>): MemoryStream<T> { | ||
if (producer) { | ||
internalizeProducer(producer); // mutates the input | ||
} | ||
if (producer) internalizeProducer(producer); // mutates the input | ||
return new MemoryStream<T>(producer as InternalProducer<T> & Producer<T>); | ||
@@ -1504,9 +1464,8 @@ } | ||
static from<T>(input: Promise<T> | Stream<T> | Array<T> | Observable<T>): Stream<T> { | ||
if (typeof input[$$observable] === 'function') { | ||
return Stream.fromObservable<T>(input); | ||
} else if (typeof (input as Promise<T>).then === 'function') { | ||
return Stream.fromPromise<T>(input as Promise<T>); | ||
} else if (Array.isArray(input)) { | ||
if (typeof input[$$observable] === 'function') | ||
return Stream.fromObservable<T>(input as Observable<T>); else | ||
if (typeof (input as Promise<T>).then === 'function') | ||
return Stream.fromPromise<T>(input as Promise<T>); else | ||
if (Array.isArray(input)) | ||
return Stream.fromArray<T>(input); | ||
} | ||
@@ -1583,4 +1542,5 @@ throw new TypeError(`Type of input to from() must be an Array, Promise, or Observable`); | ||
*/ | ||
static fromObservable<T>(observable: any): Stream<T> { | ||
return new Stream<T>(new FromObservable(observable)); | ||
static fromObservable<T>(obs: {subscribe: any}): Stream<T> { | ||
if ((obs as Stream<T>).endWhen) return obs as Stream<T>; | ||
return new Stream<T>(new FromObservable(obs)); | ||
} | ||
@@ -1681,5 +1641,3 @@ | ||
const ctor = this.ctor(); | ||
if (p instanceof Filter) { | ||
return new ctor<U>(new FilterMapFusion<T, U>(p.f, project, p.ins)); | ||
} | ||
if (p instanceof Filter) return new ctor<U>(new FilterMapFusion<T, U>(p.f, project, p.ins)); | ||
return new ctor<U>(new MapOp<T, U>(project, this)); | ||
@@ -1756,3 +1714,3 @@ } | ||
const p = this._prod; | ||
if (p instanceof Filter) { | ||
if (p instanceof Filter) | ||
return new Stream<T>(new Filter<T>( | ||
@@ -1762,3 +1720,2 @@ and((p as Filter<T>).f, passes), | ||
)); | ||
} | ||
return new Stream<T>(new Filter<T>(passes, this)); | ||
@@ -2087,11 +2044,8 @@ } | ||
imitate(target: Stream<T>): void { | ||
if (target instanceof MemoryStream) { | ||
if (target instanceof MemoryStream) | ||
throw new 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 = target; | ||
for (let ils = this._ils, N = ils.length, i = 0; i < N; i++) { | ||
target._add(ils[i]); | ||
} | ||
for (let ils = this._ils, N = ils.length, i = 0; i < N; i++) target._add(ils[i]); | ||
this._ils = []; | ||
@@ -2098,0 +2052,0 @@ } |
@@ -81,3 +81,3 @@ #!/usr/bin/env node | ||
var toPush = null; | ||
if (commit.type === 'fix' || commit.type === 'feat') { | ||
if (commit.type === 'fix' || commit.type === 'feat' || commit.type === 'perf') { | ||
status.increment = Math.max(status.increment, 2); | ||
@@ -84,0 +84,0 @@ toPush = commit; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
918265
157
17820