Comparing version 2.1.2 to 2.1.3
@@ -0,1 +1,11 @@ | ||
<a name="2.1.3"></a> | ||
## [2.1.3](https://github.com/staltz/xstream/compare/v2.1.2...v2.1.3) (2016-04-30) | ||
### Bug Fixes | ||
* **remember:** return MemoryStream, not Stream ([4f50922](https://github.com/staltz/xstream/commit/4f50922)) | ||
<a name="2.1.2"></a> | ||
@@ -2,0 +12,0 @@ ## [2.1.2](https://github.com/staltz/xstream/compare/v2.1.1...v2.1.2) (2016-04-30) |
@@ -788,5 +788,5 @@ export interface InternalListener<T> { | ||
* | ||
* @return {Stream} | ||
* @return {MemoryStream} | ||
*/ | ||
remember(): Stream<T>; | ||
remember(): MemoryStream<T>; | ||
/** | ||
@@ -860,8 +860,8 @@ * Changes this current stream to imitate the `other` given stream. | ||
export declare class MemoryStream<T> extends Stream<T> { | ||
private _val; | ||
private _v; | ||
private _has; | ||
constructor(producer: InternalProducer<T>); | ||
_n(x: T): void; | ||
_add(listener: InternalListener<T>): void; | ||
_add(il: InternalListener<T>): void; | ||
} | ||
export default Stream; |
10
core.js
@@ -1506,3 +1506,3 @@ "use strict"; | ||
* | ||
* @return {Stream} | ||
* @return {MemoryStream} | ||
*/ | ||
@@ -1641,11 +1641,11 @@ Stream.prototype.remember = function () { | ||
MemoryStream.prototype._n = function (x) { | ||
this._val = x; | ||
this._v = x; | ||
this._has = true; | ||
_super.prototype._n.call(this, x); | ||
}; | ||
MemoryStream.prototype._add = function (listener) { | ||
MemoryStream.prototype._add = function (il) { | ||
if (this._has) { | ||
listener._n(this._val); | ||
il._n(this._v); | ||
} | ||
_super.prototype._add.call(this, listener); | ||
_super.prototype._add.call(this, il); | ||
}; | ||
@@ -1652,0 +1652,0 @@ return MemoryStream; |
@@ -1127,11 +1127,11 @@ (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){ | ||
MemoryStream.prototype._n = function (x) { | ||
this._val = x; | ||
this._v = x; | ||
this._has = true; | ||
_super.prototype._n.call(this, x); | ||
}; | ||
MemoryStream.prototype._add = function (listener) { | ||
MemoryStream.prototype._add = function (il) { | ||
if (this._has) { | ||
listener._n(this._val); | ||
il._n(this._v); | ||
} | ||
_super.prototype._add.call(this, listener); | ||
_super.prototype._add.call(this, il); | ||
}; | ||
@@ -1138,0 +1138,0 @@ return MemoryStream; |
@@ -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 empty={};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}var emptyListener={_n:noop,_e:noop,_c:noop};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}function invoke(f,args){switch(args.length){case 0:return f();case 1:return f(args[0]);case 2:return f(args[0],args[1]);case 3:return f(args[0],args[1],args[2]);case 4:return f(args[0],args[1],args[2],args[3]);case 5:return f(args[0],args[1],args[2],args[3],args[4]);default:return f.apply(void 0,args)}}function compose2(f1,f2){return function composedFn(arg){return f1(f2(arg))}}function and(f1,f2){return function andFn(t){return f1(t)&&f2(t)}}var CombineListener=function(){function CombineListener(i,prod){this.i=i;this.prod=prod;prod.proxies.push(this)}CombineListener.prototype._n=function(t){var prod=this.prod;var vals=prod.vals;prod.hasVal[this.i]=true;vals[this.i]=t;if(!prod.ready){prod.up()}if(prod.ready){try{prod.out._n(invoke(prod.project,vals))}catch(e){prod.out._e(e)}}};CombineListener.prototype._e=function(err){this.prod.out._e(err)};CombineListener.prototype._c=function(){var prod=this.prod;if(--prod.ac===0){prod.out._c()}};return CombineListener}();var CombineProducer=function(){function CombineProducer(project,streams){this.project=project;this.streams=streams;this.out=emptyListener;this.proxies=[];this.ready=false;this.vals=new Array(streams.length);this.hasVal=new Array(streams.length);this.ac=streams.length}CombineProducer.prototype.up=function(){for(var i=this.hasVal.length-1;i>=0;i--){if(!this.hasVal[i]){return}}this.ready=true};CombineProducer.prototype._start=function(out){this.out=out;var streams=this.streams;for(var i=streams.length-1;i>=0;i--){streams[i]._add(new CombineListener(i,this))}};CombineProducer.prototype._stop=function(){var streams=this.streams;for(var i=streams.length-1;i>=0;i--){streams[i]._remove(this.proxies[i])}this.out=null;this.ac=streams.length;this.proxies=[];this.ready=false;this.vals=new Array(streams.length);this.hasVal=new Array(streams.length)};return CombineProducer}();var FromArrayProducer=function(){function FromArrayProducer(a){this.a=a}FromArrayProducer.prototype._start=function(out){var a=this.a;for(var i=0,l=a.length;i<l;i++){out._n(a[i])}out._c()};FromArrayProducer.prototype._stop=function(){};return FromArrayProducer}();exports.FromArrayProducer=FromArrayProducer;var FromPromiseProducer=function(){function FromPromiseProducer(p){this.p=p;this.on=false}FromPromiseProducer.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(null,function(err){setTimeout(function(){throw err})})};FromPromiseProducer.prototype._stop=function(){this.on=false};return FromPromiseProducer}();exports.FromPromiseProducer=FromPromiseProducer;var MergeProducer=function(){function MergeProducer(streams){this.streams=streams;this.out=emptyListener;this.ac=streams.length}MergeProducer.prototype._start=function(out){this.out=out;var streams=this.streams;for(var i=streams.length-1;i>=0;i--){streams[i]._add(this)}};MergeProducer.prototype._stop=function(){var streams=this.streams;for(var i=streams.length-1;i>=0;i--){streams[i]._remove(this)}this.out=null;this.ac=streams.length};MergeProducer.prototype._n=function(t){this.out._n(t)};MergeProducer.prototype._e=function(err){this.out._e(err)};MergeProducer.prototype._c=function(){if(--this.ac===0){this.out._c()}};return MergeProducer}();exports.MergeProducer=MergeProducer;var PeriodicProducer=function(){function PeriodicProducer(period){this.period=period;this.intervalID=-1;this.i=0}PeriodicProducer.prototype._start=function(stream){var self=this;function intervalHandler(){stream._n(self.i++)}this.intervalID=setInterval(intervalHandler,this.period)};PeriodicProducer.prototype._stop=function(){if(this.intervalID!==-1)clearInterval(this.intervalID);this.intervalID=-1;this.i=0};return PeriodicProducer}();exports.PeriodicProducer=PeriodicProducer;var DebugOperator=function(){function DebugOperator(spy,ins){if(spy===void 0){spy=null}this.spy=spy;this.ins=ins;this.out=null}DebugOperator.prototype._start=function(out){this.out=out;this.ins._add(this)};DebugOperator.prototype._stop=function(){this.ins._remove(this);this.out=null};DebugOperator.prototype._n=function(t){if(this.spy){try{this.spy(t)}catch(e){this.out._e(e)}}else{console.log(t)}this.out._n(t)};DebugOperator.prototype._e=function(err){this.out._e(err)};DebugOperator.prototype._c=function(){this.out._c()};return DebugOperator}();exports.DebugOperator=DebugOperator;var DropOperator=function(){function DropOperator(max,ins){this.max=max;this.ins=ins;this.out=null;this.dropped=0}DropOperator.prototype._start=function(out){this.out=out;this.ins._add(this)};DropOperator.prototype._stop=function(){this.ins._remove(this);this.out=null;this.dropped=0};DropOperator.prototype._n=function(t){if(this.dropped++>=this.max)this.out._n(t)};DropOperator.prototype._e=function(err){this.out._e(err)};DropOperator.prototype._c=function(){this.out._c()};return DropOperator}();exports.DropOperator=DropOperator;var OtherListener=function(){function OtherListener(out,op){this.out=out;this.op=op}OtherListener.prototype._n=function(t){this.op.end()};OtherListener.prototype._e=function(err){this.out._e(err)};OtherListener.prototype._c=function(){this.op.end()};return OtherListener}();var EndWhenOperator=function(){function EndWhenOperator(o,ins){this.o=o;this.ins=ins;this.out=null;this.oli=emptyListener}EndWhenOperator.prototype._start=function(out){this.out=out;this.o._add(this.oli=new OtherListener(out,this));this.ins._add(this)};EndWhenOperator.prototype._stop=function(){this.ins._remove(this);this.o._remove(this.oli);this.out=null;this.oli=null};EndWhenOperator.prototype.end=function(){this.out._c()};EndWhenOperator.prototype._n=function(t){this.out._n(t)};EndWhenOperator.prototype._e=function(err){this.out._e(err)};EndWhenOperator.prototype._c=function(){this.end()};return EndWhenOperator}();exports.EndWhenOperator=EndWhenOperator;var FilterOperator=function(){function FilterOperator(passes,ins){this.passes=passes;this.ins=ins;this.out=null}FilterOperator.prototype._start=function(out){this.out=out;this.ins._add(this)};FilterOperator.prototype._stop=function(){this.ins._remove(this);this.out=null};FilterOperator.prototype._n=function(t){try{if(this.passes(t))this.out._n(t)}catch(e){this.out._e(e)}};FilterOperator.prototype._e=function(err){this.out._e(err)};FilterOperator.prototype._c=function(){this.out._c()};return FilterOperator}();exports.FilterOperator=FilterOperator;var FCInner=function(){function FCInner(out,op){this.out=out;this.op=op}FCInner.prototype._n=function(t){this.out._n(t)};FCInner.prototype._e=function(err){this.out._e(err)};FCInner.prototype._c=function(){this.op.less()};return FCInner}();var FlattenConcOperator=function(){function FlattenConcOperator(ins){this.ins=ins;this.active=1;this.out=null}FlattenConcOperator.prototype._start=function(out){this.out=out;this.ins._add(this)};FlattenConcOperator.prototype._stop=function(){this.ins._remove(this);this.active=1;this.out=null};FlattenConcOperator.prototype.less=function(){if(--this.active===0){this.out._c()}};FlattenConcOperator.prototype._n=function(s){this.active++;s._add(new FCInner(this.out,this))};FlattenConcOperator.prototype._e=function(err){this.out._e(err)};FlattenConcOperator.prototype._c=function(){this.less()};return FlattenConcOperator}();exports.FlattenConcOperator=FlattenConcOperator;var FInner=function(){function FInner(out,op){this.out=out;this.op=op}FInner.prototype._n=function(t){this.out._n(t)};FInner.prototype._e=function(err){this.out._e(err)};FInner.prototype._c=function(){this.op.curr=null;this.op.less()};return FInner}();var FlattenOperator=function(){function FlattenOperator(ins){this.ins=ins;this.curr=null;this.inner=null;this.open=true;this.out=null}FlattenOperator.prototype._start=function(out){this.out=out;this.ins._add(this)};FlattenOperator.prototype._stop=function(){this.ins._remove(this);this.curr=null;this.inner=null;this.open=true;this.out=null};FlattenOperator.prototype.cut=function(){var _a=this,curr=_a.curr,inner=_a.inner;if(curr&&inner){curr._remove(inner)}};FlattenOperator.prototype.less=function(){if(!this.open&&!this.curr){this.out._c()}};FlattenOperator.prototype._n=function(s){this.cut();(this.curr=s)._add(this.inner=new FInner(this.out,this))};FlattenOperator.prototype._e=function(err){this.out._e(err)};FlattenOperator.prototype._c=function(){this.open=false;this.less()};return FlattenOperator}();exports.FlattenOperator=FlattenOperator;var FoldOperator=function(){function FoldOperator(f,seed,ins){this.f=f;this.seed=seed;this.ins=ins;this.out=null;this.acc=seed}FoldOperator.prototype._start=function(out){this.out=out;out._n(this.acc);this.ins._add(this)};FoldOperator.prototype._stop=function(){this.ins._remove(this);this.out=null;this.acc=this.seed};FoldOperator.prototype._n=function(t){try{this.out._n(this.acc=this.f(this.acc,t))}catch(e){this.out._e(e)}};FoldOperator.prototype._e=function(err){this.out._e(err)};FoldOperator.prototype._c=function(){this.out._c()};return FoldOperator}();exports.FoldOperator=FoldOperator;var LastOperator=function(){function LastOperator(ins){this.ins=ins;this.out=null;this.has=false;this.val=empty}LastOperator.prototype._start=function(out){this.out=out;this.ins._add(this)};LastOperator.prototype._stop=function(){this.ins._remove(this);this.out=null;this.has=false;this.val=empty};LastOperator.prototype._n=function(t){this.has=true;this.val=t};LastOperator.prototype._e=function(err){this.out._e(err)};LastOperator.prototype._c=function(){var out=this.out;if(this.has){out._n(this.val);out._c()}else{out._e("TODO show proper error")}};return LastOperator}();exports.LastOperator=LastOperator;var MFCInner=function(){function MFCInner(out,op){this.out=out;this.op=op}MFCInner.prototype._n=function(t){this.out._n(t)};MFCInner.prototype._e=function(err){this.out._e(err)};MFCInner.prototype._c=function(){this.op.less()};return MFCInner}();var MapFlattenConcOperator=function(){function MapFlattenConcOperator(mapOp){this.mapOp=mapOp;this.active=1;this.out=null}MapFlattenConcOperator.prototype._start=function(out){this.out=out;this.mapOp.ins._add(this)};MapFlattenConcOperator.prototype._stop=function(){this.mapOp.ins._remove(this);this.active=1;this.out=null};MapFlattenConcOperator.prototype.less=function(){if(--this.active===0){this.out._c()}};MapFlattenConcOperator.prototype._n=function(v){this.active++;try{this.mapOp.project(v)._add(new MFCInner(this.out,this))}catch(e){this.out._e(e)}};MapFlattenConcOperator.prototype._e=function(err){this.out._e(err)};MapFlattenConcOperator.prototype._c=function(){this.less()};return MapFlattenConcOperator}();exports.MapFlattenConcOperator=MapFlattenConcOperator;var MFInner=function(){function MFInner(out,op){this.out=out;this.op=op}MFInner.prototype._n=function(t){this.out._n(t)};MFInner.prototype._e=function(err){this.out._e(err)};MFInner.prototype._c=function(){this.op.curr=null;this.op.less()};return MFInner}();var MapFlattenOperator=function(){function MapFlattenOperator(mapOp){this.mapOp=mapOp;this.curr=null;this.inner=null;this.open=true;this.out=null}MapFlattenOperator.prototype._start=function(out){this.out=out;this.mapOp.ins._add(this)};MapFlattenOperator.prototype._stop=function(){this.mapOp.ins._remove(this);this.curr=null;this.inner=null;this.open=true;this.out=null};MapFlattenOperator.prototype.cut=function(){var _a=this,curr=_a.curr,inner=_a.inner;if(curr&&inner){curr._remove(inner)}};MapFlattenOperator.prototype.less=function(){if(!this.open&&!this.curr){this.out._c()}};MapFlattenOperator.prototype._n=function(v){this.cut();try{(this.curr=this.mapOp.project(v))._add(this.inner=new MFInner(this.out,this))}catch(e){this.out._e(e)}};MapFlattenOperator.prototype._e=function(err){this.out._e(err)};MapFlattenOperator.prototype._c=function(){this.open=false;this.less()};return MapFlattenOperator}();exports.MapFlattenOperator=MapFlattenOperator;var MapOperator=function(){function MapOperator(project,ins){this.project=project;this.ins=ins;this.out=null}MapOperator.prototype._start=function(out){this.out=out;this.ins._add(this)};MapOperator.prototype._stop=function(){this.ins._remove(this);this.out=null};MapOperator.prototype._n=function(t){try{this.out._n(this.project(t))}catch(e){this.out._e(e)}};MapOperator.prototype._e=function(err){this.out._e(err)};MapOperator.prototype._c=function(){this.out._c()};return MapOperator}();exports.MapOperator=MapOperator;var FilterMapOperator=function(_super){__extends(FilterMapOperator,_super);function FilterMapOperator(passes,project,ins){_super.call(this,project,ins);this.passes=passes}FilterMapOperator.prototype._n=function(v){if(this.passes(v)){_super.prototype._n.call(this,v)}};return FilterMapOperator}(MapOperator);exports.FilterMapOperator=FilterMapOperator;var MapToOperator=function(){function MapToOperator(val,ins){this.val=val;this.ins=ins;this.out=null}MapToOperator.prototype._start=function(out){this.out=out;this.ins._add(this)};MapToOperator.prototype._stop=function(){this.ins._remove(this);this.out=null};MapToOperator.prototype._n=function(t){this.out._n(this.val)};MapToOperator.prototype._e=function(err){this.out._e(err)};MapToOperator.prototype._c=function(){this.out._c()};return MapToOperator}();exports.MapToOperator=MapToOperator;var ReplaceErrorOperator=function(){function ReplaceErrorOperator(fn,ins){this.fn=fn;this.ins=ins;this.out=empty}ReplaceErrorOperator.prototype._start=function(out){this.out=out;this.ins._add(this)};ReplaceErrorOperator.prototype._stop=function(){this.ins._remove(this);this.out=null};ReplaceErrorOperator.prototype._n=function(t){this.out._n(t)};ReplaceErrorOperator.prototype._e=function(err){try{this.ins._remove(this);(this.ins=this.fn(err))._add(this)}catch(e){this.out._e(e)}};ReplaceErrorOperator.prototype._c=function(){this.out._c()};return ReplaceErrorOperator}();exports.ReplaceErrorOperator=ReplaceErrorOperator;var StartWithOperator=function(){function StartWithOperator(ins,value){this.ins=ins;this.value=value;this.out=emptyListener}StartWithOperator.prototype._start=function(out){this.out=out;this.out._n(this.value);this.ins._add(out)};StartWithOperator.prototype._stop=function(){this.ins._remove(this.out);this.out=null};return StartWithOperator}();exports.StartWithOperator=StartWithOperator;var TakeOperator=function(){function TakeOperator(max,ins){this.max=max;this.ins=ins;this.out=null;this.taken=0}TakeOperator.prototype._start=function(out){this.out=out;this.ins._add(this)};TakeOperator.prototype._stop=function(){this.ins._remove(this);this.out=null;this.taken=0};TakeOperator.prototype._n=function(t){var out=this.out;if(!out)return;if(this.taken++<this.max-1){out._n(t)}else{out._n(t);out._c();this._stop()}};TakeOperator.prototype._e=function(err){var out=this.out;if(!out)return;out._e(err)};TakeOperator.prototype._c=function(){var out=this.out;if(!out)return;out._c()};return TakeOperator}();exports.TakeOperator=TakeOperator;var Stream=function(){function Stream(producer){this._stopID=empty;this.combine=function combine(project){var streams=[];for(var _i=1;_i<arguments.length;_i++){streams[_i-1]=arguments[_i]}streams.unshift(this);return Stream.combine.apply(Stream,[project].concat(streams))};this._prod=producer;this._ils=[]}Stream.prototype._n=function(t){var a=this._ils;var L=a.length;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){var a=this._ils;var L=a.length;if(L==1)a[0]._e(err);else{var b=copy(a);for(var i=0;i<L;i++)b[i]._e(err)}this._x()};Stream.prototype._c=function(){var a=this._ils;var L=a.length;if(L==1)a[0]._c();else{var b=copy(a);for(var i=0;i<L;i++)b[i]._c()}this._x()};Stream.prototype._x=function(){if(this._ils.length===0)return;if(this._prod)this._prod._stop();this._ils=[]};Stream.prototype.addListener=function(listener){if(typeof listener.next!=="function"||typeof listener.error!=="function"||typeof listener.complete!=="function"){throw new Error("stream.addListener() requires all three next, error, "+"and complete functions.")}listener._n=listener.next;listener._e=listener.error;listener._c=listener.complete;this._add(listener)};Stream.prototype.removeListener=function(listener){this._remove(listener)};Stream.prototype._add=function(il){var a=this._ils;a.push(il);if(a.length===1){if(this._stopID!==empty){clearTimeout(this._stopID);this._stopID=empty}var p=this._prod;if(p)p._start(this)}};Stream.prototype._remove=function(il){var a=this._ils;var i=a.indexOf(il);if(i>-1){a.splice(i,1);var p_1=this._prod;if(p_1&&a.length<=0){this._stopID=setTimeout(function(){return p_1._stop()})}}};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.of=function(){var items=[];for(var _i=0;_i<arguments.length;_i++){items[_i-0]=arguments[_i]}return Stream.fromArray(items)};Stream.fromArray=function(array){return new Stream(new FromArrayProducer(array))};Stream.fromPromise=function(promise){return new Stream(new FromPromiseProducer(promise))};Stream.periodic=function(period){return new Stream(new PeriodicProducer(period))};Stream.merge=function(){var streams=[];for(var _i=0;_i<arguments.length;_i++){streams[_i-0]=arguments[_i]}return new Stream(new MergeProducer(streams))};Stream.prototype.map=function(project){var p=this._prod;if(p instanceof FilterOperator){return new Stream(new FilterMapOperator(p.passes,project,p.ins))}if(p instanceof FilterMapOperator){return new Stream(new FilterMapOperator(p.passes,compose2(project,p.project),p.ins))}if(p instanceof MapOperator){return new Stream(new MapOperator(compose2(project,p.project),p.ins))}return new Stream(new MapOperator(project,this))};Stream.prototype.mapTo=function(projectedValue){return new Stream(new MapToOperator(projectedValue,this))};Stream.prototype.filter=function(passes){var p=this._prod;if(p instanceof FilterOperator){return new Stream(new FilterOperator(and(passes,p.passes),p.ins))}return new Stream(new FilterOperator(passes,this))};Stream.prototype.take=function(amount){return new Stream(new TakeOperator(amount,this))};Stream.prototype.drop=function(amount){return new Stream(new DropOperator(amount,this))};Stream.prototype.last=function(){return new Stream(new LastOperator(this))};Stream.prototype.startWith=function(initial){return new Stream(new StartWithOperator(this,initial))};Stream.prototype.endWhen=function(other){return new Stream(new EndWhenOperator(other,this))};Stream.prototype.fold=function(accumulate,seed){return new Stream(new FoldOperator(accumulate,seed,this))};Stream.prototype.replaceError=function(replace){return new Stream(new ReplaceErrorOperator(replace,this))};Stream.prototype.flatten=function(){var p=this._prod;return new Stream(p instanceof MapOperator||p instanceof FilterMapOperator?new MapFlattenOperator(p):new FlattenOperator(this))};Stream.prototype.flattenConcurrently=function(){var p=this._prod;return new Stream(p instanceof MapOperator||p instanceof FilterMapOperator?new MapFlattenConcOperator(p):new FlattenConcOperator(this))};Stream.prototype.merge=function(other){return Stream.merge(this,other)};Stream.prototype.compose=function(operator){return operator(this)};Stream.prototype.remember=function(){var _this=this;return new MemoryStream({_start:function(il){_this._prod._start(il)},_stop:function(){_this._prod._stop()}})};Stream.prototype.imitate=function(other){other._add(this)};Stream.prototype.debug=function(spy){if(spy===void 0){spy=null}return new Stream(new DebugOperator(spy,this))};Stream.prototype.shamefullySendNext=function(value){this._n(value)};Stream.prototype.shamefullySendError=function(error){this._e(error)};Stream.prototype.shamefullySendComplete=function(){this._c()};Stream.combine=function combine(project){var streams=[];for(var _i=1;_i<arguments.length;_i++){streams[_i-1]=arguments[_i]}return new Stream(new CombineProducer(project,streams))};return Stream}();exports.Stream=Stream;var MemoryStream=function(_super){__extends(MemoryStream,_super);function MemoryStream(producer){_super.call(this,producer);this._has=false}MemoryStream.prototype._n=function(x){this._val=x;this._has=true;_super.prototype._n.call(this,x)};MemoryStream.prototype._add=function(listener){if(this._has){listener._n(this._val)}_super.prototype._add.call(this,listener)};return MemoryStream}(Stream);exports.MemoryStream=MemoryStream;Object.defineProperty(exports,"__esModule",{value:true});exports.default=Stream},{}],2:[function(require,module,exports){"use strict";var core_1=require("./core");exports.Stream=core_1.Stream;exports.MemoryStream=core_1.MemoryStream;Object.defineProperty(exports,"__esModule",{value:true});exports.default=core_1.Stream},{"./core":1}]},{},[2])(2)}); | ||
(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 empty={};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}var emptyListener={_n:noop,_e:noop,_c:noop};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}function invoke(f,args){switch(args.length){case 0:return f();case 1:return f(args[0]);case 2:return f(args[0],args[1]);case 3:return f(args[0],args[1],args[2]);case 4:return f(args[0],args[1],args[2],args[3]);case 5:return f(args[0],args[1],args[2],args[3],args[4]);default:return f.apply(void 0,args)}}function compose2(f1,f2){return function composedFn(arg){return f1(f2(arg))}}function and(f1,f2){return function andFn(t){return f1(t)&&f2(t)}}var CombineListener=function(){function CombineListener(i,prod){this.i=i;this.prod=prod;prod.proxies.push(this)}CombineListener.prototype._n=function(t){var prod=this.prod;var vals=prod.vals;prod.hasVal[this.i]=true;vals[this.i]=t;if(!prod.ready){prod.up()}if(prod.ready){try{prod.out._n(invoke(prod.project,vals))}catch(e){prod.out._e(e)}}};CombineListener.prototype._e=function(err){this.prod.out._e(err)};CombineListener.prototype._c=function(){var prod=this.prod;if(--prod.ac===0){prod.out._c()}};return CombineListener}();var CombineProducer=function(){function CombineProducer(project,streams){this.project=project;this.streams=streams;this.out=emptyListener;this.proxies=[];this.ready=false;this.vals=new Array(streams.length);this.hasVal=new Array(streams.length);this.ac=streams.length}CombineProducer.prototype.up=function(){for(var i=this.hasVal.length-1;i>=0;i--){if(!this.hasVal[i]){return}}this.ready=true};CombineProducer.prototype._start=function(out){this.out=out;var streams=this.streams;for(var i=streams.length-1;i>=0;i--){streams[i]._add(new CombineListener(i,this))}};CombineProducer.prototype._stop=function(){var streams=this.streams;for(var i=streams.length-1;i>=0;i--){streams[i]._remove(this.proxies[i])}this.out=null;this.ac=streams.length;this.proxies=[];this.ready=false;this.vals=new Array(streams.length);this.hasVal=new Array(streams.length)};return CombineProducer}();var FromArrayProducer=function(){function FromArrayProducer(a){this.a=a}FromArrayProducer.prototype._start=function(out){var a=this.a;for(var i=0,l=a.length;i<l;i++){out._n(a[i])}out._c()};FromArrayProducer.prototype._stop=function(){};return FromArrayProducer}();exports.FromArrayProducer=FromArrayProducer;var FromPromiseProducer=function(){function FromPromiseProducer(p){this.p=p;this.on=false}FromPromiseProducer.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(null,function(err){setTimeout(function(){throw err})})};FromPromiseProducer.prototype._stop=function(){this.on=false};return FromPromiseProducer}();exports.FromPromiseProducer=FromPromiseProducer;var MergeProducer=function(){function MergeProducer(streams){this.streams=streams;this.out=emptyListener;this.ac=streams.length}MergeProducer.prototype._start=function(out){this.out=out;var streams=this.streams;for(var i=streams.length-1;i>=0;i--){streams[i]._add(this)}};MergeProducer.prototype._stop=function(){var streams=this.streams;for(var i=streams.length-1;i>=0;i--){streams[i]._remove(this)}this.out=null;this.ac=streams.length};MergeProducer.prototype._n=function(t){this.out._n(t)};MergeProducer.prototype._e=function(err){this.out._e(err)};MergeProducer.prototype._c=function(){if(--this.ac===0){this.out._c()}};return MergeProducer}();exports.MergeProducer=MergeProducer;var PeriodicProducer=function(){function PeriodicProducer(period){this.period=period;this.intervalID=-1;this.i=0}PeriodicProducer.prototype._start=function(stream){var self=this;function intervalHandler(){stream._n(self.i++)}this.intervalID=setInterval(intervalHandler,this.period)};PeriodicProducer.prototype._stop=function(){if(this.intervalID!==-1)clearInterval(this.intervalID);this.intervalID=-1;this.i=0};return PeriodicProducer}();exports.PeriodicProducer=PeriodicProducer;var DebugOperator=function(){function DebugOperator(spy,ins){if(spy===void 0){spy=null}this.spy=spy;this.ins=ins;this.out=null}DebugOperator.prototype._start=function(out){this.out=out;this.ins._add(this)};DebugOperator.prototype._stop=function(){this.ins._remove(this);this.out=null};DebugOperator.prototype._n=function(t){if(this.spy){try{this.spy(t)}catch(e){this.out._e(e)}}else{console.log(t)}this.out._n(t)};DebugOperator.prototype._e=function(err){this.out._e(err)};DebugOperator.prototype._c=function(){this.out._c()};return DebugOperator}();exports.DebugOperator=DebugOperator;var DropOperator=function(){function DropOperator(max,ins){this.max=max;this.ins=ins;this.out=null;this.dropped=0}DropOperator.prototype._start=function(out){this.out=out;this.ins._add(this)};DropOperator.prototype._stop=function(){this.ins._remove(this);this.out=null;this.dropped=0};DropOperator.prototype._n=function(t){if(this.dropped++>=this.max)this.out._n(t)};DropOperator.prototype._e=function(err){this.out._e(err)};DropOperator.prototype._c=function(){this.out._c()};return DropOperator}();exports.DropOperator=DropOperator;var OtherListener=function(){function OtherListener(out,op){this.out=out;this.op=op}OtherListener.prototype._n=function(t){this.op.end()};OtherListener.prototype._e=function(err){this.out._e(err)};OtherListener.prototype._c=function(){this.op.end()};return OtherListener}();var EndWhenOperator=function(){function EndWhenOperator(o,ins){this.o=o;this.ins=ins;this.out=null;this.oli=emptyListener}EndWhenOperator.prototype._start=function(out){this.out=out;this.o._add(this.oli=new OtherListener(out,this));this.ins._add(this)};EndWhenOperator.prototype._stop=function(){this.ins._remove(this);this.o._remove(this.oli);this.out=null;this.oli=null};EndWhenOperator.prototype.end=function(){this.out._c()};EndWhenOperator.prototype._n=function(t){this.out._n(t)};EndWhenOperator.prototype._e=function(err){this.out._e(err)};EndWhenOperator.prototype._c=function(){this.end()};return EndWhenOperator}();exports.EndWhenOperator=EndWhenOperator;var FilterOperator=function(){function FilterOperator(passes,ins){this.passes=passes;this.ins=ins;this.out=null}FilterOperator.prototype._start=function(out){this.out=out;this.ins._add(this)};FilterOperator.prototype._stop=function(){this.ins._remove(this);this.out=null};FilterOperator.prototype._n=function(t){try{if(this.passes(t))this.out._n(t)}catch(e){this.out._e(e)}};FilterOperator.prototype._e=function(err){this.out._e(err)};FilterOperator.prototype._c=function(){this.out._c()};return FilterOperator}();exports.FilterOperator=FilterOperator;var FCInner=function(){function FCInner(out,op){this.out=out;this.op=op}FCInner.prototype._n=function(t){this.out._n(t)};FCInner.prototype._e=function(err){this.out._e(err)};FCInner.prototype._c=function(){this.op.less()};return FCInner}();var FlattenConcOperator=function(){function FlattenConcOperator(ins){this.ins=ins;this.active=1;this.out=null}FlattenConcOperator.prototype._start=function(out){this.out=out;this.ins._add(this)};FlattenConcOperator.prototype._stop=function(){this.ins._remove(this);this.active=1;this.out=null};FlattenConcOperator.prototype.less=function(){if(--this.active===0){this.out._c()}};FlattenConcOperator.prototype._n=function(s){this.active++;s._add(new FCInner(this.out,this))};FlattenConcOperator.prototype._e=function(err){this.out._e(err)};FlattenConcOperator.prototype._c=function(){this.less()};return FlattenConcOperator}();exports.FlattenConcOperator=FlattenConcOperator;var FInner=function(){function FInner(out,op){this.out=out;this.op=op}FInner.prototype._n=function(t){this.out._n(t)};FInner.prototype._e=function(err){this.out._e(err)};FInner.prototype._c=function(){this.op.curr=null;this.op.less()};return FInner}();var FlattenOperator=function(){function FlattenOperator(ins){this.ins=ins;this.curr=null;this.inner=null;this.open=true;this.out=null}FlattenOperator.prototype._start=function(out){this.out=out;this.ins._add(this)};FlattenOperator.prototype._stop=function(){this.ins._remove(this);this.curr=null;this.inner=null;this.open=true;this.out=null};FlattenOperator.prototype.cut=function(){var _a=this,curr=_a.curr,inner=_a.inner;if(curr&&inner){curr._remove(inner)}};FlattenOperator.prototype.less=function(){if(!this.open&&!this.curr){this.out._c()}};FlattenOperator.prototype._n=function(s){this.cut();(this.curr=s)._add(this.inner=new FInner(this.out,this))};FlattenOperator.prototype._e=function(err){this.out._e(err)};FlattenOperator.prototype._c=function(){this.open=false;this.less()};return FlattenOperator}();exports.FlattenOperator=FlattenOperator;var FoldOperator=function(){function FoldOperator(f,seed,ins){this.f=f;this.seed=seed;this.ins=ins;this.out=null;this.acc=seed}FoldOperator.prototype._start=function(out){this.out=out;out._n(this.acc);this.ins._add(this)};FoldOperator.prototype._stop=function(){this.ins._remove(this);this.out=null;this.acc=this.seed};FoldOperator.prototype._n=function(t){try{this.out._n(this.acc=this.f(this.acc,t))}catch(e){this.out._e(e)}};FoldOperator.prototype._e=function(err){this.out._e(err)};FoldOperator.prototype._c=function(){this.out._c()};return FoldOperator}();exports.FoldOperator=FoldOperator;var LastOperator=function(){function LastOperator(ins){this.ins=ins;this.out=null;this.has=false;this.val=empty}LastOperator.prototype._start=function(out){this.out=out;this.ins._add(this)};LastOperator.prototype._stop=function(){this.ins._remove(this);this.out=null;this.has=false;this.val=empty};LastOperator.prototype._n=function(t){this.has=true;this.val=t};LastOperator.prototype._e=function(err){this.out._e(err)};LastOperator.prototype._c=function(){var out=this.out;if(this.has){out._n(this.val);out._c()}else{out._e("TODO show proper error")}};return LastOperator}();exports.LastOperator=LastOperator;var MFCInner=function(){function MFCInner(out,op){this.out=out;this.op=op}MFCInner.prototype._n=function(t){this.out._n(t)};MFCInner.prototype._e=function(err){this.out._e(err)};MFCInner.prototype._c=function(){this.op.less()};return MFCInner}();var MapFlattenConcOperator=function(){function MapFlattenConcOperator(mapOp){this.mapOp=mapOp;this.active=1;this.out=null}MapFlattenConcOperator.prototype._start=function(out){this.out=out;this.mapOp.ins._add(this)};MapFlattenConcOperator.prototype._stop=function(){this.mapOp.ins._remove(this);this.active=1;this.out=null};MapFlattenConcOperator.prototype.less=function(){if(--this.active===0){this.out._c()}};MapFlattenConcOperator.prototype._n=function(v){this.active++;try{this.mapOp.project(v)._add(new MFCInner(this.out,this))}catch(e){this.out._e(e)}};MapFlattenConcOperator.prototype._e=function(err){this.out._e(err)};MapFlattenConcOperator.prototype._c=function(){this.less()};return MapFlattenConcOperator}();exports.MapFlattenConcOperator=MapFlattenConcOperator;var MFInner=function(){function MFInner(out,op){this.out=out;this.op=op}MFInner.prototype._n=function(t){this.out._n(t)};MFInner.prototype._e=function(err){this.out._e(err)};MFInner.prototype._c=function(){this.op.curr=null;this.op.less()};return MFInner}();var MapFlattenOperator=function(){function MapFlattenOperator(mapOp){this.mapOp=mapOp;this.curr=null;this.inner=null;this.open=true;this.out=null}MapFlattenOperator.prototype._start=function(out){this.out=out;this.mapOp.ins._add(this)};MapFlattenOperator.prototype._stop=function(){this.mapOp.ins._remove(this);this.curr=null;this.inner=null;this.open=true;this.out=null};MapFlattenOperator.prototype.cut=function(){var _a=this,curr=_a.curr,inner=_a.inner;if(curr&&inner){curr._remove(inner)}};MapFlattenOperator.prototype.less=function(){if(!this.open&&!this.curr){this.out._c()}};MapFlattenOperator.prototype._n=function(v){this.cut();try{(this.curr=this.mapOp.project(v))._add(this.inner=new MFInner(this.out,this))}catch(e){this.out._e(e)}};MapFlattenOperator.prototype._e=function(err){this.out._e(err)};MapFlattenOperator.prototype._c=function(){this.open=false;this.less()};return MapFlattenOperator}();exports.MapFlattenOperator=MapFlattenOperator;var MapOperator=function(){function MapOperator(project,ins){this.project=project;this.ins=ins;this.out=null}MapOperator.prototype._start=function(out){this.out=out;this.ins._add(this)};MapOperator.prototype._stop=function(){this.ins._remove(this);this.out=null};MapOperator.prototype._n=function(t){try{this.out._n(this.project(t))}catch(e){this.out._e(e)}};MapOperator.prototype._e=function(err){this.out._e(err)};MapOperator.prototype._c=function(){this.out._c()};return MapOperator}();exports.MapOperator=MapOperator;var FilterMapOperator=function(_super){__extends(FilterMapOperator,_super);function FilterMapOperator(passes,project,ins){_super.call(this,project,ins);this.passes=passes}FilterMapOperator.prototype._n=function(v){if(this.passes(v)){_super.prototype._n.call(this,v)}};return FilterMapOperator}(MapOperator);exports.FilterMapOperator=FilterMapOperator;var MapToOperator=function(){function MapToOperator(val,ins){this.val=val;this.ins=ins;this.out=null}MapToOperator.prototype._start=function(out){this.out=out;this.ins._add(this)};MapToOperator.prototype._stop=function(){this.ins._remove(this);this.out=null};MapToOperator.prototype._n=function(t){this.out._n(this.val)};MapToOperator.prototype._e=function(err){this.out._e(err)};MapToOperator.prototype._c=function(){this.out._c()};return MapToOperator}();exports.MapToOperator=MapToOperator;var ReplaceErrorOperator=function(){function ReplaceErrorOperator(fn,ins){this.fn=fn;this.ins=ins;this.out=empty}ReplaceErrorOperator.prototype._start=function(out){this.out=out;this.ins._add(this)};ReplaceErrorOperator.prototype._stop=function(){this.ins._remove(this);this.out=null};ReplaceErrorOperator.prototype._n=function(t){this.out._n(t)};ReplaceErrorOperator.prototype._e=function(err){try{this.ins._remove(this);(this.ins=this.fn(err))._add(this)}catch(e){this.out._e(e)}};ReplaceErrorOperator.prototype._c=function(){this.out._c()};return ReplaceErrorOperator}();exports.ReplaceErrorOperator=ReplaceErrorOperator;var StartWithOperator=function(){function StartWithOperator(ins,value){this.ins=ins;this.value=value;this.out=emptyListener}StartWithOperator.prototype._start=function(out){this.out=out;this.out._n(this.value);this.ins._add(out)};StartWithOperator.prototype._stop=function(){this.ins._remove(this.out);this.out=null};return StartWithOperator}();exports.StartWithOperator=StartWithOperator;var TakeOperator=function(){function TakeOperator(max,ins){this.max=max;this.ins=ins;this.out=null;this.taken=0}TakeOperator.prototype._start=function(out){this.out=out;this.ins._add(this)};TakeOperator.prototype._stop=function(){this.ins._remove(this);this.out=null;this.taken=0};TakeOperator.prototype._n=function(t){var out=this.out;if(!out)return;if(this.taken++<this.max-1){out._n(t)}else{out._n(t);out._c();this._stop()}};TakeOperator.prototype._e=function(err){var out=this.out;if(!out)return;out._e(err)};TakeOperator.prototype._c=function(){var out=this.out;if(!out)return;out._c()};return TakeOperator}();exports.TakeOperator=TakeOperator;var Stream=function(){function Stream(producer){this._stopID=empty;this.combine=function combine(project){var streams=[];for(var _i=1;_i<arguments.length;_i++){streams[_i-1]=arguments[_i]}streams.unshift(this);return Stream.combine.apply(Stream,[project].concat(streams))};this._prod=producer;this._ils=[]}Stream.prototype._n=function(t){var a=this._ils;var L=a.length;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){var a=this._ils;var L=a.length;if(L==1)a[0]._e(err);else{var b=copy(a);for(var i=0;i<L;i++)b[i]._e(err)}this._x()};Stream.prototype._c=function(){var a=this._ils;var L=a.length;if(L==1)a[0]._c();else{var b=copy(a);for(var i=0;i<L;i++)b[i]._c()}this._x()};Stream.prototype._x=function(){if(this._ils.length===0)return;if(this._prod)this._prod._stop();this._ils=[]};Stream.prototype.addListener=function(listener){if(typeof listener.next!=="function"||typeof listener.error!=="function"||typeof listener.complete!=="function"){throw new Error("stream.addListener() requires all three next, error, "+"and complete functions.")}listener._n=listener.next;listener._e=listener.error;listener._c=listener.complete;this._add(listener)};Stream.prototype.removeListener=function(listener){this._remove(listener)};Stream.prototype._add=function(il){var a=this._ils;a.push(il);if(a.length===1){if(this._stopID!==empty){clearTimeout(this._stopID);this._stopID=empty}var p=this._prod;if(p)p._start(this)}};Stream.prototype._remove=function(il){var a=this._ils;var i=a.indexOf(il);if(i>-1){a.splice(i,1);var p_1=this._prod;if(p_1&&a.length<=0){this._stopID=setTimeout(function(){return p_1._stop()})}}};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.of=function(){var items=[];for(var _i=0;_i<arguments.length;_i++){items[_i-0]=arguments[_i]}return Stream.fromArray(items)};Stream.fromArray=function(array){return new Stream(new FromArrayProducer(array))};Stream.fromPromise=function(promise){return new Stream(new FromPromiseProducer(promise))};Stream.periodic=function(period){return new Stream(new PeriodicProducer(period))};Stream.merge=function(){var streams=[];for(var _i=0;_i<arguments.length;_i++){streams[_i-0]=arguments[_i]}return new Stream(new MergeProducer(streams))};Stream.prototype.map=function(project){var p=this._prod;if(p instanceof FilterOperator){return new Stream(new FilterMapOperator(p.passes,project,p.ins))}if(p instanceof FilterMapOperator){return new Stream(new FilterMapOperator(p.passes,compose2(project,p.project),p.ins))}if(p instanceof MapOperator){return new Stream(new MapOperator(compose2(project,p.project),p.ins))}return new Stream(new MapOperator(project,this))};Stream.prototype.mapTo=function(projectedValue){return new Stream(new MapToOperator(projectedValue,this))};Stream.prototype.filter=function(passes){var p=this._prod;if(p instanceof FilterOperator){return new Stream(new FilterOperator(and(passes,p.passes),p.ins))}return new Stream(new FilterOperator(passes,this))};Stream.prototype.take=function(amount){return new Stream(new TakeOperator(amount,this))};Stream.prototype.drop=function(amount){return new Stream(new DropOperator(amount,this))};Stream.prototype.last=function(){return new Stream(new LastOperator(this))};Stream.prototype.startWith=function(initial){return new Stream(new StartWithOperator(this,initial))};Stream.prototype.endWhen=function(other){return new Stream(new EndWhenOperator(other,this))};Stream.prototype.fold=function(accumulate,seed){return new Stream(new FoldOperator(accumulate,seed,this))};Stream.prototype.replaceError=function(replace){return new Stream(new ReplaceErrorOperator(replace,this))};Stream.prototype.flatten=function(){var p=this._prod;return new Stream(p instanceof MapOperator||p instanceof FilterMapOperator?new MapFlattenOperator(p):new FlattenOperator(this))};Stream.prototype.flattenConcurrently=function(){var p=this._prod;return new Stream(p instanceof MapOperator||p instanceof FilterMapOperator?new MapFlattenConcOperator(p):new FlattenConcOperator(this))};Stream.prototype.merge=function(other){return Stream.merge(this,other)};Stream.prototype.compose=function(operator){return operator(this)};Stream.prototype.remember=function(){var _this=this;return new MemoryStream({_start:function(il){_this._prod._start(il)},_stop:function(){_this._prod._stop()}})};Stream.prototype.imitate=function(other){other._add(this)};Stream.prototype.debug=function(spy){if(spy===void 0){spy=null}return new Stream(new DebugOperator(spy,this))};Stream.prototype.shamefullySendNext=function(value){this._n(value)};Stream.prototype.shamefullySendError=function(error){this._e(error)};Stream.prototype.shamefullySendComplete=function(){this._c()};Stream.combine=function combine(project){var streams=[];for(var _i=1;_i<arguments.length;_i++){streams[_i-1]=arguments[_i]}return new Stream(new CombineProducer(project,streams))};return Stream}();exports.Stream=Stream;var MemoryStream=function(_super){__extends(MemoryStream,_super);function MemoryStream(producer){_super.call(this,producer);this._has=false}MemoryStream.prototype._n=function(x){this._v=x;this._has=true;_super.prototype._n.call(this,x)};MemoryStream.prototype._add=function(il){if(this._has){il._n(this._v)}_super.prototype._add.call(this,il)};return MemoryStream}(Stream);exports.MemoryStream=MemoryStream;Object.defineProperty(exports,"__esModule",{value:true});exports.default=Stream},{}],2:[function(require,module,exports){"use strict";var core_1=require("./core");exports.Stream=core_1.Stream;exports.MemoryStream=core_1.MemoryStream;Object.defineProperty(exports,"__esModule",{value:true});exports.default=core_1.Stream},{"./core":1}]},{},[2])(2)}); |
{ | ||
"name": "xstream", | ||
"version": "2.1.2", | ||
"version": "2.1.3", | ||
"description": "An extremely intuitive, small, and fast functional reactive stream library for JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -900,3 +900,3 @@ <!-- This README.md is automatically generated from source code and files in the /markdown directory. Please DO NOT send pull requests to directly modify this README. Instead, edit the JSDoc comments in source code or the md files in /markdown/. --> | ||
*(Stream)* | ||
*(MemoryStream)* | ||
@@ -1002,2 +1002,12 @@ - - - | ||
# CHANGELOG | ||
<a name="2.1.3"></a> | ||
## [2.1.3](https://github.com/staltz/xstream/compare/v2.1.2...v2.1.3) (2016-04-30) | ||
### Bug Fixes | ||
* **remember:** return MemoryStream, not Stream ([4f50922](https://github.com/staltz/xstream/commit/4f50922)) | ||
<a name="2.1.2"></a> | ||
@@ -1004,0 +1014,0 @@ ## [2.1.2](https://github.com/staltz/xstream/compare/v2.1.1...v2.1.2) (2016-04-30) |
@@ -1739,5 +1739,5 @@ import {Promise} from 'es6-promise'; | ||
* | ||
* @return {Stream} | ||
* @return {MemoryStream} | ||
*/ | ||
remember(): Stream<T> { | ||
remember(): MemoryStream<T> { | ||
return new MemoryStream<T>({ | ||
@@ -1833,3 +1833,3 @@ _start: (il: InternalListener<T>) => { this._prod._start(il); }, | ||
export class MemoryStream<T> extends Stream<T> { | ||
private _val: any; | ||
private _v: T; | ||
private _has: boolean = false; | ||
@@ -1841,3 +1841,3 @@ constructor(producer: InternalProducer<T>) { | ||
_n(x: T) { | ||
this._val = x; | ||
this._v = x; | ||
this._has = true; | ||
@@ -1847,5 +1847,5 @@ super._n(x); | ||
_add(listener: InternalListener<T>): void { | ||
if (this._has) { listener._n(this._val); } | ||
super._add(listener); | ||
_add(il: InternalListener<T>): void { | ||
if (this._has) { il._n(this._v); } | ||
super._add(il); | ||
} | ||
@@ -1852,0 +1852,0 @@ } |
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
752205
1217