Socket
Socket
Sign inDemoInstall

kefir

Package Overview
Dependencies
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kefir - npm Package Compare versions

Comparing version 3.7.1 to 3.7.2

configs/docs.js

6

changelog.md

@@ -0,4 +1,8 @@

## 3.7.2 (27/05/2017)
- Flow definitions improved [#242](https://github.com/rpominov/kefir/pull/242) [@hallettj](https://github.com/hallettj)
## 3.7.1 (21/01/2017)
- The `.setName` method has been added to Flow defenitions [#232](https://github.com/rpominov/kefir/pull/232) [@mAAdhaTTah](https://github.com/mAAdhaTTah)
- The `.setName` method has been added to Flow definitions [#232](https://github.com/rpominov/kefir/pull/232) [@mAAdhaTTah](https://github.com/mAAdhaTTah)

@@ -5,0 +9,0 @@ ## 3.7.0 (31/12/2016)

7

dist/kefir.min.js

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

/*! Kefir.js v3.7.1
/*! Kefir.js v3.7.2
* https://github.com/rpominov/kefir
*/
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(t.Kefir=t.Kefir||{})}(this,function(t){"use strict";function n(t){var n=function(){};return n.prototype=t,new n}function i(t){var n=arguments.length,i=void 0,e=void 0;for(i=1;i<n;i++)for(e in arguments[i])t[e]=arguments[i][e];return t}function e(t,e){var r=arguments.length,s=void 0;for(t.prototype=n(e.prototype),t.prototype.constructor=t,s=2;s<r;s++)i(t.prototype,arguments[s]);return t}function r(t,n){var i=void 0,e=void 0,r=void 0,s=void 0;if(0===t.length)return n;if(0===n.length)return t;for(s=0,i=new Array(t.length+n.length),e=t.length,r=0;r<e;r++,s++)i[s]=t[r];for(e=n.length,r=0;r<e;r++,s++)i[s]=n[r];return i}function s(t,n){var i=t.length,e=void 0;for(e=0;e<i;e++)if(t[e]===n)return e;return-1}function u(t,n){var i=t.length,e=void 0;for(e=0;e<i;e++)if(n(t[e]))return e;return-1}function o(t){var n=t.length,i=new Array(n),e=void 0;for(e=0;e<n;e++)i[e]=t[e];return i}function a(t,n){var i=t.length,e=void 0,r=void 0,s=void 0;if(n>=0&&n<i){if(1===i)return[];for(e=new Array(i-1),r=0,s=0;r<i;r++)r!==n&&(e[s]=t[r],s++);return e}return t}function h(t,n){var i=t.length,e=new Array(i),r=void 0;for(r=0;r<i;r++)e[r]=n(t[r]);return e}function l(t,n){var i=t.length,e=void 0;for(e=0;e<i;e++)n(t[e])}function _(t,n){var i=t.length,e=void 0;for(e=0;e<i;e++)t[e]=n}function f(t,n){return s(t,n)!==-1}function c(t,n,i){var e=Math.min(i,t.length+1),r=t.length-e+1,s=new Array(e),u=void 0;for(u=r;u<e;u++)s[u-r]=t[u];return s[e-1]=n,s}function d(t,n,i){t===_n?n(i):t===i.type&&(t===hn||t===ln?n(i.value):n())}function v(){this._items=[],this._spies=[],this._inLoop=0,this._removedItems=null}function p(){this._dispatcher=new v,this._active=!1,this._alive=!0,this._activating=!1,this._logHandlers=null,this._spyHandlers=null}function m(){p.call(this)}function y(){p.call(this),this._currentEvent=null}function g(){return fn}function E(t){function n(t,n){var i=this;m.call(this),this._wait=t,this._intervalId=null,this._$onTick=function(){return i._onTick()},this._init(n)}return e(n,m,{_init:function(){},_free:function(){},_onTick:function(){},_onActivation:function(){this._intervalId=setInterval(this._$onTick,this._wait)},_onDeactivation:function(){null!==this._intervalId&&(clearInterval(this._intervalId),this._intervalId=null)},_clear:function(){m.prototype._clear.call(this),this._$onTick=null,this._free()}},t),n}function b(t,n){return new cn(t,{x:n})}function A(t,n){return new dn(t,{x:n})}function w(t,n){return 0===n.length?g():new vn(t,{xs:n})}function S(t,n){return new pn(t,{fn:n})}function V(t){function n(n){return t._emitValue(n),t._active}function i(n){return t._emitError(n),t._active}function e(){return t._emitEnd(),t._active}function r(n){return t._emit(n.type,n.value),t._active}return{value:n,error:i,end:e,event:r,emit:n,emitEvent:r}}function T(t,n){return new mn(t,{fn:n})}function $(t){m.call(this),this._fn=t,this._unsubscribe=null}function C(t){return new $(t)}function k(t){var n=!1;return C(function(i){n||(t(function(t){i.emit(t),i.end()}),n=!0)}).setName("fromCallback")}function O(t){var n=!1;return C(function(i){n||(t(function(t,n){t?i.error(t):i.emit(n),i.end()}),n=!0)}).setName("fromNodeCallback")}function I(t,n){switch(n){case 0:return function(){return t()};case 1:return function(n){return t(n[0])};case 2:return function(n){return t(n[0],n[1])};case 3:return function(n){return t(n[0],n[1],n[2])};case 4:return function(n){return t(n[0],n[1],n[2],n[3])};default:return function(n){return t.apply(null,n)}}}function x(t,n,i){var e=i?i.length:0;if(null==n)switch(e){case 0:return t();case 1:return t(i[0]);case 2:return t(i[0],i[1]);case 3:return t(i[0],i[1],i[2]);case 4:return t(i[0],i[1],i[2],i[3]);default:return t.apply(null,i)}else switch(e){case 0:return t.call(n);default:return t.apply(n,i)}}function L(t,n,i){return C(function(e){var r=i?function(){e.emit(x(i,this,arguments))}:function(t){e.emit(t)};return t(r),function(){return n(r)}}).setName("fromSubUnsub")}function P(t,n,i){for(var e=void 0,r=void 0,s=0;s<yn.length;s++)if("function"==typeof t[yn[s][0]]&&"function"==typeof t[yn[s][1]]){e=yn[s][0],r=yn[s][1];break}if(void 0===e)throw new Error("target don't support any of addEventListener/removeEventListener, addListener/removeListener, on/off method pair");return L(function(i){return t[e](n,i)},function(i){return t[r](n,i)},i).setName("fromEvents")}function H(t){this._currentEvent={type:"value",value:t,current:!0}}function M(t){return new H(t)}function D(t){this._currentEvent={type:"error",value:t,current:!0}}function N(t){return new D(t)}function q(t,n){return function(i,e){var r=this;t.call(this),this._source=i,this._name=i._name+"."+n,this._init(e),this._$handleAny=function(t){return r._handleAny(t)}}}function W(t){return{_init:function(){},_free:function(){},_handleValue:function(t){this._emitValue(t)},_handleError:function(t){this._emitError(t)},_handleEnd:function(){this._emitEnd()},_handleAny:function(t){switch(t.type){case hn:return this._handleValue(t.value);case ln:return this._handleError(t.value);case an:return this._handleEnd()}},_onActivation:function(){this._source.onAny(this._$handleAny)},_onDeactivation:function(){this._source.offAny(this._$handleAny)},_clear:function(){t.prototype._clear.call(this),this._source=null,this._$handleAny=null,this._free()}}}function B(t,n){var i=q(m,t);return e(i,m,W(m),n),i}function j(t,n){var i=q(y,t);return e(i,y,W(y),n),i}function U(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(null!==n&&"function"!=typeof n)throw new Error("You should call toProperty() with a function or no arguments.");return new gn(t,{fn:n})}function F(t){return new En(t)}function Q(t){var n=!1,i=C(function(i){if(!n){var e=function(t){i.emit(t),i.end()},r=function(t){i.error(t),i.end()},s=t.then(e,r);s&&"function"==typeof s.done&&s.done(),n=!0}});return U(i,null).setName("fromPromise")}function z(){if("function"==typeof Promise)return Promise;throw new Error("There isn't default Promise, use shim or parameter")}function Y(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:z(),i=null;return new n(function(n,e){t.onAny(function(t){t.type===an&&null!==i?((i.type===hn?n:e)(i.value),i=null):i=t})})}function K(t,n){return n={exports:{}},t(n,n.exports),n.exports}function G(t){var n=t[$n]?t[$n]():t;return C(function(t){var i=n.subscribe({error:function(n){t.error(n),t.end()},next:function(n){t.emit(n)},complete:function(){t.end()}});return i.unsubscribe?function(){i.unsubscribe()}:i}).setName("fromESObservable")}function J(t){this._observable=t.takeErrors(1)}function R(){return new J(this)}function X(t,n,i){for(var e in t)t.hasOwnProperty(e)&&(n.push(e),i.push(t[e]))}function Z(t){for(var n=void 0,i=0;i<t.length;i++)void 0!==t[i]&&(void 0===n||n.index<t[i].index)&&(n=t[i]);return n.error}function tt(t,n,i){var e=this;m.call(this),this._activeCount=t.length,this._sources=r(t,n),this._combinator=i,this._aliveCount=0,this._latestValues=new Array(this._sources.length),this._latestErrors=new Array(this._sources.length),_(this._latestValues,on),this._emitAfterActivation=!1,this._endAfterActivation=!1,this._latestErrorIndex=0,this._$handlers=[];for(var s=function(t){e._$handlers.push(function(n){return e._handleAny(t,n)})},u=0;u<this._sources.length;u++)s(u)}function nt(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments[2];if(!Array.isArray(n))throw new Error("Combine can only combine active and passive collections of the same type.");return i=i?I(i,t.length+n.length):function(t){return t},0===t.length?g():new tt(t,n,i)}function it(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments[2];if("object"!=typeof n||Array.isArray(n))throw new Error("Combine can only combine active and passive collections of the same type.");var e=[],r=[],s=[];X(t,e,r),X(n,e,s);var u=function(t){for(var n={},r=t.length-1;0<=r;r--)n[e[r]]=t[r];return i?i(n):n};return 0===r.length?g():new tt(r,s,u)}function et(t,n,i){return"function"==typeof n&&(i=n,n=void 0),Array.isArray(t)?nt(t,n,i):it(t,n,i)}function rt(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ln;return new(t._ofSameType(In,xn))(t,{fn:n})}function st(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Dn;return new(t._ofSameType(Hn,Mn))(t,{fn:n})}function ut(t,n){return new(t._ofSameType(qn,Wn))(t,{n:n})}function ot(t,n){return new(t._ofSameType(jn,Un))(t,{n:n})}function at(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Yn;return new(t._ofSameType(Qn,zn))(t,{fn:n})}function ht(t){return new(t._ofSameType(Gn,Jn))(t)}function lt(t,n){return new(t._ofSameType(Xn,Zn))(t,{n:n})}function _t(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ei;return new(t._ofSameType(ni,ii))(t,{fn:n})}function ft(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:oi;return new(t._ofSameType(si,ui))(t,{fn:n})}function ct(t,n){return[t,n]}function dt(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:on;return new(t._ofSameType(hi,li))(t,{fn:n||ct,seed:i})}function vt(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:on;return new _i(t,{fn:n,seed:i})}function pt(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:di;return new ci(t,{fn:n})}function mt(t,n){return new(t._ofSameType(mi,yi))(t,{wait:n})}function yt(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},e=i.leading,r=void 0===e||e,s=i.trailing,u=void 0===s||s;return new(t._ofSameType(bi,Ai))(t,{wait:n,leading:r,trailing:u})}function gt(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},e=i.immediate,r=void 0!==e&&e;return new(t._ofSameType(Si,Vi))(t,{wait:n,immediate:r})}function Et(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ki;return new(t._ofSameType($i,Ci))(t,{fn:n})}function bt(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Li;return new(t._ofSameType(Ii,xi))(t,{fn:n})}function At(t){return new(t._ofSameType(Hi,Mi))(t)}function wt(t){return new(t._ofSameType(Ni,qi))(t)}function St(t){return new(t._ofSameType(Bi,ji))(t)}function Vt(t,n){return new(t._ofSameType(Fi,Qi))(t,{fn:n})}function Tt(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return new(t._ofSameType(Yi,Ki))(t,{min:i,max:n})}function $t(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},e=i.flushOnEnd,r=void 0===e||e;return new(t._ofSameType(Ji,Ri))(t,{fn:n||Xi,flushOnEnd:r})}function Ct(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},e=i.flushOnEnd,r=void 0===e||e;return new(t._ofSameType(te,ne))(t,{count:n,flushOnEnd:r})}function kt(t,n,i){var e=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=e.flushOnEnd,s=void 0===r||r;return new(t._ofSameType(ee,re))(t,{wait:n,count:i,flushOnEnd:s})}function Ot(t){return{"@@transducer/step":function(n,i){return t._emitValue(i),null},"@@transducer/result":function(){return t._emitEnd(),null}}}function It(t,n){return new(t._ofSameType(ue,oe))(t,{transducer:n})}function xt(t,n){return new(t._ofSameType(he,le))(t,{fn:n})}function Lt(t,n){var i=this;m.call(this),this._buffers=h(t,function(t){return _e(t)?o(t):[]}),this._sources=h(t,function(t){return _e(t)?g():t}),this._combinator=n?I(n,this._sources.length):function(t){return t},this._aliveCount=0,this._$handlers=[];for(var e=function(t){i._$handlers.push(function(n){return i._handleAny(t,n)})},r=0;r<this._sources.length;r++)e(r)}function Pt(t,n){return 0===t.length?g():new Lt(t,n)}function Ht(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=n.queueLim,e=void 0===i?0:i,r=n.concurLim,s=void 0===r?-1:r,u=n.drop,o=void 0===u?"new":u;m.call(this),this._queueLim=e<0?-1:e,this._concurLim=s<0?-1:s,this._drop=o,this._queue=[],this._curSources=[],this._$handleSubAny=function(n){return t._handleSubAny(n)},this._$endHandlers=[],this._currentlyAdding=null,0===this._concurLim&&this._emitEnd()}function Mt(t){Ht.call(this),this._addAll(t),this._initialised=!0}function Dt(t){return 0===t.length?g():new Mt(t)}function Nt(t){var n=this;m.call(this),this._generator=t,this._source=null,this._inLoop=!1,this._iteration=0,this._$handleAny=function(t){return n._handleAny(t)}}function qt(t){return new Nt(t)}function Wt(t){return qt(function(n){return t.length>n&&t[n]}).setName("concat")}function Bt(){Ht.call(this)}function jt(t,n,i){var e=this;Ht.call(this,i),this._source=t,this._fn=n,this._mainEnded=!1,this._lastCurrent=null,this._$handleMain=function(t){return e._handleMain(t)}}function Ut(t,n){jt.call(this,t,n)}function Ft(t,n){return function(i,e,r){var s=this;t.call(this),this._primary=i,this._secondary=e,this._name=i._name+"."+n,this._lastSecondary=on,this._$handleSecondaryAny=function(t){return s._handleSecondaryAny(t)},this._$handlePrimaryAny=function(t){return s._handlePrimaryAny(t)},this._init(r)}}function Qt(t){return{_init:function(){},_free:function(){},_handlePrimaryValue:function(t){this._emitValue(t)},_handlePrimaryError:function(t){this._emitError(t)},_handlePrimaryEnd:function(){this._emitEnd()},_handleSecondaryValue:function(t){this._lastSecondary=t},_handleSecondaryError:function(t){this._emitError(t)},_handleSecondaryEnd:function(){},_handlePrimaryAny:function(t){switch(t.type){case hn:return this._handlePrimaryValue(t.value);case ln:return this._handlePrimaryError(t.value);case an:return this._handlePrimaryEnd(t.value)}},_handleSecondaryAny:function(t){switch(t.type){case hn:return this._handleSecondaryValue(t.value);case ln:return this._handleSecondaryError(t.value);case an:this._handleSecondaryEnd(t.value),this._removeSecondary()}},_removeSecondary:function(){null!==this._secondary&&(this._secondary.offAny(this._$handleSecondaryAny),this._$handleSecondaryAny=null,this._secondary=null)},_onActivation:function(){null!==this._secondary&&this._secondary.onAny(this._$handleSecondaryAny),this._active&&this._primary.onAny(this._$handlePrimaryAny)},_onDeactivation:function(){null!==this._secondary&&this._secondary.offAny(this._$handleSecondaryAny),this._primary.offAny(this._$handlePrimaryAny)},_clear:function(){t.prototype._clear.call(this),this._primary=null,this._secondary=null,this._lastSecondary=null,this._$handleSecondaryAny=null,this._$handlePrimaryAny=null,this._free()}}}function zt(t,n){var i=Ft(m,t);return e(i,m,Qt(m),n),i}function Yt(t,n){var i=Ft(y,t);return e(i,y,Qt(y),n),i}function Kt(t,n){return new(t._ofSameType(de,ve))(t,n)}function Gt(t,n,i){var e=i?function(t,n){return i(n,t)}:pe;return et([n],[t],e).setName(t,"sampledBy")}function Jt(t,n){return new(t._ofSameType(ye,ge))(t,n)}function Rt(t,n){return new(t._ofSameType(be,Ae))(t,n)}function Xt(t,n,i){return new(t._ofSameType(Se,Ve))(t,n,i)}function Zt(t,n,i){return new(t._ofSameType($e,Ce))(t,n,i)}function tn(t,n){var i=Dt([rt(t,Oe),rt(n,ke)]);return i=ft(i),i=U(i,ke),i.setName(t,"awaiting")}function nn(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Pe;return new(t._ofSameType(xe,Le))(t,{fn:n})}function en(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ne;return new(t._ofSameType(Me,De))(t,{fn:n})}function rn(t){return new(t._ofSameType(We,Be))(t)}function sn(){Ue=!1}function un(t){if(Ue&&console&&"function"==typeof console.warn){var n="\nHere is an Error object for you containing the call stack:";console.warn(t,n,new Error)}}var on=["<nothing>"],an="end",hn="value",ln="error",_n="any";i(v.prototype,{add:function(t,n){return this._items=r(this._items,[{type:t,fn:n}]),this._items.length},remove:function(t,n){var i=u(this._items,function(i){return i.type===t&&i.fn===n});return 0!==this._inLoop&&i!==-1&&(null===this._removedItems&&(this._removedItems=[]),this._removedItems.push(this._items[i])),this._items=a(this._items,i),this._items.length},addSpy:function(t){return this._spies=r(this._spies,[t]),this._spies.length},removeSpy:function(t){return this._spies=a(this._spies,this._spies.indexOf(t)),this._spies.length},dispatch:function(t){this._inLoop++;for(var n=0,i=this._spies;null!==this._spies&&n<i.length;n++)i[n](t);for(var e=0,r=this._items;e<r.length&&null!==this._items;e++)null!==this._removedItems&&f(this._removedItems,r[e])||d(r[e].type,r[e].fn,t);this._inLoop--,0===this._inLoop&&(this._removedItems=null)},cleanup:function(){this._items=null,this._spies=null}}),i(p.prototype,{_name:"observable",_onActivation:function(){},_onDeactivation:function(){},_setActive:function(t){this._active!==t&&(this._active=t,t?(this._activating=!0,this._onActivation(),this._activating=!1):this._onDeactivation())},_clear:function(){this._setActive(!1),this._dispatcher.cleanup(),this._dispatcher=null,this._logHandlers=null},_emit:function(t,n){switch(t){case hn:return this._emitValue(n);case ln:return this._emitError(n);case an:return this._emitEnd()}},_emitValue:function(t){this._alive&&this._dispatcher.dispatch({type:hn,value:t})},_emitError:function(t){this._alive&&this._dispatcher.dispatch({type:ln,value:t})},_emitEnd:function(){this._alive&&(this._alive=!1,this._dispatcher.dispatch({type:an}),this._clear())},_on:function(t,n){return this._alive?(this._dispatcher.add(t,n),this._setActive(!0)):d(t,n,{type:an}),this},_off:function(t,n){if(this._alive){var i=this._dispatcher.remove(t,n);0===i&&this._setActive(!1)}return this},onValue:function(t){return this._on(hn,t)},onError:function(t){return this._on(ln,t)},onEnd:function(t){return this._on(an,t)},onAny:function(t){return this._on(_n,t)},offValue:function(t){return this._off(hn,t)},offError:function(t){return this._off(ln,t)},offEnd:function(t){return this._off(an,t)},offAny:function(t){return this._off(_n,t)},observe:function(t,n,i){var e=this,r=!1,s=t&&"function"!=typeof t?t:{value:t,error:n,end:i},u=function(t){t.type===an&&(r=!0),t.type===hn&&s.value?s.value(t.value):t.type===ln&&s.error?s.error(t.value):t.type===an&&s.end&&s.end(t.value)};return this.onAny(u),{unsubscribe:function(){r||(e.offAny(u),r=!0)},get closed(){return r}}},_ofSameType:function(t,n){return t.prototype.getType()===this.getType()?t:n},setName:function(t,n){return this._name=n?t._name+"."+n:t,this},log:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.toString(),n=void 0,i=function(i){var e="<"+i.type+(n?":current":"")+">";i.type===an?console.log(t,e):console.log(t,e,i.value)};return this._alive&&(this._logHandlers||(this._logHandlers=[]),this._logHandlers.push({name:t,handler:i})),n=!0,this.onAny(i),n=!1,this},offLog:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.toString();if(this._logHandlers){var n=u(this._logHandlers,function(n){return n.name===t});n!==-1&&(this.offAny(this._logHandlers[n].handler),this._logHandlers.splice(n,1))}return this},spy:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.toString(),n=function(n){var i="<"+n.type+">";n.type===an?console.log(t,i):console.log(t,i,n.value)};return this._alive&&(this._spyHandlers||(this._spyHandlers=[]),this._spyHandlers.push({name:t,handler:n}),this._dispatcher.addSpy(n)),this},offSpy:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.toString();if(this._spyHandlers){var n=u(this._spyHandlers,function(n){return n.name===t});n!==-1&&(this._dispatcher.removeSpy(this._spyHandlers[n].handler),this._spyHandlers.splice(n,1))}return this}}),p.prototype.toString=function(){return"["+this._name+"]"},e(m,p,{_name:"stream",getType:function(){return"stream"}}),e(y,p,{_name:"property",_emitValue:function(t){this._alive&&(this._currentEvent={type:hn,value:t},this._activating||this._dispatcher.dispatch({type:hn,value:t}))},_emitError:function(t){this._alive&&(this._currentEvent={type:ln,value:t},this._activating||this._dispatcher.dispatch({type:ln,value:t}))},_emitEnd:function(){this._alive&&(this._alive=!1,this._activating||this._dispatcher.dispatch({type:an}),this._clear())},_on:function(t,n){return this._alive&&(this._dispatcher.add(t,n),this._setActive(!0)),null!==this._currentEvent&&d(t,n,this._currentEvent),this._alive||d(t,n,{type:an}),this},getType:function(){return"property"}});var fn=new m;fn._emitEnd(),fn._name="never";var cn=E({_name:"later",_init:function(t){var n=t.x;this._x=n},_free:function(){this._x=null},_onTick:function(){this._emitValue(this._x),this._emitEnd()}}),dn=E({_name:"interval",_init:function(t){var n=t.x;this._x=n},_free:function(){this._x=null},_onTick:function(){this._emitValue(this._x)}}),vn=E({_name:"sequentially",_init:function(t){var n=t.xs;this._xs=o(n)},_free:function(){this._xs=null},_onTick:function(){1===this._xs.length?(this._emitValue(this._xs[0]),this._emitEnd()):this._emitValue(this._xs.shift())}}),pn=E({_name:"fromPoll",_init:function(t){var n=t.fn;this._fn=n},_free:function(){this._fn=null},_onTick:function(){var t=this._fn;this._emitValue(t())}}),mn=E({_name:"withInterval",_init:function(t){var n=t.fn;this._fn=n,this._emitter=V(this)},_free:function(){this._fn=null,this._emitter=null},_onTick:function(){var t=this._fn;t(this._emitter)}});e($,m,{_name:"stream",_onActivation:function(){var t=this._fn,n=t(V(this));this._unsubscribe="function"==typeof n?n:null,this._active||this._callUnsubscribe()},_callUnsubscribe:function(){null!==this._unsubscribe&&(this._unsubscribe(),this._unsubscribe=null)},_onDeactivation:function(){this._callUnsubscribe()},_clear:function(){m.prototype._clear.call(this),this._fn=null}});var yn=[["addEventListener","removeEventListener"],["addListener","removeListener"],["on","off"]];e(H,y,{_name:"constant",_active:!1,_activating:!1,_alive:!1,_dispatcher:null,_logHandlers:null}),e(D,y,{_name:"constantError",_active:!1,_activating:!1,_alive:!1,_dispatcher:null,_logHandlers:null});var gn=j("toProperty",{_init:function(t){var n=t.fn;this._getInitialCurrent=n},_onActivation:function(){if(null!==this._getInitialCurrent){var t=this._getInitialCurrent;this._emitValue(t())}this._source.onAny(this._$handleAny)}}),En=B("changes",{_handleValue:function(t){this._activating||this._emitValue(t)},_handleError:function(t){this._activating||this._emitError(t)}}),bn="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},An=K(function(t,n){function i(t){var n,i=t.Symbol;return"function"==typeof i?i.observable?n=i.observable:(n=i("observable"),i.observable=n):n="@@observable",n}Object.defineProperty(n,"__esModule",{value:!0}),n.default=i}),wn=An&&"object"==typeof An&&"default"in An?An.default:An,Sn=K(function(t,n){function i(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(n,"__esModule",{value:!0});var e,r=wn,s=i(r);e="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof bn?bn:"undefined"!=typeof t?t:Function("return this")();var u=(0,s.default)(e);n.default=u}),Vn=Sn&&"object"==typeof Sn&&"default"in Sn?Sn.default:Sn,Tn=K(function(t){t.exports=Vn}),$n=Tn&&"object"==typeof Tn&&"default"in Tn?Tn.default:Tn;i(J.prototype,{subscribe:function(t,n,i){var e=this,r="function"==typeof t?{next:t,error:n,complete:i}:t,s=function(t){t.type===an&&(u=!0),t.type===hn&&r.next?r.next(t.value):t.type===ln&&r.error?r.error(t.value):t.type===an&&r.complete&&r.complete(t.value)};this._observable.onAny(s);var u=!1,o={unsubscribe:function(){u=!0,e._observable.offAny(s)},get closed(){return u}};return o}}),J.prototype[$n]=function(){return this},e(tt,m,{_name:"combine",_onActivation:function(){this._aliveCount=this._activeCount;for(var t=this._activeCount;t<this._sources.length;t++)this._sources[t].onAny(this._$handlers[t]);for(var n=0;n<this._activeCount;n++)this._sources[n].onAny(this._$handlers[n]);this._emitAfterActivation&&(this._emitAfterActivation=!1,this._emitIfFull()),this._endAfterActivation&&this._emitEnd()},_onDeactivation:function(){var t=this._sources.length,n=void 0;for(n=0;n<t;n++)this._sources[n].offAny(this._$handlers[n])},_emitIfFull:function(){for(var t=!0,n=!1,i=this._latestValues.length,e=new Array(i),r=new Array(i),s=0;s<i;s++)e[s]=this._latestValues[s],r[s]=this._latestErrors[s],e[s]===on&&(t=!1),void 0!==r[s]&&(n=!0);if(t){var u=this._combinator;this._emitValue(u(e))}n&&this._emitError(Z(r))},_handleAny:function(t,n){n.type===hn||n.type===ln?(n.type===hn&&(this._latestValues[t]=n.value,this._latestErrors[t]=void 0),n.type===ln&&(this._latestValues[t]=on,this._latestErrors[t]={index:this._latestErrorIndex++,error:n.value}),t<this._activeCount&&(this._activating?this._emitAfterActivation=!0:this._emitIfFull())):t<this._activeCount&&(this._aliveCount--,0===this._aliveCount&&(this._activating?this._endAfterActivation=!0:this._emitEnd()))},_clear:function(){m.prototype._clear.call(this),this._sources=null,this._latestValues=null,this._latestErrors=null,this._combinator=null,this._$handlers=null}});var Cn={empty:function(){return g()},concat:function(t,n){return t.merge(n)},of:function(t){return M(t)},map:function(t,n){return n.map(t)},bimap:function(t,n,i){return i.mapErrors(t).map(n)},ap:function(t,n){return et([t,n],function(t,n){return t(n)})},chain:function(t,n){return n.flatMap(t)}},kn=Object.freeze({Observable:Cn}),On={_init:function(t){var n=t.fn;this._fn=n},_free:function(){this._fn=null},_handleValue:function(t){var n=this._fn;this._emitValue(n(t))}},In=B("map",On),xn=j("map",On),Ln=function(t){return t},Pn={_init:function(t){var n=t.fn;this._fn=n},_free:function(){this._fn=null},_handleValue:function(t){var n=this._fn;n(t)&&this._emitValue(t)}},Hn=B("filter",Pn),Mn=j("filter",Pn),Dn=function(t){return t},Nn={_init:function(t){var n=t.n;this._n=n,n<=0&&this._emitEnd()},_handleValue:function(t){this._n--,this._emitValue(t),0===this._n&&this._emitEnd()}},qn=B("take",Nn),Wn=j("take",Nn),Bn={_init:function(t){var n=t.n;this._n=n,n<=0&&this._emitEnd()},_handleError:function(t){this._n--,this._emitError(t),0===this._n&&this._emitEnd()}},jn=B("takeErrors",Bn),Un=j("takeErrors",Bn),Fn={_init:function(t){var n=t.fn;this._fn=n},_free:function(){this._fn=null},_handleValue:function(t){var n=this._fn;n(t)?this._emitValue(t):this._emitEnd()}},Qn=B("takeWhile",Fn),zn=j("takeWhile",Fn),Yn=function(t){return t},Kn={_init:function(){this._lastValue=on},_free:function(){this._lastValue=null},_handleValue:function(t){this._lastValue=t},_handleEnd:function(){this._lastValue!==on&&this._emitValue(this._lastValue),this._emitEnd()}},Gn=B("last",Kn),Jn=j("last",Kn),Rn={_init:function(t){var n=t.n;this._n=Math.max(0,n)},_handleValue:function(t){0===this._n?this._emitValue(t):this._n--}},Xn=B("skip",Rn),Zn=j("skip",Rn),ti={_init:function(t){var n=t.fn;this._fn=n},_free:function(){this._fn=null},_handleValue:function(t){var n=this._fn;null===this._fn||n(t)||(this._fn=null),null===this._fn&&this._emitValue(t)}},ni=B("skipWhile",ti),ii=j("skipWhile",ti),ei=function(t){return t},ri={_init:function(t){var n=t.fn;this._fn=n,this._prev=on},_free:function(){this._fn=null,this._prev=null},_handleValue:function(t){var n=this._fn;this._prev!==on&&n(this._prev,t)||(this._prev=t,this._emitValue(t))}},si=B("skipDuplicates",ri),ui=j("skipDuplicates",ri),oi=function(t,n){return t===n},ai={_init:function(t){var n=t.fn,i=t.seed;this._fn=n,this._prev=i},_free:function(){this._prev=null,this._fn=null},_handleValue:function(t){if(this._prev!==on){var n=this._fn;this._emitValue(n(this._prev,t))}this._prev=t}},hi=B("diff",ai),li=j("diff",ai),_i=j("scan",{_init:function(t){var n=t.fn,i=t.seed;this._fn=n,this._seed=i,i!==on&&this._emitValue(i)},_free:function(){this._fn=null,this._seed=null},_handleValue:function(t){var n=this._fn;null===this._currentEvent||this._currentEvent.type===ln?this._emitValue(this._seed===on?t:n(this._seed,t)):this._emitValue(n(this._currentEvent.value,t))}}),fi={_init:function(t){var n=t.fn;this._fn=n},_free:function(){this._fn=null},_handleValue:function(t){for(var n=this._fn,i=n(t),e=0;e<i.length;e++)this._emitValue(i[e])}},ci=B("flatten",fi),di=function(t){return t},vi={},pi={_init:function(t){var n=this,i=t.wait;this._wait=Math.max(0,i),this._buff=[],this._$shiftBuff=function(){var t=n._buff.shift();t===vi?n._emitEnd():n._emitValue(t)}},_free:function(){this._buff=null,this._$shiftBuff=null},_handleValue:function(t){this._activating?this._emitValue(t):(this._buff.push(t),setTimeout(this._$shiftBuff,this._wait))},_handleEnd:function(){this._activating?this._emitEnd():(this._buff.push(vi),setTimeout(this._$shiftBuff,this._wait))}},mi=B("delay",pi),yi=j("delay",pi),gi=Date.now?function(){return Date.now()}:function(){return(new Date).getTime()},Ei={_init:function(t){var n=this,i=t.wait,e=t.leading,r=t.trailing;this._wait=Math.max(0,i),this._leading=e,this._trailing=r,this._trailingValue=null,this._timeoutId=null,this._endLater=!1,this._lastCallTime=0,this._$trailingCall=function(){return n._trailingCall()}},_free:function(){this._trailingValue=null,this._$trailingCall=null},_handleValue:function(t){if(this._activating)this._emitValue(t);else{var n=gi();0!==this._lastCallTime||this._leading||(this._lastCallTime=n);var i=this._wait-(n-this._lastCallTime);i<=0?(this._cancelTrailing(),this._lastCallTime=n,this._emitValue(t)):this._trailing&&(this._cancelTrailing(),this._trailingValue=t,this._timeoutId=setTimeout(this._$trailingCall,i))}},_handleEnd:function(){this._activating?this._emitEnd():this._timeoutId?this._endLater=!0:this._emitEnd()},_cancelTrailing:function(){null!==this._timeoutId&&(clearTimeout(this._timeoutId),this._timeoutId=null)},_trailingCall:function(){this._emitValue(this._trailingValue),this._timeoutId=null,this._trailingValue=null,this._lastCallTime=this._leading?gi():0,this._endLater&&this._emitEnd()}},bi=B("throttle",Ei),Ai=j("throttle",Ei),wi={_init:function(t){var n=this,i=t.wait,e=t.immediate;this._wait=Math.max(0,i),this._immediate=e,this._lastAttempt=0,this._timeoutId=null,this._laterValue=null,this._endLater=!1,this._$later=function(){return n._later()}},_free:function(){this._laterValue=null,this._$later=null},_handleValue:function(t){this._activating?this._emitValue(t):(this._lastAttempt=gi(),this._immediate&&!this._timeoutId&&this._emitValue(t),this._timeoutId||(this._timeoutId=setTimeout(this._$later,this._wait)),this._immediate||(this._laterValue=t))},_handleEnd:function(){this._activating?this._emitEnd():this._timeoutId&&!this._immediate?this._endLater=!0:this._emitEnd()},_later:function(){var t=gi()-this._lastAttempt;t<this._wait&&t>=0?this._timeoutId=setTimeout(this._$later,this._wait-t):(this._timeoutId=null,this._immediate||(this._emitValue(this._laterValue),this._laterValue=null),this._endLater&&this._emitEnd())}},Si=B("debounce",wi),Vi=j("debounce",wi),Ti={_init:function(t){var n=t.fn;this._fn=n},_free:function(){this._fn=null},_handleError:function(t){var n=this._fn;this._emitError(n(t))}},$i=B("mapErrors",Ti),Ci=j("mapErrors",Ti),ki=function(t){return t},Oi={_init:function(t){var n=t.fn;this._fn=n},_free:function(){this._fn=null},_handleError:function(t){var n=this._fn;n(t)&&this._emitError(t)}},Ii=B("filterErrors",Oi),xi=j("filterErrors",Oi),Li=function(t){return t},Pi={_handleValue:function(){}},Hi=B("ignoreValues",Pi),Mi=j("ignoreValues",Pi),Di={_handleError:function(){}},Ni=B("ignoreErrors",Di),qi=j("ignoreErrors",Di),Wi={_handleEnd:function(){}},Bi=B("ignoreEnd",Wi),ji=j("ignoreEnd",Wi),Ui={_init:function(t){var n=t.fn;this._fn=n},_free:function(){this._fn=null},_handleEnd:function(){var t=this._fn;this._emitValue(t()),this._emitEnd()}},Fi=B("beforeEnd",Ui),Qi=j("beforeEnd",Ui),zi={_init:function(t){var n=t.min,i=t.max;this._max=i,this._min=n,this._buff=[]},_free:function(){this._buff=null},_handleValue:function(t){this._buff=c(this._buff,t,this._max),this._buff.length>=this._min&&this._emitValue(this._buff)}},Yi=B("slidingWindow",zi),Ki=j("slidingWindow",zi),Gi={_init:function(t){var n=t.fn,i=t.flushOnEnd;this._fn=n,this._flushOnEnd=i,this._buff=[]},_free:function(){this._buff=null},_flush:function(){null!==this._buff&&0!==this._buff.length&&(this._emitValue(this._buff),this._buff=[])},_handleValue:function(t){this._buff.push(t);var n=this._fn;n(t)||this._flush();
},_handleEnd:function(){this._flushOnEnd&&this._flush(),this._emitEnd()}},Ji=B("bufferWhile",Gi),Ri=j("bufferWhile",Gi),Xi=function(t){return t},Zi={_init:function(t){var n=t.count,i=t.flushOnEnd;this._count=n,this._flushOnEnd=i,this._buff=[]},_free:function(){this._buff=null},_flush:function(){null!==this._buff&&0!==this._buff.length&&(this._emitValue(this._buff),this._buff=[])},_handleValue:function(t){this._buff.push(t),this._buff.length>=this._count&&this._flush()},_handleEnd:function(){this._flushOnEnd&&this._flush(),this._emitEnd()}},te=B("bufferWithCount",Zi),ne=j("bufferWithCount",Zi),ie={_init:function(t){var n=this,i=t.wait,e=t.count,r=t.flushOnEnd;this._wait=i,this._count=e,this._flushOnEnd=r,this._intervalId=null,this._$onTick=function(){return n._flush()},this._buff=[]},_free:function(){this._$onTick=null,this._buff=null},_flush:function(){null!==this._buff&&(this._emitValue(this._buff),this._buff=[])},_handleValue:function(t){this._buff.push(t),this._buff.length>=this._count&&(clearInterval(this._intervalId),this._flush(),this._intervalId=setInterval(this._$onTick,this._wait))},_handleEnd:function(){this._flushOnEnd&&0!==this._buff.length&&this._flush(),this._emitEnd()},_onActivation:function(){this._intervalId=setInterval(this._$onTick,this._wait),this._source.onAny(this._$handleAny)},_onDeactivation:function(){null!==this._intervalId&&(clearInterval(this._intervalId),this._intervalId=null),this._source.offAny(this._$handleAny)}},ee=B("bufferWithTimeOrCount",ie),re=j("bufferWithTimeOrCount",ie),se={_init:function(t){var n=t.transducer;this._xform=n(Ot(this))},_free:function(){this._xform=null},_handleValue:function(t){null!==this._xform["@@transducer/step"](null,t)&&this._xform["@@transducer/result"](null)},_handleEnd:function(){this._xform["@@transducer/result"](null)}},ue=B("transduce",se),oe=j("transduce",se),ae={_init:function(t){var n=t.fn;this._handler=n,this._emitter=V(this)},_free:function(){this._handler=null,this._emitter=null},_handleAny:function(t){this._handler(this._emitter,t)}},he=B("withHandler",ae),le=j("withHandler",ae),_e=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};e(Lt,m,{_name:"zip",_onActivation:function(){for(;this._isFull();)this._emit();var t=this._sources.length;this._aliveCount=t;for(var n=0;n<t&&this._active;n++)this._sources[n].onAny(this._$handlers[n])},_onDeactivation:function(){for(var t=0;t<this._sources.length;t++)this._sources[t].offAny(this._$handlers[t])},_emit:function(){for(var t=new Array(this._buffers.length),n=0;n<this._buffers.length;n++)t[n]=this._buffers[n].shift();var i=this._combinator;this._emitValue(i(t))},_isFull:function(){for(var t=0;t<this._buffers.length;t++)if(0===this._buffers[t].length)return!1;return!0},_handleAny:function(t,n){n.type===hn&&(this._buffers[t].push(n.value),this._isFull()&&this._emit()),n.type===ln&&this._emitError(n.value),n.type===an&&(this._aliveCount--,0===this._aliveCount&&this._emitEnd())},_clear:function(){m.prototype._clear.call(this),this._sources=null,this._buffers=null,this._combinator=null,this._$handlers=null}});var fe=function(t){return t};e(Ht,m,{_name:"abstractPool",_add:function(t,n){n=n||fe,this._concurLim===-1||this._curSources.length<this._concurLim?this._addToCur(n(t)):this._queueLim===-1||this._queue.length<this._queueLim?this._addToQueue(n(t)):"old"===this._drop&&(this._removeOldest(),this._add(t,n))},_addAll:function(t){var n=this;l(t,function(t){return n._add(t)})},_remove:function(t){this._removeCur(t)===-1&&this._removeQueue(t)},_addToQueue:function(t){this._queue=r(this._queue,[t])},_addToCur:function(t){if(this._active){if(!t._alive)return void(t._currentEvent&&this._emit(t._currentEvent.type,t._currentEvent.value));this._currentlyAdding=t,t.onAny(this._$handleSubAny),this._currentlyAdding=null,t._alive&&(this._curSources=r(this._curSources,[t]),this._active&&this._subToEnd(t))}else this._curSources=r(this._curSources,[t])},_subToEnd:function(t){var n=this,i=function(){return n._removeCur(t)};this._$endHandlers.push({obs:t,handler:i}),t.onEnd(i)},_subscribe:function(t){t.onAny(this._$handleSubAny),this._active&&this._subToEnd(t)},_unsubscribe:function(t){t.offAny(this._$handleSubAny);var n=u(this._$endHandlers,function(n){return n.obs===t});n!==-1&&(t.offEnd(this._$endHandlers[n].handler),this._$endHandlers.splice(n,1))},_handleSubAny:function(t){t.type===hn?this._emitValue(t.value):t.type===ln&&this._emitError(t.value)},_removeQueue:function(t){var n=s(this._queue,t);return this._queue=a(this._queue,n),n},_removeCur:function(t){this._active&&this._unsubscribe(t);var n=s(this._curSources,t);return this._curSources=a(this._curSources,n),n!==-1&&(0!==this._queue.length?this._pullQueue():0===this._curSources.length&&this._onEmpty()),n},_removeOldest:function(){this._removeCur(this._curSources[0])},_pullQueue:function(){0!==this._queue.length&&(this._queue=o(this._queue),this._addToCur(this._queue.shift()))},_onActivation:function(){for(var t=0,n=this._curSources;t<n.length&&this._active;t++)this._subscribe(n[t])},_onDeactivation:function(){for(var t=0,n=this._curSources;t<n.length;t++)this._unsubscribe(n[t]);null!==this._currentlyAdding&&this._unsubscribe(this._currentlyAdding)},_isEmpty:function(){return 0===this._curSources.length},_onEmpty:function(){},_clear:function(){m.prototype._clear.call(this),this._queue=null,this._curSources=null,this._$handleSubAny=null,this._$endHandlers=null}}),e(Mt,Ht,{_name:"merge",_onEmpty:function(){this._initialised&&this._emitEnd()}}),e(Nt,m,{_name:"repeat",_handleAny:function(t){t.type===an?(this._source=null,this._getSource()):this._emit(t.type,t.value)},_getSource:function(){if(!this._inLoop){this._inLoop=!0;for(var t=this._generator;null===this._source&&this._alive&&this._active;)this._source=t(this._iteration++),this._source?this._source.onAny(this._$handleAny):this._emitEnd();this._inLoop=!1}},_onActivation:function(){this._source?this._source.onAny(this._$handleAny):this._getSource()},_onDeactivation:function(){this._source&&this._source.offAny(this._$handleAny)},_clear:function(){m.prototype._clear.call(this),this._generator=null,this._source=null,this._$handleAny=null}}),e(Bt,Ht,{_name:"pool",plug:function(t){return this._add(t),this},unplug:function(t){return this._remove(t),this}}),e(jt,Ht,{_onActivation:function(){Ht.prototype._onActivation.call(this),this._active&&this._source.onAny(this._$handleMain)},_onDeactivation:function(){Ht.prototype._onDeactivation.call(this),this._source.offAny(this._$handleMain),this._hadNoEvSinceDeact=!0},_handleMain:function(t){if(t.type===hn){var n=this._activating&&this._hadNoEvSinceDeact&&this._lastCurrent===t.value;n||this._add(t.value,this._fn),this._lastCurrent=t.value,this._hadNoEvSinceDeact=!1}t.type===ln&&this._emitError(t.value),t.type===an&&(this._isEmpty()?this._emitEnd():this._mainEnded=!0)},_onEmpty:function(){this._mainEnded&&this._emitEnd()},_clear:function(){Ht.prototype._clear.call(this),this._source=null,this._lastCurrent=null,this._$handleMain=null}}),e(Ut,jt,{_handleMain:function(t){if(t.type===ln){var n=this._activating&&this._hadNoEvSinceDeact&&this._lastCurrent===t.value;n||this._add(t.value,this._fn),this._lastCurrent=t.value,this._hadNoEvSinceDeact=!1}t.type===hn&&this._emitValue(t.value),t.type===an&&(this._isEmpty()?this._emitEnd():this._mainEnded=!0)}});var ce={_handlePrimaryValue:function(t){this._lastSecondary!==on&&this._lastSecondary&&this._emitValue(t)},_handleSecondaryEnd:function(){this._lastSecondary!==on&&this._lastSecondary||this._emitEnd()}},de=zt("filterBy",ce),ve=Yt("filterBy",ce),pe=function(t,n){return n},me={_handlePrimaryValue:function(t){this._lastSecondary!==on&&this._emitValue(t)},_handleSecondaryEnd:function(){this._lastSecondary===on&&this._emitEnd()}},ye=zt("skipUntilBy",me),ge=Yt("skipUntilBy",me),Ee={_handleSecondaryValue:function(){this._emitEnd()}},be=zt("takeUntilBy",Ee),Ae=Yt("takeUntilBy",Ee),we={_init:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.flushOnEnd,i=void 0===n||n;this._buff=[],this._flushOnEnd=i},_free:function(){this._buff=null},_flush:function(){null!==this._buff&&(this._emitValue(this._buff),this._buff=[])},_handlePrimaryEnd:function(){this._flushOnEnd&&this._flush(),this._emitEnd()},_onActivation:function(){this._primary.onAny(this._$handlePrimaryAny),this._alive&&null!==this._secondary&&this._secondary.onAny(this._$handleSecondaryAny)},_handlePrimaryValue:function(t){this._buff.push(t)},_handleSecondaryValue:function(){this._flush()},_handleSecondaryEnd:function(){this._flushOnEnd||this._emitEnd()}},Se=zt("bufferBy",we),Ve=Yt("bufferBy",we),Te={_init:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.flushOnEnd,i=void 0===n||n,e=t.flushOnChange,r=void 0!==e&&e;this._buff=[],this._flushOnEnd=i,this._flushOnChange=r},_free:function(){this._buff=null},_flush:function(){null!==this._buff&&(this._emitValue(this._buff),this._buff=[])},_handlePrimaryEnd:function(){this._flushOnEnd&&this._flush(),this._emitEnd()},_handlePrimaryValue:function(t){this._buff.push(t),this._lastSecondary===on||this._lastSecondary||this._flush()},_handleSecondaryEnd:function(){this._flushOnEnd||this._lastSecondary!==on&&!this._lastSecondary||this._emitEnd()},_handleSecondaryValue:function(t){this._flushOnChange&&!t&&this._flush(),this._lastSecondary=t}},$e=zt("bufferWhileBy",Te),Ce=Yt("bufferWhileBy",Te),ke=function(){return!1},Oe=function(){return!0},Ie={_init:function(t){var n=t.fn;this._fn=n},_free:function(){this._fn=null},_handleValue:function(t){var n=this._fn,i=n(t);i.convert?this._emitError(i.error):this._emitValue(t)}},xe=B("valuesToErrors",Ie),Le=j("valuesToErrors",Ie),Pe=function(t){return{convert:!0,error:t}},He={_init:function(t){var n=t.fn;this._fn=n},_free:function(){this._fn=null},_handleError:function(t){var n=this._fn,i=n(t);i.convert?this._emitValue(i.value):this._emitError(t)}},Me=B("errorsToValues",He),De=j("errorsToValues",He),Ne=function(t){return{convert:!0,value:t}},qe={_handleError:function(t){this._emitError(t),this._emitEnd()}},We=B("endOnError",qe),Be=j("endOnError",qe);p.prototype.toProperty=function(t){return U(this,t)},p.prototype.changes=function(){return F(this)},p.prototype.toPromise=function(t){return Y(this,t)},p.prototype.toESObservable=R,p.prototype[$n]=R,p.prototype.map=function(t){return rt(this,t)},p.prototype.filter=function(t){return st(this,t)},p.prototype.take=function(t){return ut(this,t)},p.prototype.takeErrors=function(t){return ot(this,t)},p.prototype.takeWhile=function(t){return at(this,t)},p.prototype.last=function(){return ht(this)},p.prototype.skip=function(t){return lt(this,t)},p.prototype.skipWhile=function(t){return _t(this,t)},p.prototype.skipDuplicates=function(t){return ft(this,t)},p.prototype.diff=function(t,n){return dt(this,t,n)},p.prototype.scan=function(t,n){return vt(this,t,n)},p.prototype.flatten=function(t){return pt(this,t)},p.prototype.delay=function(t){return mt(this,t)},p.prototype.throttle=function(t,n){return yt(this,t,n)},p.prototype.debounce=function(t,n){return gt(this,t,n)},p.prototype.mapErrors=function(t){return Et(this,t)},p.prototype.filterErrors=function(t){return bt(this,t)},p.prototype.ignoreValues=function(){return At(this)},p.prototype.ignoreErrors=function(){return wt(this)},p.prototype.ignoreEnd=function(){return St(this)},p.prototype.beforeEnd=function(t){return Vt(this,t)},p.prototype.slidingWindow=function(t,n){return Tt(this,t,n)},p.prototype.bufferWhile=function(t,n){return $t(this,t,n)},p.prototype.bufferWithCount=function(t,n){return Ct(this,t,n)},p.prototype.bufferWithTimeOrCount=function(t,n,i){return kt(this,t,n,i)},p.prototype.transduce=function(t){return It(this,t)},p.prototype.withHandler=function(t){return xt(this,t)},p.prototype.combine=function(t,n){return et([this,t],n)},p.prototype.zip=function(t,n){return Pt([this,t],n)},p.prototype.merge=function(t){return Dt([this,t])},p.prototype.concat=function(t){return Wt([this,t])};var je=function(){return new Bt};p.prototype.flatMap=function(t){return new jt(this,t).setName(this,"flatMap")},p.prototype.flatMapLatest=function(t){return new jt(this,t,{concurLim:1,drop:"old"}).setName(this,"flatMapLatest")},p.prototype.flatMapFirst=function(t){return new jt(this,t,{concurLim:1}).setName(this,"flatMapFirst")},p.prototype.flatMapConcat=function(t){return new jt(this,t,{queueLim:-1,concurLim:1}).setName(this,"flatMapConcat")},p.prototype.flatMapConcurLimit=function(t,n){return new jt(this,t,{queueLim:-1,concurLim:n}).setName(this,"flatMapConcurLimit")},p.prototype.flatMapErrors=function(t){return new Ut(this,t).setName(this,"flatMapErrors")},p.prototype.filterBy=function(t){return Kt(this,t)},p.prototype.sampledBy=function(t,n){return Gt(this,t,n)},p.prototype.skipUntilBy=function(t){return Jt(this,t)},p.prototype.takeUntilBy=function(t){return Rt(this,t)},p.prototype.bufferBy=function(t,n){return Xt(this,t,n)},p.prototype.bufferWhileBy=function(t,n){return Zt(this,t,n)};var Ue=!0;p.prototype.awaiting=function(t){return un("You are using deprecated .awaiting() method, see https://github.com/rpominov/kefir/issues/145"),tn(this,t)},p.prototype.valuesToErrors=function(t){return un("You are using deprecated .valuesToErrors() method, see https://github.com/rpominov/kefir/issues/149"),nn(this,t)},p.prototype.errorsToValues=function(t){return un("You are using deprecated .errorsToValues() method, see https://github.com/rpominov/kefir/issues/149"),en(this,t)},p.prototype.endOnError=function(){return un("You are using deprecated .endOnError() method, see https://github.com/rpominov/kefir/issues/150"),rn(this)};var Fe={Observable:p,Stream:m,Property:y,never:g,later:b,interval:A,sequentially:w,fromPoll:S,withInterval:T,fromCallback:k,fromNodeCallback:O,fromEvents:P,stream:C,constant:M,constantError:N,fromPromise:Q,fromESObservable:G,combine:et,zip:Pt,merge:Dt,concat:Wt,Pool:Bt,pool:je,repeat:qt,staticLand:kn};Fe.Kefir=Fe,t.dissableDeprecationWarnings=sn,t.Kefir=Fe,t.Observable=p,t.Stream=m,t.Property=y,t.never=g,t.later=b,t.interval=A,t.sequentially=w,t.fromPoll=S,t.withInterval=T,t.fromCallback=k,t.fromNodeCallback=O,t.fromEvents=P,t.stream=C,t.constant=M,t.constantError=N,t.fromPromise=Q,t.fromESObservable=G,t.combine=et,t.zip=Pt,t.merge=Dt,t.concat=Wt,t.Pool=Bt,t.pool=je,t.repeat=qt,t.staticLand=kn,t.default=Fe,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=kefir.min.js.map
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(t.Kefir=t.Kefir||{})}(this,function(t){"use strict";function n(t){var n=function(){};return n.prototype=t,new n}function i(t){var n=arguments.length,i=void 0,e=void 0;for(i=1;i<n;i++)for(e in arguments[i])t[e]=arguments[i][e];return t}function e(t,e){var r=arguments.length,s=void 0;for(t.prototype=n(e.prototype),t.prototype.constructor=t,s=2;s<r;s++)i(t.prototype,arguments[s]);return t}function r(t,n){var i=void 0,e=void 0,r=void 0,s=void 0;if(0===t.length)return n;if(0===n.length)return t;for(s=0,i=new Array(t.length+n.length),e=t.length,r=0;r<e;r++,s++)i[s]=t[r];for(e=n.length,r=0;r<e;r++,s++)i[s]=n[r];return i}function s(t,n){var i=t.length,e=void 0;for(e=0;e<i;e++)if(t[e]===n)return e;return-1}function u(t,n){var i=t.length,e=void 0;for(e=0;e<i;e++)if(n(t[e]))return e;return-1}function o(t){var n=t.length,i=new Array(n),e=void 0;for(e=0;e<n;e++)i[e]=t[e];return i}function a(t,n){var i=t.length,e=void 0,r=void 0,s=void 0;if(n>=0&&n<i){if(1===i)return[];for(e=new Array(i-1),r=0,s=0;r<i;r++)r!==n&&(e[s]=t[r],s++);return e}return t}function h(t,n){var i=t.length,e=new Array(i),r=void 0;for(r=0;r<i;r++)e[r]=n(t[r]);return e}function l(t,n){var i=t.length,e=void 0;for(e=0;e<i;e++)n(t[e])}function _(t,n){var i=t.length,e=void 0;for(e=0;e<i;e++)t[e]=n}function f(t,n){return-1!==s(t,n)}function c(t,n,i){var e=Math.min(i,t.length+1),r=t.length-e+1,s=new Array(e),u=void 0;for(u=r;u<e;u++)s[u-r]=t[u];return s[e-1]=n,s}function d(t,n,i){t===hn?n(i):t===i.type&&(t===on||t===an?n(i.value):n())}function v(){this._items=[],this._spies=[],this._inLoop=0,this._removedItems=null}function m(){this._dispatcher=new v,this._active=!1,this._alive=!0,this._activating=!1,this._logHandlers=null,this._spyHandlers=null}function p(){m.call(this)}function y(){m.call(this),this._currentEvent=null}function g(){return ln}function E(t){function n(t,n){var i=this;p.call(this),this._wait=t,this._intervalId=null,this._$onTick=function(){return i._onTick()},this._init(n)}return e(n,p,{_init:function(){},_free:function(){},_onTick:function(){},_onActivation:function(){this._intervalId=setInterval(this._$onTick,this._wait)},_onDeactivation:function(){null!==this._intervalId&&(clearInterval(this._intervalId),this._intervalId=null)},_clear:function(){p.prototype._clear.call(this),this._$onTick=null,this._free()}},t),n}function b(t,n){return new _n(t,{x:n})}function A(t,n){return new fn(t,{x:n})}function w(t,n){return 0===n.length?g():new cn(t,{xs:n})}function S(t,n){return new dn(t,{fn:n})}function V(t){function n(n){return t._emitValue(n),t._active}function i(n){return t._emitError(n),t._active}function e(){return t._emitEnd(),t._active}function r(n){return t._emit(n.type,n.value),t._active}return{value:n,error:i,end:e,event:r,emit:n,emitEvent:r}}function T(t,n){return new vn(t,{fn:n})}function $(t){p.call(this),this._fn=t,this._unsubscribe=null}function C(t){return new $(t)}function k(t){var n=!1;return C(function(i){n||(t(function(t){i.emit(t),i.end()}),n=!0)}).setName("fromCallback")}function O(t){var n=!1;return C(function(i){n||(t(function(t,n){t?i.error(t):i.emit(n),i.end()}),n=!0)}).setName("fromNodeCallback")}function I(t,n){switch(n){case 0:return function(){return t()};case 1:return function(n){return t(n[0])};case 2:return function(n){return t(n[0],n[1])};case 3:return function(n){return t(n[0],n[1],n[2])};case 4:return function(n){return t(n[0],n[1],n[2],n[3])};default:return function(n){return t.apply(null,n)}}}function x(t,n,i){var e=i?i.length:0;if(null==n)switch(e){case 0:return t();case 1:return t(i[0]);case 2:return t(i[0],i[1]);case 3:return t(i[0],i[1],i[2]);case 4:return t(i[0],i[1],i[2],i[3]);default:return t.apply(null,i)}else switch(e){case 0:return t.call(n);default:return t.apply(n,i)}}function L(t,n,i){return C(function(e){var r=i?function(){e.emit(x(i,this,arguments))}:function(t){e.emit(t)};return t(r),function(){return n(r)}}).setName("fromSubUnsub")}function P(t,n,i){for(var e=void 0,r=void 0,s=0;s<mn.length;s++)if("function"==typeof t[mn[s][0]]&&"function"==typeof t[mn[s][1]]){e=mn[s][0],r=mn[s][1];break}if(void 0===e)throw new Error("target don't support any of addEventListener/removeEventListener, addListener/removeListener, on/off method pair");return L(function(i){return t[e](n,i)},function(i){return t[r](n,i)},i).setName("fromEvents")}function H(t){this._currentEvent={type:"value",value:t,current:!0}}function M(t){return new H(t)}function D(t){this._currentEvent={type:"error",value:t,current:!0}}function N(t){return new D(t)}function q(t,n){return function(i,e){var r=this;t.call(this),this._source=i,this._name=i._name+"."+n,this._init(e),this._$handleAny=function(t){return r._handleAny(t)}}}function W(t){return{_init:function(){},_free:function(){},_handleValue:function(t){this._emitValue(t)},_handleError:function(t){this._emitError(t)},_handleEnd:function(){this._emitEnd()},_handleAny:function(t){switch(t.type){case on:return this._handleValue(t.value);case an:return this._handleError(t.value);case un:return this._handleEnd()}},_onActivation:function(){this._source.onAny(this._$handleAny)},_onDeactivation:function(){this._source.offAny(this._$handleAny)},_clear:function(){t.prototype._clear.call(this),this._source=null,this._$handleAny=null,this._free()}}}function B(t,n){var i=q(p,t);return e(i,p,W(p),n),i}function j(t,n){var i=q(y,t);return e(i,y,W(y),n),i}function U(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(null!==n&&"function"!=typeof n)throw new Error("You should call toProperty() with a function or no arguments.");return new pn(t,{fn:n})}function F(t){return new yn(t)}function Q(t){var n=!1;return U(C(function(i){if(!n){var e=function(t){i.emit(t),i.end()},r=function(t){i.error(t),i.end()},s=t.then(e,r);s&&"function"==typeof s.done&&s.done(),n=!0}}),null).setName("fromPromise")}function z(){if("function"==typeof Promise)return Promise;throw new Error("There isn't default Promise, use shim or parameter")}function Y(t,n){return n={exports:{}},t(n,n.exports),n.exports}function K(t){var n=t[Sn]?t[Sn]():t;return C(function(t){var i=n.subscribe({error:function(n){t.error(n),t.end()},next:function(n){t.emit(n)},complete:function(){t.end()}});return i.unsubscribe?function(){i.unsubscribe()}:i}).setName("fromESObservable")}function G(t){this._observable=t.takeErrors(1)}function J(){return new G(this)}function R(t,n,i){for(var e in t)t.hasOwnProperty(e)&&(n.push(e),i.push(t[e]))}function X(t){for(var n=void 0,i=0;i<t.length;i++)void 0!==t[i]&&(void 0===n||n.index<t[i].index)&&(n=t[i]);return n.error}function Z(t,n,i){var e=this;p.call(this),this._activeCount=t.length,this._sources=r(t,n),this._combinator=i,this._aliveCount=0,this._latestValues=new Array(this._sources.length),this._latestErrors=new Array(this._sources.length),_(this._latestValues,sn),this._emitAfterActivation=!1,this._endAfterActivation=!1,this._latestErrorIndex=0,this._$handlers=[];for(var s=0;s<this._sources.length;s++)!function(t){e._$handlers.push(function(n){return e._handleAny(t,n)})}(s)}function tt(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments[2];if(!Array.isArray(n))throw new Error("Combine can only combine active and passive collections of the same type.");return i=i?I(i,t.length+n.length):function(t){return t},0===t.length?g():new Z(t,n,i)}function nt(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments[2];if("object"!=typeof n||Array.isArray(n))throw new Error("Combine can only combine active and passive collections of the same type.");var e=[],r=[],s=[];R(t,e,r),R(n,e,s);var u=function(t){for(var n={},r=t.length-1;0<=r;r--)n[e[r]]=t[r];return i?i(n):n};return 0===r.length?g():new Z(r,s,u)}function it(t,n,i){return"function"==typeof n&&(i=n,n=void 0),Array.isArray(t)?tt(t,n,i):nt(t,n,i)}function et(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:On;return new(t._ofSameType(Cn,kn))(t,{fn:n})}function rt(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Pn;return new(t._ofSameType(xn,Ln))(t,{fn:n})}function st(t,n){return new(t._ofSameType(Mn,Dn))(t,{n:n})}function ut(t,n){return new(t._ofSameType(qn,Wn))(t,{n:n})}function ot(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Fn;return new(t._ofSameType(jn,Un))(t,{fn:n})}function at(t){return new(t._ofSameType(zn,Yn))(t)}function ht(t,n){return new(t._ofSameType(Gn,Jn))(t,{n:n})}function lt(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ti;return new(t._ofSameType(Xn,Zn))(t,{fn:n})}function _t(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ri;return new(t._ofSameType(ii,ei))(t,{fn:n})}function ft(t,n){return[t,n]}function ct(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:sn;return new(t._ofSameType(ui,oi))(t,{fn:n||ft,seed:i})}function dt(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:sn;return new ai(t,{fn:n,seed:i})}function vt(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:_i;return new li(t,{fn:n})}function mt(t,n){return new(t._ofSameType(di,vi))(t,{wait:n})}function pt(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},e=i.leading,r=void 0===e||e,s=i.trailing,u=void 0===s||s;return new(t._ofSameType(yi,gi))(t,{wait:n,leading:r,trailing:u})}function yt(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},e=i.immediate,r=void 0!==e&&e;return new(t._ofSameType(bi,Ai))(t,{wait:n,immediate:r})}function gt(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ti;return new(t._ofSameType(Si,Vi))(t,{fn:n})}function Et(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Oi;return new(t._ofSameType(Ci,ki))(t,{fn:n})}function bt(t){return new(t._ofSameType(xi,Li))(t)}function At(t){return new(t._ofSameType(Hi,Mi))(t)}function wt(t){return new(t._ofSameType(Ni,qi))(t)}function St(t,n){return new(t._ofSameType(Bi,ji))(t,{fn:n})}function Vt(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return new(t._ofSameType(Fi,Qi))(t,{min:i,max:n})}function Tt(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},e=i.flushOnEnd,r=void 0===e||e;return new(t._ofSameType(Yi,Ki))(t,{fn:n||Gi,flushOnEnd:r})}function $t(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},e=i.flushOnEnd,r=void 0===e||e;return new(t._ofSameType(Ri,Xi))(t,{count:n,flushOnEnd:r})}function Ct(t,n,i){var e=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=e.flushOnEnd,s=void 0===r||r;return new(t._ofSameType(te,ne))(t,{wait:n,count:i,flushOnEnd:s})}function kt(t){return{"@@transducer/step":function(n,i){return t._emitValue(i),null},"@@transducer/result":function(){return t._emitEnd(),null}}}function Ot(t,n){return new(t._ofSameType(ee,re))(t,{transducer:n})}function It(t,n){return new(t._ofSameType(ue,oe))(t,{fn:n})}function xt(t,n){var i=this;p.call(this),this._buffers=h(t,function(t){return ae(t)?o(t):[]}),this._sources=h(t,function(t){return ae(t)?g():t}),this._combinator=n?I(n,this._sources.length):function(t){return t},this._aliveCount=0,this._$handlers=[];for(var e=0;e<this._sources.length;e++)!function(t){i._$handlers.push(function(n){return i._handleAny(t,n)})}(e)}function Lt(t,n){return 0===t.length?g():new xt(t,n)}function Pt(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=n.queueLim,e=void 0===i?0:i,r=n.concurLim,s=void 0===r?-1:r,u=n.drop,o=void 0===u?"new":u;p.call(this),this._queueLim=e<0?-1:e,this._concurLim=s<0?-1:s,this._drop=o,this._queue=[],this._curSources=[],this._$handleSubAny=function(n){return t._handleSubAny(n)},this._$endHandlers=[],this._currentlyAdding=null,0===this._concurLim&&this._emitEnd()}function Ht(t){Pt.call(this),this._addAll(t),this._initialised=!0}function Mt(t){return 0===t.length?g():new Ht(t)}function Dt(t){var n=this;p.call(this),this._generator=t,this._source=null,this._inLoop=!1,this._iteration=0,this._$handleAny=function(t){return n._handleAny(t)}}function Nt(t){return le(function(n){return t.length>n&&t[n]}).setName("concat")}function qt(){Pt.call(this)}function Wt(t,n,i){var e=this;Pt.call(this,i),this._source=t,this._fn=n,this._mainEnded=!1,this._lastCurrent=null,this._$handleMain=function(t){return e._handleMain(t)}}function Bt(t,n){Wt.call(this,t,n)}function jt(t,n){return function(i,e,r){var s=this;t.call(this),this._primary=i,this._secondary=e,this._name=i._name+"."+n,this._lastSecondary=sn,this._$handleSecondaryAny=function(t){return s._handleSecondaryAny(t)},this._$handlePrimaryAny=function(t){return s._handlePrimaryAny(t)},this._init(r)}}function Ut(t){return{_init:function(){},_free:function(){},_handlePrimaryValue:function(t){this._emitValue(t)},_handlePrimaryError:function(t){this._emitError(t)},_handlePrimaryEnd:function(){this._emitEnd()},_handleSecondaryValue:function(t){this._lastSecondary=t},_handleSecondaryError:function(t){this._emitError(t)},_handleSecondaryEnd:function(){},_handlePrimaryAny:function(t){switch(t.type){case on:return this._handlePrimaryValue(t.value);case an:return this._handlePrimaryError(t.value);case un:return this._handlePrimaryEnd(t.value)}},_handleSecondaryAny:function(t){switch(t.type){case on:return this._handleSecondaryValue(t.value);case an:return this._handleSecondaryError(t.value);case un:this._handleSecondaryEnd(t.value),this._removeSecondary()}},_removeSecondary:function(){null!==this._secondary&&(this._secondary.offAny(this._$handleSecondaryAny),this._$handleSecondaryAny=null,this._secondary=null)},_onActivation:function(){null!==this._secondary&&this._secondary.onAny(this._$handleSecondaryAny),this._active&&this._primary.onAny(this._$handlePrimaryAny)},_onDeactivation:function(){null!==this._secondary&&this._secondary.offAny(this._$handleSecondaryAny),this._primary.offAny(this._$handlePrimaryAny)},_clear:function(){t.prototype._clear.call(this),this._primary=null,this._secondary=null,this._lastSecondary=null,this._$handleSecondaryAny=null,this._$handlePrimaryAny=null,this._free()}}}function Ft(t,n){var i=jt(p,t);return e(i,p,Ut(p),n),i}function Qt(t,n){var i=jt(y,t);return e(i,y,Ut(y),n),i}function zt(t,n){return new(t._ofSameType(fe,ce))(t,n)}function Yt(t,n,i){return it([n],[t],i?function(t,n){return i(n,t)}:de).setName(t,"sampledBy")}function Kt(t,n){return new(t._ofSameType(me,pe))(t,n)}function Gt(t,n){return new(t._ofSameType(ge,Ee))(t,n)}function Jt(t,n,i){return new(t._ofSameType(Ae,we))(t,n,i)}function Rt(t,n,i){return new(t._ofSameType(Ve,Te))(t,n,i)}function Xt(t,n){var i=Mt([et(t,Ce),et(n,$e)]);return i=_t(i),i=U(i,$e),i.setName(t,"awaiting")}function Zt(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:xe;return new(t._ofSameType(Oe,Ie))(t,{fn:n})}function tn(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Me;return new(t._ofSameType(Pe,He))(t,{fn:n})}function nn(t){return new(t._ofSameType(Ne,qe))(t)}function en(){Be=!1}function rn(t){if(Be&&console&&"function"==typeof console.warn){console.warn(t,"\nHere is an Error object for you containing the call stack:",new Error)}}var sn=["<nothing>"],un="end",on="value",an="error",hn="any";i(v.prototype,{add:function(t,n){return this._items=r(this._items,[{type:t,fn:n}]),this._items.length},remove:function(t,n){var i=u(this._items,function(i){return i.type===t&&i.fn===n});return 0!==this._inLoop&&-1!==i&&(null===this._removedItems&&(this._removedItems=[]),this._removedItems.push(this._items[i])),this._items=a(this._items,i),this._items.length},addSpy:function(t){return this._spies=r(this._spies,[t]),this._spies.length},removeSpy:function(t){return this._spies=a(this._spies,this._spies.indexOf(t)),this._spies.length},dispatch:function(t){this._inLoop++;for(var n=0,i=this._spies;null!==this._spies&&n<i.length;n++)i[n](t);for(var e=0,r=this._items;e<r.length&&null!==this._items;e++)null!==this._removedItems&&f(this._removedItems,r[e])||d(r[e].type,r[e].fn,t);0===--this._inLoop&&(this._removedItems=null)},cleanup:function(){this._items=null,this._spies=null}}),i(m.prototype,{_name:"observable",_onActivation:function(){},_onDeactivation:function(){},_setActive:function(t){this._active!==t&&(this._active=t,t?(this._activating=!0,this._onActivation(),this._activating=!1):this._onDeactivation())},_clear:function(){this._setActive(!1),this._dispatcher.cleanup(),this._dispatcher=null,this._logHandlers=null},_emit:function(t,n){switch(t){case on:return this._emitValue(n);case an:return this._emitError(n);case un:return this._emitEnd()}},_emitValue:function(t){this._alive&&this._dispatcher.dispatch({type:on,value:t})},_emitError:function(t){this._alive&&this._dispatcher.dispatch({type:an,value:t})},_emitEnd:function(){this._alive&&(this._alive=!1,this._dispatcher.dispatch({type:un}),this._clear())},_on:function(t,n){return this._alive?(this._dispatcher.add(t,n),this._setActive(!0)):d(t,n,{type:un}),this},_off:function(t,n){if(this._alive){0===this._dispatcher.remove(t,n)&&this._setActive(!1)}return this},onValue:function(t){return this._on(on,t)},onError:function(t){return this._on(an,t)},onEnd:function(t){return this._on(un,t)},onAny:function(t){return this._on(hn,t)},offValue:function(t){return this._off(on,t)},offError:function(t){return this._off(an,t)},offEnd:function(t){return this._off(un,t)},offAny:function(t){return this._off(hn,t)},observe:function(t,n,i){var e=this,r=!1,s=t&&"function"!=typeof t?t:{value:t,error:n,end:i},u=function(t){t.type===un&&(r=!0),t.type===on&&s.value?s.value(t.value):t.type===an&&s.error?s.error(t.value):t.type===un&&s.end&&s.end(t.value)};return this.onAny(u),{unsubscribe:function(){r||(e.offAny(u),r=!0)},get closed(){return r}}},_ofSameType:function(t,n){return t.prototype.getType()===this.getType()?t:n},setName:function(t,n){return this._name=n?t._name+"."+n:t,this},log:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.toString(),n=void 0,i=function(i){var e="<"+i.type+(n?":current":"")+">";i.type===un?console.log(t,e):console.log(t,e,i.value)};return this._alive&&(this._logHandlers||(this._logHandlers=[]),this._logHandlers.push({name:t,handler:i})),n=!0,this.onAny(i),n=!1,this},offLog:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.toString();if(this._logHandlers){var n=u(this._logHandlers,function(n){return n.name===t});-1!==n&&(this.offAny(this._logHandlers[n].handler),this._logHandlers.splice(n,1))}return this},spy:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.toString(),n=function(n){var i="<"+n.type+">";n.type===un?console.log(t,i):console.log(t,i,n.value)};return this._alive&&(this._spyHandlers||(this._spyHandlers=[]),this._spyHandlers.push({name:t,handler:n}),this._dispatcher.addSpy(n)),this},offSpy:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.toString();if(this._spyHandlers){var n=u(this._spyHandlers,function(n){return n.name===t});-1!==n&&(this._dispatcher.removeSpy(this._spyHandlers[n].handler),this._spyHandlers.splice(n,1))}return this}}),m.prototype.toString=function(){return"["+this._name+"]"},e(p,m,{_name:"stream",getType:function(){return"stream"}}),e(y,m,{_name:"property",_emitValue:function(t){this._alive&&(this._currentEvent={type:on,value:t},this._activating||this._dispatcher.dispatch({type:on,value:t}))},_emitError:function(t){this._alive&&(this._currentEvent={type:an,value:t},this._activating||this._dispatcher.dispatch({type:an,value:t}))},_emitEnd:function(){this._alive&&(this._alive=!1,this._activating||this._dispatcher.dispatch({type:un}),this._clear())},_on:function(t,n){return this._alive&&(this._dispatcher.add(t,n),this._setActive(!0)),null!==this._currentEvent&&d(t,n,this._currentEvent),this._alive||d(t,n,{type:un}),this},getType:function(){return"property"}});var ln=new p;ln._emitEnd(),ln._name="never";var _n=E({_name:"later",_init:function(t){var n=t.x;this._x=n},_free:function(){this._x=null},_onTick:function(){this._emitValue(this._x),this._emitEnd()}}),fn=E({_name:"interval",_init:function(t){var n=t.x;this._x=n},_free:function(){this._x=null},_onTick:function(){this._emitValue(this._x)}}),cn=E({_name:"sequentially",_init:function(t){var n=t.xs;this._xs=o(n)},_free:function(){this._xs=null},_onTick:function(){1===this._xs.length?(this._emitValue(this._xs[0]),this._emitEnd()):this._emitValue(this._xs.shift())}}),dn=E({_name:"fromPoll",_init:function(t){var n=t.fn;this._fn=n},_free:function(){this._fn=null},_onTick:function(){var t=this._fn;this._emitValue(t())}}),vn=E({_name:"withInterval",_init:function(t){var n=t.fn;this._fn=n,this._emitter=V(this)},_free:function(){this._fn=null,this._emitter=null},_onTick:function(){(0,this._fn)(this._emitter)}});e($,p,{_name:"stream",_onActivation:function(){var t=this._fn,n=t(V(this));this._unsubscribe="function"==typeof n?n:null,this._active||this._callUnsubscribe()},_callUnsubscribe:function(){null!==this._unsubscribe&&(this._unsubscribe(),this._unsubscribe=null)},_onDeactivation:function(){this._callUnsubscribe()},_clear:function(){p.prototype._clear.call(this),this._fn=null}});var mn=[["addEventListener","removeEventListener"],["addListener","removeListener"],["on","off"]];e(H,y,{_name:"constant",_active:!1,_activating:!1,_alive:!1,_dispatcher:null,_logHandlers:null}),e(D,y,{_name:"constantError",_active:!1,_activating:!1,_alive:!1,_dispatcher:null,_logHandlers:null});var pn=j("toProperty",{_init:function(t){var n=t.fn;this._getInitialCurrent=n},_onActivation:function(){if(null!==this._getInitialCurrent){var t=this._getInitialCurrent;this._emitValue(t())}this._source.onAny(this._$handleAny)}}),yn=B("changes",{_handleValue:function(t){this._activating||this._emitValue(t)},_handleError:function(t){this._activating||this._emitError(t)}}),gn=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:z(),i=null;return new n(function(n,e){t.onAny(function(t){t.type===un&&null!==i?((i.type===on?n:e)(i.value),i=null):i=t})})},En="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},bn=Y(function(t,n){function i(t){var n,i=t.Symbol;return"function"==typeof i?i.observable?n=i.observable:(n=i("observable"),i.observable=n):n="@@observable",n}Object.defineProperty(n,"__esModule",{value:!0}),n.default=i}),An=Y(function(t,n){Object.defineProperty(n,"__esModule",{value:!0});var i,e=function(t){return t&&t.__esModule?t:{default:t}}(bn);i="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==En?En:t;var r=(0,e.default)(i);n.default=r}),wn=An,Sn=wn.default?wn.default:wn;i(G.prototype,{subscribe:function(t,n,i){var e=this,r="function"==typeof t?{next:t,error:n,complete:i}:t,s=function(t){t.type===un&&(u=!0),t.type===on&&r.next?r.next(t.value):t.type===an&&r.error?r.error(t.value):t.type===un&&r.complete&&r.complete(t.value)};this._observable.onAny(s);var u=!1;return{unsubscribe:function(){u=!0,e._observable.offAny(s)},get closed(){return u}}}}),G.prototype[Sn]=function(){return this},e(Z,p,{_name:"combine",_onActivation:function(){this._aliveCount=this._activeCount;for(var t=this._activeCount;t<this._sources.length;t++)this._sources[t].onAny(this._$handlers[t]);for(var n=0;n<this._activeCount;n++)this._sources[n].onAny(this._$handlers[n]);this._emitAfterActivation&&(this._emitAfterActivation=!1,this._emitIfFull()),this._endAfterActivation&&this._emitEnd()},_onDeactivation:function(){var t=this._sources.length,n=void 0;for(n=0;n<t;n++)this._sources[n].offAny(this._$handlers[n])},_emitIfFull:function(){for(var t=!0,n=!1,i=this._latestValues.length,e=new Array(i),r=new Array(i),s=0;s<i;s++)e[s]=this._latestValues[s],r[s]=this._latestErrors[s],e[s]===sn&&(t=!1),void 0!==r[s]&&(n=!0);if(t){var u=this._combinator;this._emitValue(u(e))}n&&this._emitError(X(r))},_handleAny:function(t,n){n.type===on||n.type===an?(n.type===on&&(this._latestValues[t]=n.value,this._latestErrors[t]=void 0),n.type===an&&(this._latestValues[t]=sn,this._latestErrors[t]={index:this._latestErrorIndex++,error:n.value}),t<this._activeCount&&(this._activating?this._emitAfterActivation=!0:this._emitIfFull())):t<this._activeCount&&0===--this._aliveCount&&(this._activating?this._endAfterActivation=!0:this._emitEnd())},_clear:function(){p.prototype._clear.call(this),this._sources=null,this._latestValues=null,this._latestErrors=null,this._combinator=null,this._$handlers=null}});var Vn={empty:function(){return g()},concat:function(t,n){return t.merge(n)},of:function(t){return M(t)},map:function(t,n){return n.map(t)},bimap:function(t,n,i){return i.mapErrors(t).map(n)},ap:function(t,n){return it([t,n],function(t,n){return t(n)})},chain:function(t,n){return n.flatMap(t)}},Tn=Object.freeze({Observable:Vn}),$n={_init:function(t){var n=t.fn;this._fn=n},_free:function(){this._fn=null},_handleValue:function(t){var n=this._fn;this._emitValue(n(t))}},Cn=B("map",$n),kn=j("map",$n),On=function(t){return t},In={_init:function(t){var n=t.fn;this._fn=n},_free:function(){this._fn=null},_handleValue:function(t){(0,this._fn)(t)&&this._emitValue(t)}},xn=B("filter",In),Ln=j("filter",In),Pn=function(t){return t},Hn={_init:function(t){var n=t.n;this._n=n,n<=0&&this._emitEnd()},_handleValue:function(t){this._n--,this._emitValue(t),0===this._n&&this._emitEnd()}},Mn=B("take",Hn),Dn=j("take",Hn),Nn={_init:function(t){var n=t.n;this._n=n,n<=0&&this._emitEnd()},_handleError:function(t){this._n--,this._emitError(t),0===this._n&&this._emitEnd()}},qn=B("takeErrors",Nn),Wn=j("takeErrors",Nn),Bn={_init:function(t){var n=t.fn;this._fn=n},_free:function(){this._fn=null},_handleValue:function(t){(0,this._fn)(t)?this._emitValue(t):this._emitEnd()}},jn=B("takeWhile",Bn),Un=j("takeWhile",Bn),Fn=function(t){return t},Qn={_init:function(){this._lastValue=sn},_free:function(){this._lastValue=null},_handleValue:function(t){this._lastValue=t},_handleEnd:function(){this._lastValue!==sn&&this._emitValue(this._lastValue),this._emitEnd()}},zn=B("last",Qn),Yn=j("last",Qn),Kn={_init:function(t){var n=t.n;this._n=Math.max(0,n)},_handleValue:function(t){0===this._n?this._emitValue(t):this._n--}},Gn=B("skip",Kn),Jn=j("skip",Kn),Rn={_init:function(t){var n=t.fn;this._fn=n},_free:function(){this._fn=null},_handleValue:function(t){var n=this._fn;null===this._fn||n(t)||(this._fn=null),null===this._fn&&this._emitValue(t)}},Xn=B("skipWhile",Rn),Zn=j("skipWhile",Rn),ti=function(t){return t},ni={_init:function(t){var n=t.fn;this._fn=n,this._prev=sn},_free:function(){this._fn=null,this._prev=null},_handleValue:function(t){var n=this._fn;this._prev!==sn&&n(this._prev,t)||(this._prev=t,this._emitValue(t))}},ii=B("skipDuplicates",ni),ei=j("skipDuplicates",ni),ri=function(t,n){return t===n},si={_init:function(t){var n=t.fn,i=t.seed;this._fn=n,this._prev=i},_free:function(){this._prev=null,this._fn=null},_handleValue:function(t){if(this._prev!==sn){var n=this._fn;this._emitValue(n(this._prev,t))}this._prev=t}},ui=B("diff",si),oi=j("diff",si),ai=j("scan",{_init:function(t){var n=t.fn,i=t.seed;this._fn=n,this._seed=i,i!==sn&&this._emitValue(i)},_free:function(){this._fn=null,this._seed=null},_handleValue:function(t){var n=this._fn;null===this._currentEvent||this._currentEvent.type===an?this._emitValue(this._seed===sn?t:n(this._seed,t)):this._emitValue(n(this._currentEvent.value,t))}}),hi={_init:function(t){var n=t.fn;this._fn=n},_free:function(){this._fn=null},_handleValue:function(t){for(var n=this._fn,i=n(t),e=0;e<i.length;e++)this._emitValue(i[e])}},li=B("flatten",hi),_i=function(t){return t},fi={},ci={_init:function(t){var n=this,i=t.wait;this._wait=Math.max(0,i),this._buff=[],this._$shiftBuff=function(){var t=n._buff.shift();t===fi?n._emitEnd():n._emitValue(t)}},_free:function(){this._buff=null,this._$shiftBuff=null},_handleValue:function(t){this._activating?this._emitValue(t):(this._buff.push(t),setTimeout(this._$shiftBuff,this._wait))},_handleEnd:function(){this._activating?this._emitEnd():(this._buff.push(fi),setTimeout(this._$shiftBuff,this._wait))}},di=B("delay",ci),vi=j("delay",ci),mi=Date.now?function(){return Date.now()}:function(){return(new Date).getTime()},pi={_init:function(t){var n=this,i=t.wait,e=t.leading,r=t.trailing;this._wait=Math.max(0,i),this._leading=e,this._trailing=r,this._trailingValue=null,this._timeoutId=null,this._endLater=!1,this._lastCallTime=0,this._$trailingCall=function(){return n._trailingCall()}},_free:function(){this._trailingValue=null,this._$trailingCall=null},_handleValue:function(t){if(this._activating)this._emitValue(t);else{var n=mi();0!==this._lastCallTime||this._leading||(this._lastCallTime=n);var i=this._wait-(n-this._lastCallTime);i<=0?(this._cancelTrailing(),this._lastCallTime=n,this._emitValue(t)):this._trailing&&(this._cancelTrailing(),this._trailingValue=t,this._timeoutId=setTimeout(this._$trailingCall,i))}},_handleEnd:function(){this._activating?this._emitEnd():this._timeoutId?this._endLater=!0:this._emitEnd()},_cancelTrailing:function(){null!==this._timeoutId&&(clearTimeout(this._timeoutId),this._timeoutId=null)},_trailingCall:function(){this._emitValue(this._trailingValue),this._timeoutId=null,this._trailingValue=null,this._lastCallTime=this._leading?mi():0,this._endLater&&this._emitEnd()}},yi=B("throttle",pi),gi=j("throttle",pi),Ei={_init:function(t){var n=this,i=t.wait,e=t.immediate;this._wait=Math.max(0,i),this._immediate=e,this._lastAttempt=0,this._timeoutId=null,this._laterValue=null,this._endLater=!1,this._$later=function(){return n._later()}},_free:function(){this._laterValue=null,this._$later=null},_handleValue:function(t){this._activating?this._emitValue(t):(this._lastAttempt=mi(),this._immediate&&!this._timeoutId&&this._emitValue(t),this._timeoutId||(this._timeoutId=setTimeout(this._$later,this._wait)),this._immediate||(this._laterValue=t))},_handleEnd:function(){this._activating?this._emitEnd():this._timeoutId&&!this._immediate?this._endLater=!0:this._emitEnd()},_later:function(){var t=mi()-this._lastAttempt;t<this._wait&&t>=0?this._timeoutId=setTimeout(this._$later,this._wait-t):(this._timeoutId=null,this._immediate||(this._emitValue(this._laterValue),this._laterValue=null),this._endLater&&this._emitEnd())}},bi=B("debounce",Ei),Ai=j("debounce",Ei),wi={_init:function(t){var n=t.fn;this._fn=n},_free:function(){this._fn=null},_handleError:function(t){var n=this._fn;this._emitError(n(t))}},Si=B("mapErrors",wi),Vi=j("mapErrors",wi),Ti=function(t){return t},$i={_init:function(t){var n=t.fn;this._fn=n},_free:function(){this._fn=null},_handleError:function(t){(0,this._fn)(t)&&this._emitError(t)}},Ci=B("filterErrors",$i),ki=j("filterErrors",$i),Oi=function(t){return t},Ii={_handleValue:function(){}},xi=B("ignoreValues",Ii),Li=j("ignoreValues",Ii),Pi={_handleError:function(){}},Hi=B("ignoreErrors",Pi),Mi=j("ignoreErrors",Pi),Di={_handleEnd:function(){}},Ni=B("ignoreEnd",Di),qi=j("ignoreEnd",Di),Wi={_init:function(t){var n=t.fn;this._fn=n},_free:function(){this._fn=null},_handleEnd:function(){var t=this._fn;this._emitValue(t()),this._emitEnd()}},Bi=B("beforeEnd",Wi),ji=j("beforeEnd",Wi),Ui={_init:function(t){var n=t.min,i=t.max;this._max=i,this._min=n,this._buff=[]},_free:function(){this._buff=null},_handleValue:function(t){this._buff=c(this._buff,t,this._max),this._buff.length>=this._min&&this._emitValue(this._buff)}},Fi=B("slidingWindow",Ui),Qi=j("slidingWindow",Ui),zi={_init:function(t){var n=t.fn,i=t.flushOnEnd;this._fn=n,this._flushOnEnd=i,this._buff=[]},_free:function(){this._buff=null},_flush:function(){null!==this._buff&&0!==this._buff.length&&(this._emitValue(this._buff),this._buff=[])},_handleValue:function(t){this._buff.push(t),(0,this._fn)(t)||this._flush()},_handleEnd:function(){this._flushOnEnd&&this._flush(),this._emitEnd()}},Yi=B("bufferWhile",zi),Ki=j("bufferWhile",zi),Gi=function(t){return t},Ji={_init:function(t){var n=t.count,i=t.flushOnEnd;this._count=n,this._flushOnEnd=i,this._buff=[]},_free:function(){this._buff=null},_flush:function(){
null!==this._buff&&0!==this._buff.length&&(this._emitValue(this._buff),this._buff=[])},_handleValue:function(t){this._buff.push(t),this._buff.length>=this._count&&this._flush()},_handleEnd:function(){this._flushOnEnd&&this._flush(),this._emitEnd()}},Ri=B("bufferWithCount",Ji),Xi=j("bufferWithCount",Ji),Zi={_init:function(t){var n=this,i=t.wait,e=t.count,r=t.flushOnEnd;this._wait=i,this._count=e,this._flushOnEnd=r,this._intervalId=null,this._$onTick=function(){return n._flush()},this._buff=[]},_free:function(){this._$onTick=null,this._buff=null},_flush:function(){null!==this._buff&&(this._emitValue(this._buff),this._buff=[])},_handleValue:function(t){this._buff.push(t),this._buff.length>=this._count&&(clearInterval(this._intervalId),this._flush(),this._intervalId=setInterval(this._$onTick,this._wait))},_handleEnd:function(){this._flushOnEnd&&0!==this._buff.length&&this._flush(),this._emitEnd()},_onActivation:function(){this._intervalId=setInterval(this._$onTick,this._wait),this._source.onAny(this._$handleAny)},_onDeactivation:function(){null!==this._intervalId&&(clearInterval(this._intervalId),this._intervalId=null),this._source.offAny(this._$handleAny)}},te=B("bufferWithTimeOrCount",Zi),ne=j("bufferWithTimeOrCount",Zi),ie={_init:function(t){var n=t.transducer;this._xform=n(kt(this))},_free:function(){this._xform=null},_handleValue:function(t){null!==this._xform["@@transducer/step"](null,t)&&this._xform["@@transducer/result"](null)},_handleEnd:function(){this._xform["@@transducer/result"](null)}},ee=B("transduce",ie),re=j("transduce",ie),se={_init:function(t){var n=t.fn;this._handler=n,this._emitter=V(this)},_free:function(){this._handler=null,this._emitter=null},_handleAny:function(t){this._handler(this._emitter,t)}},ue=B("withHandler",se),oe=j("withHandler",se),ae=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};e(xt,p,{_name:"zip",_onActivation:function(){for(;this._isFull();)this._emit();var t=this._sources.length;this._aliveCount=t;for(var n=0;n<t&&this._active;n++)this._sources[n].onAny(this._$handlers[n])},_onDeactivation:function(){for(var t=0;t<this._sources.length;t++)this._sources[t].offAny(this._$handlers[t])},_emit:function(){for(var t=new Array(this._buffers.length),n=0;n<this._buffers.length;n++)t[n]=this._buffers[n].shift();var i=this._combinator;this._emitValue(i(t))},_isFull:function(){for(var t=0;t<this._buffers.length;t++)if(0===this._buffers[t].length)return!1;return!0},_handleAny:function(t,n){n.type===on&&(this._buffers[t].push(n.value),this._isFull()&&this._emit()),n.type===an&&this._emitError(n.value),n.type===un&&0===--this._aliveCount&&this._emitEnd()},_clear:function(){p.prototype._clear.call(this),this._sources=null,this._buffers=null,this._combinator=null,this._$handlers=null}});var he=function(t){return t};e(Pt,p,{_name:"abstractPool",_add:function(t,n){n=n||he,-1===this._concurLim||this._curSources.length<this._concurLim?this._addToCur(n(t)):-1===this._queueLim||this._queue.length<this._queueLim?this._addToQueue(n(t)):"old"===this._drop&&(this._removeOldest(),this._add(t,n))},_addAll:function(t){var n=this;l(t,function(t){return n._add(t)})},_remove:function(t){-1===this._removeCur(t)&&this._removeQueue(t)},_addToQueue:function(t){this._queue=r(this._queue,[t])},_addToCur:function(t){if(this._active){if(!t._alive)return void(t._currentEvent&&this._emit(t._currentEvent.type,t._currentEvent.value));this._currentlyAdding=t,t.onAny(this._$handleSubAny),this._currentlyAdding=null,t._alive&&(this._curSources=r(this._curSources,[t]),this._active&&this._subToEnd(t))}else this._curSources=r(this._curSources,[t])},_subToEnd:function(t){var n=this,i=function(){return n._removeCur(t)};this._$endHandlers.push({obs:t,handler:i}),t.onEnd(i)},_subscribe:function(t){t.onAny(this._$handleSubAny),this._active&&this._subToEnd(t)},_unsubscribe:function(t){t.offAny(this._$handleSubAny);var n=u(this._$endHandlers,function(n){return n.obs===t});-1!==n&&(t.offEnd(this._$endHandlers[n].handler),this._$endHandlers.splice(n,1))},_handleSubAny:function(t){t.type===on?this._emitValue(t.value):t.type===an&&this._emitError(t.value)},_removeQueue:function(t){var n=s(this._queue,t);return this._queue=a(this._queue,n),n},_removeCur:function(t){this._active&&this._unsubscribe(t);var n=s(this._curSources,t);return this._curSources=a(this._curSources,n),-1!==n&&(0!==this._queue.length?this._pullQueue():0===this._curSources.length&&this._onEmpty()),n},_removeOldest:function(){this._removeCur(this._curSources[0])},_pullQueue:function(){0!==this._queue.length&&(this._queue=o(this._queue),this._addToCur(this._queue.shift()))},_onActivation:function(){for(var t=0,n=this._curSources;t<n.length&&this._active;t++)this._subscribe(n[t])},_onDeactivation:function(){for(var t=0,n=this._curSources;t<n.length;t++)this._unsubscribe(n[t]);null!==this._currentlyAdding&&this._unsubscribe(this._currentlyAdding)},_isEmpty:function(){return 0===this._curSources.length},_onEmpty:function(){},_clear:function(){p.prototype._clear.call(this),this._queue=null,this._curSources=null,this._$handleSubAny=null,this._$endHandlers=null}}),e(Ht,Pt,{_name:"merge",_onEmpty:function(){this._initialised&&this._emitEnd()}}),e(Dt,p,{_name:"repeat",_handleAny:function(t){t.type===un?(this._source=null,this._getSource()):this._emit(t.type,t.value)},_getSource:function(){if(!this._inLoop){this._inLoop=!0;for(var t=this._generator;null===this._source&&this._alive&&this._active;)this._source=t(this._iteration++),this._source?this._source.onAny(this._$handleAny):this._emitEnd();this._inLoop=!1}},_onActivation:function(){this._source?this._source.onAny(this._$handleAny):this._getSource()},_onDeactivation:function(){this._source&&this._source.offAny(this._$handleAny)},_clear:function(){p.prototype._clear.call(this),this._generator=null,this._source=null,this._$handleAny=null}});var le=function(t){return new Dt(t)};e(qt,Pt,{_name:"pool",plug:function(t){return this._add(t),this},unplug:function(t){return this._remove(t),this}}),e(Wt,Pt,{_onActivation:function(){Pt.prototype._onActivation.call(this),this._active&&this._source.onAny(this._$handleMain)},_onDeactivation:function(){Pt.prototype._onDeactivation.call(this),this._source.offAny(this._$handleMain),this._hadNoEvSinceDeact=!0},_handleMain:function(t){if(t.type===on){this._activating&&this._hadNoEvSinceDeact&&this._lastCurrent===t.value||this._add(t.value,this._fn),this._lastCurrent=t.value,this._hadNoEvSinceDeact=!1}t.type===an&&this._emitError(t.value),t.type===un&&(this._isEmpty()?this._emitEnd():this._mainEnded=!0)},_onEmpty:function(){this._mainEnded&&this._emitEnd()},_clear:function(){Pt.prototype._clear.call(this),this._source=null,this._lastCurrent=null,this._$handleMain=null}}),e(Bt,Wt,{_handleMain:function(t){if(t.type===an){this._activating&&this._hadNoEvSinceDeact&&this._lastCurrent===t.value||this._add(t.value,this._fn),this._lastCurrent=t.value,this._hadNoEvSinceDeact=!1}t.type===on&&this._emitValue(t.value),t.type===un&&(this._isEmpty()?this._emitEnd():this._mainEnded=!0)}});var _e={_handlePrimaryValue:function(t){this._lastSecondary!==sn&&this._lastSecondary&&this._emitValue(t)},_handleSecondaryEnd:function(){this._lastSecondary!==sn&&this._lastSecondary||this._emitEnd()}},fe=Ft("filterBy",_e),ce=Qt("filterBy",_e),de=function(t,n){return n},ve={_handlePrimaryValue:function(t){this._lastSecondary!==sn&&this._emitValue(t)},_handleSecondaryEnd:function(){this._lastSecondary===sn&&this._emitEnd()}},me=Ft("skipUntilBy",ve),pe=Qt("skipUntilBy",ve),ye={_handleSecondaryValue:function(){this._emitEnd()}},ge=Ft("takeUntilBy",ye),Ee=Qt("takeUntilBy",ye),be={_init:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.flushOnEnd,i=void 0===n||n;this._buff=[],this._flushOnEnd=i},_free:function(){this._buff=null},_flush:function(){null!==this._buff&&(this._emitValue(this._buff),this._buff=[])},_handlePrimaryEnd:function(){this._flushOnEnd&&this._flush(),this._emitEnd()},_onActivation:function(){this._primary.onAny(this._$handlePrimaryAny),this._alive&&null!==this._secondary&&this._secondary.onAny(this._$handleSecondaryAny)},_handlePrimaryValue:function(t){this._buff.push(t)},_handleSecondaryValue:function(){this._flush()},_handleSecondaryEnd:function(){this._flushOnEnd||this._emitEnd()}},Ae=Ft("bufferBy",be),we=Qt("bufferBy",be),Se={_init:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.flushOnEnd,i=void 0===n||n,e=t.flushOnChange,r=void 0!==e&&e;this._buff=[],this._flushOnEnd=i,this._flushOnChange=r},_free:function(){this._buff=null},_flush:function(){null!==this._buff&&(this._emitValue(this._buff),this._buff=[])},_handlePrimaryEnd:function(){this._flushOnEnd&&this._flush(),this._emitEnd()},_handlePrimaryValue:function(t){this._buff.push(t),this._lastSecondary===sn||this._lastSecondary||this._flush()},_handleSecondaryEnd:function(){this._flushOnEnd||this._lastSecondary!==sn&&!this._lastSecondary||this._emitEnd()},_handleSecondaryValue:function(t){this._flushOnChange&&!t&&this._flush(),this._lastSecondary=t}},Ve=Ft("bufferWhileBy",Se),Te=Qt("bufferWhileBy",Se),$e=function(){return!1},Ce=function(){return!0},ke={_init:function(t){var n=t.fn;this._fn=n},_free:function(){this._fn=null},_handleValue:function(t){var n=this._fn,i=n(t);i.convert?this._emitError(i.error):this._emitValue(t)}},Oe=B("valuesToErrors",ke),Ie=j("valuesToErrors",ke),xe=function(t){return{convert:!0,error:t}},Le={_init:function(t){var n=t.fn;this._fn=n},_free:function(){this._fn=null},_handleError:function(t){var n=this._fn,i=n(t);i.convert?this._emitValue(i.value):this._emitError(t)}},Pe=B("errorsToValues",Le),He=j("errorsToValues",Le),Me=function(t){return{convert:!0,value:t}},De={_handleError:function(t){this._emitError(t),this._emitEnd()}},Ne=B("endOnError",De),qe=j("endOnError",De);m.prototype.toProperty=function(t){return U(this,t)},m.prototype.changes=function(){return F(this)},m.prototype.toPromise=function(t){return gn(this,t)},m.prototype.toESObservable=J,m.prototype[Sn]=J,m.prototype.map=function(t){return et(this,t)},m.prototype.filter=function(t){return rt(this,t)},m.prototype.take=function(t){return st(this,t)},m.prototype.takeErrors=function(t){return ut(this,t)},m.prototype.takeWhile=function(t){return ot(this,t)},m.prototype.last=function(){return at(this)},m.prototype.skip=function(t){return ht(this,t)},m.prototype.skipWhile=function(t){return lt(this,t)},m.prototype.skipDuplicates=function(t){return _t(this,t)},m.prototype.diff=function(t,n){return ct(this,t,n)},m.prototype.scan=function(t,n){return dt(this,t,n)},m.prototype.flatten=function(t){return vt(this,t)},m.prototype.delay=function(t){return mt(this,t)},m.prototype.throttle=function(t,n){return pt(this,t,n)},m.prototype.debounce=function(t,n){return yt(this,t,n)},m.prototype.mapErrors=function(t){return gt(this,t)},m.prototype.filterErrors=function(t){return Et(this,t)},m.prototype.ignoreValues=function(){return bt(this)},m.prototype.ignoreErrors=function(){return At(this)},m.prototype.ignoreEnd=function(){return wt(this)},m.prototype.beforeEnd=function(t){return St(this,t)},m.prototype.slidingWindow=function(t,n){return Vt(this,t,n)},m.prototype.bufferWhile=function(t,n){return Tt(this,t,n)},m.prototype.bufferWithCount=function(t,n){return $t(this,t,n)},m.prototype.bufferWithTimeOrCount=function(t,n,i){return Ct(this,t,n,i)},m.prototype.transduce=function(t){return Ot(this,t)},m.prototype.withHandler=function(t){return It(this,t)},m.prototype.combine=function(t,n){return it([this,t],n)},m.prototype.zip=function(t,n){return Lt([this,t],n)},m.prototype.merge=function(t){return Mt([this,t])},m.prototype.concat=function(t){return Nt([this,t])};var We=function(){return new qt};m.prototype.flatMap=function(t){return new Wt(this,t).setName(this,"flatMap")},m.prototype.flatMapLatest=function(t){return new Wt(this,t,{concurLim:1,drop:"old"}).setName(this,"flatMapLatest")},m.prototype.flatMapFirst=function(t){return new Wt(this,t,{concurLim:1}).setName(this,"flatMapFirst")},m.prototype.flatMapConcat=function(t){return new Wt(this,t,{queueLim:-1,concurLim:1}).setName(this,"flatMapConcat")},m.prototype.flatMapConcurLimit=function(t,n){return new Wt(this,t,{queueLim:-1,concurLim:n}).setName(this,"flatMapConcurLimit")},m.prototype.flatMapErrors=function(t){return new Bt(this,t).setName(this,"flatMapErrors")},m.prototype.filterBy=function(t){return zt(this,t)},m.prototype.sampledBy=function(t,n){return Yt(this,t,n)},m.prototype.skipUntilBy=function(t){return Kt(this,t)},m.prototype.takeUntilBy=function(t){return Gt(this,t)},m.prototype.bufferBy=function(t,n){return Jt(this,t,n)},m.prototype.bufferWhileBy=function(t,n){return Rt(this,t,n)};var Be=!0;m.prototype.awaiting=function(t){return rn("You are using deprecated .awaiting() method, see https://github.com/rpominov/kefir/issues/145"),Xt(this,t)},m.prototype.valuesToErrors=function(t){return rn("You are using deprecated .valuesToErrors() method, see https://github.com/rpominov/kefir/issues/149"),Zt(this,t)},m.prototype.errorsToValues=function(t){return rn("You are using deprecated .errorsToValues() method, see https://github.com/rpominov/kefir/issues/149"),tn(this,t)},m.prototype.endOnError=function(){return rn("You are using deprecated .endOnError() method, see https://github.com/rpominov/kefir/issues/150"),nn(this)};var je={Observable:m,Stream:p,Property:y,never:g,later:b,interval:A,sequentially:w,fromPoll:S,withInterval:T,fromCallback:k,fromNodeCallback:O,fromEvents:P,stream:C,constant:M,constantError:N,fromPromise:Q,fromESObservable:K,combine:it,zip:Lt,merge:Mt,concat:Nt,Pool:qt,pool:We,repeat:le,staticLand:Tn};je.Kefir=je,t.dissableDeprecationWarnings=en,t.Kefir=je,t.Observable=m,t.Stream=p,t.Property=y,t.never=g,t.later=b,t.interval=A,t.sequentially=w,t.fromPoll=S,t.withInterval=T,t.fromCallback=k,t.fromNodeCallback=O,t.fromEvents=P,t.stream=C,t.constant=M,t.constantError=N,t.fromPromise=Q,t.fromESObservable=K,t.combine=it,t.zip=Lt,t.merge=Mt,t.concat=Nt,t.Pool=qt,t.pool=We,t.repeat=le,t.staticLand=Tn,t.default=je,Object.defineProperty(t,"__esModule",{value:!0})});
{
"name": "kefir",
"version": "3.7.1",
"version": "3.7.2",
"description": "Reactive Programming library for JavaScript inspired by Bacon.js and RxJS with focus on high performance and low memory usage",
"main": "dist/kefir.js",
"scripts": {
"test": "eslint . && grunt rollup:dev && jasmine-node --coffee --matchall test/specs && flow check",
"test-only": "grunt rollup:dev && jasmine-node --coffee --matchall test/specs"
"prettify": "./configs/prettier.sh",
"build-js": "rollup -c ./configs/rollup.dev.js && rollup -c ./configs/rollup.prod.js && cp kefir.js.flow dist/",
"build-docs": "node configs/docs.js",
"clean": "rm -r dist index.html || true",
"build": "npm run clean && npm run build-js && npm run build-docs",
"test": "./configs/prettier.sh check && rollup -c ./configs/rollup.dev.js && jasmine-node --coffee --matchall test/specs && flow check",
"test-only": "rollup -c ./configs/rollup.dev.js && jasmine-node --coffee --matchall test/specs",
"test-debug": "rollup -c ./configs/rollup.dev.js && node --inspect-brk `npm bin`/jasmine-node --coffee --matchall test/specs"
},

@@ -33,39 +39,25 @@ "keywords": [

"devDependencies": {
"@reactivex/rxjs": "5.0.0-alpha.1",
"babel-core": "6.10.4",
"babel-preset-es2015": "6.9.0",
"babel-preset-es2015-loose": "7.0.0",
"@reactivex/rxjs": "5.3.0",
"babel-preset-es2015-loose-rollup": "7.0.0",
"babelify": "7.3.0",
"coffee-script": "1.10.0",
"coffeeify": "1.1.0",
"eslint": "2.2.0",
"flow-bin": "^0.36.0",
"grunt": "0.4.5",
"grunt-bower-task": "0.4.0",
"grunt-browserify": "4.0.1",
"grunt-cli": "0.1.13",
"grunt-contrib-clean": "0.6.0",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-jade": "0.15.0",
"grunt-rollup": "0.7.1",
"coffee-script": "1.12.5",
"flow-bin": "0.46.0",
"inquirer": "0.10.1",
"jasmine-node": "1.14.5",
"load-grunt-tasks": "3.3.0",
"rollup": "0.33.0",
"rollup-plugin-babel": "2.6.1",
"rollup-plugin-commonjs": "3.1.0",
"rollup-plugin-node-resolve": "1.7.1",
"prettier": "1.0.2",
"pug": "2.0.0-beta11",
"rollup": "0.41.6",
"rollup-plugin-babel": "2.7.1",
"rollup-plugin-commonjs": "8.0.2",
"rollup-plugin-node-resolve": "3.0.0",
"rollup-plugin-uglify": "1.0.1",
"semver": "5.0.3",
"semver": "5.3.0",
"shelljs": "0.5.3",
"sinon": "1.17.1",
"time-grunt": "1.2.1",
"transducers-js": "0.4.174",
"transducers.js": "0.3.2",
"zen-observable": "0.3.0"
"zen-observable": "0.5.1"
},
"dependencies": {
"symbol-observable": "^1.0.1"
"symbol-observable": "1.0.4"
}
}

@@ -19,8 +19,5 @@ # <a href="http://rpominov.github.io/kefir/"><img src="http://rpominov.github.io/kefir/Kefir-with-bg.svg" width="60" height="60"></a> Kefir

[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/pozadi/kefir?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
<!-- [![Code Climate](http://img.shields.io/codeclimate/github/rpominov/kefir.svg)](https://codeclimate.com/github/rpominov/kefir) -->
[Run tests in your browser](http://rpominov.github.io/kefir/test/in-browser/SpecRunner.html) (`gh-pages` branch, i.e. last stable version)
# Installation

@@ -74,9 +71,9 @@

To build all the things: `/dist`, docs, tests for browser, etc. run:
grunt
grunt bower # to also install bower packages which needed for docs
To run tests:
npm test
```sh
npm run prettify # makes source code pretty (you must run it before a PR could be merged)
npm run build-js # builds js bundlers
npm run test # runs all the checks
npm run test-only # runs only unit tests without other checks
npm run test-debug # runs tests with a chrome inspector connected to the node process
npm run build-docs # builds the documentation html file
```

@@ -1,19 +0,19 @@

var inquirer = require('inquirer');
var semver = require('semver');
var shell = require('shelljs');
var fs = require('fs');
var inquirer = require('inquirer')
var semver = require('semver')
var shell = require('shelljs')
var fs = require('fs')
var pkg = require('./package.json');
var bower = require('./bower.json');
var pkg = require('./package.json')
var bower = require('./bower.json')
console.log("");
console.log("Wellcome to Kefir release utility!");
console.log("----------------------------------------------------------------");
console.log("");
console.log('')
console.log('Wellcome to Kefir release utility!')
console.log('----------------------------------------------------------------')
console.log('')
var questions = [
{
type: "list",
name: "version",
message: "Which version will it be? (current is " + pkg.version + ")",
type: 'list',
name: 'version',
message: 'Which version will it be? (current is ' + pkg.version + ')',
choices: [

@@ -23,79 +23,70 @@ semver.inc(pkg.version, 'patch'),

semver.inc(pkg.version, 'major'),
semver.inc(pkg.version, 'premajor', 'rc')
]
semver.inc(pkg.version, 'premajor', 'rc'),
],
},
{
type: "list",
name: "dryRun",
message: "Do you want to release, or just see what would happen if you do?",
choices: [
'Just see',
'Release!'
]
}
];
type: 'list',
name: 'dryRun',
message: 'Do you want to release, or just see what would happen if you do?',
choices: ['Just see', 'Release!'],
},
]
inquirer.prompt(questions, function(answers) {
var newVerison = answers.version;
var dryRun = (answers.dryRun === 'Just see');
var newVerison = answers.version
var dryRun = answers.dryRun === 'Just see'
bower.version = pkg.version = newVerison;
bower.version = pkg.version = newVerison
console.log('');
console.log('')
if (dryRun) {
console.log('Ok, here is what would happen:');
console.log('Ok, here is what would happen:')
} else {
console.log('Doing actual release:');
console.log('Doing actual release:')
}
console.log('');
console.log('')
run('npm test', dryRun) &&
bumpVersion('package.json', pkg, dryRun) &&
bumpVersion('bower.json', bower, dryRun) &&
run('`npm bin`/grunt', dryRun) &&
run('`npm bin`/grunt bower', dryRun) &&
run('git add .', dryRun) &&
run('git add -f dist', dryRun) &&
run('git add -f index.html', dryRun) &&
run('git add -f bower-packages', dryRun) &&
run('git add -f test/in-browser/spec/KefirSpecs.js', dryRun) &&
run('git commit -m "' + newVerison + '"', dryRun) &&
run('git push', dryRun) &&
run('git tag -a ' + newVerison + ' -m "v' + newVerison + '"', dryRun) &&
run('git push origin --tags', dryRun) &&
run('npm publish', dryRun) &&
run('git rm -r dist', dryRun) &&
run('git rm -r bower-packages', dryRun) &&
run('git rm index.html', dryRun) &&
run('git rm test/in-browser/spec/KefirSpecs.js', dryRun) &&
run('git commit -m "cleanup repository after release"', dryRun) &&
run('git push', dryRun);
bumpVersion('package.json', pkg, dryRun) &&
bumpVersion('bower.json', bower, dryRun) &&
run('npm run build', dryRun) &&
run('git add .', dryRun) &&
run('git add -f dist', dryRun) &&
run('git add -f index.html', dryRun) &&
run('git commit -m "' + newVerison + '"', dryRun) &&
run('git push', dryRun) &&
run('git tag -a ' + newVerison + ' -m "v' + newVerison + '"', dryRun) &&
run('git push origin --tags', dryRun) &&
run('npm publish', dryRun) &&
run('git rm -r dist', dryRun) &&
run('git rm index.html', dryRun) &&
run('git commit -m "cleanup repository after release"', dryRun) &&
run('git push', dryRun)
})
});
function bumpVersion(fileName, obj, dry) {
console.log('Bumping version in `' + fileName + '` to ' + obj.version);
console.log('Bumping version in `' + fileName + '` to ' + obj.version)
if (!dry) {
try {
fs.writeFileSync(fileName, JSON.stringify(obj, null, ' ') + '\n');
console.log('... ok');
} catch(e) {
console.error(e);
return false;
fs.writeFileSync(fileName, JSON.stringify(obj, null, ' ') + '\n')
console.log('... ok')
} catch (e) {
console.error(e)
return false
}
}
return true;
return true
}
function run(cmd, dry){
console.log('Running `' + cmd + '`');
function run(cmd, dry) {
console.log('Running `' + cmd + '`')
if (!dry) {
if (shell.exec(cmd, {silent:false}).code === 0){
console.log('... ok');
} else{
console.error('... fail!');
return false;
if (shell.exec(cmd, {silent: false}).code === 0) {
console.log('... ok')
} else {
console.error('... fail!')
return false
}
}
return true;
return true
}

@@ -1,5 +0,5 @@

export const NOTHING = ['<nothing>'];
export const END = 'end';
export const VALUE = 'value';
export const ERROR = 'error';
export const ANY = 'any';
export const NOTHING = ['<nothing>']
export const END = 'end'
export const VALUE = 'value'
export const ERROR = 'error'
export const ANY = 'any'

@@ -1,13 +0,13 @@

import {extend} from './utils/objects';
import {VALUE, ERROR, ANY} from './constants';
import {concat, findByPred, remove, contains} from './utils/collections';
import {extend} from './utils/objects'
import {VALUE, ERROR, ANY} from './constants'
import {concat, findByPred, remove, contains} from './utils/collections'
function callSubscriber(type, fn, event) {
if (type === ANY) {
fn(event);
fn(event)
} else if (type === event.type) {
if (type === VALUE || type === ERROR) {
fn(event.value);
fn(event.value)
} else {
fn();
fn()
}

@@ -18,17 +18,16 @@ }

function Dispatcher() {
this._items = [];
this._spies = [];
this._inLoop = 0;
this._removedItems = null;
this._items = []
this._spies = []
this._inLoop = 0
this._removedItems = null
}
extend(Dispatcher.prototype, {
add(type, fn) {
this._items = concat(this._items, [{type, fn}]);
return this._items.length;
this._items = concat(this._items, [{type, fn}])
return this._items.length
},
remove(type, fn) {
const index = findByPred(this._items, (x) => x.type === type && x.fn === fn);
const index = findByPred(this._items, x => x.type === type && x.fn === fn)

@@ -39,15 +38,14 @@ // if we're currently in a notification loop,

if (this._removedItems === null) {
this._removedItems = [];
this._removedItems = []
}
this._removedItems.push(this._items[index]);
this._removedItems.push(this._items[index])
}
this._items = remove(this._items, index);
return this._items.length;
this._items = remove(this._items, index)
return this._items.length
},
addSpy(fn) {
this._spies = concat(this._spies, [fn]);
return this._spies.length;
this._spies = concat(this._spies, [fn])
return this._spies.length
},

@@ -59,17 +57,16 @@

removeSpy(fn) {
this._spies = remove(this._spies, this._spies.indexOf(fn));
return this._spies.length;
this._spies = remove(this._spies, this._spies.indexOf(fn))
return this._spies.length
},
dispatch(event) {
this._inLoop++;
this._inLoop++
for (let i = 0, spies = this._spies; this._spies !== null && i < spies.length; i++) {
spies[i](event);
spies[i](event)
}
for (let i = 0, items = this._items; i < items.length; i++) {
// cleanup was called
if (this._items === null) {
break;
break
}

@@ -79,10 +76,10 @@

if (this._removedItems !== null && contains(this._removedItems, items[i])) {
continue;
continue
}
callSubscriber(items[i].type, items[i].fn, event);
callSubscriber(items[i].type, items[i].fn, event)
}
this._inLoop--;
this._inLoop--
if (this._inLoop === 0) {
this._removedItems = null;
this._removedItems = null
}

@@ -92,9 +89,7 @@ },

cleanup() {
this._items = null;
this._spies = null;
}
this._items = null
this._spies = null
},
})
});
export {callSubscriber, Dispatcher};
export {callSubscriber, Dispatcher}
export default function emitter(obs) {
function value(x) {
obs._emitValue(x);
return obs._active;
obs._emitValue(x)
return obs._active
}
function error(x) {
obs._emitError(x);
return obs._active;
obs._emitError(x)
return obs._active
}
function end() {
obs._emitEnd();
return obs._active;
obs._emitEnd()
return obs._active
}
function event(e) {
obs._emit(e.type, e.value);
return obs._active;
obs._emit(e.type, e.value)
return obs._active
}

@@ -31,4 +30,4 @@

emit: value,
emitEvent: event
};
emitEvent: event,
}
}

