Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

xstream

Package Overview
Dependencies
Maintainers
2
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xstream - npm Package Compare versions

Comparing version 2.2.1 to 2.3.0

14

CHANGELOG.md

@@ -0,1 +1,15 @@

<a name="2.3.0"></a>
# [2.3.0](https://github.com/staltz/xstream/compare/v2.2.1...v2.3.0) (2016-05-09)
### Bug Fixes
* **combine:** fix combine() to export its Producer class ([700a129](https://github.com/staltz/xstream/commit/700a129))
### Features
* **operators:** add type metadata string to all operators/producers ([a734fd4](https://github.com/staltz/xstream/commit/a734fd4))
<a name="2.2.1"></a>

@@ -2,0 +16,0 @@ ## [2.2.1](https://github.com/staltz/xstream/compare/v2.2.0...v2.2.1) (2016-05-03)

48

core.d.ts

@@ -16,2 +16,3 @@ export interface InternalListener<T> {

_c: () => void;
type: string;
}

@@ -49,4 +50,28 @@ export interface Producer<T> {

}
export declare class CombineListener<T> implements InternalListener<T> {
private i;
private p;
constructor(i: number, p: CombineProducer<T>);
_n(t: T): void;
_e(err: any): void;
_c(): void;
}
export declare class CombineProducer<R> implements InternalProducer<R> {
project: CombineProjectFunction;
streams: Array<Stream<any>>;
type: string;
out: InternalListener<R>;
ils: Array<CombineListener<any>>;
ac: number;
left: number;
vals: Array<any>;
constructor(project: CombineProjectFunction, streams: Array<Stream<any>>);
up(t: any, i: number): boolean;
_start(out: InternalListener<R>): void;
_stop(): void;
zero(out: InternalListener<R>): void;
}
export declare class FromArrayProducer<T> implements InternalProducer<T> {
a: Array<T>;
type: string;
constructor(a: Array<T>);

@@ -58,2 +83,3 @@ _start(out: InternalListener<T>): void;

p: Promise<T>;
type: string;
on: boolean;

@@ -65,6 +91,7 @@ constructor(p: Promise<T>);

export declare class MergeProducer<T> implements InternalProducer<T>, InternalListener<T> {
s: Array<Stream<T>>;
streams: Array<Stream<T>>;
type: string;
private out;
private ac;
constructor(s: Array<Stream<T>>);
constructor(streams: Array<Stream<T>>);
_start(out: InternalListener<T>): void;

@@ -78,2 +105,3 @@ _stop(): void;

period: number;
type: string;
private intervalID;

@@ -88,2 +116,3 @@ private i;

ins: Stream<T>;
type: string;
private out;

@@ -100,2 +129,3 @@ constructor(spy: (t: T) => any, ins: Stream<T>);

ins: Stream<T>;
type: string;
private out;

@@ -113,2 +143,3 @@ private dropped;

ins: Stream<T>;
type: string;
private out;

@@ -127,2 +158,3 @@ private oil;

ins: Stream<T>;
type: string;
private out;

@@ -138,2 +170,3 @@ constructor(passes: (t: T) => boolean, ins: Stream<T>);

ins: Stream<Stream<T>>;
type: string;
private active;

@@ -151,2 +184,3 @@ private out;

ins: Stream<Stream<T>>;
type: string;
inner: Stream<T>;

@@ -168,2 +202,3 @@ private il;

ins: Stream<T>;
type: string;
private out;

@@ -180,2 +215,3 @@ private acc;

ins: Stream<T>;
type: string;
private out;

@@ -193,2 +229,3 @@ private has;

mapOp: MapOperator<T, Stream<T>>;
type: string;
private active;

@@ -206,2 +243,3 @@ private out;

mapOp: MapOperator<T, Stream<T>>;
type: string;
inner: Stream<T>;

@@ -222,2 +260,3 @@ private il;

ins: Stream<T>;
type: string;
protected out: Stream<R>;

@@ -233,2 +272,3 @@ constructor(project: (t: T) => R, ins: Stream<T>);

passes: (t: T) => boolean;
type: string;
constructor(passes: (t: T) => boolean, project: (t: T) => R, ins: Stream<T>);

@@ -240,2 +280,3 @@ _n(v: T): void;

ins: Stream<T>;
type: string;
private out;

@@ -252,2 +293,3 @@ constructor(val: R, ins: Stream<T>);

ins: Stream<T>;
type: string;
private out;

@@ -264,2 +306,3 @@ constructor(fn: (err: any) => Stream<T>, ins: Stream<T>);

value: T;
type: string;
private out;

@@ -273,2 +316,3 @@ constructor(ins: Stream<T>, value: T);

ins: Stream<T>;
type: string;
private out;

@@ -275,0 +319,0 @@ private taken;

@@ -89,2 +89,3 @@ "use strict";

}());
exports.CombineListener = CombineListener;
var CombineProducer = (function () {

@@ -94,2 +95,3 @@ function CombineProducer(project, streams) {

this.streams = streams;
this.type = 'combine';
this.out = emptyListener;

@@ -143,5 +145,7 @@ this.ils = [];

}());
exports.CombineProducer = CombineProducer;
var FromArrayProducer = (function () {
function FromArrayProducer(a) {
this.a = a;
this.type = 'fromArray';
}

@@ -163,2 +167,3 @@ FromArrayProducer.prototype._start = function (out) {

this.p = p;
this.type = 'fromPromise';
this.on = false;

@@ -187,10 +192,11 @@ }

var MergeProducer = (function () {
function MergeProducer(s) {
this.s = s;
function MergeProducer(streams) {
this.streams = streams;
this.type = 'merge';
this.out = emptyListener;
this.ac = s.length;
this.ac = streams.length;
}
MergeProducer.prototype._start = function (out) {
this.out = out;
var s = this.s;
var s = this.streams;
var L = s.length;

@@ -202,3 +208,3 @@ for (var i = 0; i < L; i++) {

MergeProducer.prototype._stop = function () {
var s = this.s;
var s = this.streams;
var L = s.length;

@@ -228,2 +234,3 @@ for (var i = 0; i < L; i++) {

this.period = period;
this.type = 'periodic';
this.intervalID = -1;

@@ -251,2 +258,3 @@ this.i = 0;

this.ins = ins;
this.type = 'debug';
this.out = null;

@@ -289,2 +297,3 @@ }

this.ins = ins;
this.type = 'drop';
this.out = null;

@@ -336,2 +345,3 @@ this.dropped = 0;

this.ins = ins;
this.type = 'endWhen';
this.out = null;

@@ -370,2 +380,3 @@ this.oil = emptyListener; // oil = other InternalListener

this.ins = ins;
this.type = 'filter';
this.out = null;

@@ -418,2 +429,3 @@ }

this.ins = ins;
this.type = 'flattenConcurrently';
this.active = 1; // number of outers and inners that have not yet ended

@@ -469,2 +481,3 @@ this.out = null;

this.ins = ins;
this.type = 'flatten';
this.inner = null; // Current inner Stream

@@ -511,2 +524,3 @@ this.il = null; // Current inner InternalListener

this.ins = ins;
this.type = 'fold';
this.out = null;

@@ -545,2 +559,3 @@ this.acc = seed;

this.ins = ins;
this.type = 'last';
this.out = null;

@@ -599,2 +614,3 @@ this.has = false;

this.mapOp = mapOp;
this.type = 'map+flattenConcurrently';
this.active = 1; // number of outers and inners that have not yet ended

@@ -655,2 +671,3 @@ this.out = null;

this.mapOp = mapOp;
this.type = 'map+flatten';
this.inner = null; // Current inner Stream

@@ -702,2 +719,3 @@ this.il = null; // Current inner InternalListener

this.ins = ins;
this.type = 'map';
this.out = null;

@@ -735,2 +753,3 @@ }

this.passes = passes;
this.type = 'filter+map';
}

@@ -750,2 +769,3 @@ FilterMapOperator.prototype._n = function (v) {

this.ins = ins;
this.type = 'mapTo';
this.out = null;

@@ -777,2 +797,3 @@ }

this.ins = ins;
this.type = 'replaceError';
this.out = empty;

@@ -810,2 +831,3 @@ }

this.value = value;
this.type = 'startWith';
this.out = emptyListener;

@@ -829,2 +851,3 @@ }

this.ins = ins;
this.type = 'take';
this.out = null;

@@ -831,0 +854,0 @@ this.taken = 0;

@@ -90,2 +90,3 @@ (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){

}());
exports.CombineListener = CombineListener;
var CombineProducer = (function () {

@@ -95,2 +96,3 @@ function CombineProducer(project, streams) {

this.streams = streams;
this.type = 'combine';
this.out = emptyListener;

@@ -144,5 +146,7 @@ this.ils = [];

}());
exports.CombineProducer = CombineProducer;
var FromArrayProducer = (function () {
function FromArrayProducer(a) {
this.a = a;
this.type = 'fromArray';
}

@@ -164,2 +168,3 @@ FromArrayProducer.prototype._start = function (out) {

this.p = p;
this.type = 'fromPromise';
this.on = false;

@@ -188,10 +193,11 @@ }

var MergeProducer = (function () {
function MergeProducer(s) {
this.s = s;
function MergeProducer(streams) {
this.streams = streams;
this.type = 'merge';
this.out = emptyListener;
this.ac = s.length;
this.ac = streams.length;
}
MergeProducer.prototype._start = function (out) {
this.out = out;
var s = this.s;
var s = this.streams;
var L = s.length;

@@ -203,3 +209,3 @@ for (var i = 0; i < L; i++) {

MergeProducer.prototype._stop = function () {
var s = this.s;
var s = this.streams;
var L = s.length;

@@ -229,2 +235,3 @@ for (var i = 0; i < L; i++) {

this.period = period;
this.type = 'periodic';
this.intervalID = -1;

@@ -252,2 +259,3 @@ this.i = 0;

this.ins = ins;
this.type = 'debug';
this.out = null;

@@ -290,2 +298,3 @@ }

this.ins = ins;
this.type = 'drop';
this.out = null;

@@ -337,2 +346,3 @@ this.dropped = 0;

this.ins = ins;
this.type = 'endWhen';
this.out = null;

@@ -371,2 +381,3 @@ this.oil = emptyListener;

this.ins = ins;
this.type = 'filter';
this.out = null;

@@ -419,2 +430,3 @@ }

this.ins = ins;
this.type = 'flattenConcurrently';
this.active = 1;

@@ -470,2 +482,3 @@ this.out = null;

this.ins = ins;
this.type = 'flatten';
this.inner = null;

@@ -512,2 +525,3 @@ this.il = null;

this.ins = ins;
this.type = 'fold';
this.out = null;

@@ -546,2 +560,3 @@ this.acc = seed;

this.ins = ins;
this.type = 'last';
this.out = null;

@@ -600,2 +615,3 @@ this.has = false;

this.mapOp = mapOp;
this.type = 'map+flattenConcurrently';
this.active = 1;

@@ -656,2 +672,3 @@ this.out = null;

this.mapOp = mapOp;
this.type = 'map+flatten';
this.inner = null;

@@ -703,2 +720,3 @@ this.il = null;

this.ins = ins;
this.type = 'map';
this.out = null;

@@ -736,2 +754,3 @@ }

this.passes = passes;
this.type = 'filter+map';
}

@@ -751,2 +770,3 @@ FilterMapOperator.prototype._n = function (v) {

this.ins = ins;
this.type = 'mapTo';
this.out = null;

@@ -778,2 +798,3 @@ }

this.ins = ins;
this.type = 'replaceError';
this.out = empty;

@@ -811,2 +832,3 @@ }

this.value = value;
this.type = 'startWith';
this.out = emptyListener;

@@ -830,2 +852,3 @@ }

this.ins = ins;
this.type = 'take';
this.out = null;

@@ -832,0 +855,0 @@ this.taken = 0;

2

dist/xstream.min.js

@@ -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,p){this.i=i;this.p=p;p.ils.push(this)}CombineListener.prototype._n=function(t){var p=this.p,out=p.out;if(!out)return;if(p.up(t,this.i)){try{out._n(invoke(p.project,p.vals))}catch(e){out._e(e)}}};CombineListener.prototype._e=function(err){var out=this.p.out;if(!out)return;out._e(err)};CombineListener.prototype._c=function(){var p=this.p;if(!p.out)return;if(--p.ac===0){p.out._c()}};return CombineListener}();var CombineProducer=function(){function CombineProducer(project,streams){this.project=project;this.streams=streams;this.out=emptyListener;this.ils=[];var n=this.ac=this.left=streams.length;var vals=this.vals=new Array(n);for(var i=0;i<n;i++){vals[i]=empty}}CombineProducer.prototype.up=function(t,i){var v=this.vals[i];var left=!this.left?0:v===empty?--this.left:this.left;this.vals[i]=t;return left===0};CombineProducer.prototype._start=function(out){this.out=out;var s=this.streams;var n=s.length;if(n===0)this.zero(out);else{for(var i=0;i<n;i++){s[i]._add(new CombineListener(i,this))}}};CombineProducer.prototype._stop=function(){var s=this.streams;var n=this.ac=this.left=s.length;var vals=this.vals=new Array(n);for(var i=0;i<n;i++){s[i]._remove(this.ils[i]);vals[i]=empty}this.out=null;this.ils=[]};CombineProducer.prototype.zero=function(out){try{out._n(this.project());out._c()}catch(e){out._e(e)}};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(s){this.s=s;this.out=emptyListener;this.ac=s.length}MergeProducer.prototype._start=function(out){this.out=out;var s=this.s;var L=s.length;for(var i=0;i<L;i++){s[i]._add(this)}};MergeProducer.prototype._stop=function(){var s=this.s;var L=s.length;for(var i=0;i<L;i++){s[i]._remove(this)}this.out=null;this.ac=L};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 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.o=o;this.ins=ins;this.out=null;this.oil=emptyListener}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=null;this.oil=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 FCIL=function(){function FCIL(out,op){this.out=out;this.op=op}FCIL.prototype._n=function(t){this.out._n(t)};FCIL.prototype._e=function(err){this.out._e(err)};FCIL.prototype._c=function(){this.op.less()};return FCIL}();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 FCIL(this.out,this))};FlattenConcOperator.prototype._e=function(err){this.out._e(err)};FlattenConcOperator.prototype._c=function(){this.less()};return FlattenConcOperator}();exports.FlattenConcOperator=FlattenConcOperator;var FIL=function(){function FIL(out,op){this.out=out;this.op=op}FIL.prototype._n=function(t){this.out._n(t)};FIL.prototype._e=function(err){this.out._e(err)};FIL.prototype._c=function(){this.op.inner=null;this.op.less()};return FIL}();var FlattenOperator=function(){function FlattenOperator(ins){this.ins=ins;this.inner=null;this.il=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.inner=null;this.il=null;this.open=true;this.out=null};FlattenOperator.prototype.less=function(){if(!this.open&&!this.inner)this.out._c()};FlattenOperator.prototype._n=function(s){var _a=this,inner=_a.inner,il=_a.il;if(inner&&il)inner._remove(il);(this.inner=s)._add(this.il=new FIL(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 MFCIL=function(){function MFCIL(out,op){this.out=out;this.op=op}MFCIL.prototype._n=function(t){this.out._n(t)};MFCIL.prototype._e=function(err){this.out._e(err)};MFCIL.prototype._c=function(){this.op.less()};return MFCIL}();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 MFCIL(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 MFIL=function(){function MFIL(out,op){this.out=out;this.op=op}MFIL.prototype._n=function(t){this.out._n(t)};MFIL.prototype._e=function(err){this.out._e(err)};MFIL.prototype._c=function(){this.op.inner=null;this.op.less()};return MFIL}();var MapFlattenOperator=function(){function MapFlattenOperator(mapOp){this.mapOp=mapOp;this.inner=null;this.il=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.inner=null;this.il=null;this.open=true;this.out=null};MapFlattenOperator.prototype.less=function(){if(!this.open&&!this.inner){this.out._c()}};MapFlattenOperator.prototype._n=function(v){var _a=this,inner=_a.inner,il=_a.il;if(inner&&il)inner._remove(il);try{(this.inner=this.mapOp.project(v))._add(this.il=new MFIL(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)});
(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,p){this.i=i;this.p=p;p.ils.push(this)}CombineListener.prototype._n=function(t){var p=this.p,out=p.out;if(!out)return;if(p.up(t,this.i)){try{out._n(invoke(p.project,p.vals))}catch(e){out._e(e)}}};CombineListener.prototype._e=function(err){var out=this.p.out;if(!out)return;out._e(err)};CombineListener.prototype._c=function(){var p=this.p;if(!p.out)return;if(--p.ac===0){p.out._c()}};return CombineListener}();exports.CombineListener=CombineListener;var CombineProducer=function(){function CombineProducer(project,streams){this.project=project;this.streams=streams;this.type="combine";this.out=emptyListener;this.ils=[];var n=this.ac=this.left=streams.length;var vals=this.vals=new Array(n);for(var i=0;i<n;i++){vals[i]=empty}}CombineProducer.prototype.up=function(t,i){var v=this.vals[i];var left=!this.left?0:v===empty?--this.left:this.left;this.vals[i]=t;return left===0};CombineProducer.prototype._start=function(out){this.out=out;var s=this.streams;var n=s.length;if(n===0)this.zero(out);else{for(var i=0;i<n;i++){s[i]._add(new CombineListener(i,this))}}};CombineProducer.prototype._stop=function(){var s=this.streams;var n=this.ac=this.left=s.length;var vals=this.vals=new Array(n);for(var i=0;i<n;i++){s[i]._remove(this.ils[i]);vals[i]=empty}this.out=null;this.ils=[]};CombineProducer.prototype.zero=function(out){try{out._n(this.project());out._c()}catch(e){out._e(e)}};return CombineProducer}();exports.CombineProducer=CombineProducer;var FromArrayProducer=function(){function FromArrayProducer(a){this.a=a;this.type="fromArray"}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.type="fromPromise";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.type="merge";this.out=emptyListener;this.ac=streams.length}MergeProducer.prototype._start=function(out){this.out=out;var s=this.streams;var L=s.length;for(var i=0;i<L;i++){s[i]._add(this)}};MergeProducer.prototype._stop=function(){var s=this.streams;var L=s.length;for(var i=0;i<L;i++){s[i]._remove(this)}this.out=null;this.ac=L};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.type="periodic";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.type="debug";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.type="drop";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 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.o=o;this.ins=ins;this.type="endWhen";this.out=null;this.oil=emptyListener}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=null;this.oil=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.type="filter";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 FCIL=function(){function FCIL(out,op){this.out=out;this.op=op}FCIL.prototype._n=function(t){this.out._n(t)};FCIL.prototype._e=function(err){this.out._e(err)};FCIL.prototype._c=function(){this.op.less()};return FCIL}();var FlattenConcOperator=function(){function FlattenConcOperator(ins){this.ins=ins;this.type="flattenConcurrently";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 FCIL(this.out,this))};FlattenConcOperator.prototype._e=function(err){this.out._e(err)};FlattenConcOperator.prototype._c=function(){this.less()};return FlattenConcOperator}();exports.FlattenConcOperator=FlattenConcOperator;var FIL=function(){function FIL(out,op){this.out=out;this.op=op}FIL.prototype._n=function(t){this.out._n(t)};FIL.prototype._e=function(err){this.out._e(err)};FIL.prototype._c=function(){this.op.inner=null;this.op.less()};return FIL}();var FlattenOperator=function(){function FlattenOperator(ins){this.ins=ins;this.type="flatten";this.inner=null;this.il=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.inner=null;this.il=null;this.open=true;this.out=null};FlattenOperator.prototype.less=function(){if(!this.open&&!this.inner)this.out._c()};FlattenOperator.prototype._n=function(s){var _a=this,inner=_a.inner,il=_a.il;if(inner&&il)inner._remove(il);(this.inner=s)._add(this.il=new FIL(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.type="fold";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.type="last";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 MFCIL=function(){function MFCIL(out,op){this.out=out;this.op=op}MFCIL.prototype._n=function(t){this.out._n(t)};MFCIL.prototype._e=function(err){this.out._e(err)};MFCIL.prototype._c=function(){this.op.less()};return MFCIL}();var MapFlattenConcOperator=function(){function MapFlattenConcOperator(mapOp){this.mapOp=mapOp;this.type="map+flattenConcurrently";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 MFCIL(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 MFIL=function(){function MFIL(out,op){this.out=out;this.op=op}MFIL.prototype._n=function(t){this.out._n(t)};MFIL.prototype._e=function(err){this.out._e(err)};MFIL.prototype._c=function(){this.op.inner=null;this.op.less()};return MFIL}();var MapFlattenOperator=function(){function MapFlattenOperator(mapOp){this.mapOp=mapOp;this.type="map+flatten";this.inner=null;this.il=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.inner=null;this.il=null;this.open=true;this.out=null};MapFlattenOperator.prototype.less=function(){if(!this.open&&!this.inner){this.out._c()}};MapFlattenOperator.prototype._n=function(v){var _a=this,inner=_a.inner,il=_a.il;if(inner&&il)inner._remove(il);try{(this.inner=this.mapOp.project(v))._add(this.il=new MFIL(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.type="map";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;this.type="filter+map"}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.type="mapTo";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.type="replaceError";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.type="startWith";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.type="take";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)});

@@ -6,2 +6,3 @@ "use strict";

this.streams = streams;
this.type = 'concat';
this.out = null;

@@ -8,0 +9,0 @@ this.i = 0;

@@ -7,2 +7,3 @@ "use strict";

this.ins = ins;
this.type = 'debounce';
this.out = null;

@@ -9,0 +10,0 @@ this.value = null;

@@ -7,2 +7,3 @@ "use strict";

this.ins = ins;
this.type = 'delay';
this.out = null;

@@ -9,0 +10,0 @@ }

@@ -5,2 +5,3 @@ import { Operator, Stream } from '../core';

ins: Stream<T>;
type: string;
private out;

@@ -7,0 +8,0 @@ private v;

@@ -8,2 +8,3 @@ "use strict";

this.ins = ins;
this.type = 'dropRepeats';
this.out = null;

@@ -10,0 +11,0 @@ this.v = empty;

import { Operator, Stream } from '../core';
export declare class FlattenSeqOperator<T> implements Operator<Stream<T>, T> {
ins: Stream<Stream<T>>;
type: string;
private open;

@@ -5,0 +6,0 @@ private active;

@@ -22,2 +22,3 @@ "use strict";

this.ins = ins;
this.type = 'flattenSequentially';
this.open = true;

@@ -24,0 +25,0 @@ this.active = false;

@@ -6,2 +6,3 @@ import { Stream, InternalProducer, InternalListener } from '../core';

private useCapture;
type: string;
private listener;

@@ -8,0 +9,0 @@ constructor(node: EventTarget, eventType: string, useCapture: boolean);

@@ -8,2 +8,3 @@ "use strict";

this.useCapture = useCapture;
this.type = 'fromEvent';
}

@@ -10,0 +11,0 @@ DOMEventProducer.prototype._start = function (out) {

@@ -6,2 +6,3 @@ "use strict";

this.ins = ins;
this.type = 'pairwise';
this.val = null;

@@ -8,0 +9,0 @@ this.has = false;

{
"name": "xstream",
"version": "2.2.1",
"version": "2.3.0",
"description": "An extremely intuitive, small, and fast functional reactive stream library for JavaScript",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -1001,2 +1001,16 @@ <!-- 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/. -->

# CHANGELOG
<a name="2.3.0"></a>
# [2.3.0](https://github.com/staltz/xstream/compare/v2.2.1...v2.3.0) (2016-05-09)
### Bug Fixes
* **combine:** fix combine() to export its Producer class ([700a129](https://github.com/staltz/xstream/commit/700a129))
### Features
* **operators:** add type metadata string to all operators/producers ([a734fd4](https://github.com/staltz/xstream/commit/a734fd4))
<a name="2.2.1"></a>

@@ -1003,0 +1017,0 @@ ## [2.2.1](https://github.com/staltz/xstream/compare/v2.2.0...v2.2.1) (2016-05-03)

@@ -38,2 +38,3 @@ import {Promise} from 'es6-promise';

_c: () => void;
type: string;
}

@@ -145,3 +146,3 @@

class CombineListener<T> implements InternalListener<T> {
export class CombineListener<T> implements InternalListener<T> {
constructor(private i: number,

@@ -179,3 +180,4 @@ private p: CombineProducer<T>) {

class CombineProducer<R> implements InternalProducer<R> {
export class CombineProducer<R> implements InternalProducer<R> {
public type = 'combine';
public out: InternalListener<R> = emptyListener;

@@ -237,2 +239,3 @@ public ils: Array<CombineListener<any>> = [];

export class FromArrayProducer<T> implements InternalProducer<T> {
public type = 'fromArray';
constructor(public a: Array<T>) {

@@ -254,2 +257,3 @@ }

export class FromPromiseProducer<T> implements InternalProducer<T> {
public type = 'fromPromise';
public on: boolean = false;

@@ -284,7 +288,8 @@

export class MergeProducer<T> implements InternalProducer<T>, InternalListener<T> {
public type = 'merge';
private out: InternalListener<T> = emptyListener;
private ac: number; // ac is activeCount, starts initialized
constructor(public s: Array<Stream<T>>) {
this.ac = s.length;
constructor(public streams: Array<Stream<T>>) {
this.ac = streams.length;
}

@@ -294,3 +299,3 @@

this.out = out;
const s = this.s;
const s = this.streams;
const L = s.length;

@@ -303,3 +308,3 @@ for (let i = 0; i < L; i++) {

_stop(): void {
const s = this.s;
const s = this.streams;
const L = s.length;

@@ -329,2 +334,3 @@ for (let i = 0; i < L; i++) {

export class PeriodicProducer implements InternalProducer<number> {
public type = 'periodic';
private intervalID: any = -1;

@@ -350,2 +356,3 @@ private i: number = 0;

export class DebugOperator<T> implements Operator<T, T> {
public type = 'debug';
private out: Stream<T> = null;

@@ -390,2 +397,3 @@

export class DropOperator<T> implements Operator<T, T> {
public type = 'drop';
private out: Stream<T> = null;

@@ -441,2 +449,3 @@ private dropped: number = 0;

export class EndWhenOperator<T> implements Operator<T, T> {
public type = 'endWhen';
private out: Stream<T> = null;

@@ -480,2 +489,3 @@ private oil: InternalListener<any> = emptyListener; // oil = other InternalListener

export class FilterOperator<T> implements Operator<T, T> {
public type = 'filter';
private out: Stream<T> = null;

@@ -533,2 +543,3 @@

export class FlattenConcOperator<T> implements Operator<Stream<T>, T> {
public type = 'flattenConcurrently';
private active: number = 1; // number of outers and inners that have not yet ended

@@ -591,2 +602,3 @@ private out: Stream<T> = null;

export class FlattenOperator<T> implements Operator<Stream<T>, T> {
public type = 'flatten';
public inner: Stream<T> = null; // Current inner Stream

@@ -634,2 +646,3 @@ private il: InternalListener<T> = null; // Current inner InternalListener

export class FoldOperator<T, R> implements Operator<T, R> {
public type = 'fold';
private out: Stream<R> = null;

@@ -674,2 +687,3 @@ private acc: R; // initialized as seed

export class LastOperator<T> implements Operator<T, T> {
public type = 'last';
private out: Stream<T> = null;

@@ -733,2 +747,3 @@ private has: boolean = false;

export class MapFlattenConcOperator<T> implements InternalProducer<T>, InternalListener<T> {
public type = 'map+flattenConcurrently';
private active: number = 1; // number of outers and inners that have not yet ended

@@ -795,2 +810,3 @@ private out: Stream<T> = null;

export class MapFlattenOperator<T> implements InternalProducer<T>, InternalListener<T> {
public type = 'map+flatten';
public inner: Stream<T> = null; // Current inner Stream

@@ -844,2 +860,3 @@ private il: InternalListener<T> = null; // Current inner InternalListener

export class MapOperator<T, R> implements Operator<T, R> {
public type = 'map';
protected out: Stream<R> = null;

@@ -879,2 +896,3 @@

export class FilterMapOperator<T, R> extends MapOperator<T, R> {
public type = 'filter+map';
constructor(public passes: (t: T) => boolean,

@@ -894,2 +912,3 @@ project: (t: T) => R,

export class MapToOperator<T, R> implements Operator<T, R> {
public type = 'mapTo';
private out: Stream<R> = null;

@@ -925,2 +944,3 @@

export class ReplaceErrorOperator<T> implements Operator<T, T> {
public type = 'replaceError';
private out: Stream<T> = <Stream<T>> empty;

@@ -961,2 +981,3 @@

export class StartWithOperator<T> implements InternalProducer<T> {
public type = 'startWith';
private out: InternalListener<T> = emptyListener;

@@ -981,2 +1002,3 @@

export class TakeOperator<T> implements Operator<T, T> {
public type = 'take';
private out: Stream<T> = null;

@@ -983,0 +1005,0 @@ private taken: number = 0;

import {Stream, InternalProducer, InternalListener} from '../core';
class ConcatProducer<T> implements InternalProducer<T>, InternalListener<T> {
public type = 'concat';
private out: InternalListener<T> = null;

@@ -5,0 +6,0 @@ private i: number = 0;

import {Operator, Stream} from '../core';
class DebounceOperator<T> implements Operator<T, T> {
public type = 'debounce';
private out: Stream<T> = null;

@@ -5,0 +6,0 @@ private value: T = null;

import {Operator, Stream} from '../core';
class DelayOperator<T> implements Operator<T, T> {
public type = 'delay';
private out: Stream<T> = null;

@@ -5,0 +6,0 @@

@@ -5,2 +5,3 @@ import {Operator, Stream} from '../core';

export class DropRepeatsOperator<T> implements Operator<T, T> {
public type = 'dropRepeats';
private out: Stream<T> = null;

@@ -7,0 +8,0 @@ private v: T = <any> empty;

@@ -22,2 +22,3 @@ import {Operator, Stream, InternalListener} from '../core';

export class FlattenSeqOperator<T> implements Operator<Stream<T>, T> {
public type = 'flattenSequentially';
private open: boolean = true;

@@ -24,0 +25,0 @@ private active: boolean = false;

import {Stream, InternalProducer, InternalListener} from '../core';
export class DOMEventProducer implements InternalProducer<Event> {
public type = 'fromEvent';
private listener: EventListener;

@@ -5,0 +6,0 @@

import {Operator, Stream} from '../core';
class PairwiseOperator<T> implements Operator<T, [T, T]> {
public type = 'pairwise';
private val: T = null;

@@ -5,0 +6,0 @@ private has: boolean = false;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc