From 5829bf94255e98f480e7d1f51d1ae23f1ccf0376 Mon Sep 17 00:00:00 2001 From: Andre Staltz Date: Wed, 20 Jul 2016 11:37:02 +0300 Subject: [PATCH] chore(package): release new version --- CHANGELOG.md | 10 ++++++++++ dist/xstream.js | 16 ++++++++-------- dist/xstream.min.js | 2 +- package.json | 2 +- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00f78d7..0febeb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ + +## [5.2.3](https://github.com/staltz/xstream/compare/v5.2.2...v5.2.3) (2016-07-20) + + +### Bug Fixes + +* **merge:** support union types ([5327cb0](https://github.com/staltz/xstream/commit/5327cb0)), closes [staltz/xstream#80](https://github.com/staltz/xstream/issues/80) + + + ## [5.2.2](https://github.com/staltz/xstream/compare/v5.2.1...v5.2.2) (2016-07-19) diff --git a/dist/xstream.js b/dist/xstream.js index 9b7c741..122a13c 100644 --- a/dist/xstream.js +++ b/dist/xstream.js @@ -1047,14 +1047,6 @@ var Stream = (function () { 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; var ctor = this.ctor(); @@ -1161,6 +1153,14 @@ var Stream = (function () { this._c(); }; + Stream.merge = function merge() { + var streams = []; + for (var _i = 0; _i < arguments.length; _i++) { + streams[_i - 0] = arguments[_i]; + } + return new Stream(new MergeProducer(streams)); + }; + Stream.combine = function combine() { var streams = []; for (var _i = 0; _i < arguments.length; _i++) { diff --git a/dist/xstream.min.js b/dist/xstream.min.js index 317e133..da75b98 100644 --- a/dist/xstream.min.js +++ b/dist/xstream.min.js @@ -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=this.max)u._n(t)};DropOperator.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};DropOperator.prototype._c=function(){var u=this.out;if(u===NO)return;u._c()};return DropOperator}();exports.DropOperator=DropOperator;var OtherIL=function(){function OtherIL(out,op){this.out=out;this.op=op}OtherIL.prototype._n=function(t){this.op.end()};OtherIL.prototype._e=function(err){this.out._e(err)};OtherIL.prototype._c=function(){this.op.end()};return OtherIL}();var EndWhenOperator=function(){function EndWhenOperator(o,ins){this.type="endWhen";this.ins=ins;this.out=NO;this.o=o;this.oil=exports.NO_IL}EndWhenOperator.prototype._start=function(out){this.out=out;this.o._add(this.oil=new OtherIL(out,this));this.ins._add(this)};EndWhenOperator.prototype._stop=function(){this.ins._remove(this);this.o._remove(this.oil);this.out=NO;this.oil=exports.NO_IL};EndWhenOperator.prototype.end=function(){var u=this.out;if(u===NO)return;u._c()};EndWhenOperator.prototype._n=function(t){var u=this.out;if(u===NO)return;u._n(t)};EndWhenOperator.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};EndWhenOperator.prototype._c=function(){this.end()};return EndWhenOperator}();exports.EndWhenOperator=EndWhenOperator;var FilterOperator=function(){function FilterOperator(passes,ins){this.type="filter";this.ins=ins;this.out=NO;this.passes=passes}FilterOperator.prototype._start=function(out){this.out=out;this.ins._add(this)};FilterOperator.prototype._stop=function(){this.ins._remove(this);this.out=NO};FilterOperator.prototype._n=function(t){var u=this.out;if(u===NO)return;try{if(this.passes(t))u._n(t)}catch(e){u._e(e)}};FilterOperator.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};FilterOperator.prototype._c=function(){var u=this.out;if(u===NO)return;u._c()};return FilterOperator}();exports.FilterOperator=FilterOperator;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 FlattenOperator=function(){function FlattenOperator(ins){this.type="flatten";this.ins=ins;this.out=NO;this.open=true;this.inner=NO;this.il=exports.NO_IL}FlattenOperator.prototype._start=function(out){this.out=out;this.open=true;this.inner=NO;this.il=exports.NO_IL;this.ins._add(this)};FlattenOperator.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=exports.NO_IL};FlattenOperator.prototype.less=function(){var u=this.out;if(u===NO)return;if(!this.open&&this.inner===NO)u._c()};FlattenOperator.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!==exports.NO_IL)inner._remove(il);(this.inner=s)._add(this.il=new FlattenListener(u,this))};FlattenOperator.prototype._e=function(err){var u=this.out;if(u===NO)return;u._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.type="fold";this.ins=ins;this.out=NO;this.f=f;this.acc=this.seed=seed}FoldOperator.prototype._start=function(out){this.out=out;this.acc=this.seed;out._n(this.acc);this.ins._add(this)};FoldOperator.prototype._stop=function(){this.ins._remove(this);this.out=NO;this.acc=this.seed};FoldOperator.prototype._n=function(t){var u=this.out;if(u===NO)return;try{u._n(this.acc=this.f(this.acc,t))}catch(e){u._e(e)}};FoldOperator.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};FoldOperator.prototype._c=function(){var u=this.out;if(u===NO)return;u._c()};return FoldOperator}();exports.FoldOperator=FoldOperator;var LastOperator=function(){function LastOperator(ins){this.type="last";this.ins=ins;this.out=NO;this.has=false;this.val=NO}LastOperator.prototype._start=function(out){this.out=out;this.has=false;this.ins._add(this)};LastOperator.prototype._stop=function(){this.ins._remove(this);this.out=NO;this.val=NO};LastOperator.prototype._n=function(t){this.has=true;this.val=t};LastOperator.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};LastOperator.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 LastOperator}();exports.LastOperator=LastOperator;var MapFlattenInner=function(){function MapFlattenInner(out,op){this.out=out;this.op=op}MapFlattenInner.prototype._n=function(r){this.out._n(r)};MapFlattenInner.prototype._e=function(err){this.out._e(err)};MapFlattenInner.prototype._c=function(){this.op.inner=NO;this.op.less()};return MapFlattenInner}();var MapFlattenOperator=function(){function MapFlattenOperator(mapOp){this.type=mapOp.type+"+flatten";this.ins=mapOp.ins;this.out=NO;this.mapOp=mapOp;this.inner=NO;this.il=exports.NO_IL;this.open=true}MapFlattenOperator.prototype._start=function(out){this.out=out;this.inner=NO;this.il=exports.NO_IL;this.open=true;this.mapOp.ins._add(this)};MapFlattenOperator.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=exports.NO_IL};MapFlattenOperator.prototype.less=function(){if(!this.open&&this.inner===NO){var u=this.out;if(u===NO)return;u._c()}};MapFlattenOperator.prototype._n=function(v){var u=this.out;if(u===NO)return;var _a=this,inner=_a.inner,il=_a.il;if(inner!==NO&&il!==exports.NO_IL)inner._remove(il);try{(this.inner=this.mapOp.project(v))._add(this.il=new MapFlattenInner(u,this))}catch(e){u._e(e)}};MapFlattenOperator.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};MapFlattenOperator.prototype._c=function(){this.open=false;this.less()};return MapFlattenOperator}();exports.MapFlattenOperator=MapFlattenOperator;var MapOperator=function(){function MapOperator(project,ins){this.type="map";this.ins=ins;this.out=NO;this.project=project}MapOperator.prototype._start=function(out){this.out=out;this.ins._add(this)};MapOperator.prototype._stop=function(){this.ins._remove(this);this.out=NO};MapOperator.prototype._n=function(t){var u=this.out;if(u===NO)return;try{u._n(this.project(t))}catch(e){u._e(e)}};MapOperator.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};MapOperator.prototype._c=function(){var u=this.out;if(u===NO)return;u._c()};return MapOperator}();exports.MapOperator=MapOperator;var FilterMapOperator=function(_super){__extends(FilterMapOperator,_super);function FilterMapOperator(passes,project,ins){_super.call(this,project,ins);this.type="filter+map";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 RememberOperator=function(){function RememberOperator(ins){this.type="remember";this.ins=ins;this.out=NO}RememberOperator.prototype._start=function(out){this.out=out;this.ins._add(out)};RememberOperator.prototype._stop=function(){this.ins._remove(this.out);this.out=NO};return RememberOperator}();exports.RememberOperator=RememberOperator;var ReplaceErrorOperator=function(){function ReplaceErrorOperator(fn,ins){this.type="replaceError";this.ins=ins;this.out=NO;this.fn=fn}ReplaceErrorOperator.prototype._start=function(out){this.out=out;this.ins._add(this)};ReplaceErrorOperator.prototype._stop=function(){this.ins._remove(this);this.out=NO};ReplaceErrorOperator.prototype._n=function(t){var u=this.out;if(u===NO)return;u._n(t)};ReplaceErrorOperator.prototype._e=function(err){var u=this.out;if(u===NO)return;try{this.ins._remove(this);(this.ins=this.fn(err))._add(this)}catch(e){u._e(e)}};ReplaceErrorOperator.prototype._c=function(){var u=this.out;if(u===NO)return;u._c()};return ReplaceErrorOperator}();exports.ReplaceErrorOperator=ReplaceErrorOperator;var StartWithOperator=function(){function StartWithOperator(ins,val){this.type="startWith";this.ins=ins;this.out=NO;this.val=val}StartWithOperator.prototype._start=function(out){this.out=out;this.out._n(this.val);this.ins._add(out)};StartWithOperator.prototype._stop=function(){this.ins._remove(this.out);this.out=NO};return StartWithOperator}();exports.StartWithOperator=StartWithOperator;var TakeOperator=function(){function TakeOperator(max,ins){this.type="take";this.ins=ins;this.out=NO;this.max=max;this.taken=0}TakeOperator.prototype._start=function(out){this.out=out;this.taken=0;this.ins._add(this)};TakeOperator.prototype._stop=function(){this.ins._remove(this);this.out=NO};TakeOperator.prototype._n=function(t){var u=this.out;if(u===NO)return;if(this.taken++-1){a.splice(i,1);if(this._prod!==NO&&a.length<=0){this._err=NO;this._stopID=setTimeout(function(){return _this._lateStop()})}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=this.max)u._n(t)};DropOperator.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};DropOperator.prototype._c=function(){var u=this.out;if(u===NO)return;u._c()};return DropOperator}();exports.DropOperator=DropOperator;var OtherIL=function(){function OtherIL(out,op){this.out=out;this.op=op}OtherIL.prototype._n=function(t){this.op.end()};OtherIL.prototype._e=function(err){this.out._e(err)};OtherIL.prototype._c=function(){this.op.end()};return OtherIL}();var EndWhenOperator=function(){function EndWhenOperator(o,ins){this.type="endWhen";this.ins=ins;this.out=NO;this.o=o;this.oil=exports.NO_IL}EndWhenOperator.prototype._start=function(out){this.out=out;this.o._add(this.oil=new OtherIL(out,this));this.ins._add(this)};EndWhenOperator.prototype._stop=function(){this.ins._remove(this);this.o._remove(this.oil);this.out=NO;this.oil=exports.NO_IL};EndWhenOperator.prototype.end=function(){var u=this.out;if(u===NO)return;u._c()};EndWhenOperator.prototype._n=function(t){var u=this.out;if(u===NO)return;u._n(t)};EndWhenOperator.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};EndWhenOperator.prototype._c=function(){this.end()};return EndWhenOperator}();exports.EndWhenOperator=EndWhenOperator;var FilterOperator=function(){function FilterOperator(passes,ins){this.type="filter";this.ins=ins;this.out=NO;this.passes=passes}FilterOperator.prototype._start=function(out){this.out=out;this.ins._add(this)};FilterOperator.prototype._stop=function(){this.ins._remove(this);this.out=NO};FilterOperator.prototype._n=function(t){var u=this.out;if(u===NO)return;try{if(this.passes(t))u._n(t)}catch(e){u._e(e)}};FilterOperator.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};FilterOperator.prototype._c=function(){var u=this.out;if(u===NO)return;u._c()};return FilterOperator}();exports.FilterOperator=FilterOperator;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 FlattenOperator=function(){function FlattenOperator(ins){this.type="flatten";this.ins=ins;this.out=NO;this.open=true;this.inner=NO;this.il=exports.NO_IL}FlattenOperator.prototype._start=function(out){this.out=out;this.open=true;this.inner=NO;this.il=exports.NO_IL;this.ins._add(this)};FlattenOperator.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=exports.NO_IL};FlattenOperator.prototype.less=function(){var u=this.out;if(u===NO)return;if(!this.open&&this.inner===NO)u._c()};FlattenOperator.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!==exports.NO_IL)inner._remove(il);(this.inner=s)._add(this.il=new FlattenListener(u,this))};FlattenOperator.prototype._e=function(err){var u=this.out;if(u===NO)return;u._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.type="fold";this.ins=ins;this.out=NO;this.f=f;this.acc=this.seed=seed}FoldOperator.prototype._start=function(out){this.out=out;this.acc=this.seed;out._n(this.acc);this.ins._add(this)};FoldOperator.prototype._stop=function(){this.ins._remove(this);this.out=NO;this.acc=this.seed};FoldOperator.prototype._n=function(t){var u=this.out;if(u===NO)return;try{u._n(this.acc=this.f(this.acc,t))}catch(e){u._e(e)}};FoldOperator.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};FoldOperator.prototype._c=function(){var u=this.out;if(u===NO)return;u._c()};return FoldOperator}();exports.FoldOperator=FoldOperator;var LastOperator=function(){function LastOperator(ins){this.type="last";this.ins=ins;this.out=NO;this.has=false;this.val=NO}LastOperator.prototype._start=function(out){this.out=out;this.has=false;this.ins._add(this)};LastOperator.prototype._stop=function(){this.ins._remove(this);this.out=NO;this.val=NO};LastOperator.prototype._n=function(t){this.has=true;this.val=t};LastOperator.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};LastOperator.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 LastOperator}();exports.LastOperator=LastOperator;var MapFlattenInner=function(){function MapFlattenInner(out,op){this.out=out;this.op=op}MapFlattenInner.prototype._n=function(r){this.out._n(r)};MapFlattenInner.prototype._e=function(err){this.out._e(err)};MapFlattenInner.prototype._c=function(){this.op.inner=NO;this.op.less()};return MapFlattenInner}();var MapFlattenOperator=function(){function MapFlattenOperator(mapOp){this.type=mapOp.type+"+flatten";this.ins=mapOp.ins;this.out=NO;this.mapOp=mapOp;this.inner=NO;this.il=exports.NO_IL;this.open=true}MapFlattenOperator.prototype._start=function(out){this.out=out;this.inner=NO;this.il=exports.NO_IL;this.open=true;this.mapOp.ins._add(this)};MapFlattenOperator.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=exports.NO_IL};MapFlattenOperator.prototype.less=function(){if(!this.open&&this.inner===NO){var u=this.out;if(u===NO)return;u._c()}};MapFlattenOperator.prototype._n=function(v){var u=this.out;if(u===NO)return;var _a=this,inner=_a.inner,il=_a.il;if(inner!==NO&&il!==exports.NO_IL)inner._remove(il);try{(this.inner=this.mapOp.project(v))._add(this.il=new MapFlattenInner(u,this))}catch(e){u._e(e)}};MapFlattenOperator.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};MapFlattenOperator.prototype._c=function(){this.open=false;this.less()};return MapFlattenOperator}();exports.MapFlattenOperator=MapFlattenOperator;var MapOperator=function(){function MapOperator(project,ins){this.type="map";this.ins=ins;this.out=NO;this.project=project}MapOperator.prototype._start=function(out){this.out=out;this.ins._add(this)};MapOperator.prototype._stop=function(){this.ins._remove(this);this.out=NO};MapOperator.prototype._n=function(t){var u=this.out;if(u===NO)return;try{u._n(this.project(t))}catch(e){u._e(e)}};MapOperator.prototype._e=function(err){var u=this.out;if(u===NO)return;u._e(err)};MapOperator.prototype._c=function(){var u=this.out;if(u===NO)return;u._c()};return MapOperator}();exports.MapOperator=MapOperator;var FilterMapOperator=function(_super){__extends(FilterMapOperator,_super);function FilterMapOperator(passes,project,ins){_super.call(this,project,ins);this.type="filter+map";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 RememberOperator=function(){function RememberOperator(ins){this.type="remember";this.ins=ins;this.out=NO}RememberOperator.prototype._start=function(out){this.out=out;this.ins._add(out)};RememberOperator.prototype._stop=function(){this.ins._remove(this.out);this.out=NO};return RememberOperator}();exports.RememberOperator=RememberOperator;var ReplaceErrorOperator=function(){function ReplaceErrorOperator(fn,ins){this.type="replaceError";this.ins=ins;this.out=NO;this.fn=fn}ReplaceErrorOperator.prototype._start=function(out){this.out=out;this.ins._add(this)};ReplaceErrorOperator.prototype._stop=function(){this.ins._remove(this);this.out=NO};ReplaceErrorOperator.prototype._n=function(t){var u=this.out;if(u===NO)return;u._n(t)};ReplaceErrorOperator.prototype._e=function(err){var u=this.out;if(u===NO)return;try{this.ins._remove(this);(this.ins=this.fn(err))._add(this)}catch(e){u._e(e)}};ReplaceErrorOperator.prototype._c=function(){var u=this.out;if(u===NO)return;u._c()};return ReplaceErrorOperator}();exports.ReplaceErrorOperator=ReplaceErrorOperator;var StartWithOperator=function(){function StartWithOperator(ins,val){this.type="startWith";this.ins=ins;this.out=NO;this.val=val}StartWithOperator.prototype._start=function(out){this.out=out;this.out._n(this.val);this.ins._add(out)};StartWithOperator.prototype._stop=function(){this.ins._remove(this.out);this.out=NO};return StartWithOperator}();exports.StartWithOperator=StartWithOperator;var TakeOperator=function(){function TakeOperator(max,ins){this.type="take";this.ins=ins;this.out=NO;this.max=max;this.taken=0}TakeOperator.prototype._start=function(out){this.out=out;this.taken=0;this.ins._add(this)};TakeOperator.prototype._stop=function(){this.ins._remove(this);this.out=NO};TakeOperator.prototype._n=function(t){var u=this.out;if(u===NO)return;if(this.taken++-1){a.splice(i,1);if(this._prod!==NO&&a.length<=0){this._err=NO;this._stopID=setTimeout(function(){return _this._lateStop()})}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