@@ -1,7 +0,5 @@

import Observable from './observable';
import Stream from './stream';
import Property from './property';
import Observable from './observable'
import Stream from './stream'
import Property from './property'
// Create a stream

@@ -11,34 +9,32 @@ // -----------------------------------------------------------------------------

// () -> Stream
import never from './primary/never';
import never from './primary/never'
// (number, any) -> Stream
import later from './time-based/later';
import later from './time-based/later'
// (number, any) -> Stream
import interval from './time-based/interval';
import interval from './time-based/interval'
// (number, Array<any>) -> Stream
import sequentially from './time-based/sequentially';
import sequentially from './time-based/sequentially'
// (number, Function) -> Stream
import fromPoll from './time-based/from-poll';
import fromPoll from './time-based/from-poll'
// (number, Function) -> Stream
import withInterval from './time-based/with-interval';
import withInterval from './time-based/with-interval'
// (Function) -> Stream
import fromCallback from './primary/from-callback';
import fromCallback from './primary/from-callback'
// (Function) -> Stream
import fromNodeCallback from './primary/from-node-callback';
import fromNodeCallback from './primary/from-node-callback'
// Target = {addEventListener, removeEventListener}|{addListener, removeListener}|{on, off}
// (Target, string, Function|undefined) -> Stream
import fromEvents from './primary/from-events';
import fromEvents from './primary/from-events'
// (Function) -> Stream
import stream from './primary/stream';
import stream from './primary/stream'
// Create a property

@@ -48,9 +44,7 @@ // -----------------------------------------------------------------------------

// (any) -> Property
import constant from './primary/constant';
import constant from './primary/constant'
// (any) -> Property
import constantError from './primary/constant-error';
import constantError from './primary/constant-error'
// Convert observables

@@ -60,15 +54,13 @@ // -----------------------------------------------------------------------------

// (Stream|Property, Function|undefined) -> Property
import toProperty from './one-source/to-property';
import toProperty from './one-source/to-property'
Observable.prototype.toProperty = function(fn) {
return toProperty(this, fn);
};
return toProperty(this, fn)
}
// (Stream|Property) -> Stream
import changes from './one-source/changes';
import changes from './one-source/changes'
Observable.prototype.changes = function() {
return changes(this);
};
return changes(this)
}
// Interoperation with other implimentations

@@ -78,22 +70,21 @@ // -----------------------------------------------------------------------------

// (Promise) -> Property
import fromPromise from './interop/from-promise';
import fromPromise from './interop/from-promise'
// (Stream|Property, Function|undefined) -> Promise
import toPromise from './interop/to-promise';
import toPromise from './interop/to-promise'
Observable.prototype.toPromise = function(Promise) {
return toPromise(this, Promise);
};
return toPromise(this, Promise)
}
// (ESObservable) -> Stream
import fromESObservable from './interop/from-es-observable';
import fromESObservable from './interop/from-es-observable'
// (Stream|Property) -> ES7 Observable
import toESObservable from './interop/to-es-observable';
Observable.prototype.toESObservable = toESObservable;
import $$observable from 'symbol-observable';
Observable.prototype[$$observable] = toESObservable;
import toESObservable from './interop/to-es-observable'
Observable.prototype.toESObservable = toESObservable
import $$observable from './interop/symbol'
Observable.prototype[$$observable] = toESObservable
import * as staticLand from './interop/static-land'
// Modify an observable

@@ -104,89 +95,89 @@ // -----------------------------------------------------------------------------

// (Property, Function|undefined) -> Property
import map from './one-source/map';
import map from './one-source/map'
Observable.prototype.map = function(fn) {
return map(this, fn);
};
return map(this, fn)
}
// (Stream, Function|undefined) -> Stream
// (Property, Function|undefined) -> Property
import filter from './one-source/filter';
import filter from './one-source/filter'
Observable.prototype.filter = function(fn) {
return filter(this, fn);
};
return filter(this, fn)
}
// (Stream, number) -> Stream
// (Property, number) -> Property
import take from './one-source/take';
import take from './one-source/take'
Observable.prototype.take = function(n) {
return take(this, n);
};
return take(this, n)
}
// (Stream, number) -> Stream
// (Property, number) -> Property
import takeErrors from './one-source/take-errors';
import takeErrors from './one-source/take-errors'
Observable.prototype.takeErrors = function(n) {
return takeErrors(this, n);
};
return takeErrors(this, n)
}
// (Stream, Function|undefined) -> Stream
// (Property, Function|undefined) -> Property
import takeWhile from './one-source/take-while';
import takeWhile from './one-source/take-while'
Observable.prototype.takeWhile = function(fn) {
return takeWhile(this, fn);
};
return takeWhile(this, fn)
}
// (Stream) -> Stream
// (Property) -> Property
import last from './one-source/last';
import last from './one-source/last'
Observable.prototype.last = function() {
return last(this);
};
return last(this)
}
// (Stream, number) -> Stream
// (Property, number) -> Property
import skip from './one-source/skip';
import skip from './one-source/skip'
Observable.prototype.skip = function(n) {
return skip(this, n);
};
return skip(this, n)
}
// (Stream, Function|undefined) -> Stream
// (Property, Function|undefined) -> Property
import skipWhile from './one-source/skip-while';
import skipWhile from './one-source/skip-while'
Observable.prototype.skipWhile = function(fn) {
return skipWhile(this, fn);
};
return skipWhile(this, fn)
}
// (Stream, Function|undefined) -> Stream
// (Property, Function|undefined) -> Property
import skipDuplicates from './one-source/skip-duplicates';
import skipDuplicates from './one-source/skip-duplicates'
Observable.prototype.skipDuplicates = function(fn) {
return skipDuplicates(this, fn);
};
return skipDuplicates(this, fn)
}
// (Stream, Function|falsey, any|undefined) -> Stream
// (Property, Function|falsey, any|undefined) -> Property
import diff from './one-source/diff';
import diff from './one-source/diff'
Observable.prototype.diff = function(fn, seed) {
return diff(this, fn, seed);
};
return diff(this, fn, seed)
}
// (Stream|Property, Function, any|undefined) -> Property
import scan from './one-source/scan';
import scan from './one-source/scan'
Observable.prototype.scan = function(fn, seed) {
return scan(this, fn, seed);
};
return scan(this, fn, seed)
}
// (Stream, Function|undefined) -> Stream
// (Property, Function|undefined) -> Property
import flatten from './one-source/flatten';
import flatten from './one-source/flatten'
Observable.prototype.flatten = function(fn) {
return flatten(this, fn);
};
return flatten(this, fn)
}
// (Stream, number) -> Stream
// (Property, number) -> Property
import delay from './one-source/delay';
import delay from './one-source/delay'
Observable.prototype.delay = function(wait) {
return delay(this, wait);
};
return delay(this, wait)
}

@@ -196,6 +187,6 @@ // Options = {leading: boolean|undefined, trailing: boolean|undefined}

// (Property, number, Options|undefined) -> Property
import throttle from './one-source/throttle';
import throttle from './one-source/throttle'
Observable.prototype.throttle = function(wait, options) {
return throttle(this, wait, options);
};
return throttle(this, wait, options)
}

@@ -205,55 +196,55 @@ // Options = {immediate: boolean|undefined}

// (Property, number, Options|undefined) -> Property
import debounce from './one-source/debounce';
import debounce from './one-source/debounce'
Observable.prototype.debounce = function(wait, options) {
return debounce(this, wait, options);
};
return debounce(this, wait, options)
}
// (Stream, Function|undefined) -> Stream
// (Property, Function|undefined) -> Property
import mapErrors from './one-source/map-errors';
import mapErrors from './one-source/map-errors'
Observable.prototype.mapErrors = function(fn) {
return mapErrors(this, fn);
};
return mapErrors(this, fn)
}
// (Stream, Function|undefined) -> Stream
// (Property, Function|undefined) -> Property
import filterErrors from './one-source/filter-errors';
import filterErrors from './one-source/filter-errors'
Observable.prototype.filterErrors = function(fn) {
return filterErrors(this, fn);
};
return filterErrors(this, fn)
}
// (Stream) -> Stream
// (Property) -> Property
import ignoreValues from './one-source/ignore-values';
import ignoreValues from './one-source/ignore-values'
Observable.prototype.ignoreValues = function() {
return ignoreValues(this);
};
return ignoreValues(this)
}
// (Stream) -> Stream
// (Property) -> Property
import ignoreErrors from './one-source/ignore-errors';
import ignoreErrors from './one-source/ignore-errors'
Observable.prototype.ignoreErrors = function() {
return ignoreErrors(this);
};
return ignoreErrors(this)
}
// (Stream) -> Stream
// (Property) -> Property
import ignoreEnd from './one-source/ignore-end';
import ignoreEnd from './one-source/ignore-end'
Observable.prototype.ignoreEnd = function() {
return ignoreEnd(this);
};
return ignoreEnd(this)
}
// (Stream, Function) -> Stream
// (Property, Function) -> Property
import beforeEnd from './one-source/before-end';
import beforeEnd from './one-source/before-end'
Observable.prototype.beforeEnd = function(fn) {
return beforeEnd(this, fn);
};
return beforeEnd(this, fn)
}
// (Stream, number, number|undefined) -> Stream
// (Property, number, number|undefined) -> Property
import slidingWindow from './one-source/sliding-window';
import slidingWindow from './one-source/sliding-window'
Observable.prototype.slidingWindow = function(max, min) {
return slidingWindow(this, max, min);
};
return slidingWindow(this, max, min)
}

@@ -263,13 +254,13 @@ // Options = {flushOnEnd: boolean|undefined}

// (Property, Function|falsey, Options|undefined) -> Property
import bufferWhile from './one-source/buffer-while';
import bufferWhile from './one-source/buffer-while'
Observable.prototype.bufferWhile = function(fn, options) {
return bufferWhile(this, fn, options);
};
return bufferWhile(this, fn, options)
}
// (Stream, number) -> Stream
// (Property, number) -> Property
import bufferWithCount from './one-source/buffer-with-count';
import bufferWithCount from './one-source/buffer-with-count'
Observable.prototype.bufferWithCount = function(count, options) {
return bufferWithCount(this, count, options);
};
return bufferWithCount(this, count, options)
}

@@ -279,23 +270,21 @@ // Options = {flushOnEnd: boolean|undefined}

// (Property, number, number, Options|undefined) -> Property
import bufferWithTimeOrCount from './one-source/buffer-with-time-or-count';
import bufferWithTimeOrCount from './one-source/buffer-with-time-or-count'
Observable.prototype.bufferWithTimeOrCount = function(wait, count, options) {
return bufferWithTimeOrCount(this, wait, count, options);
};
return bufferWithTimeOrCount(this, wait, count, options)
}
// (Stream, Function) -> Stream
// (Property, Function) -> Property
import transduce from './one-source/transduce';
import transduce from './one-source/transduce'
Observable.prototype.transduce = function(transducer) {
return transduce(this, transducer);
};
return transduce(this, transducer)
}
// (Stream, Function) -> Stream
// (Property, Function) -> Property
import withHandler from './one-source/with-handler';
import withHandler from './one-source/with-handler'
Observable.prototype.withHandler = function(fn) {
return withHandler(this, fn);
};
return withHandler(this, fn)
}
// Combine observables

@@ -306,61 +295,59 @@ // -----------------------------------------------------------------------------

// (Array<Stream|Property>, Array<Stream|Property>, Function|undefiend) -> Stream
import combine from './many-sources/combine';
import combine from './many-sources/combine'
Observable.prototype.combine = function(other, combinator) {
return combine([this, other], combinator);
};
return combine([this, other], combinator)
}
// (Array<Stream|Property>, Function|undefiend) -> Stream
import zip from './many-sources/zip';
import zip from './many-sources/zip'
Observable.prototype.zip = function(other, combinator) {
return zip([this, other], combinator);
};
return zip([this, other], combinator)
}
// (Array<Stream|Property>) -> Stream
import merge from './many-sources/merge';
import merge from './many-sources/merge'
Observable.prototype.merge = function(other) {
return merge([this, other]);
};
return merge([this, other])
}
// (Array<Stream|Property>) -> Stream
import concat from './many-sources/concat';
import concat from './many-sources/concat'
Observable.prototype.concat = function(other) {
return concat([this, other]);
};
return concat([this, other])
}
// () -> Pool
import Pool from './many-sources/pool';
import Pool from './many-sources/pool'
const pool = function() {
return new Pool();
};
return new Pool()
}
// (Function) -> Stream
import repeat from './many-sources/repeat';
import repeat from './many-sources/repeat'
// Options = {concurLim: number|undefined, queueLim: number|undefined, drop: 'old'|'new'|undefiend}
// (Stream|Property, Function|falsey, Options|undefined) -> Stream
import FlatMap from './many-sources/flat-map';
import FlatMap from './many-sources/flat-map'
Observable.prototype.flatMap = function(fn) {
return new FlatMap(this, fn).setName(this, 'flatMap');
};
return new FlatMap(this, fn).setName(this, 'flatMap')
}
Observable.prototype.flatMapLatest = function(fn) {
return new FlatMap(this, fn, {concurLim: 1, drop: 'old'}).setName(this, 'flatMapLatest');
};
return new FlatMap(this, fn, {concurLim: 1, drop: 'old'}).setName(this, 'flatMapLatest')
}
Observable.prototype.flatMapFirst = function(fn) {
return new FlatMap(this, fn, {concurLim: 1}).setName(this, 'flatMapFirst');
};
return new FlatMap(this, fn, {concurLim: 1}).setName(this, 'flatMapFirst')
}
Observable.prototype.flatMapConcat = function(fn) {
return new FlatMap(this, fn, {queueLim: -1, concurLim: 1}).setName(this, 'flatMapConcat');
};
return new FlatMap(this, fn, {queueLim: -1, concurLim: 1}).setName(this, 'flatMapConcat')
}
Observable.prototype.flatMapConcurLimit = function(fn, limit) {
return new FlatMap(this, fn, {queueLim: -1, concurLim: limit}).setName(this, 'flatMapConcurLimit');
};
return new FlatMap(this, fn, {queueLim: -1, concurLim: limit}).setName(this, 'flatMapConcurLimit')
}
// (Stream|Property, Function|falsey) -> Stream
import FlatMapErrors from './many-sources/flat-map-errors';
import FlatMapErrors from './many-sources/flat-map-errors'
Observable.prototype.flatMapErrors = function(fn) {
return new FlatMapErrors(this, fn).setName(this, 'flatMapErrors');
};
return new FlatMapErrors(this, fn).setName(this, 'flatMapErrors')
}
// Combine two observables

@@ -371,27 +358,27 @@ // -----------------------------------------------------------------------------

// (Property, Stream|Property) -> Property
import filterBy from './two-sources/filter-by';
import filterBy from './two-sources/filter-by'
Observable.prototype.filterBy = function(other) {
return filterBy(this, other);
};
return filterBy(this, other)
}
// (Stream, Stream|Property, Function|undefiend) -> Stream
// (Property, Stream|Property, Function|undefiend) -> Property
import sampledBy2items from './two-sources/sampled-by';
import sampledBy2items from './two-sources/sampled-by'
Observable.prototype.sampledBy = function(other, combinator) {
return sampledBy2items(this, other, combinator);
};
return sampledBy2items(this, other, combinator)
}
// (Stream, Stream|Property) -> Stream
// (Property, Stream|Property) -> Property
import skipUntilBy from './two-sources/skip-until-by';
import skipUntilBy from './two-sources/skip-until-by'
Observable.prototype.skipUntilBy = function(other) {
return skipUntilBy(this, other);
};
return skipUntilBy(this, other)
}
// (Stream, Stream|Property) -> Stream
// (Property, Stream|Property) -> Property
import takeUntilBy from './two-sources/take-until-by';
import takeUntilBy from './two-sources/take-until-by'
Observable.prototype.takeUntilBy = function(other) {
return takeUntilBy(this, other);
};
return takeUntilBy(this, other)
}

@@ -401,6 +388,6 @@ // Options = {flushOnEnd: boolean|undefined}

// (Property, Stream|Property, Options|undefined) -> Property
import bufferBy from './two-sources/buffer-by';
import bufferBy from './two-sources/buffer-by'
Observable.prototype.bufferBy = function(other, options) {
return bufferBy(this, other, options);
};
return bufferBy(this, other, options)
}

@@ -410,9 +397,7 @@ // Options = {flushOnEnd: boolean|undefined}

// (Property, Stream|Property, Options|undefined) -> Property
import bufferWhileBy from './two-sources/buffer-while-by';
import bufferWhileBy from './two-sources/buffer-while-by'
Observable.prototype.bufferWhileBy = function(other, options) {
return bufferWhileBy(this, other, options);
};
return bufferWhileBy(this, other, options)
}
// Deprecated

@@ -428,4 +413,4 @@ // -----------------------------------------------------------------------------

if (DEPRECATION_WARNINGS && console && typeof console.warn === 'function') {
const msg2 = '\nHere is an Error object for you containing the call stack:';
console.warn(msg, msg2, new Error());
const msg2 = '\nHere is an Error object for you containing the call stack:'
console.warn(msg, msg2, new Error())
}

@@ -435,50 +420,94 @@ }

// (Stream|Property, Stream|Property) -> Property
import awaiting from './two-sources/awaiting';
import awaiting from './two-sources/awaiting'
Observable.prototype.awaiting = function(other) {
warn('You are using deprecated .awaiting() method, see https://github.com/rpominov/kefir/issues/145')
return awaiting(this, other);
};
return awaiting(this, other)
}
// (Stream, Function|undefined) -> Stream
// (Property, Function|undefined) -> Property
import valuesToErrors from './one-source/values-to-errors';
import valuesToErrors from './one-source/values-to-errors'
Observable.prototype.valuesToErrors = function(fn) {
warn('You are using deprecated .valuesToErrors() method, see https://github.com/rpominov/kefir/issues/149')
return valuesToErrors(this, fn);
};
return valuesToErrors(this, fn)
}
// (Stream, Function|undefined) -> Stream
// (Property, Function|undefined) -> Property
import errorsToValues from './one-source/errors-to-values';
import errorsToValues from './one-source/errors-to-values'
Observable.prototype.errorsToValues = function(fn) {
warn('You are using deprecated .errorsToValues() method, see https://github.com/rpominov/kefir/issues/149')
return errorsToValues(this, fn);
};
return errorsToValues(this, fn)
}
// (Stream) -> Stream
// (Property) -> Property
import endOnError from './one-source/end-on-error';
import endOnError from './one-source/end-on-error'
Observable.prototype.endOnError = function() {
warn('You are using deprecated .endOnError() method, see https://github.com/rpominov/kefir/issues/150')
return endOnError(this);
};
return endOnError(this)
}
// Exports
// --------------------------------------------------------------------------
const Kefir = { Observable, Stream, Property, never, later, interval, sequentially,
fromPoll, withInterval, fromCallback, fromNodeCallback, fromEvents, stream,
constant, constantError, fromPromise, fromESObservable, combine, zip, merge,
concat, Pool, pool, repeat, staticLand };
const Kefir = {
Observable,
Stream,
Property,
never,
later,
interval,
sequentially,
fromPoll,
withInterval,
fromCallback,
fromNodeCallback,
fromEvents,
stream,
constant,
constantError,
fromPromise,
fromESObservable,
combine,
zip,
merge,
concat,
Pool,
pool,
repeat,
staticLand,
}
Kefir.Kefir = Kefir;
Kefir.Kefir = Kefir
export { Kefir, Observable, Stream, Property, never, later, interval, sequentially,
fromPoll, withInterval, fromCallback, fromNodeCallback, fromEvents, stream,
constant, constantError, fromPromise, fromESObservable, combine, zip, merge,
concat, Pool, pool, repeat, staticLand };
export {
Kefir,
Observable,
Stream,
Property,
never,
later,
interval,
sequentially,
fromPoll,
withInterval,
fromCallback,
fromNodeCallback,
fromEvents,
stream,
constant,
constantError,
fromPromise,
fromESObservable,
combine,
zip,
merge,
concat,
Pool,
pool,
repeat,
staticLand,
}
export default Kefir

@@ -1,26 +0,28 @@

import stream from '../primary/stream';
import $$observable from 'symbol-observable';
import stream from '../primary/stream'
import $$observable from './symbol'
export default function fromESObservable(_observable) {
const observable = _observable[$$observable] ? _observable[$$observable]() : _observable;
const observable = _observable[$$observable] ? _observable[$$observable]() : _observable
return stream(function(emitter) {
const unsub = observable.subscribe({
error(error) {
emitter.error(error);
emitter.end();
emitter.error(error)
emitter.end()
},
next(value) {
emitter.emit(value);
emitter.emit(value)
},
complete() {
emitter.end();
}
emitter.end()
},
})
if (unsub.unsubscribe) {
return function () { unsub.unsubscribe(); };
return function() {
unsub.unsubscribe()
}
} else {
return unsub;
return unsub
}
}).setName('fromESObservable');
}).setName('fromESObservable')
}

@@ -1,31 +0,29 @@

import stream from '../primary/stream';
import toProperty from '../one-source/to-property';
import stream from '../primary/stream'
import toProperty from '../one-source/to-property'
export default function fromPromise(promise) {
let called = false
let called = false;
let result = stream(function(emitter) {
if (!called) {
let onValue = function(x) {
emitter.emit(x);
emitter.end();
};
emitter.emit(x)
emitter.end()
}
let onError = function(x) {
emitter.error(x);
emitter.end();
};
let _promise = promise.then(onValue, onError);
emitter.error(x)
emitter.end()
}
let _promise = promise.then(onValue, onError)
// prevent libraries like 'Q' or 'when' from swallowing exceptions
if (_promise && typeof _promise.done === 'function') {
_promise.done();
_promise.done()
}
called = true;
called = true
}
})
return toProperty(result, null).setName('fromPromise');
return toProperty(result, null).setName('fromPromise')
}

@@ -1,9 +0,8 @@

import constant from '../primary/constant';
import never from '../primary/never';
import combine from '../many-sources/combine';
import constant from '../primary/constant'
import never from '../primary/never'
import combine from '../many-sources/combine'
const Observable = {
empty() {
return never();
return never()
},

@@ -13,15 +12,15 @@

concat(a, b) {
return a.merge(b);
return a.merge(b)
},
of(x) {
return constant(x);
return constant(x)
},
map(fn, obs) {
return obs.map(fn);
return obs.map(fn)
},
bimap(fnErr, fnVal, obs) {
return obs.mapErrors(fnErr).map(fnVal);
return obs.mapErrors(fnErr).map(fnVal)
},

@@ -34,11 +33,10 @@

ap(obsFn, obsVal) {
return combine([obsFn, obsVal], (fn, val) => fn(val));
return combine([obsFn, obsVal], (fn, val) => fn(val))
},
chain(fn, obs) {
return obs.flatMap(fn);
}
return obs.flatMap(fn)
},
}
export {Observable}

@@ -1,7 +0,7 @@

import $$observable from 'symbol-observable';
import {extend} from '../utils/objects';
import {VALUE, ERROR, END} from '../constants';
import {extend} from '../utils/objects'
import {VALUE, ERROR, END} from '../constants'
import $$observable from './symbol'
function ESObservable(observable) {
this._observable = observable.takeErrors(1);
this._observable = observable.takeErrors(1)
}

@@ -11,3 +11,2 @@

subscribe(observerOrOnNext, onError, onComplete) {
const observer = typeof observerOrOnNext === 'function'

@@ -19,15 +18,15 @@ ? {next: observerOrOnNext, error: onError, complete: onComplete}

if (event.type === END) {
closed = true;
closed = true
}
if (event.type === VALUE && observer.next) {
observer.next(event.value);
observer.next(event.value)
} else if (event.type === ERROR && observer.error) {
observer.error(event.value);
observer.error(event.value)
} else if (event.type === END && observer.complete) {
observer.complete(event.value);
observer.complete(event.value)
}
}
this._observable.onAny(fn);
this._observable.onAny(fn)
let closed = false

@@ -37,21 +36,20 @@

unsubscribe: () => {
closed = true;
this._observable.offAny(fn);
closed = true
this._observable.offAny(fn)
},
get closed() {
return closed
}
};
return subscription;
},
}
return subscription
},
})
}
});
// Need to assign directly b/c Symbols aren't enumerable.
ESObservable.prototype[$$observable] = function() {
return this;
};
return this
}
export default function toESObservable() {
return new ESObservable(this);
return new ESObservable(this)
}

@@ -1,8 +0,8 @@

import {VALUE, END} from '../constants';
import {VALUE, END} from '../constants'
function getGlodalPromise() {
if (typeof Promise === 'function') {
return Promise;
return Promise
} else {
throw new Error('There isn\'t default Promise, use shim or parameter');
throw new Error("There isn't default Promise, use shim or parameter")
}

@@ -12,13 +12,13 @@ }

export default function(obs, Promise = getGlodalPromise()) {
let last = null;
let last = null
return new Promise((resolve, reject) => {
obs.onAny(event => {
if (event.type === END && last !== null) {
(last.type === VALUE ? resolve : reject)(last.value);
last = null;
;(last.type === VALUE ? resolve : reject)(last.value)
last = null
} else {
last = event;
last = event
}
});
});
})
})
}

@@ -1,22 +0,22 @@

import Stream from '../stream';
import {VALUE, ERROR} from '../constants';
import {inherit} from '../utils/objects';
import {concat, forEach, findByPred, find, remove, cloneArray} from '../utils/collections';
import Stream from '../stream'
import {VALUE, ERROR} from '../constants'
import {inherit} from '../utils/objects'
import {concat, forEach, findByPred, find, remove, cloneArray} from '../utils/collections'
const id = (x => x);
const id = x => x
function AbstractPool({queueLim = 0, concurLim = -1, drop = 'new'} = {}) {
Stream.call(this);
Stream.call(this)
this._queueLim = queueLim < 0 ? -1 : queueLim;
this._concurLim = concurLim < 0 ? -1 : concurLim;
this._drop = drop;
this._queue = [];
this._curSources = [];
this._$handleSubAny = (event) => this._handleSubAny(event);
this._$endHandlers = [];
this._currentlyAdding = null;
this._queueLim = queueLim < 0 ? -1 : queueLim
this._concurLim = concurLim < 0 ? -1 : concurLim
this._drop = drop
this._queue = []
this._curSources = []
this._$handleSubAny = event => this._handleSubAny(event)
this._$endHandlers = []
this._currentlyAdding = null
if (this._concurLim === 0) {
this._emitEnd();
this._emitEnd()
}

@@ -26,15 +26,14 @@ }

inherit(AbstractPool, Stream, {
_name: 'abstractPool',
_add(obj, toObs /* Function | falsey */) {
toObs = toObs || id;
toObs = toObs || id
if (this._concurLim === -1 || this._curSources.length < this._concurLim) {
this._addToCur(toObs(obj));
this._addToCur(toObs(obj))
} else {
if (this._queueLim === -1 || this._queue.length < this._queueLim) {
this._addToQueue(toObs(obj));
this._addToQueue(toObs(obj))
} else if (this._drop === 'old') {
this._removeOldest();
this._add(obj, toObs);
this._removeOldest()
this._add(obj, toObs)
}

@@ -45,3 +44,3 @@ }

_addAll(obss) {
forEach(obss, (obs) => this._add(obs));
forEach(obss, obs => this._add(obs))
},

@@ -51,3 +50,3 @@

if (this._removeCur(obs) === -1) {
this._removeQueue(obs);
this._removeQueue(obs)
}

@@ -57,3 +56,3 @@ },

_addToQueue(obs) {
this._queue = concat(this._queue, [obs]);
this._queue = concat(this._queue, [obs])
},

@@ -63,3 +62,2 @@

if (this._active) {
// HACK:

@@ -83,5 +81,5 @@ //

if (obs._currentEvent) {
this._emit(obs._currentEvent.type, obs._currentEvent.value);
this._emit(obs._currentEvent.type, obs._currentEvent.value)
}
return;
return
}

@@ -92,14 +90,13 @@

// first subscriber e.g., Kefir.stream(em => {em.emit(1); em.end()})
this._currentlyAdding = obs;
obs.onAny(this._$handleSubAny);
this._currentlyAdding = null;
this._currentlyAdding = obs
obs.onAny(this._$handleSubAny)
this._currentlyAdding = null
if (obs._alive) {
this._curSources = concat(this._curSources, [obs]);
this._curSources = concat(this._curSources, [obs])
if (this._active) {
this._subToEnd(obs);
this._subToEnd(obs)
}
}
} else {
this._curSources = concat(this._curSources, [obs]);
this._curSources = concat(this._curSources, [obs])
}

@@ -109,13 +106,13 @@ },

_subToEnd(obs) {
const onEnd = () => this._removeCur(obs);
this._$endHandlers.push({obs: obs, handler: onEnd});
obs.onEnd(onEnd);
const onEnd = () => this._removeCur(obs)
this._$endHandlers.push({obs: obs, handler: onEnd})
obs.onEnd(onEnd)
},
_subscribe(obs) {
obs.onAny(this._$handleSubAny);
obs.onAny(this._$handleSubAny)
// it can become inactive in responce of subscribing to `obs.onAny` above
if (this._active) {
this._subToEnd(obs);
this._subToEnd(obs)
}

@@ -125,8 +122,8 @@ },

_unsubscribe(obs) {
obs.offAny(this._$handleSubAny);
obs.offAny(this._$handleSubAny)
let onEndI = findByPred(this._$endHandlers, (obj) => obj.obs === obs);
let onEndI = findByPred(this._$endHandlers, obj => obj.obs === obs)
if (onEndI !== -1) {
obs.offEnd(this._$endHandlers[onEndI].handler);
this._$endHandlers.splice(onEndI, 1);
obs.offEnd(this._$endHandlers[onEndI].handler)
this._$endHandlers.splice(onEndI, 1)
}

@@ -137,5 +134,5 @@ },

if (event.type === VALUE) {
this._emitValue(event.value);
this._emitValue(event.value)
} else if (event.type === ERROR) {
this._emitError(event.value);
this._emitError(event.value)
}

@@ -145,5 +142,5 @@ },

_removeQueue(obs) {
let index = find(this._queue, obs);
this._queue = remove(this._queue, index);
return index;
let index = find(this._queue, obs)
this._queue = remove(this._queue, index)
return index
},

@@ -153,18 +150,18 @@

if (this._active) {
this._unsubscribe(obs);
this._unsubscribe(obs)
}
let index = find(this._curSources, obs);
this._curSources = remove(this._curSources, index);
let index = find(this._curSources, obs)
this._curSources = remove(this._curSources, index)
if (index !== -1) {
if (this._queue.length !== 0) {
this._pullQueue();
this._pullQueue()
} else if (this._curSources.length === 0) {
this._onEmpty();
this._onEmpty()
}
}
return index;
return index
},
_removeOldest() {
this._removeCur(this._curSources[0]);
this._removeCur(this._curSources[0])
},

@@ -174,4 +171,4 @@

if (this._queue.length !== 0) {
this._queue = cloneArray(this._queue);
this._addToCur(this._queue.shift());
this._queue = cloneArray(this._queue)
this._addToCur(this._queue.shift())
}

@@ -182,3 +179,3 @@ },

for (let i = 0, sources = this._curSources; i < sources.length && this._active; i++) {
this._subscribe(sources[i]);
this._subscribe(sources[i])
}

@@ -189,6 +186,6 @@ },

for (let i = 0, sources = this._curSources; i < sources.length; i++) {
this._unsubscribe(sources[i]);
this._unsubscribe(sources[i])
}
if (this._currentlyAdding !== null) {
this._unsubscribe(this._currentlyAdding);
this._unsubscribe(this._currentlyAdding)
}

@@ -198,3 +195,3 @@ },

_isEmpty() {
return this._curSources.length === 0;
return this._curSources.length === 0
},

@@ -205,11 +202,10 @@

_clear() {
Stream.prototype._clear.call(this);
this._queue = null;
this._curSources = null;
this._$handleSubAny = null;
this._$endHandlers = null;
}
Stream.prototype._clear.call(this)
this._queue = null
this._curSources = null
this._$handleSubAny = null
this._$endHandlers = null
},
})
});
export default AbstractPool;
export default AbstractPool

@@ -1,13 +0,13 @@

import Stream from '../stream';
import {VALUE, ERROR, NOTHING} from '../constants';
import {inherit} from '../utils/objects';
import {concat, fillArray} from '../utils/collections';
import {spread} from '../utils/functions';
import never from '../primary/never';
import Stream from '../stream'
import {VALUE, ERROR, NOTHING} from '../constants'
import {inherit} from '../utils/objects'
import {concat, fillArray} from '../utils/collections'
import {spread} from '../utils/functions'
import never from '../primary/never'
function collect(source, keys, values) {
for (var prop in source) {
if( source.hasOwnProperty( prop ) ) {
keys.push(prop);
values.push(source[prop]);
if (source.hasOwnProperty(prop)) {
keys.push(prop)
values.push(source[prop])
}

@@ -18,40 +18,37 @@ }

function defaultErrorsCombinator(errors) {
let latestError;
let latestError
for (let i = 0; i < errors.length; i++) {
if (errors[i] !== undefined) {
if (latestError === undefined || latestError.index < errors[i].index) {
latestError = errors[i];
latestError = errors[i]
}
}
}
return latestError.error;
return latestError.error
}
function Combine(active, passive, combinator) {
Stream.call(this);
this._activeCount = active.length;
this._sources = concat(active, passive);
this._combinator = combinator;
this._aliveCount = 0;
this._latestValues = new Array(this._sources.length);
this._latestErrors = new Array(this._sources.length);
fillArray(this._latestValues, NOTHING);
this._emitAfterActivation = false;
this._endAfterActivation = false;
this._latestErrorIndex = 0;
Stream.call(this)
this._activeCount = active.length
this._sources = concat(active, passive)
this._combinator = combinator
this._aliveCount = 0
this._latestValues = new Array(this._sources.length)
this._latestErrors = new Array(this._sources.length)
fillArray(this._latestValues, NOTHING)
this._emitAfterActivation = false
this._endAfterActivation = false
this._latestErrorIndex = 0
this._$handlers = [];
this._$handlers = []
for (let i = 0; i < this._sources.length; i++) {
this._$handlers.push((event) => this._handleAny(i, event));
this._$handlers.push(event => this._handleAny(i, event))
}
}
inherit(Combine, Stream, {
_name: 'combine',
_onActivation() {
this._aliveCount = this._activeCount;
this._aliveCount = this._activeCount

@@ -61,14 +58,14 @@ // we need to suscribe to _passive_ sources before _active_

for (let i = this._activeCount; i < this._sources.length; i++) {
this._sources[i].onAny(this._$handlers[i]);
this._sources[i].onAny(this._$handlers[i])
}
for (let i = 0; i < this._activeCount; i++) {
this._sources[i].onAny(this._$handlers[i]);
this._sources[i].onAny(this._$handlers[i])
}
if (this._emitAfterActivation) {
this._emitAfterActivation = false;
this._emitIfFull();
this._emitAfterActivation = false
this._emitIfFull()
}
if (this._endAfterActivation) {
this._emitEnd();
this._emitEnd()
}

@@ -78,6 +75,5 @@ },

_onDeactivation() {
let length = this._sources.length,
i;
let length = this._sources.length, i
for (i = 0; i < length; i++) {
this._sources[i].offAny(this._$handlers[i]);
this._sources[i].offAny(this._$handlers[i])
}

@@ -87,18 +83,18 @@ },

_emitIfFull() {
let hasAllValues = true;
let hasErrors = false;
let length = this._latestValues.length;
let valuesCopy = new Array(length);
let errorsCopy = new Array(length);
let hasAllValues = true
let hasErrors = false
let length = this._latestValues.length
let valuesCopy = new Array(length)
let errorsCopy = new Array(length)
for (let i = 0; i < length; i++) {
valuesCopy[i] = this._latestValues[i];
errorsCopy[i] = this._latestErrors[i];
valuesCopy[i] = this._latestValues[i]
errorsCopy[i] = this._latestErrors[i]
if (valuesCopy[i] === NOTHING) {
hasAllValues = false;
hasAllValues = false
}
if (errorsCopy[i] !== undefined) {
hasErrors = true;
hasErrors = true
}

@@ -108,7 +104,7 @@ }

if (hasAllValues) {
const combinator = this._combinator;
this._emitValue(combinator(valuesCopy));
const combinator = this._combinator
this._emitValue(combinator(valuesCopy))
}
if (hasErrors) {
this._emitError(defaultErrorsCombinator(errorsCopy));
this._emitError(defaultErrorsCombinator(errorsCopy))
}

@@ -118,15 +114,13 @@ },

_handleAny(i, event) {
if (event.type === VALUE || event.type === ERROR) {
if (event.type === VALUE) {
this._latestValues[i] = event.value;
this._latestErrors[i] = undefined;
this._latestValues[i] = event.value
this._latestErrors[i] = undefined
}
if (event.type === ERROR) {
this._latestValues[i] = NOTHING;
this._latestValues[i] = NOTHING
this._latestErrors[i] = {
index: this._latestErrorIndex++,
error: event.value
};
error: event.value,
}
}

@@ -136,21 +130,20 @@

if (this._activating) {
this._emitAfterActivation = true;
this._emitAfterActivation = true
} else {
this._emitIfFull();
this._emitIfFull()
}
}
} else {
// END
} else { // END
if (i < this._activeCount) {
this._aliveCount--;
this._aliveCount--
if (this._aliveCount === 0) {
if (this._activating) {
this._endAfterActivation = true;
this._endAfterActivation = true
} else {
this._emitEnd();
this._emitEnd()
}
}
}
}

@@ -160,19 +153,18 @@ },

_clear() {
Stream.prototype._clear.call(this);
this._sources = null;
this._latestValues = null;
this._latestErrors = null;
this._combinator = null;
this._$handlers = null;
}
Stream.prototype._clear.call(this)
this._sources = null
this._latestValues = null
this._latestErrors = null
this._combinator = null
this._$handlers = null
},
})
});
function combineAsArray(active, passive = [], combinator) {
if (!Array.isArray(passive)) {
throw new Error('Combine can only combine active and passive collections of the same type.');
throw new Error('Combine can only combine active and passive collections of the same type.')
}
combinator = combinator ? spread(combinator, active.length + passive.length) : (x => x);
return active.length === 0 ? never() : new Combine(active, passive, combinator);
combinator = combinator ? spread(combinator, active.length + passive.length) : x => x
return active.length === 0 ? never() : new Combine(active, passive, combinator)
}

@@ -182,21 +174,19 @@

if (typeof passive !== 'object' || Array.isArray(passive)) {
throw new Error('Combine can only combine active and passive collections of the same type.');
throw new Error('Combine can only combine active and passive collections of the same type.')
}
let keys = [],
activeObservables = [],
passiveObservables = [];
let keys = [], activeObservables = [], passiveObservables = []
collect(active, keys, activeObservables);
collect(passive, keys, passiveObservables);
collect(active, keys, activeObservables)
collect(passive, keys, passiveObservables)
const objectify = values => {
let event = {};
for(let i = values.length - 1; 0 <= i; i--) {
event[keys[i]] = values[i];
let event = {}
for (let i = values.length - 1; 0 <= i; i--) {
event[keys[i]] = values[i]
}
return combinator ? combinator(event) : event;
return combinator ? combinator(event) : event
}
return activeObservables.length === 0 ? never() : new Combine(activeObservables, passiveObservables, objectify);
return activeObservables.length === 0 ? never() : new Combine(activeObservables, passiveObservables, objectify)
}

@@ -206,7 +196,9 @@

if (typeof passive === 'function') {
combinator = passive;
passive = undefined;
combinator = passive
passive = undefined
}
return Array.isArray(active) ? combineAsArray(active, passive, combinator) : combineAsObject(active, passive, combinator);
return Array.isArray(active)
? combineAsArray(active, passive, combinator)
: combineAsObject(active, passive, combinator)
}

@@ -1,7 +0,7 @@

import repeat from './repeat';
import repeat from './repeat'
export default function concat(observables) {
return repeat(function(index) {
return observables.length > index ? observables[index] : false;
}).setName('concat');
return observables.length > index ? observables[index] : false
}).setName('concat')
}

@@ -1,25 +0,23 @@

import {VALUE, ERROR, END} from '../constants';
import {inherit} from '../utils/objects';
import FlatMap from './flat-map';
import {VALUE, ERROR, END} from '../constants'
import {inherit} from '../utils/objects'
import FlatMap from './flat-map'
function FlatMapErrors(source, fn) {
FlatMap.call(this, source, fn);
FlatMap.call(this, source, fn)
}
inherit(FlatMapErrors, FlatMap, {
// Same as in FlatMap, only VALUE/ERROR flipped
_handleMain(event) {
if (event.type === ERROR) {
let sameCurr = this._activating && this._hadNoEvSinceDeact && this._lastCurrent === event.value;
let sameCurr = this._activating && this._hadNoEvSinceDeact && this._lastCurrent === event.value
if (!sameCurr) {
this._add(event.value, this._fn);
this._add(event.value, this._fn)
}
this._lastCurrent = event.value;
this._hadNoEvSinceDeact = false;
this._lastCurrent = event.value
this._hadNoEvSinceDeact = false
}
if (event.type === VALUE) {
this._emitValue(event.value);
this._emitValue(event.value)
}

@@ -29,14 +27,10 @@

if (this._isEmpty()) {
this._emitEnd();
this._emitEnd()
} else {
this._mainEnded = true;
this._mainEnded = true
}
}
},
})
}
});
export default FlatMapErrors;
export default FlatMapErrors

@@ -1,23 +0,19 @@

import {VALUE, ERROR, END} from '../constants';
import {inherit} from '../utils/objects';
import AbstractPool from './abstract-pool';
import {VALUE, ERROR, END} from '../constants'
import {inherit} from '../utils/objects'
import AbstractPool from './abstract-pool'
function FlatMap(source, fn, options) {
AbstractPool.call(this, options);
this._source = source;
this._fn = fn;
this._mainEnded = false;
this._lastCurrent = null;
this._$handleMain = (event) => this._handleMain(event);
AbstractPool.call(this, options)
this._source = source
this._fn = fn
this._mainEnded = false
this._lastCurrent = null
this._$handleMain = event => this._handleMain(event)
}
inherit(FlatMap, AbstractPool, {
_onActivation() {
AbstractPool.prototype._onActivation.call(this);
AbstractPool.prototype._onActivation.call(this)
if (this._active) {
this._source.onAny(this._$handleMain);
this._source.onAny(this._$handleMain)
}

@@ -27,9 +23,8 @@ },

_onDeactivation() {
AbstractPool.prototype._onDeactivation.call(this);
this._source.offAny(this._$handleMain);
this._hadNoEvSinceDeact = true;
AbstractPool.prototype._onDeactivation.call(this)
this._source.offAny(this._$handleMain)
this._hadNoEvSinceDeact = true
},
_handleMain(event) {
if (event.type === VALUE) {

@@ -40,12 +35,12 @@ // Is latest value before deactivation survived, and now is 'current' on this activation?

// is a `Kefir.conatant()` for example.
let sameCurr = this._activating && this._hadNoEvSinceDeact && this._lastCurrent === event.value;
let sameCurr = this._activating && this._hadNoEvSinceDeact && this._lastCurrent === event.value
if (!sameCurr) {
this._add(event.value, this._fn);
this._add(event.value, this._fn)
}
this._lastCurrent = event.value;
this._hadNoEvSinceDeact = false;
this._lastCurrent = event.value
this._hadNoEvSinceDeact = false
}
if (event.type === ERROR) {
this._emitError(event.value);
this._emitError(event.value)
}

@@ -55,8 +50,7 @@

if (this._isEmpty()) {
this._emitEnd();
this._emitEnd()
} else {
this._mainEnded = true;
this._mainEnded = true
}
}
},

@@ -66,3 +60,3 @@

if (this._mainEnded) {
this._emitEnd();
this._emitEnd()
}

@@ -72,13 +66,9 @@ },

_clear() {
AbstractPool.prototype._clear.call(this);
this._source = null;
this._lastCurrent = null;
this._$handleMain = null;
}
AbstractPool.prototype._clear.call(this)
this._source = null
this._lastCurrent = null
this._$handleMain = null
},
})
});
export default FlatMap;
export default FlatMap

@@ -1,14 +0,12 @@

import {inherit} from '../utils/objects';
import AbstractPool from './abstract-pool';
import never from '../primary/never';
import {inherit} from '../utils/objects'
import AbstractPool from './abstract-pool'
import never from '../primary/never'
function Merge(sources) {
AbstractPool.call(this);
this._addAll(sources);
this._initialised = true;
AbstractPool.call(this)
this._addAll(sources)
this._initialised = true
}
inherit(Merge, AbstractPool, {
_name: 'merge',

@@ -18,10 +16,9 @@

if (this._initialised) {
this._emitEnd();
this._emitEnd()
}
}
},
})
});
export default function merge(observables) {
return observables.length === 0 ? never() : new Merge(observables);
return observables.length === 0 ? never() : new Merge(observables)
}

@@ -1,26 +0,22 @@

import {inherit} from '../utils/objects';
import AbstractPool from './abstract-pool';
import {inherit} from '../utils/objects'
import AbstractPool from './abstract-pool'
function Pool() {
AbstractPool.call(this);
AbstractPool.call(this)
}
inherit(Pool, AbstractPool, {
_name: 'pool',
plug(obs) {
this._add(obs);
return this;
this._add(obs)
return this
},
unplug(obs) {
this._remove(obs);
return this;
}
this._remove(obs)
return this
},
})
});
export default Pool;
export default Pool

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

import {inherit} from '../utils/objects';
import Stream from '../stream';
import {END} from '../constants';
import {inherit} from '../utils/objects'
import Stream from '../stream'
import {END} from '../constants'
function S(generator) {
Stream.call(this);
this._generator = generator;
this._source = null;
this._inLoop = false;
this._iteration = 0;
this._$handleAny = (event) => this._handleAny(event);
Stream.call(this)
this._generator = generator
this._source = null
this._inLoop = false
this._iteration = 0
this._$handleAny = event => this._handleAny(event)
}
inherit(S, Stream, {
_name: 'repeat',

@@ -22,6 +19,6 @@

if (event.type === END) {
this._source = null;
this._getSource();
this._source = null
this._getSource()
} else {
this._emit(event.type, event.value);
this._emit(event.type, event.value)
}

@@ -32,13 +29,13 @@ },

if (!this._inLoop) {
this._inLoop = true;
const generator = this._generator;
this._inLoop = true
const generator = this._generator
while (this._source === null && this._alive && this._active) {
this._source = generator(this._iteration++);
this._source = generator(this._iteration++)
if (this._source) {
this._source.onAny(this._$handleAny);
this._source.onAny(this._$handleAny)
} else {
this._emitEnd();
this._emitEnd()
}
}
this._inLoop = false;
this._inLoop = false
}

@@ -49,5 +46,5 @@ },

if (this._source) {
this._source.onAny(this._$handleAny);
this._source.onAny(this._$handleAny)
} else {
this._getSource();
this._getSource()
}

@@ -58,3 +55,3 @@ },

if (this._source) {
this._source.offAny(this._$handleAny);
this._source.offAny(this._$handleAny)
}

@@ -64,13 +61,11 @@ },

_clear() {
Stream.prototype._clear.call(this);
this._generator = null;
this._source = null;
this._$handleAny = null;
}
Stream.prototype._clear.call(this)
this._generator = null
this._source = null
this._$handleAny = null
},
})
});
export default function(generator) {
return new S(generator);
return new S(generator)
}

@@ -1,45 +0,42 @@

import Stream from '../stream';
import {VALUE, ERROR, END} from '../constants';
import {inherit} from '../utils/objects';
import {map, cloneArray} from '../utils/collections';
import {spread} from '../utils/functions';
import never from '../primary/never';
import Stream from '../stream'
import {VALUE, ERROR, END} from '../constants'
import {inherit} from '../utils/objects'
import {map, cloneArray} from '../utils/collections'
import {spread} from '../utils/functions'
import never from '../primary/never'
const isArray =
Array.isArray ||
function(xs) {
return Object.prototype.toString.call(xs) === '[object Array]'
}
const isArray = Array.isArray || function(xs) {
return Object.prototype.toString.call(xs) === '[object Array]';
};
function Zip(sources, combinator) {
Stream.call(this);
Stream.call(this)
this._buffers = map(sources, (source) => isArray(source) ? cloneArray(source) : []);
this._sources = map(sources, (source) => isArray(source) ? never() : source);
this._buffers = map(sources, source => (isArray(source) ? cloneArray(source) : []))
this._sources = map(sources, source => (isArray(source) ? never() : source))
this._combinator = combinator ? spread(combinator, this._sources.length) : (x => x);
this._aliveCount = 0;
this._combinator = combinator ? spread(combinator, this._sources.length) : x => x
this._aliveCount = 0
this._$handlers = [];
this._$handlers = []
for (let i = 0; i < this._sources.length; i++) {
this._$handlers.push((event) => this._handleAny(i, event));
this._$handlers.push(event => this._handleAny(i, event))
}
}
inherit(Zip, Stream, {
_name: 'zip',
_onActivation() {
// if all sources are arrays
while (this._isFull()) {
this._emit();
this._emit()
}
const length = this._sources.length;
this._aliveCount = length;
const length = this._sources.length
this._aliveCount = length
for (let i = 0; i < length && this._active; i++) {
this._sources[i].onAny(this._$handlers[i]);
this._sources[i].onAny(this._$handlers[i])
}

@@ -50,3 +47,3 @@ },

for (let i = 0; i < this._sources.length; i++) {
this._sources[i].offAny(this._$handlers[i]);
this._sources[i].offAny(this._$handlers[i])
}

@@ -56,8 +53,8 @@ },

_emit() {
let values = new Array(this._buffers.length);
let values = new Array(this._buffers.length)
for (let i = 0; i < this._buffers.length; i++) {
values[i] = this._buffers[i].shift();
values[i] = this._buffers[i].shift()
}
const combinator = this._combinator;
this._emitValue(combinator(values));
const combinator = this._combinator
this._emitValue(combinator(values))
},

@@ -68,6 +65,6 @@

if (this._buffers[i].length === 0) {
return false;
return false
}
}
return true;
return true
},

@@ -77,14 +74,14 @@

if (event.type === VALUE) {
this._buffers[i].push(event.value);
this._buffers[i].push(event.value)
if (this._isFull()) {
this._emit();
this._emit()
}
}
if (event.type === ERROR) {
this._emitError(event.value);
this._emitError(event.value)
}
if (event.type === END) {
this._aliveCount--;
this._aliveCount--
if (this._aliveCount === 0) {
this._emitEnd();
this._emitEnd()
}

@@ -95,15 +92,12 @@ }

_clear() {
Stream.prototype._clear.call(this);
this._sources = null;
this._buffers = null;
this._combinator = null;
this._$handlers = null;
}
Stream.prototype._clear.call(this)
this._sources = null
this._buffers = null
this._combinator = null
this._$handlers = null
},
})
});
export default function zip(observables, combinator /* Function | falsey */) {
return observables.length === 0 ? never() : new Zip(observables, combinator);
return observables.length === 0 ? never() : new Zip(observables, combinator)
}

@@ -1,19 +0,16 @@

import {extend} from './utils/objects';
import {VALUE, ERROR, ANY, END} from './constants';
import {Dispatcher, callSubscriber} from './dispatcher';
import {findByPred} from './utils/collections';
import {extend} from './utils/objects'
import {VALUE, ERROR, ANY, END} from './constants'
import {Dispatcher, callSubscriber} from './dispatcher'
import {findByPred} from './utils/collections'
function Observable() {
this._dispatcher = new Dispatcher();
this._active = false;
this._alive = true;
this._activating = false;
this._logHandlers = null;
this._spyHandlers = null;
this._dispatcher = new Dispatcher()
this._active = false
this._alive = true
this._activating = false
this._logHandlers = null
this._spyHandlers = null
}
extend(Observable.prototype, {
_name: 'observable',

@@ -26,9 +23,9 @@

if (this._active !== active) {
this._active = active;
this._active = active
if (active) {
this._activating = true;
this._onActivation();
this._activating = false;
this._activating = true
this._onActivation()
this._activating = false
} else {
this._onDeactivation();
this._onDeactivation()
}

@@ -39,6 +36,6 @@ }

_clear() {
this._setActive(false);
this._dispatcher.cleanup();
this._dispatcher = null;
this._logHandlers = null;
this._setActive(false)
this._dispatcher.cleanup()
this._dispatcher = null
this._logHandlers = null
},

@@ -48,5 +45,8 @@

switch (type) {
case VALUE: return this._emitValue(x);
case ERROR: return this._emitError(x);
case END: return this._emitEnd();
case VALUE:
return this._emitValue(x)
case ERROR:
return this._emitError(x)
case END:
return this._emitEnd()
}

@@ -57,3 +57,3 @@ },

if (this._alive) {
this._dispatcher.dispatch({type: VALUE, value});
this._dispatcher.dispatch({type: VALUE, value})
}

@@ -64,3 +64,3 @@ },

if (this._alive) {
this._dispatcher.dispatch({type: ERROR, value});
this._dispatcher.dispatch({type: ERROR, value})
}

@@ -72,4 +72,4 @@ },

this._alive = false
this._dispatcher.dispatch({type: END});
this._clear();
this._dispatcher.dispatch({type: END})
this._clear()
}

@@ -80,8 +80,8 @@ },

if (this._alive) {
this._dispatcher.add(type, fn);
this._setActive(true);
this._dispatcher.add(type, fn)
this._setActive(true)
} else {
callSubscriber(type, fn, {type: END});
callSubscriber(type, fn, {type: END})
}
return this;
return this
},

@@ -91,58 +91,58 @@

if (this._alive) {
let count = this._dispatcher.remove(type, fn);
let count = this._dispatcher.remove(type, fn)
if (count === 0) {
this._setActive(false);
this._setActive(false)
}
}
return this;
return this
},
onValue(fn) {
return this._on(VALUE, fn);
return this._on(VALUE, fn)
},
onError(fn) {
return this._on(ERROR, fn);
return this._on(ERROR, fn)
},
onEnd(fn) {
return this._on(END, fn);
return this._on(END, fn)
},
onAny(fn) {
return this._on(ANY, fn);
return this._on(ANY, fn)
},
offValue(fn) {
return this._off(VALUE, fn);
return this._off(VALUE, fn)
},
offError(fn) {
return this._off(ERROR, fn);
return this._off(ERROR, fn)
},
offEnd(fn) {
return this._off(END, fn);
return this._off(END, fn)
},
offAny(fn) {
return this._off(ANY, fn);
return this._off(ANY, fn)
},
observe(observerOrOnValue, onError, onEnd) {
const _this = this;
let closed = false;
const _this = this
let closed = false
const observer = !observerOrOnValue || typeof observerOrOnValue === 'function'
? {value: observerOrOnValue, error: onError, end: onEnd}
: observerOrOnValue;
: observerOrOnValue
const handler = function(event) {
if (event.type === END) {
closed = true;
closed = true
}
if (event.type === VALUE && observer.value) {
observer.value(event.value);
observer.value(event.value)
} else if (event.type === ERROR && observer.error) {
observer.error(event.value);
observer.error(event.value)
} else if (event.type === END && observer.end) {
observer.end(event.value);
observer.end(event.value)
}
};
}
this.onAny(handler);
this.onAny(handler)

@@ -152,10 +152,10 @@ return {

if (!closed) {
_this.offAny(handler);
closed = true;
_this.offAny(handler)
closed = true
}
},
get closed() {
return closed;
}
};
return closed
},
}
},

@@ -165,48 +165,45 @@

_ofSameType(A, B) {
return A.prototype.getType() === this.getType() ? A : B;
return A.prototype.getType() === this.getType() ? A : B
},
setName(sourceObs /* optional */, selfName) {
this._name = selfName ? `${sourceObs._name}.${selfName}` : sourceObs;
return this;
this._name = selfName ? `${sourceObs._name}.${selfName}` : sourceObs
return this
},
log(name = this.toString()) {
let isCurrent
let handler = function(event) {
let type = `<${event.type}${isCurrent ? ':current' : ''}>`;
let type = `<${event.type}${isCurrent ? ':current' : ''}>`
if (event.type === END) {
console.log(name, type);
console.log(name, type)
} else {
console.log(name, type, event.value);
console.log(name, type, event.value)
}
};
}
if (this._alive) {
if (!this._logHandlers) {
this._logHandlers = [];
this._logHandlers = []
}
this._logHandlers.push({name: name, handler: handler});
this._logHandlers.push({name: name, handler: handler})
}
isCurrent = true;
this.onAny(handler);
isCurrent = false;
isCurrent = true
this.onAny(handler)
isCurrent = false
return this;
return this
},
offLog(name = this.toString()) {
if (this._logHandlers) {
let handlerIndex = findByPred(this._logHandlers, obj => obj.name === name);
let handlerIndex = findByPred(this._logHandlers, obj => obj.name === name)
if (handlerIndex !== -1) {
this.offAny(this._logHandlers[handlerIndex].handler);
this._logHandlers.splice(handlerIndex, 1);
this.offAny(this._logHandlers[handlerIndex].handler)
this._logHandlers.splice(handlerIndex, 1)
}
}
return this;
return this
},

@@ -216,17 +213,17 @@

let handler = function(event) {
let type = `<${event.type}>`;
let type = `<${event.type}>`
if (event.type === END) {
console.log(name, type);
console.log(name, type)
} else {
console.log(name, type, event.value);
console.log(name, type, event.value)
}
};
}
if (this._alive) {
if (!this._spyHandlers) {
this._spyHandlers = [];
this._spyHandlers = []
}
this._spyHandlers.push({name: name, handler: handler});
this._dispatcher.addSpy(handler);
this._spyHandlers.push({name: name, handler: handler})
this._dispatcher.addSpy(handler)
}
return this;
return this
},

@@ -236,18 +233,17 @@

if (this._spyHandlers) {
let handlerIndex = findByPred(this._spyHandlers, obj => obj.name === name);
let handlerIndex = findByPred(this._spyHandlers, obj => obj.name === name)
if (handlerIndex !== -1) {
this._dispatcher.removeSpy(this._spyHandlers[handlerIndex].handler);
this._spyHandlers.splice(handlerIndex, 1);
this._dispatcher.removeSpy(this._spyHandlers[handlerIndex].handler)
this._spyHandlers.splice(handlerIndex, 1)
}
}
return this;
}
});
return this
},
})
// extend() can't handle `toString` in IE8
Observable.prototype.toString = function() {
return `[${this._name}]`;
};
return `[${this._name}]`
}
export default Observable;
export default Observable

@@ -1,26 +0,24 @@

import {createStream, createProperty} from '../patterns/one-source';
import {createStream, createProperty} from '../patterns/one-source'
const mixin = {
_init({fn}) {
this._fn = fn;
this._fn = fn
},
_free() {
this._fn = null;
this._fn = null
},
_handleEnd() {
const fn = this._fn;
this._emitValue(fn());
this._emitEnd();
}
const fn = this._fn
this._emitValue(fn())
this._emitEnd()
},
}
};
const S = createStream('beforeEnd', mixin)
const P = createProperty('beforeEnd', mixin)
const S = createStream('beforeEnd', mixin);
const P = createProperty('beforeEnd', mixin);
export default function beforeEnd(obs, fn) {
return new (obs._ofSameType(S, P))(obs, {fn});
return new (obs._ofSameType(S, P))(obs, {fn})
}

@@ -1,13 +0,12 @@

import {createStream, createProperty} from '../patterns/one-source';
import {createStream, createProperty} from '../patterns/one-source'
const mixin = {
_init({fn, flushOnEnd}) {
this._fn = fn;
this._flushOnEnd = flushOnEnd;
this._buff = [];
this._fn = fn
this._flushOnEnd = flushOnEnd
this._buff = []
},
_free() {
this._buff = null;
this._buff = null
},

@@ -17,4 +16,4 @@

if (this._buff !== null && this._buff.length !== 0) {
this._emitValue(this._buff);
this._buff = [];
this._emitValue(this._buff)
this._buff = []
}

@@ -24,6 +23,6 @@ },

_handleValue(x) {
this._buff.push(x);
const fn = this._fn;
this._buff.push(x)
const fn = this._fn
if (!fn(x)) {
this._flush();
this._flush()
}

@@ -34,17 +33,15 @@ },

if (this._flushOnEnd) {
this._flush();
this._flush()
}
this._emitEnd();
}
this._emitEnd()
},
}
};
const S = createStream('bufferWhile', mixin)
const P = createProperty('bufferWhile', mixin)
const S = createStream('bufferWhile', mixin);
const P = createProperty('bufferWhile', mixin);
const id = x => x
const id = x => x;
export default function bufferWhile(obs, fn, {flushOnEnd = true} = {}) {
return new (obs._ofSameType(S, P))(obs, {fn: fn || id, flushOnEnd});
return new (obs._ofSameType(S, P))(obs, {fn: fn || id, flushOnEnd})
}

@@ -1,13 +0,12 @@

import {createStream, createProperty} from '../patterns/one-source';
import {createStream, createProperty} from '../patterns/one-source'
const mixin = {
_init({count, flushOnEnd}) {
this._count = count;
this._flushOnEnd = flushOnEnd;
this._buff = [];
this._count = count
this._flushOnEnd = flushOnEnd
this._buff = []
},
_free() {
this._buff = null;
this._buff = null
},

@@ -17,4 +16,4 @@

if (this._buff !== null && this._buff.length !== 0) {
this._emitValue(this._buff);
this._buff = [];
this._emitValue(this._buff)
this._buff = []
}

@@ -24,5 +23,5 @@ },

_handleValue(x) {
this._buff.push(x);
this._buff.push(x)
if (this._buff.length >= this._count) {
this._flush();
this._flush()
}

@@ -33,14 +32,13 @@ },

if (this._flushOnEnd) {
this._flush();
this._flush()
}
this._emitEnd();
}
this._emitEnd()
},
}
};
const S = createStream('bufferWithCount', mixin)
const P = createProperty('bufferWithCount', mixin)
const S = createStream('bufferWithCount', mixin);
const P = createProperty('bufferWithCount', mixin);
export default function bufferWhile(obs, count, {flushOnEnd = true} = {}) {
return new (obs._ofSameType(S, P))(obs, {count: count, flushOnEnd});
return new (obs._ofSameType(S, P))(obs, {count: count, flushOnEnd})
}

@@ -1,17 +0,16 @@

import {createStream, createProperty} from '../patterns/one-source';
import {createStream, createProperty} from '../patterns/one-source'
const mixin = {
_init({wait, count, flushOnEnd}) {
this._wait = wait;
this._count = count;
this._flushOnEnd = flushOnEnd;
this._intervalId = null;
this._$onTick = () => this._flush();
this._buff = [];
this._wait = wait
this._count = count
this._flushOnEnd = flushOnEnd
this._intervalId = null
this._$onTick = () => this._flush()
this._buff = []
},
_free() {
this._$onTick = null;
this._buff = null;
this._$onTick = null
this._buff = null
},

@@ -21,4 +20,4 @@

if (this._buff !== null) {
this._emitValue(this._buff);
this._buff = [];
this._emitValue(this._buff)
this._buff = []
}

@@ -28,7 +27,7 @@ },

_handleValue(x) {
this._buff.push(x);
this._buff.push(x)
if (this._buff.length >= this._count) {
clearInterval(this._intervalId);
this._flush();
this._intervalId = setInterval(this._$onTick, this._wait);
clearInterval(this._intervalId)
this._flush()
this._intervalId = setInterval(this._$onTick, this._wait)
}

@@ -39,10 +38,10 @@ },

if (this._flushOnEnd && this._buff.length !== 0) {
this._flush();
this._flush()
}
this._emitEnd();
this._emitEnd()
},
_onActivation() {
this._intervalId = setInterval(this._$onTick, this._wait);
this._source.onAny(this._$handleAny); // copied from patterns/one-source
this._intervalId = setInterval(this._$onTick, this._wait)
this._source.onAny(this._$handleAny) // copied from patterns/one-source
},

@@ -52,16 +51,14 @@

if (this._intervalId !== null) {
clearInterval(this._intervalId);
this._intervalId = null;
clearInterval(this._intervalId)
this._intervalId = null
}
this._source.offAny(this._$handleAny); // copied from patterns/one-source
}
this._source.offAny(this._$handleAny) // copied from patterns/one-source
},
}
};
const S = createStream('bufferWithTimeOrCount', mixin)
const P = createProperty('bufferWithTimeOrCount', mixin)
const S = createStream('bufferWithTimeOrCount', mixin);
const P = createProperty('bufferWithTimeOrCount', mixin);
export default function bufferWithTimeOrCount(obs, wait, count, {flushOnEnd = true} = {}) {
return new (obs._ofSameType(S, P))(obs, {wait, count, flushOnEnd});
return new (obs._ofSameType(S, P))(obs, {wait, count, flushOnEnd})
}

@@ -1,10 +0,7 @@

import {createStream} from '../patterns/one-source';
import {createStream} from '../patterns/one-source'
const S = createStream('changes', {
_handleValue(x) {
if (!this._activating) {
this._emitValue(x);
this._emitValue(x)
}

@@ -15,11 +12,9 @@ },

if (!this._activating) {
this._emitError(x);
this._emitError(x)
}
}
},
})
});
export default function changes(obs) {
return new S(obs);
return new S(obs)
}

@@ -1,20 +0,18 @@

import {createStream, createProperty} from '../patterns/one-source';
import now from '../utils/now';
import {createStream, createProperty} from '../patterns/one-source'
import now from '../utils/now'
const mixin = {
_init({wait, immediate}) {
this._wait = Math.max(0, wait);
this._immediate = immediate;
this._lastAttempt = 0;
this._timeoutId = null;
this._laterValue = null;
this._endLater = false;
this._$later = () => this._later();
this._wait = Math.max(0, wait)
this._immediate = immediate
this._lastAttempt = 0
this._timeoutId = null
this._laterValue = null
this._endLater = false
this._$later = () => this._later()
},
_free() {
this._laterValue = null;
this._$later = null;
this._laterValue = null
this._$later = null
},

@@ -24,13 +22,13 @@

if (this._activating) {
this._emitValue(x);
this._emitValue(x)
} else {
this._lastAttempt = now();
this._lastAttempt = now()
if (this._immediate && !this._timeoutId) {
this._emitValue(x);
this._emitValue(x)
}
if (!this._timeoutId) {
this._timeoutId = setTimeout(this._$later, this._wait);
this._timeoutId = setTimeout(this._$later, this._wait)
}
if (!this._immediate) {
this._laterValue = x;
this._laterValue = x
}

@@ -42,8 +40,8 @@ }

if (this._activating) {
this._emitEnd();
this._emitEnd()
} else {
if (this._timeoutId && !this._immediate) {
this._endLater = true;
this._endLater = true
} else {
this._emitEnd();
this._emitEnd()
}

@@ -54,25 +52,23 @@ }

_later() {
let last = now() - this._lastAttempt;
let last = now() - this._lastAttempt
if (last < this._wait && last >= 0) {
this._timeoutId = setTimeout(this._$later, this._wait - last);
this._timeoutId = setTimeout(this._$later, this._wait - last)
} else {
this._timeoutId = null;
this._timeoutId = null
if (!this._immediate) {
this._emitValue(this._laterValue);
this._laterValue = null;
this._emitValue(this._laterValue)
this._laterValue = null
}
if (this._endLater) {
this._emitEnd();
this._emitEnd()
}
}
}
},
}
};
const S = createStream('debounce', mixin)
const P = createProperty('debounce', mixin)
const S = createStream('debounce', mixin);
const P = createProperty('debounce', mixin);
export default function debounce(obs, wait, {immediate = false} = {}) {
return new (obs._ofSameType(S, P))(obs, {wait, immediate});
return new (obs._ofSameType(S, P))(obs, {wait, immediate})
}

@@ -1,23 +0,22 @@

import {createStream, createProperty} from '../patterns/one-source';
import {createStream, createProperty} from '../patterns/one-source'
const END_MARKER = {};
const END_MARKER = {}
const mixin = {
_init({wait}) {
this._wait = Math.max(0, wait);
this._buff = [];
this._wait = Math.max(0, wait)
this._buff = []
this._$shiftBuff = () => {
const value = this._buff.shift();
const value = this._buff.shift()
if (value === END_MARKER) {
this._emitEnd();
this._emitEnd()
} else {
this._emitValue(value);
this._emitValue(value)
}
};
}
},
_free() {
this._buff = null;
this._$shiftBuff = null;
this._buff = null
this._$shiftBuff = null
},

@@ -27,6 +26,6 @@

if (this._activating) {
this._emitValue(x);
this._emitValue(x)
} else {
this._buff.push(x);
setTimeout(this._$shiftBuff, this._wait);
this._buff.push(x)
setTimeout(this._$shiftBuff, this._wait)
}

@@ -37,16 +36,15 @@ },

if (this._activating) {
this._emitEnd();
this._emitEnd()
} else {
this._buff.push(END_MARKER);
setTimeout(this._$shiftBuff, this._wait);
this._buff.push(END_MARKER)
setTimeout(this._$shiftBuff, this._wait)
}
}
},
}
};
const S = createStream('delay', mixin)
const P = createProperty('delay', mixin)
const S = createStream('delay', mixin);
const P = createProperty('delay', mixin);
export default function delay(obs, wait) {
return new (obs._ofSameType(S, P))(obs, {wait});
return new (obs._ofSameType(S, P))(obs, {wait})
}

@@ -1,14 +0,13 @@

import {createStream, createProperty} from '../patterns/one-source';
import {NOTHING} from '../constants';
import {createStream, createProperty} from '../patterns/one-source'
import {NOTHING} from '../constants'
const mixin = {
_init({fn, seed}) {
this._fn = fn;
this._prev = seed;
this._fn = fn
this._prev = seed
},
_free() {
this._prev = null;
this._fn = null;
this._prev = null
this._fn = null
},

@@ -18,20 +17,18 @@

if (this._prev !== NOTHING) {
const fn = this._fn;
this._emitValue(fn(this._prev, x));
const fn = this._fn
this._emitValue(fn(this._prev, x))
}
this._prev = x;
}
this._prev = x
},
}
};
const S = createStream('diff', mixin)
const P = createProperty('diff', mixin)
const S = createStream('diff', mixin);
const P = createProperty('diff', mixin);
function defaultFn(a, b) {
return [a, b];
return [a, b]
}
export default function diff(obs, fn, seed = NOTHING) {
return new (obs._ofSameType(S, P))(obs, {fn: fn || defaultFn, seed});
return new (obs._ofSameType(S, P))(obs, {fn: fn || defaultFn, seed})
}

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

import {createStream, createProperty} from '../patterns/one-source';
import {createStream, createProperty} from '../patterns/one-source'
const mixin = {
_handleError(x) {
this._emitError(x);
this._emitEnd();
}
this._emitError(x)
this._emitEnd()
},
}
};
const S = createStream('endOnError', mixin)
const P = createProperty('endOnError', mixin)
const S = createStream('endOnError', mixin);
const P = createProperty('endOnError', mixin);
export default function endOnError(obs) {
return new (obs._ofSameType(S, P))(obs);
return new (obs._ofSameType(S, P))(obs)
}

@@ -1,33 +0,30 @@

import {createStream, createProperty} from '../patterns/one-source';
import {createStream, createProperty} from '../patterns/one-source'
const mixin = {
_init({fn}) {
this._fn = fn;
this._fn = fn
},
_free() {
this._fn = null;
this._fn = null
},
_handleError(x) {
const fn = this._fn;
const result = fn(x);
const fn = this._fn
const result = fn(x)
if (result.convert) {
this._emitValue(result.value);
this._emitValue(result.value)
} else {
this._emitError(x);
this._emitError(x)
}
}
},
}
};
const S = createStream('errorsToValues', mixin)
const P = createProperty('errorsToValues', mixin)
const S = createStream('errorsToValues', mixin);
const P = createProperty('errorsToValues', mixin);
const defFn = x => ({convert: true, value: x})
const defFn = x => ({convert: true, value: x});
export default function errorsToValues(obs, fn = defFn) {
return new (obs._ofSameType(S, P))(obs, {fn});
return new (obs._ofSameType(S, P))(obs, {fn})
}

@@ -1,30 +0,27 @@

import {createStream, createProperty} from '../patterns/one-source';
import {createStream, createProperty} from '../patterns/one-source'
const mixin = {
_init({fn}) {
this._fn = fn;
this._fn = fn
},
_free() {
this._fn = null;
this._fn = null
},
_handleError(x) {
const fn = this._fn;
const fn = this._fn
if (fn(x)) {
this._emitError(x);
this._emitError(x)
}
}
},
}
};
const S = createStream('filterErrors', mixin)
const P = createProperty('filterErrors', mixin)
const S = createStream('filterErrors', mixin);
const P = createProperty('filterErrors', mixin);
const id = x => x
const id = x => x;
export default function filterErrors(obs, fn = id) {
return new (obs._ofSameType(S, P))(obs, {fn});
return new (obs._ofSameType(S, P))(obs, {fn})
}

@@ -1,30 +0,27 @@

import {createStream, createProperty} from '../patterns/one-source';
import {createStream, createProperty} from '../patterns/one-source'
const mixin = {
_init({fn}) {
this._fn = fn;
this._fn = fn
},
_free() {
this._fn = null;
this._fn = null
},
_handleValue(x) {
const fn = this._fn;
const fn = this._fn
if (fn(x)) {
this._emitValue(x);
this._emitValue(x)
}
}
},
}
};
const S = createStream('filter', mixin)
const P = createProperty('filter', mixin)
const S = createStream('filter', mixin);
const P = createProperty('filter', mixin);
const id = x => x
const id = x => x;
export default function filter(obs, fn = id) {
return new (obs._ofSameType(S, P))(obs, {fn});
return new (obs._ofSameType(S, P))(obs, {fn})
}

@@ -1,30 +0,27 @@

import {createStream} from '../patterns/one-source';
import {createStream} from '../patterns/one-source'
const mixin = {
_init({fn}) {
this._fn = fn;
this._fn = fn
},
_free() {
this._fn = null;
this._fn = null
},
_handleValue(x) {
const fn = this._fn;
const xs = fn(x);
const fn = this._fn
const xs = fn(x)
for (let i = 0; i < xs.length; i++) {
this._emitValue(xs[i]);
this._emitValue(xs[i])
}
}
},
}
};
const S = createStream('flatten', mixin)
const S = createStream('flatten', mixin);
const id = x => x
const id = x => x;
export default function flatten(obs, fn = id) {
return new S(obs, {fn});
return new S(obs, {fn})
}

@@ -1,13 +0,12 @@

import {createStream, createProperty} from '../patterns/one-source';
import {createStream, createProperty} from '../patterns/one-source'
const mixin = {
_handleEnd() {}
};
_handleEnd() {},
}
const S = createStream('ignoreEnd', mixin);
const P = createProperty('ignoreEnd', mixin);
const S = createStream('ignoreEnd', mixin)
const P = createProperty('ignoreEnd', mixin)
export default function ignoreEnd(obs) {
return new (obs._ofSameType(S, P))(obs);
return new (obs._ofSameType(S, P))(obs)
}

@@ -1,13 +0,12 @@

import {createStream, createProperty} from '../patterns/one-source';
import {createStream, createProperty} from '../patterns/one-source'
const mixin = {
_handleError() {}
};
_handleError() {},
}
const S = createStream('ignoreErrors', mixin);
const P = createProperty('ignoreErrors', mixin);
const S = createStream('ignoreErrors', mixin)
const P = createProperty('ignoreErrors', mixin)
export default function ignoreErrors(obs) {
return new (obs._ofSameType(S, P))(obs);
return new (obs._ofSameType(S, P))(obs)
}

@@ -1,13 +0,12 @@

import {createStream, createProperty} from '../patterns/one-source';
import {createStream, createProperty} from '../patterns/one-source'
const mixin = {
_handleValue() {}
};
_handleValue() {},
}
const S = createStream('ignoreValues', mixin);
const P = createProperty('ignoreValues', mixin);
const S = createStream('ignoreValues', mixin)
const P = createProperty('ignoreValues', mixin)
export default function ignoreValues(obs) {
return new (obs._ofSameType(S, P))(obs);
return new (obs._ofSameType(S, P))(obs)
}

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

import {createStream, createProperty} from '../patterns/one-source';
import {NOTHING} from '../constants';
import {createStream, createProperty} from '../patterns/one-source'
import {NOTHING} from '../constants'
const mixin = {
_init() {
this._lastValue = NOTHING;
this._lastValue = NOTHING
},
_free() {
this._lastValue = null;
this._lastValue = null
},
_handleValue(x) {
this._lastValue = x;
this._lastValue = x
},

@@ -20,15 +19,13 @@

if (this._lastValue !== NOTHING) {
this._emitValue(this._lastValue);
this._emitValue(this._lastValue)
}
this._emitEnd();
}
this._emitEnd()
},
}
};
const S = createStream('last', mixin)
const P = createProperty('last', mixin)
const S = createStream('last', mixin);
const P = createProperty('last', mixin);
export default function last(obs) {
return new (obs._ofSameType(S, P))(obs);
return new (obs._ofSameType(S, P))(obs)
}

@@ -1,28 +0,25 @@

import {createStream, createProperty} from '../patterns/one-source';
import {createStream, createProperty} from '../patterns/one-source'
const mixin = {
_init({fn}) {
this._fn = fn;
this._fn = fn
},
_free() {
this._fn = null;
this._fn = null
},
_handleError(x) {
const fn = this._fn;
this._emitError(fn(x));
}
const fn = this._fn
this._emitError(fn(x))
},
}
};
const S = createStream('mapErrors', mixin)
const P = createProperty('mapErrors', mixin)
const S = createStream('mapErrors', mixin);
const P = createProperty('mapErrors', mixin);
const id = x => x
const id = x => x;
export default function mapErrors(obs, fn = id) {
return new (obs._ofSameType(S, P))(obs, {fn});
return new (obs._ofSameType(S, P))(obs, {fn})
}

@@ -1,28 +0,25 @@

import {createStream, createProperty} from '../patterns/one-source';
import {createStream, createProperty} from '../patterns/one-source'
const mixin = {
_init({fn}) {
this._fn = fn;
this._fn = fn
},
_free() {
this._fn = null;
this._fn = null
},
_handleValue(x) {
const fn = this._fn;
this._emitValue(fn(x));
}
const fn = this._fn
this._emitValue(fn(x))
},
}
};
const S = createStream('map', mixin)
const P = createProperty('map', mixin)
const S = createStream('map', mixin);
const P = createProperty('map', mixin);
const id = x => x
const id = x => x;
export default function map(obs, fn = id) {
return new (obs._ofSameType(S, P))(obs, {fn});
return new (obs._ofSameType(S, P))(obs, {fn})
}

@@ -1,12 +0,10 @@

import {createProperty} from '../patterns/one-source';
import {ERROR, NOTHING} from '../constants';
import {createProperty} from '../patterns/one-source'
import {ERROR, NOTHING} from '../constants'
const P = createProperty('scan', {
_init({fn, seed}) {
this._fn = fn;
this._seed = seed;
this._fn = fn
this._seed = seed
if (seed !== NOTHING) {
this._emitValue(seed);
this._emitValue(seed)
}

@@ -16,20 +14,18 @@ },

_free() {
this._fn = null;
this._seed = null;
this._fn = null
this._seed = null
},
_handleValue(x) {
const fn = this._fn;
const fn = this._fn
if (this._currentEvent === null || this._currentEvent.type === ERROR) {
this._emitValue(this._seed === NOTHING ? x : fn(this._seed, x));
this._emitValue(this._seed === NOTHING ? x : fn(this._seed, x))
} else {
this._emitValue(fn(this._currentEvent.value, x));
this._emitValue(fn(this._currentEvent.value, x))
}
}
},
})
});
export default function scan(obs, fn, seed = NOTHING) {
return new P(obs, {fn, seed});
return new P(obs, {fn, seed})
}

@@ -1,34 +0,31 @@

import {createStream, createProperty} from '../patterns/one-source';
import {NOTHING} from '../constants';
import {createStream, createProperty} from '../patterns/one-source'
import {NOTHING} from '../constants'
const mixin = {
_init({fn}) {
this._fn = fn;
this._prev = NOTHING;
this._fn = fn
this._prev = NOTHING
},
_free() {
this._fn = null;
this._prev = null;
this._fn = null
this._prev = null
},
_handleValue(x) {
const fn = this._fn;
const fn = this._fn
if (this._prev === NOTHING || !fn(this._prev, x)) {
this._prev = x;
this._emitValue(x);
this._prev = x
this._emitValue(x)
}
}
},
}
};
const S = createStream('skipDuplicates', mixin)
const P = createProperty('skipDuplicates', mixin)
const S = createStream('skipDuplicates', mixin);
const P = createProperty('skipDuplicates', mixin);
const eq = (a, b) => a === b
const eq = (a, b) => a === b;
export default function skipDuplicates(obs, fn = eq) {
return new (obs._ofSameType(S, P))(obs, {fn});
return new (obs._ofSameType(S, P))(obs, {fn})
}

@@ -1,13 +0,12 @@

import {createStream, createProperty} from '../patterns/one-source';
import {createStream, createProperty} from '../patterns/one-source'
const mixin = {
_handleEnd() {}
};
_handleEnd() {},
}
const S = createStream('skipEnd', mixin);
const P = createProperty('skipEnd', mixin);
const S = createStream('skipEnd', mixin)
const P = createProperty('skipEnd', mixin)
export default function skipEnd(obs) {
return new (obs._ofSameType(S, P))(obs);
return new (obs._ofSameType(S, P))(obs)
}

@@ -1,33 +0,30 @@

import {createStream, createProperty} from '../patterns/one-source';
import {createStream, createProperty} from '../patterns/one-source'
const mixin = {
_init({fn}) {
this._fn = fn;
this._fn = fn
},
_free() {
this._fn = null;
this._fn = null
},
_handleValue(x) {
const fn = this._fn;
const fn = this._fn
if (this._fn !== null && !fn(x)) {
this._fn = null;
this._fn = null
}
if (this._fn === null) {
this._emitValue(x);
this._emitValue(x)
}
}
},
}
};
const S = createStream('skipWhile', mixin)
const P = createProperty('skipWhile', mixin)
const S = createStream('skipWhile', mixin);
const P = createProperty('skipWhile', mixin);
const id = x => x
const id = x => x;
export default function skipWhile(obs, fn = id) {
return new (obs._ofSameType(S, P))(obs, {fn});
return new (obs._ofSameType(S, P))(obs, {fn})
}

@@ -1,7 +0,6 @@

import {createStream, createProperty} from '../patterns/one-source';
import {createStream, createProperty} from '../patterns/one-source'
const mixin = {
_init({n}) {
this._n = Math.max(0, n);
this._n = Math.max(0, n)
},

@@ -11,16 +10,14 @@

if (this._n === 0) {
this._emitValue(x);
this._emitValue(x)
} else {
this._n--;
this._n--
}
}
},
}
};
const S = createStream('skip', mixin)
const P = createProperty('skip', mixin)
const S = createStream('skip', mixin);
const P = createProperty('skip', mixin);
export default function skip(obs, n) {
return new (obs._ofSameType(S, P))(obs, {n});
return new (obs._ofSameType(S, P))(obs, {n})
}

@@ -1,31 +0,28 @@

import {createStream, createProperty} from '../patterns/one-source';
import {slide} from '../utils/collections';
import {createStream, createProperty} from '../patterns/one-source'
import {slide} from '../utils/collections'
const mixin = {
_init({min, max}) {
this._max = max;
this._min = min;
this._buff = [];
this._max = max
this._min = min
this._buff = []
},
_free() {
this._buff = null;
this._buff = null
},
_handleValue(x) {
this._buff = slide(this._buff, x, this._max);
this._buff = slide(this._buff, x, this._max)
if (this._buff.length >= this._min) {
this._emitValue(this._buff);
this._emitValue(this._buff)
}
}
},
}
};
const S = createStream('slidingWindow', mixin)
const P = createProperty('slidingWindow', mixin)
const S = createStream('slidingWindow', mixin);
const P = createProperty('slidingWindow', mixin);
export default function slidingWindow(obs, max, min = 0) {
return new (obs._ofSameType(S, P))(obs, {min, max});
return new (obs._ofSameType(S, P))(obs, {min, max})
}

@@ -1,9 +0,8 @@

import {createStream, createProperty} from '../patterns/one-source';
import {createStream, createProperty} from '../patterns/one-source'
const mixin = {
_init({n}) {
this._n = n;
this._n = n
if (n <= 0) {
this._emitEnd();
this._emitEnd()
}

@@ -13,17 +12,15 @@ },

_handleError(x) {
this._n--;
this._emitError(x);
this._n--
this._emitError(x)
if (this._n === 0) {
this._emitEnd();
this._emitEnd()
}
}
},
}
};
const S = createStream('takeErrors', mixin)
const P = createProperty('takeErrors', mixin)
const S = createStream('takeErrors', mixin);
const P = createProperty('takeErrors', mixin);
export default function takeErrors(obs, n) {
return new (obs._ofSameType(S, P))(obs, {n});
return new (obs._ofSameType(S, P))(obs, {n})
}

@@ -1,32 +0,29 @@

import {createStream, createProperty} from '../patterns/one-source';
import {createStream, createProperty} from '../patterns/one-source'
const mixin = {
_init({fn}) {
this._fn = fn;
this._fn = fn
},
_free() {
this._fn = null;
this._fn = null
},
_handleValue(x) {
const fn = this._fn;
const fn = this._fn
if (fn(x)) {
this._emitValue(x);
this._emitValue(x)
} else {
this._emitEnd();
this._emitEnd()
}
}
},
}
};
const S = createStream('takeWhile', mixin)
const P = createProperty('takeWhile', mixin)
const S = createStream('takeWhile', mixin);
const P = createProperty('takeWhile', mixin);
const id = x => x
const id = x => x;
export default function takeWhile(obs, fn = id) {
return new (obs._ofSameType(S, P))(obs, {fn});
return new (obs._ofSameType(S, P))(obs, {fn})
}

@@ -1,9 +0,8 @@

import {createStream, createProperty} from '../patterns/one-source';
import {createStream, createProperty} from '../patterns/one-source'
const mixin = {
_init({n}) {
this._n = n;
this._n = n
if (n <= 0) {
this._emitEnd();
this._emitEnd()
}

@@ -13,17 +12,15 @@ },

_handleValue(x) {
this._n--;
this._emitValue(x);
this._n--
this._emitValue(x)
if (this._n === 0) {
this._emitEnd();
this._emitEnd()
}
}
},
}
};
const S = createStream('take', mixin)
const P = createProperty('take', mixin)
const S = createStream('take', mixin);
const P = createProperty('take', mixin);
export default function take(obs, n) {
return new (obs._ofSameType(S, P))(obs, {n});
return new (obs._ofSameType(S, P))(obs, {n})
}

@@ -1,21 +0,19 @@

import {createStream, createProperty} from '../patterns/one-source';
import now from '../utils/now';
import {createStream, createProperty} from '../patterns/one-source'
import now from '../utils/now'
const mixin = {
_init({wait, leading, trailing}) {
this._wait = Math.max(0, wait);
this._leading = leading;
this._trailing = trailing;
this._trailingValue = null;
this._timeoutId = null;
this._endLater = false;
this._lastCallTime = 0;
this._$trailingCall = () => this._trailingCall();
this._wait = Math.max(0, wait)
this._leading = leading
this._trailing = trailing
this._trailingValue = null
this._timeoutId = null
this._endLater = false
this._lastCallTime = 0
this._$trailingCall = () => this._trailingCall()
},
_free() {
this._trailingValue = null;
this._$trailingCall = null;
this._trailingValue = null
this._$trailingCall = null
},

@@ -25,17 +23,17 @@

if (this._activating) {
this._emitValue(x);
this._emitValue(x)
} else {
let curTime = now();
let curTime = now()
if (this._lastCallTime === 0 && !this._leading) {
this._lastCallTime = curTime;
this._lastCallTime = curTime
}
let remaining = this._wait - (curTime - this._lastCallTime);
let remaining = this._wait - (curTime - this._lastCallTime)
if (remaining <= 0) {
this._cancelTrailing();
this._lastCallTime = curTime;
this._emitValue(x);
this._cancelTrailing()
this._lastCallTime = curTime
this._emitValue(x)
} else if (this._trailing) {
this._cancelTrailing();
this._trailingValue = x;
this._timeoutId = setTimeout(this._$trailingCall, remaining);
this._cancelTrailing()
this._trailingValue = x
this._timeoutId = setTimeout(this._$trailingCall, remaining)
}

@@ -47,8 +45,8 @@ }

if (this._activating) {
this._emitEnd();
this._emitEnd()
} else {
if (this._timeoutId) {
this._endLater = true;
this._endLater = true
} else {
this._emitEnd();
this._emitEnd()
}

@@ -60,4 +58,4 @@ }

if (this._timeoutId !== null) {
clearTimeout(this._timeoutId);
this._timeoutId = null;
clearTimeout(this._timeoutId)
this._timeoutId = null
}

@@ -67,19 +65,17 @@ },

_trailingCall() {
this._emitValue(this._trailingValue);
this._timeoutId = null;
this._trailingValue = null;
this._lastCallTime = !this._leading ? 0 : now();
this._emitValue(this._trailingValue)
this._timeoutId = null
this._trailingValue = null
this._lastCallTime = !this._leading ? 0 : now()
if (this._endLater) {
this._emitEnd();
this._emitEnd()
}
}
},
}
};
const S = createStream('throttle', mixin)
const P = createProperty('throttle', mixin)
const S = createStream('throttle', mixin);
const P = createProperty('throttle', mixin);
export default function throttle(obs, wait, {leading = true, trailing = true} = {}) {
return new (obs._ofSameType(S, P))(obs, {wait, leading, trailing});
return new (obs._ofSameType(S, P))(obs, {wait, leading, trailing})
}

@@ -1,8 +0,6 @@

import {createProperty} from '../patterns/one-source';
import {createProperty} from '../patterns/one-source'
const P = createProperty('toProperty', {
_init({fn}) {
this._getInitialCurrent = fn;
this._getInitialCurrent = fn
},

@@ -12,17 +10,14 @@

if (this._getInitialCurrent !== null) {
const getInitial = this._getInitialCurrent;
this._emitValue(getInitial());
const getInitial = this._getInitialCurrent
this._emitValue(getInitial())
}
this._source.onAny(this._$handleAny); // copied from patterns/one-source
}
this._source.onAny(this._$handleAny) // copied from patterns/one-source
},
})
});
export default function toProperty(obs, fn = null) {
if (fn !== null && typeof fn !== 'function') {
throw new Error('You should call toProperty() with a function or no arguments.');
throw new Error('You should call toProperty() with a function or no arguments.')
}
return new P(obs, {fn});
return new P(obs, {fn})
}

@@ -1,27 +0,24 @@

import {createStream, createProperty} from '../patterns/one-source';
import {createStream, createProperty} from '../patterns/one-source'
function xformForObs(obs) {
return {
'@@transducer/step'(res, input) {
obs._emitValue(input);
return null;
obs._emitValue(input)
return null
},
'@@transducer/result'() {
obs._emitEnd();
return null;
}
};
obs._emitEnd()
return null
},
}
}
const mixin = {
_init({transducer}) {
this._xform = transducer(xformForObs(this));
this._xform = transducer(xformForObs(this))
},
_free() {
this._xform = null;
this._xform = null
},

@@ -31,3 +28,3 @@

if (this._xform['@@transducer/step'](null, x) !== null) {
this._xform['@@transducer/result'](null);
this._xform['@@transducer/result'](null)
}

@@ -37,13 +34,11 @@ },

_handleEnd() {
this._xform['@@transducer/result'](null);
}
this._xform['@@transducer/result'](null)
},
}
};
const S = createStream('transduce', mixin)
const P = createProperty('transduce', mixin)
const S = createStream('transduce', mixin);
const P = createProperty('transduce', mixin);
export default function transduce(obs, transducer) {
return new (obs._ofSameType(S, P))(obs, {transducer});
return new (obs._ofSameType(S, P))(obs, {transducer})
}

@@ -1,33 +0,30 @@

import {createStream, createProperty} from '../patterns/one-source';
import {createStream, createProperty} from '../patterns/one-source'
const mixin = {
_init({fn}) {
this._fn = fn;
this._fn = fn
},
_free() {
this._fn = null;
this._fn = null
},
_handleValue(x) {
const fn = this._fn;
let result = fn(x);
const fn = this._fn
let result = fn(x)
if (result.convert) {
this._emitError(result.error);
this._emitError(result.error)
} else {
this._emitValue(x);
this._emitValue(x)
}
}
},
}
};
const S = createStream('valuesToErrors', mixin)
const P = createProperty('valuesToErrors', mixin)
const S = createStream('valuesToErrors', mixin);
const P = createProperty('valuesToErrors', mixin);
const defFn = x => ({convert: true, error: x})
const defFn = x => ({convert: true, error: x});
export default function valuesToErrors(obs, fn = defFn) {
return new (obs._ofSameType(S, P))(obs, {fn});
return new (obs._ofSameType(S, P))(obs, {fn})
}

@@ -1,29 +0,25 @@

import {createStream, createProperty} from '../patterns/one-source';
import emitter from '../emitter';
import {createStream, createProperty} from '../patterns/one-source'
import emitter from '../emitter'
const mixin = {
_init({fn}) {
this._handler = fn;
this._emitter = emitter(this);
this._handler = fn
this._emitter = emitter(this)
},
_free() {
this._handler = null;
this._emitter = null;
this._handler = null
this._emitter = null
},
_handleAny(event) {
this._handler(this._emitter, event);
}
this._handler(this._emitter, event)
},
}
};
const S = createStream('withHandler', mixin)
const P = createProperty('withHandler', mixin)
const S = createStream('withHandler', mixin);
const P = createProperty('withHandler', mixin);
export default function withHandler(obs, fn) {
return new (obs._ofSameType(S, P))(obs, {fn});
return new (obs._ofSameType(S, P))(obs, {fn})
}

@@ -1,14 +0,13 @@

import Stream from '../stream';
import Property from '../property';
import {inherit} from '../utils/objects';
import {VALUE, ERROR, END} from '../constants';
import Stream from '../stream'
import Property from '../property'
import {inherit} from '../utils/objects'
import {VALUE, ERROR, END} from '../constants'
function createConstructor(BaseClass, name) {
return function AnonymousObservable(source, options) {
BaseClass.call(this);
this._source = source;
this._name = `${source._name}.${name}`;
this._init(options);
this._$handleAny = (event) => this._handleAny(event);
BaseClass.call(this)
this._source = source
this._name = `${source._name}.${name}`
this._init(options)
this._$handleAny = event => this._handleAny(event)
}

@@ -19,3 +18,2 @@ }

return {
_init() {},

@@ -25,9 +23,9 @@ _free() {},

_handleValue(x) {
this._emitValue(x);
this._emitValue(x)
},
_handleError(x) {
this._emitError(x);
this._emitError(x)
},
_handleEnd() {
this._emitEnd();
this._emitEnd()
},

@@ -37,5 +35,8 @@

switch (event.type) {
case VALUE: return this._handleValue(event.value);
case ERROR: return this._handleError(event.value);
case END: return this._handleEnd();
case VALUE:
return this._handleValue(event.value)
case ERROR:
return this._handleError(event.value)
case END:
return this._handleEnd()
}

@@ -45,34 +46,29 @@ },

_onActivation() {
this._source.onAny(this._$handleAny);
this._source.onAny(this._$handleAny)
},
_onDeactivation() {
this._source.offAny(this._$handleAny);
this._source.offAny(this._$handleAny)
},
_clear() {
BaseClass.prototype._clear.call(this);
this._source = null;
this._$handleAny = null;
this._free();
}
};
BaseClass.prototype._clear.call(this)
this._source = null
this._$handleAny = null
this._free()
},
}
}
function createStream(name, mixin) {
const S = createConstructor(Stream, name);
inherit(S, Stream, createClassMethods(Stream), mixin);
return S;
const S = createConstructor(Stream, name)
inherit(S, Stream, createClassMethods(Stream), mixin)
return S
}
function createProperty(name, mixin) {
const P = createConstructor(Property, name);
inherit(P, Property, createClassMethods(Property), mixin);
return P;
const P = createConstructor(Property, name)
inherit(P, Property, createClassMethods(Property), mixin)
return P
}
export {createStream, createProperty};
export {createStream, createProperty}

@@ -1,41 +0,43 @@

import {inherit} from '../utils/objects';
import Stream from '../stream';
import {inherit} from '../utils/objects'
import Stream from '../stream'
export default function timeBased(mixin) {
function AnonymousStream(wait, options) {
Stream.call(this);
this._wait = wait;
this._intervalId = null;
this._$onTick = () => this._onTick();
this._init(options);
Stream.call(this)
this._wait = wait
this._intervalId = null
this._$onTick = () => this._onTick()
this._init(options)
}
inherit(AnonymousStream, Stream, {
inherit(
AnonymousStream,
Stream,
{
_init() {},
_free() {},
_init() {},
_free() {},
_onTick() {},
_onTick() {},
_onActivation() {
this._intervalId = setInterval(this._$onTick, this._wait)
},
_onActivation() {
this._intervalId = setInterval(this._$onTick, this._wait);
},
_onDeactivation() {
if (this._intervalId !== null) {
clearInterval(this._intervalId)
this._intervalId = null
}
},
_onDeactivation() {
if (this._intervalId !== null) {
clearInterval(this._intervalId);
this._intervalId = null;
}
_clear() {
Stream.prototype._clear.call(this)
this._$onTick = null
this._free()
},
},
mixin
)
_clear() {
Stream.prototype._clear.call(this);
this._$onTick = null;
this._free();
}
}, mixin);
return AnonymousStream;
return AnonymousStream
}

@@ -1,20 +0,16 @@

import Stream from '../stream';
import Property from '../property';
import {inherit} from '../utils/objects';
import {VALUE, ERROR, END, NOTHING} from '../constants';
import Stream from '../stream'
import Property from '../property'
import {inherit} from '../utils/objects'
import {VALUE, ERROR, END, NOTHING} from '../constants'
function createConstructor(BaseClass, name) {
return function AnonymousObservable(primary, secondary, options) {
BaseClass.call(this);
this._primary = primary;
this._secondary = secondary;
this._name = `${primary._name}.${name}`;
this._lastSecondary = NOTHING;
this._$handleSecondaryAny = (event) => this._handleSecondaryAny(event);
this._$handlePrimaryAny = (event) => this._handlePrimaryAny(event);
this._init(options);
BaseClass.call(this)
this._primary = primary
this._secondary = secondary
this._name = `${primary._name}.${name}`
this._lastSecondary = NOTHING
this._$handleSecondaryAny = event => this._handleSecondaryAny(event)
this._$handlePrimaryAny = event => this._handlePrimaryAny(event)
this._init(options)
}

@@ -29,16 +25,16 @@ }

_handlePrimaryValue(x) {
this._emitValue(x);
this._emitValue(x)
},
_handlePrimaryError(x) {
this._emitError(x);
this._emitError(x)
},
_handlePrimaryEnd() {
this._emitEnd();
this._emitEnd()
},
_handleSecondaryValue(x) {
this._lastSecondary = x;
this._lastSecondary = x
},
_handleSecondaryError(x) {
this._emitError(x);
this._emitError(x)
},

@@ -49,5 +45,8 @@ _handleSecondaryEnd() {},

switch (event.type) {
case VALUE: return this._handlePrimaryValue(event.value);
case ERROR: return this._handlePrimaryError(event.value);
case END: return this._handlePrimaryEnd(event.value);
case VALUE:
return this._handlePrimaryValue(event.value)
case ERROR:
return this._handlePrimaryError(event.value)
case END:
return this._handlePrimaryEnd(event.value)
}

@@ -57,7 +56,9 @@ },

switch (event.type) {
case VALUE: return this._handleSecondaryValue(event.value);
case ERROR: return this._handleSecondaryError(event.value);
case VALUE:
return this._handleSecondaryValue(event.value)
case ERROR:
return this._handleSecondaryError(event.value)
case END:
this._handleSecondaryEnd(event.value);
this._removeSecondary();
this._handleSecondaryEnd(event.value)
this._removeSecondary()
}

@@ -68,5 +69,5 @@ },

if (this._secondary !== null) {
this._secondary.offAny(this._$handleSecondaryAny);
this._$handleSecondaryAny = null;
this._secondary = null;
this._secondary.offAny(this._$handleSecondaryAny)
this._$handleSecondaryAny = null
this._secondary = null
}

@@ -77,6 +78,6 @@ },

if (this._secondary !== null) {
this._secondary.onAny(this._$handleSecondaryAny);
this._secondary.onAny(this._$handleSecondaryAny)
}
if (this._active) {
this._primary.onAny(this._$handlePrimaryAny);
this._primary.onAny(this._$handlePrimaryAny)
}

@@ -86,37 +87,31 @@ },

if (this._secondary !== null) {
this._secondary.offAny(this._$handleSecondaryAny);
this._secondary.offAny(this._$handleSecondaryAny)
}
this._primary.offAny(this._$handlePrimaryAny);
this._primary.offAny(this._$handlePrimaryAny)
},
_clear() {
BaseClass.prototype._clear.call(this);
this._primary = null;
this._secondary = null;
this._lastSecondary = null;
this._$handleSecondaryAny = null;
this._$handlePrimaryAny = null;
this._free();
}
};
BaseClass.prototype._clear.call(this)
this._primary = null
this._secondary = null
this._lastSecondary = null
this._$handleSecondaryAny = null
this._$handlePrimaryAny = null
this._free()
},
}
}
function createStream(name, mixin) {
const S = createConstructor(Stream, name);
inherit(S, Stream, createClassMethods(Stream), mixin);
return S;
const S = createConstructor(Stream, name)
inherit(S, Stream, createClassMethods(Stream), mixin)
return S
}
function createProperty(name, mixin) {
const P = createConstructor(Property, name);
inherit(P, Property, createClassMethods(Property), mixin);
return P;
const P = createConstructor(Property, name)
inherit(P, Property, createClassMethods(Property), mixin)
return P
}
export {createStream, createProperty};
export {createStream, createProperty}

@@ -1,5 +0,4 @@

import {inherit} from '../utils/objects';
import Property from '../property';
import {inherit} from '../utils/objects'
import Property from '../property'
// HACK:

@@ -11,3 +10,3 @@ // We don't call parent Class constructor, but instead putting all necessary

function P(value) {
this._currentEvent = {type: 'error', value, current: true};
this._currentEvent = {type: 'error', value, current: true}
}

@@ -21,7 +20,7 @@

_dispatcher: null,
_logHandlers: null
});
_logHandlers: null,
})
export default function constantError(x) {
return new P(x);
return new P(x)
}

@@ -1,3 +0,3 @@

import {inherit} from '../utils/objects';
import Property from '../property';
import {inherit} from '../utils/objects'
import Property from '../property'

@@ -10,3 +10,3 @@ // HACK:

function P(value) {
this._currentEvent = {type: 'value', value, current: true};
this._currentEvent = {type: 'value', value, current: true}
}

@@ -20,7 +20,7 @@

_dispatcher: null,
_logHandlers: null
});
_logHandlers: null,
})
export default function constant(x) {
return new P(x);
return new P(x)
}

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

import stream from './stream';
import stream from './stream'
export default function fromCallback(callbackConsumer) {
let called = false
let called = false;
return stream(function(emitter) {
if (!called) {
callbackConsumer(function(x) {
emitter.emit(x);
emitter.end();
});
called = true;
emitter.emit(x)
emitter.end()
})
called = true
}
}).setName('fromCallback');
}).setName('fromCallback')
}

@@ -1,17 +0,13 @@

import fromSubUnsub from './from-sub-unsub';
import fromSubUnsub from './from-sub-unsub'
const pairs = [
['addEventListener', 'removeEventListener'],
['addListener', 'removeListener'],
['on', 'off']
];
const pairs = [['addEventListener', 'removeEventListener'], ['addListener', 'removeListener'], ['on', 'off']]
export default function fromEvents(target, eventName, transformer) {
let sub, unsub;
let sub, unsub
for (let i = 0; i < pairs.length; i++) {
if (typeof target[pairs[i][0]] === 'function' && typeof target[pairs[i][1]] === 'function') {
sub = pairs[i][0];
unsub = pairs[i][1];
break;
sub = pairs[i][0]
unsub = pairs[i][1]
break
}

@@ -21,11 +17,13 @@ }

if (sub === undefined) {
throw new Error('target don\'t support any of ' +
'addEventListener/removeEventListener, addListener/removeListener, on/off method pair');
throw new Error(
"target don't support any of " +
'addEventListener/removeEventListener, addListener/removeListener, on/off method pair'
)
}
return fromSubUnsub(
(handler) => target[sub](eventName, handler),
(handler) => target[unsub](eventName, handler),
handler => target[sub](eventName, handler),
handler => target[unsub](eventName, handler),
transformer
).setName('fromEvents');
).setName('fromEvents')
}

@@ -1,23 +0,19 @@

import stream from './stream';
import stream from './stream'
export default function fromNodeCallback(callbackConsumer) {
let called = false
let called = false;
return stream(function(emitter) {
if (!called) {
callbackConsumer(function(error, x) {
if (error) {
emitter.error(error);
emitter.error(error)
} else {
emitter.emit(x);
emitter.emit(x)
}
emitter.end();
});
called = true;
emitter.end()
})
called = true
}
}).setName('fromNodeCallback');
}).setName('fromNodeCallback')
}

@@ -1,19 +0,17 @@

import stream from './stream';
import {apply} from '../utils/functions';
import stream from './stream'
import {apply} from '../utils/functions'
export default function fromSubUnsub(sub, unsub, transformer /* Function | falsey */) {
return stream(function(emitter) {
let handler = transformer
? function() {
emitter.emit(apply(transformer, this, arguments));
}
emitter.emit(apply(transformer, this, arguments))
}
: x => {
emitter.emit(x)
};
emitter.emit(x)
}
sub(handler);
return () => unsub(handler);
}).setName('fromSubUnsub');
sub(handler)
return () => unsub(handler)
}).setName('fromSubUnsub')
}

@@ -1,10 +0,9 @@

import Stream from '../stream';
import Stream from '../stream'
const neverS = new Stream()
neverS._emitEnd()
neverS._name = 'never'
const neverS = new Stream();
neverS._emitEnd();
neverS._name = 'never';
export default function never() {
return neverS;
return neverS
}

@@ -1,23 +0,22 @@

import {inherit} from '../utils/objects';
import Stream from '../stream';
import emitter from '../emitter';
import {inherit} from '../utils/objects'
import Stream from '../stream'
import emitter from '../emitter'
function S(fn) {
Stream.call(this);
this._fn = fn;
this._unsubscribe = null;
Stream.call(this)
this._fn = fn
this._unsubscribe = null
}
inherit(S, Stream, {
_name: 'stream',
_onActivation() {
const fn = this._fn;
const unsubscribe = fn(emitter(this));
this._unsubscribe = (typeof unsubscribe === 'function') ? unsubscribe : null;
const fn = this._fn
const unsubscribe = fn(emitter(this))
this._unsubscribe = typeof unsubscribe === 'function' ? unsubscribe : null
// fix https://github.com/rpominov/kefir/issues/35
if (!this._active) {
this._callUnsubscribe();
this._callUnsubscribe()
}

@@ -28,4 +27,4 @@ },

if (this._unsubscribe !== null) {
this._unsubscribe();
this._unsubscribe = null;
this._unsubscribe()
this._unsubscribe = null
}

@@ -35,14 +34,13 @@ },

_onDeactivation() {
this._callUnsubscribe();
this._callUnsubscribe()
},
_clear() {
Stream.prototype._clear.call(this);
this._fn = null;
}
Stream.prototype._clear.call(this)
this._fn = null
},
})
});
export default function stream(fn) {
return new S(fn);
return new S(fn)
}

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

import {inherit} from './utils/objects';
import {VALUE, ERROR, END} from './constants';
import {callSubscriber} from './dispatcher';
import Observable from './observable';
import {inherit} from './utils/objects'
import {VALUE, ERROR, END} from './constants'
import {callSubscriber} from './dispatcher'
import Observable from './observable'
function Property() {
Observable.call(this);
this._currentEvent = null;
Observable.call(this)
this._currentEvent = null
}
inherit(Property, Observable, {
_name: 'property',

@@ -19,5 +16,5 @@

if (this._alive) {
this._currentEvent = {type: VALUE, value};
this._currentEvent = {type: VALUE, value}
if (!this._activating) {
this._dispatcher.dispatch({type: VALUE, value});
this._dispatcher.dispatch({type: VALUE, value})
}

@@ -29,5 +26,5 @@ }

if (this._alive) {
this._currentEvent = {type: ERROR, value};
this._currentEvent = {type: ERROR, value}
if (!this._activating) {
this._dispatcher.dispatch({type: ERROR, value});
this._dispatcher.dispatch({type: ERROR, value})
}

@@ -41,35 +38,27 @@ }

if (!this._activating) {
this._dispatcher.dispatch({type: END});
this._dispatcher.dispatch({type: END})
}
this._clear();
this._clear()
}
},
_on(type, fn) {
if (this._alive) {
this._dispatcher.add(type, fn);
this._setActive(true);
this._dispatcher.add(type, fn)
this._setActive(true)
}
if (this._currentEvent !== null) {
callSubscriber(type, fn, this._currentEvent);
callSubscriber(type, fn, this._currentEvent)
}
if (!this._alive) {
callSubscriber(type, fn, {type: END});
callSubscriber(type, fn, {type: END})
}
return this;
return this
},
getType() {
return 'property';
}
return 'property'
},
})
});
export default Property;
export default Property

@@ -1,19 +0,16 @@

import {inherit} from './utils/objects';
import Observable from './observable';
import {inherit} from './utils/objects'
import Observable from './observable'
function Stream() {
Observable.call(this);
Observable.call(this)
}
inherit(Stream, Observable, {
_name: 'stream',
getType() {
return 'stream';
}
return 'stream'
},
})
});
export default Stream;
export default Stream

@@ -1,25 +0,22 @@

import timeBased from '../patterns/time-based';
import timeBased from '../patterns/time-based'
const S = timeBased({
_name: 'fromPoll',
_init({fn}) {
this._fn = fn;
this._fn = fn
},
_free() {
this._fn = null;
this._fn = null
},
_onTick() {
const fn = this._fn;
this._emitValue(fn());
}
const fn = this._fn
this._emitValue(fn())
},
})
});
export default function fromPoll(wait, fn) {
return new S(wait, {fn});
return new S(wait, {fn})
}

@@ -1,24 +0,21 @@

import timeBased from '../patterns/time-based';
import timeBased from '../patterns/time-based'
const S = timeBased({
_name: 'interval',
_init({x}) {
this._x = x;
this._x = x
},
_free() {
this._x = null;
this._x = null
},
_onTick() {
this._emitValue(this._x);
}
this._emitValue(this._x)
},
})
});
export default function interval(wait, x) {
return new S(wait, {x});
return new S(wait, {x})
}

@@ -1,25 +0,22 @@

import timeBased from '../patterns/time-based';
import timeBased from '../patterns/time-based'
const S = timeBased({
_name: 'later',
_init({x}) {
this._x = x;
this._x = x
},
_free() {
this._x = null;
this._x = null
},
_onTick() {
this._emitValue(this._x);
this._emitEnd();
}
this._emitValue(this._x)
this._emitEnd()
},
})
});
export default function later(wait, x) {
return new S(wait, {x});
return new S(wait, {x})
}

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

import timeBased from '../patterns/time-based';
import {cloneArray} from '../utils/collections';
import never from '../primary/never';
import timeBased from '../patterns/time-based'
import {cloneArray} from '../utils/collections'
import never from '../primary/never'
const S = timeBased({
_name: 'sequentially',
_init({xs}) {
this._xs = cloneArray(xs);
this._xs = cloneArray(xs)
},
_free() {
this._xs = null;
this._xs = null
},

@@ -19,14 +18,12 @@

if (this._xs.length === 1) {
this._emitValue(this._xs[0]);
this._emitEnd();
this._emitValue(this._xs[0])
this._emitEnd()
} else {
this._emitValue(this._xs.shift());
this._emitValue(this._xs.shift())
}
}
},
})
});
export default function sequentially(wait, xs) {
return xs.length === 0 ? never() : new S(wait, {xs});
return xs.length === 0 ? never() : new S(wait, {xs})
}

@@ -1,29 +0,25 @@

import timeBased from '../patterns/time-based';
import emitter from '../emitter';
import timeBased from '../patterns/time-based'
import emitter from '../emitter'
const S = timeBased({
_name: 'withInterval',
_init({fn}) {
this._fn = fn;
this._emitter = emitter(this);
this._fn = fn
this._emitter = emitter(this)
},
_free() {
this._fn = null;
this._emitter = null;
this._fn = null
this._emitter = null
},
_onTick() {
const fn = this._fn;
fn(this._emitter);
}
const fn = this._fn
fn(this._emitter)
},
})
});
export default function withInterval(wait, fn) {
return new S(wait, {fn});
return new S(wait, {fn})
}

@@ -1,14 +0,14 @@

import merge from '../many-sources/merge';
import map from '../one-source/map';
import skipDuplicates from '../one-source/skip-duplicates';
import toProperty from '../one-source/to-property';
import merge from '../many-sources/merge'
import map from '../one-source/map'
import skipDuplicates from '../one-source/skip-duplicates'
import toProperty from '../one-source/to-property'
const f = () => false;
const t = () => true;
const f = () => false
const t = () => true
export default function awaiting(a, b) {
let result = merge([map(a, t), map(b, f)]);
result = skipDuplicates(result);
result = toProperty(result, f);
return result.setName(a, 'awaiting');
let result = merge([map(a, t), map(b, f)])
result = skipDuplicates(result)
result = toProperty(result, f)
return result.setName(a, 'awaiting')
}

@@ -1,13 +0,11 @@

import {createStream, createProperty} from '../patterns/two-sources';
import {createStream, createProperty} from '../patterns/two-sources'
const mixin = {
_init({flushOnEnd = true} = {}) {
this._buff = [];
this._flushOnEnd = flushOnEnd;
this._buff = []
this._flushOnEnd = flushOnEnd
},
_free() {
this._buff = null;
this._buff = null
},

@@ -17,4 +15,4 @@

if (this._buff !== null) {
this._emitValue(this._buff);
this._buff = [];
this._emitValue(this._buff)
this._buff = []
}

@@ -25,11 +23,11 @@ },

if (this._flushOnEnd) {
this._flush();
this._flush()
}
this._emitEnd();
this._emitEnd()
},
_onActivation() {
this._primary.onAny(this._$handlePrimaryAny);
this._primary.onAny(this._$handlePrimaryAny)
if (this._alive && this._secondary !== null) {
this._secondary.onAny(this._$handleSecondaryAny);
this._secondary.onAny(this._$handleSecondaryAny)
}

@@ -39,7 +37,7 @@ },

_handlePrimaryValue(x) {
this._buff.push(x);
this._buff.push(x)
},
_handleSecondaryValue() {
this._flush();
this._flush()
},

@@ -49,15 +47,12 @@

if (!this._flushOnEnd) {
this._emitEnd();
this._emitEnd()
}
}
},
}
};
const S = createStream('bufferBy', mixin)
const P = createProperty('bufferBy', mixin)
const S = createStream('bufferBy', mixin);
const P = createProperty('bufferBy', mixin);
export default function bufferBy(primary, secondary, options /* optional */) {
return new (primary._ofSameType(S, P))(primary, secondary, options);
return new (primary._ofSameType(S, P))(primary, secondary, options)
}

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

import {createStream, createProperty} from '../patterns/two-sources';
import {NOTHING} from '../constants';
import {createStream, createProperty} from '../patterns/two-sources'
import {NOTHING} from '../constants'
const mixin = {
_init({flushOnEnd = true, flushOnChange = false} = {}) {
this._buff = [];
this._flushOnEnd = flushOnEnd;
this._flushOnChange = flushOnChange;
this._buff = []
this._flushOnEnd = flushOnEnd
this._flushOnChange = flushOnChange
},
_free() {
this._buff = null;
this._buff = null
},

@@ -19,4 +17,4 @@

if (this._buff !== null) {
this._emitValue(this._buff);
this._buff = [];
this._emitValue(this._buff)
this._buff = []
}

@@ -27,11 +25,11 @@ },

if (this._flushOnEnd) {
this._flush();
this._flush()
}
this._emitEnd();
this._emitEnd()
},
_handlePrimaryValue(x) {
this._buff.push(x);
this._buff.push(x)
if (this._lastSecondary !== NOTHING && !this._lastSecondary) {
this._flush();
this._flush()
}

@@ -42,3 +40,3 @@ },

if (!this._flushOnEnd && (this._lastSecondary === NOTHING || this._lastSecondary)) {
this._emitEnd();
this._emitEnd()
}

@@ -49,18 +47,15 @@ },

if (this._flushOnChange && !x) {
this._flush();
this._flush()
}
// from default _handleSecondaryValue
this._lastSecondary = x;
}
this._lastSecondary = x
},
}
};
const S = createStream('bufferWhileBy', mixin)
const P = createProperty('bufferWhileBy', mixin)
const S = createStream('bufferWhileBy', mixin);
const P = createProperty('bufferWhileBy', mixin);
export default function bufferWhileBy(primary, secondary, options /* optional */) {
return new (primary._ofSameType(S, P))(primary, secondary, options);
return new (primary._ofSameType(S, P))(primary, secondary, options)
}

@@ -1,10 +0,8 @@

import {createStream, createProperty} from '../patterns/two-sources';
import {NOTHING} from '../constants';
import {createStream, createProperty} from '../patterns/two-sources'
import {NOTHING} from '../constants'
const mixin = {
_handlePrimaryValue(x) {
if (this._lastSecondary !== NOTHING && this._lastSecondary) {
this._emitValue(x);
this._emitValue(x)
}

@@ -15,15 +13,12 @@ },

if (this._lastSecondary === NOTHING || !this._lastSecondary) {
this._emitEnd();
this._emitEnd()
}
}
},
}
};
const S = createStream('filterBy', mixin)
const P = createProperty('filterBy', mixin)
const S = createStream('filterBy', mixin);
const P = createProperty('filterBy', mixin);
export default function filterBy(primary, secondary) {
return new (primary._ofSameType(S, P))(primary, secondary);
return new (primary._ofSameType(S, P))(primary, secondary)
}

@@ -1,8 +0,8 @@

import combine from '../many-sources/combine';
import combine from '../many-sources/combine'
const id2 = (_, x) => x;
const id2 = (_, x) => x
export default function sampledBy(passive, active, combinator) {
let _combinator = combinator ? ((a, b) => combinator(b, a)) : id2;
return combine([active], [passive], _combinator).setName(passive, 'sampledBy');
let _combinator = combinator ? (a, b) => combinator(b, a) : id2
return combine([active], [passive], _combinator).setName(passive, 'sampledBy')
}

@@ -1,10 +0,8 @@

import {createStream, createProperty} from '../patterns/two-sources';
import {NOTHING} from '../constants';
import {createStream, createProperty} from '../patterns/two-sources'
import {NOTHING} from '../constants'
const mixin = {
_handlePrimaryValue(x) {
if (this._lastSecondary !== NOTHING) {
this._emitValue(x);
this._emitValue(x)
}

@@ -15,15 +13,12 @@ },

if (this._lastSecondary === NOTHING) {
this._emitEnd();
this._emitEnd()
}
}
},
}
};
const S = createStream('skipUntilBy', mixin)
const P = createProperty('skipUntilBy', mixin)
const S = createStream('skipUntilBy', mixin);
const P = createProperty('skipUntilBy', mixin);
export default function skipUntilBy(primary, secondary) {
return new (primary._ofSameType(S, P))(primary, secondary);
return new (primary._ofSameType(S, P))(primary, secondary)
}

@@ -1,18 +0,14 @@

import {createStream, createProperty} from '../patterns/two-sources';
import {createStream, createProperty} from '../patterns/two-sources'
const mixin = {
_handleSecondaryValue() {
this._emitEnd();
}
this._emitEnd()
},
}
};
const S = createStream('takeUntilBy', mixin)
const P = createProperty('takeUntilBy', mixin)
const S = createStream('takeUntilBy', mixin);
const P = createProperty('takeUntilBy', mixin);
export default function takeUntilBy(primary, secondary) {
return new (primary._ofSameType(S, P))(primary, secondary);
return new (primary._ofSameType(S, P))(primary, secondary)
}
function concat(a, b) {
let result, length, i, j;
let result, length, i, j
if (a.length === 0) {
return b;
return b
}
if (b.length === 0) {
return a;
return a
}
j = 0;
result = new Array(a.length + b.length);
length = a.length;
j = 0
result = new Array(a.length + b.length)
length = a.length
for (i = 0; i < length; i++, j++) {
result[j] = a[i];
result[j] = a[i]
}
length = b.length;
length = b.length
for (i = 0; i < length; i++, j++) {
result[j] = b[i];
result[j] = b[i]
}
return result;
return result
}
function circleShift(arr, distance) {
let length = arr.length
, result = new Array(length)
, i;
let length = arr.length, result = new Array(length), i
for (i = 0; i < length; i++) {
result[(i + distance) % length] = arr[i];
result[(i + distance) % length] = arr[i]
}
return result;
return result
}
function find(arr, value) {
let length = arr.length
, i;
let length = arr.length, i
for (i = 0; i < length; i++) {
if (arr[i] === value) {
return i;
return i
}
}
return -1;
return -1
}
function findByPred(arr, pred) {
let length = arr.length
, i;
let length = arr.length, i
for (i = 0; i < length; i++) {
if (pred(arr[i])) {
return i;
return i
}
}
return -1;
return -1
}
function cloneArray(input) {
let length = input.length
, result = new Array(length)
, i;
let length = input.length, result = new Array(length), i
for (i = 0; i < length; i++) {
result[i] = input[i];
result[i] = input[i]
}
return result;
return result
}
function remove(input, index) {
let length = input.length
, result, i, j;
let length = input.length, result, i, j
if (index >= 0 && index < length) {
if (length === 1) {
return [];
return []
} else {
result = new Array(length - 1);
for (i = 0, j = 0; i < length; i++) {
result = new Array(length - 1)
for ((i = 0), (j = 0); i < length; i++) {
if (i !== index) {
result[j] = input[i];
j++;
result[j] = input[i]
j++
}
}
return result;
return result
}
} else {
return input;
return input
}

@@ -86,20 +79,17 @@ }

function removeByPred(input, pred) {
return remove(input, findByPred(input, pred));
return remove(input, findByPred(input, pred))
}
function map(input, fn) {
let length = input.length
, result = new Array(length)
, i;
let length = input.length, result = new Array(length), i
for (i = 0; i < length; i++) {
result[i] = fn(input[i]);
result[i] = fn(input[i])
}
return result;
return result
}
function forEach(arr, fn) {
let length = arr.length
, i;
let length = arr.length, i
for (i = 0; i < length; i++) {
fn(arr[i]);
fn(arr[i])
}

@@ -109,6 +99,5 @@ }

function fillArray(arr, value) {
let length = arr.length
, i;
let length = arr.length, i
for (i = 0; i < length; i++) {
arr[i] = value;
arr[i] = value
}

@@ -118,20 +107,14 @@ }

function contains(arr, value) {
return find(arr, value) !== -1;
return find(arr, value) !== -1
}
function slide(cur, next, max) {
let length = Math.min(max, cur.length + 1),
offset = cur.length - length + 1,
result = new Array(length),
i;
let length = Math.min(max, cur.length + 1), offset = cur.length - length + 1, result = new Array(length), i
for (i = offset; i < length; i++) {
result[i - offset] = cur[i];
result[i - offset] = cur[i]
}
result[length - 1] = next;
return result;
result[length - 1] = next
return result
}
export {

@@ -149,3 +132,3 @@ concat,

contains,
slide
};
slide,
}
function spread(fn, length) {
switch(length) {
case 0: return function() {return fn();};
case 1: return function(a) {return fn(a[0]);};
case 2: return function(a) {return fn(a[0], a[1]);};
case 3: return function(a) {return fn(a[0], a[1], a[2]);};
case 4: return function(a) {return fn(a[0], a[1], a[2], a[3]);};
default: return function(a) {return fn.apply(null, a);};
switch (length) {
case 0:
return function() {
return fn()
}
case 1:
return function(a) {
return fn(a[0])
}
case 2:
return function(a) {
return fn(a[0], a[1])
}
case 3:
return function(a) {
return fn(a[0], a[1], a[2])
}
case 4:
return function(a) {
return fn(a[0], a[1], a[2], a[3])
}
default:
return function(a) {
return fn.apply(null, a)
}
}

@@ -13,16 +31,24 @@ }

function apply(fn, c, a) {
let aLength = a ? a.length : 0;
let aLength = a ? a.length : 0
if (c == null) {
switch (aLength) {
case 0: return fn();
case 1: return fn(a[0]);
case 2: return fn(a[0], a[1]);
case 3: return fn(a[0], a[1], a[2]);
case 4: return fn(a[0], a[1], a[2], a[3]);
default: return fn.apply(null, a);
case 0:
return fn()
case 1:
return fn(a[0])
case 2:
return fn(a[0], a[1])
case 3:
return fn(a[0], a[1], a[2])
case 4:
return fn(a[0], a[1], a[2], a[3])
default:
return fn.apply(null, a)
}
} else {
switch (aLength) {
case 0: return fn.call(c);
default: return fn.apply(c, a);
case 0:
return fn.call(c)
default:
return fn.apply(c, a)
}

@@ -32,2 +58,2 @@ }

export {spread, apply};
export {spread, apply}

@@ -1,3 +0,1 @@

export default Date.now ?
(() => Date.now()) :
(() => new Date().getTime());
export default (Date.now ? () => Date.now() : () => new Date().getTime())
function createObj(proto) {
let F = function() {};
F.prototype = proto;
return new F();
let F = function() {}
F.prototype = proto
return new F()
}
function extend(target /*, mixin1, mixin2...*/) {
let length = arguments.length
, i, prop;
let length = arguments.length, i, prop
for (i = 1; i < length; i++) {
for (prop in arguments[i]) {
target[prop] = arguments[i][prop];
target[prop] = arguments[i][prop]
}
}
return target;
return target
}
function inherit(Child, Parent /*, mixin1, mixin2...*/) {
let length = arguments.length
, i;
Child.prototype = createObj(Parent.prototype);
Child.prototype.constructor = Child;
let length = arguments.length, i
Child.prototype = createObj(Parent.prototype)
Child.prototype.constructor = Child
for (i = 2; i < length; i++) {
extend(Child.prototype, arguments[i]);
extend(Child.prototype, arguments[i])
}
return Child;
return Child
}
export {extend, inherit};
export {extend, inherit}

Sorry, the diff of this file is too big to display

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