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 0.2.6 to 0.2.7

test/specs/from-event.coffee

2

bower.json
{
"name": "kefir",
"version": "0.2.6",
"version": "0.2.7",
"homepage": "https://github.com/pozadi/kefir",

@@ -5,0 +5,0 @@ "authors": [

@@ -1,2 +0,2 @@

/*! An addon for Kefir.js v0.2.6
/*! An addon for Kefir.js v0.2.7
* https://github.com/pozadi/kefir

@@ -3,0 +3,0 @@ */

@@ -1,2 +0,2 @@

/*! An addon for Kefir.js v0.2.6
/*! An addon for Kefir.js v0.2.7
* https://github.com/pozadi/kefir

@@ -3,0 +3,0 @@ */

@@ -1,2 +0,2 @@

/*! Kefir.js v0.2.6
/*! Kefir.js v0.2.7
* https://github.com/pozadi/kefir

@@ -907,5 +907,5 @@ */

this._queueLim = get(options, 'queueLim', 0); // -1...∞
this._concurLim = get(options, 'concurLim', -1); // -1, 1...∞
this._drop = get(options, 'drop', 'new'); // old, new
this._queueLim = get(options, 'queueLim', 0);
this._concurLim = get(options, 'concurLim', -1);
this._drop = get(options, 'drop', 'new');
if (this._concurLim === 0) {

@@ -1084,7 +1084,7 @@ throw new Error('options.concurLim can\'t be 0');

add: function(obs) {
plug: function(obs) {
this._add(obs);
return this;
},
remove: function(obs) {
unplug: function(obs) {
this._remove(obs);

@@ -1792,4 +1792,10 @@ return this;

_name: 'emitter',
emit: function(x) { this._send('value', x) },
end: function() { this._send('end') }
emit: function(x) {
this._send('value', x);
return this;
},
end: function() {
this._send('end');
return this;
}
});

@@ -1964,2 +1970,23 @@

// .fromEvent
Kefir.fromEvent = function(target, eventName, transformer) {
transformer = transformer && Fn(transformer);
var sub = target.addEventListener || target.addListener || target.bind;
var unsub = target.removeEventListener || target.removeListener || target.unbind;
return Kefir.fromBinder(function(emitter) {
var handler = transformer ?
function() {
emitter.emit(transformer.applyWithContext(this, arguments));
} : emitter.emit;
sub.call(target, eventName, handler);
return function() {
unsub.call(target, eventName, handler);
}
}).setName('fromEvent');
}
if (typeof define === 'function' && define.amd) {

@@ -1966,0 +1993,0 @@ define([], function() {

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

/*! Kefir.js v0.2.6
/*! Kefir.js v0.2.7
* https://github.com/pozadi/kefir
*/
!function(a){"use strict";function b(a,b,c){return a&&b in a?a[b]:c}function c(a,b){return Object.prototype.hasOwnProperty.call(a,b)}function d(a){var b=function(){};return b.prototype=a,new b}function e(a){var b,c,d=arguments.length;for(b=1;d>b;b++)for(c in arguments[b])a[c]=arguments[b][c];return a}function f(a,b){var c,f=arguments.length;for(a.prototype=d(b.prototype),a.prototype.constructor=a,c=2;f>c;c++)e(a.prototype,arguments[c]);return a}function g(a){return 1===a.length&&$(a[0])?a[0]:p(a)}function h(a,b){if(w(a))return a;if(null!=b&&w(b[a]))return b[a];throw new Error("Not a function: "+a+" in context: "+b)}function i(a,b,c){var d=c?c.length:0;if(null==b)switch(d){case 0:return a();case 1:return a(c[0]);case 2:return a(c[0],c[1]);case 3:return a(c[0],c[1],c[2]);case 4:return a(c[0],c[1],c[2],c[3]);default:return a.apply(null,c)}else switch(d){case 0:return a.call(b);default:return a.apply(b,c)}}function j(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3];switch(c){case 0:switch(b.length){case 0:return a;case 1:return function(){return a(d)};case 2:return function(){return a(d,e)};case 3:return function(){return a(d,e,f)};case 4:return function(){return a(d,e,f,g)};default:return function(){return a.apply(null,b)}}break;case 1:switch(b.length){case 0:return a;case 1:return function(b){return a(d,b)};case 2:return function(b){return a(d,e,b)};case 3:return function(b){return a(d,e,f,b)};case 4:return function(b){return a(d,e,f,g,b)};default:return function(c){return a.apply(null,m(b,[c]))}}break;case 2:switch(b.length){case 0:return a;case 1:return function(b,c){return a(d,b,c)};case 2:return function(b,c){return a(d,e,b,c)};case 3:return function(b,c){return a(d,e,f,b,c)};case 4:return function(b,c){return a(d,e,f,g,b,c)};default:return function(c,d){return a.apply(null,m(b,[c,d]))}}break;default:switch(b.length){case 0:return a;default:return function(){return i(a,null,m(b,arguments))}}}}function k(a,b,c,d){var e=c[0],f=c[1],g=c[2],h=c[3];switch(d){case 0:switch(c.length){case 0:return function(){return a.call(b)};default:return function(){return a.apply(b,c)}}break;case 1:switch(c.length){case 0:return function(c){return a.call(b,c)};case 1:return function(c){return a.call(b,e,c)};case 2:return function(c){return a.call(b,e,f,c)};case 3:return function(c){return a.call(b,e,f,g,c)};case 4:return function(c){return a.call(b,e,f,g,h,c)};default:return function(d){return a.apply(b,m(c,[d]))}}break;case 2:switch(c.length){case 0:return function(c,d){return a.call(b,c,d)};case 1:return function(c,d){return a.call(b,e,c,d)};case 2:return function(c,d){return a.call(b,e,f,c,d)};case 3:return function(c,d){return a.call(b,e,f,g,c,d)};case 4:return function(c,d){return a.call(b,e,f,g,h,c,d)};default:return function(d,e){return a.apply(b,m(c,[d,e]))}}break;default:switch(c.length){case 0:return function(){return a.apply(b,arguments)};default:return function(){return a.apply(b,m(c,arguments))}}}}function l(a,b,c,d){return null==b?j(a,c,d):k(a,b,c,d)}function m(a,b){var c,d,e=new Array(a.length+b.length),f=0;if(0===a.length)return b;if(0===b.length)return a;for(c=a.length,d=0;c>d;d++,f++)e[f]=a[d];for(c=b.length,d=0;c>d;d++,f++)e[f]=b[d];return e}function n(a,b){var c,d=a.length;for(c=0;d>c;c++)if(a[c]===b)return c;return-1}function o(a,b){var c,d=a.length;for(c=0;d>c;c++)if(b(a[c]))return c;return-1}function p(a){var b,c=a.length,d=new Array(c);for(b=0;c>b;b++)d[b]=a[b];return d}function q(a,b){var c,d,e,f=a.length;if(b>=0&&f>b){if(1===f)return[];for(c=new Array(f-1),d=0,e=0;f>d;d++)d!==b&&(c[e]=a[d],e++);return c}return a}function r(a,b){return q(a,o(a,b))}function s(a,b){var c,d=a.length;for(c=0;d>c;c++)b(a[c])}function t(a,b){var c,d=a.length;for(c=0;d>c;c++)a[c]=b}function u(a,b){return-1!==n(a,b)}function v(a,b,c){return a.length>b?Array.prototype.slice.call(a,b):c}function w(a){return"function"==typeof a}function x(a){return $(a)||_(a)}function y(a,b){var c,d;if(null==a&&null==b)return!0;if(null==a||null==b)return!1;if(a.length!==b.length)return!1;for(d=0,c=a.length;c>d;d++)if(a[d]!==b[d])return!1;return!0}function z(){for(var a=0;a<arguments.length;a++)if(!arguments[a])return arguments[a];return arguments[a-1]}function A(){for(var a=0;a<arguments.length;a++)if(arguments[a])return arguments[a];return arguments[a-1]}function B(a,b){function c(a,b){K.call(this),this._wait=a,this._intervalId=null;var c=this;this._$onTick=function(){c._onTick()},this._init(b)}f(c,K,{_name:a,_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(){K.prototype._clear.call(this),this._$onTick=null,this._free()}},b),ab[a]=function(a){return new c(a,v(arguments,1,[]))}}function C(a,b,c){function d(c){function d(b,d){c.call(this),this._source=b,this._name=b._name+"."+a,this._init(d)}return f(d,c,{_clear:function(){c.prototype._clear.call(this),this._source=null,this._free()}},b),d}c=e({streamMethod:function(a){return function(){return new a(this,arguments)}},propertyMethod:function(a,b){return function(){return new b(this,arguments)}}},c||{}),b=e({_init:function(){},_free:function(){},_handleValue:function(a,b){this._send("value",a,b)},_handleEnd:function(a,b){this._send("end",null,b)},_onActivationHook:function(){},_onDeactivationHook:function(){},_handleAny:function(a){switch(a.type){case"value":this._handleValue(a.value,a.current);break;case"end":this._handleEnd(a.value,a.current)}},_onActivation:function(){this._onActivationHook(),this._source.onAny([this._handleAny,this])},_onDeactivation:function(){this._onDeactivationHook(),this._source.offAny([this._handleAny,this])}},b||{});var g=d(K),h=d(L);c.streamMethod&&(K.prototype[a]=c.streamMethod(g,h)),c.propertyMethod&&(L.prototype[a]=c.propertyMethod(g,h))}function D(a){if(a instanceof F)return a;if(w(a))return{fn:a,context:null,args:[]};if(x(a))return{fn:h(a[0],a[1]),context:null==a[1]?null:a[1],args:v(a,2,[])};throw new Error("Object isn't a function, and can't be converted to it: "+a)}function E(a,b){return a=D(a),i(a.fn,a.context,m(a.args,b))}function F(a,b){this.context=a.context,this.fn=a.fn,this.args=a.args,this.invoke=l(this.fn,this.context,this.args,b)}function G(a,b){return a instanceof F?a:new F(D(a),null==b?100:b)}function H(){this._fns=[]}function I(a,b,c){return{type:a,value:b,current:!!c}}function J(){this._subscribers=new H,this._active=!1,this._alive=!0}function K(){J.call(this)}function L(){J.call(this),this._current=Y}function M(a,b){var c="<"+b.type+(b.current?":current":"")+">";"value"===b.type?console.log(a,c,b.value):console.log(a,c)}function N(a){if(K.call(this),this._queueLim=b(a,"queueLim",0),this._concurLim=b(a,"concurLim",-1),this._drop=b(a,"drop","new"),0===this._concurLim)throw new Error("options.concurLim can't be 0");this._queue=[],this._curSources=[],this._activating=!1}function O(a){N.call(this),0===a.length?this._send("end"):this._addAll(a),this._initialised=!0}function P(a){N.call(this,{concurLim:1,queueLim:-1}),0===a.length?this._send("end"):this._addAll(a),this._initialised=!0}function Q(){N.call(this)}function R(a,b,c){N.call(this,c),this._source=a,this._fn=b?G(b,1):null,this._mainEnded=!1,this._lastCurrent=null}function S(a,b,c){K.call(this),0===b.length?this._send("end"):(this._passiveCount=a.length,this._combinator=c?G(c):null,this._sources=m(a,b),this._aliveCount=0,this._currents=new Array(this._sources.length),t(this._currents,Y),this._activating=!1,this._emitAfterActivation=!1,this._endAfterActivation=!1)}function T(a){return function(){return new a(this,arguments)}}function U(a,b){return function(){return new b(this,arguments)}}function V(a){K.call(this),this._fn=G(a,1),this._unsubscribe=null}function W(){K.call(this)}function X(a){L.call(this),this._send("value",a),this._send("end")}var Y=["<nothing>"],Z=Date.now?function(){return Date.now()}:function(){return(new Date).getTime()},$=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},_=function(a){return"[object Arguments]"===Object.prototype.toString.call(a)};_(arguments)||(_=function(a){return!(!a||!c(a,"callee"))});var ab={};F.prototype.apply=function(a){return i(this.invoke,null,a)},F.prototype.applyWithContext=function(a,b){return null===this.context?i(this.fn,a,m(this.args,b)):this.apply(b)},G.isEqual=function(a,b){return a===b?!0:(a=G(a,null,!0),b=G(b,null,!0),a.fn===b.fn&&a.context===b.context&&y(a.args,b.args))},ab.Fn=G,e(H,{callOne:function(a,b){"any"===a.type?a.invoke(b):a.type===b.type&&("value"===a.type?a.invoke(b.value):a.invoke())},callOnce:function(a,b,c){"any"===a?E(b,[c]):a===c.type&&("value"===a?E(b,[c.value]):E(b,[]))}}),e(H.prototype,{add:function(a,b){b=G(b,"end"===a?0:1),b.type=a,this._fns=m(this._fns,[b])},remove:function(a,b){b=G(b),this._fns=r(this._fns,function(c){return c.type===a&&G.isEqual(c,b)})},callAll:function(a){for(var b=this._fns,c=0;c<b.length;c++)H.callOne(b[c],a)},isEmpty:function(){return 0===this._fns.length}});var bb=I("end",void 0,!0);ab.Observable=J,e(J.prototype,{_name:"observable",_onActivation:function(){},_onDeactivation:function(){},_setActive:function(a){this._active!==a&&(this._active=a,a?this._onActivation():this._onDeactivation())},_clear:function(){this._setActive(!1),this._alive=!1,this._subscribers=null},_send:function(a,b,c){this._alive&&(this._subscribers.callAll(I(a,b,c)),"end"===a&&this._clear())},on:function(a,b){return this._alive?(this._subscribers.add(a,b),this._setActive(!0)):H.callOnce(a,b,bb),this},off:function(a,b){return this._alive&&(this._subscribers.remove(a,b),this._subscribers.isEmpty()&&this._setActive(!1)),this},onValue:function(a){return this.on("value",a)},onEnd:function(a){return this.on("end",a)},onAny:function(a){return this.on("any",a)},offValue:function(a){return this.off("value",a)},offEnd:function(a){return this.off("end",a)},offAny:function(a){return this.off("any",a)}}),J.prototype.toString=function(){return"["+this._name+"]"},ab.Stream=K,f(K,J,{_name:"stream"}),ab.Property=L,f(L,J,{_name:"property",_send:function(a,b,c){this._alive&&(c||this._subscribers.callAll(I(a,b)),"value"===a&&(this._current=b),"end"===a&&this._clear())},on:function(a,b){return this._alive&&(this._subscribers.add(a,b),this._setActive(!0)),this._current!==Y&&H.callOnce(a,b,I("value",this._current,!0)),this._alive||H.callOnce(a,b,bb),this}}),J.prototype.log=function(a){return this.onAny([M,null,a||this.toString()]),this},J.prototype.offLog=function(a){return this.offAny([M,null,a||this.toString()]),this},B("withInterval",{_init:function(a){this._fn=G(a[0],1);var b=this;this._emitter={emit:function(a){b._send("value",a)},end:function(){b._send("end")}}},_free:function(){this._fn=null,this._emitter=null},_onTick:function(){this._fn.invoke(this._emitter)}}),B("fromPoll",{_init:function(a){this._fn=G(a[0],0)},_free:function(){this._fn=null},_onTick:function(){this._send("value",this._fn.invoke())}}),B("interval",{_init:function(a){this._x=a[0]},_free:function(){this._x=null},_onTick:function(){this._send("value",this._x)}}),B("sequentially",{_init:function(a){this._xs=p(a[0]),0===this._xs.length&&this._send("end")},_free:function(){this._xs=null},_onTick:function(){switch(this._xs.length){case 1:this._send("value",this._xs[0]),this._send("end");break;default:this._send("value",this._xs.shift())}}}),B("repeatedly",{_init:function(a){this._xs=p(a[0]),this._i=-1},_onTick:function(){this._xs.length>0&&(this._i=(this._i+1)%this._xs.length,this._send("value",this._xs[this._i]))}}),B("later",{_init:function(a){this._x=a[0]},_free:function(){this._x=null},_onTick:function(){this._send("value",this._x),this._send("end")}}),f(N,K,{_name:"abstractPool",_add:function(a){-1===this._concurLim||this._curSources.length<this._concurLim?this._addToCur(a):-1===this._queueLim||this._queue.length<this._queueLim?this._addToQueue(a):"old"===this._drop&&(this._removeOldest(),this._add(a))},_addAll:function(a){var b=this;s(a,function(a){b._add(a)})},_remove:function(a){-1===this._removeCur(a)&&this._removeQueue(a)},_addToQueue:function(a){this._queue=m(this._queue,[a])},_addToCur:function(a){this._curSources=m(this._curSources,[a]),this._active&&this._sub(a)},_sub:function(a){a.onAny([this._handleSubAny,this]),a.onEnd([this._removeCur,this,a])},_unsub:function(a){a.offAny([this._handleSubAny,this]),a.offEnd([this._removeCur,this,a])},_handleSubAny:function(a){"value"===a.type&&this._send("value",a.value,a.current&&this._activating)},_removeQueue:function(a){var b=n(this._queue,a);return this._queue=q(this._queue,b),b},_removeCur:function(a){this._active&&this._unsub(a);var b=n(this._curSources,a);return this._curSources=q(this._curSources,b),-1!==b&&(0!==this._queue.length?this._pullQueue():0===this._curSources.length&&this._onEmpty()),b},_removeOldest:function(){this._removeCur(this._curSources[0])},_pullQueue:function(){0!==this._queue.length&&(this._queue=p(this._queue),this._addToCur(this._queue.shift()))},_onActivation:function(){var a,b=this._curSources;for(this._activating=!0,a=0;a<b.length;a++)this._sub(b[a]);this._activating=!1},_onDeactivation:function(){var a,b=this._curSources;for(a=0;a<b.length;a++)this._unsub(b[a])},_isEmpty:function(){return 0===this._curSources.length},_onEmpty:function(){},_clear:function(){K.prototype._clear.call(this),this._queue=null,this._curSources=null}});var cb={_onEmpty:function(){this._initialised&&this._send("end",null,this._activating)}};f(O,N,e({_name:"merge"},cb)),ab.merge=function(){return new O(g(arguments))},J.prototype.merge=function(a){return ab.merge([this,a])},f(P,N,e({_name:"concat"},cb)),ab.concat=function(){return new P(g(arguments))},J.prototype.concat=function(a){return ab.concat([this,a])},f(Q,N,{_name:"pool",add:function(a){return this._add(a),this},remove:function(a){return this._remove(a),this}}),ab.pool=function(){return new Q},f(R,N,{_onActivation:function(){N.prototype._onActivation.call(this),this._activating=!0,this._source.onAny([this._handleMainSource,this]),this._activating=!1},_onDeactivation:function(){N.prototype._onDeactivation.call(this),this._source.offAny([this._handleMainSource,this])},_handleMainSource:function(a){"value"===a.type?(a.current&&this._lastCurrent===a.value||this._add(this._fn?this._fn.invoke(a.value):a.value),this._lastCurrent=a.value):this._isEmpty()?this._send("end",null,a.current):this._mainEnded=!0},_onEmpty:function(){this._mainEnded&&this._send("end")},_clear:function(){N.prototype._clear.call(this),this._source=null,this._lastCurrent=null}}),J.prototype.flatMap=function(a){return new R(this,a).setName(this,"flatMap")},J.prototype.flatMapLatest=function(a){return new R(this,a,{concurLim:1,drop:"old"}).setName(this,"flatMapLatest")},J.prototype.flatMapFirst=function(a){return new R(this,a,{concurLim:1}).setName(this,"flatMapFirst")},J.prototype.flatMapConcat=function(a){return new R(this,a,{queueLim:-1,concurLim:1}).setName(this,"flatMapConcat")},J.prototype.flatMapWithConcurrencyLimit=function(a,b){var c;return 0===b?c=ab.never():(0>b&&(b=-1),c=new R(this,a,{queueLim:-1,concurLim:b})),c.setName(this,"flatMapWithConcurrencyLimit")},f(S,K,{_name:"sampledBy",_onActivation:function(){var a,b=this._sources.length;for(this._aliveCount=b-this._passiveCount,this._activating=!0,a=0;b>a;a++)this._sources[a].onAny([this._handleAny,this,a]);this._activating=!1,this._emitAfterActivation&&(this._emitAfterActivation=!1,this._emitIfFull(!0)),this._endAfterActivation&&this._send("end",null,!0)},_onDeactivation:function(){var a,b=this._sources.length;for(a=0;b>a;a++)this._sources[a].offAny([this._handleAny,this,a])},_emitIfFull:function(a){if(!u(this._currents,Y)){var b=p(this._currents);this._combinator&&(b=this._combinator.apply(this._currents)),this._send("value",b,a)}},_handleAny:function(a,b){"value"===b.type?(this._currents[a]=b.value,a>=this._passiveCount&&(this._activating?this._emitAfterActivation=!0:this._emitIfFull(b.current))):a>=this._passiveCount&&(this._aliveCount--,0===this._aliveCount&&(this._activating?this._endAfterActivation=!0:this._send("end",null,b.current)))},_clear:function(){K.prototype._clear.call(this),this._sources=null,this._currents=null}}),ab.sampledBy=function(a,b,c){return new S(a,b,c)},J.prototype.sampledBy=function(a,b){return ab.sampledBy([this],[a],b)},ab.combine=function(a,b){var c=new S([],a,b);return c._name="combine",c},J.prototype.combine=function(a,b){return ab.combine([this,a],b)},C("toProperty",{_init:function(a){a.length>0&&this._send("value",a[0])}},{propertyMethod:null,streamMethod:U}),C("changes",{_handleValue:function(a,b){b||this._send("value",a)}},{streamMethod:null,propertyMethod:T}),C("withHandler",{_init:function(a){this._handler=G(a[0],2),this._forcedCurrent=!1;var b=this;this._emitter={emit:function(a){b._send("value",a,b._forcedCurrent)},end:function(){b._send("end",null,b._forcedCurrent)}}},_free:function(){this._handler=null,this._emitter=null},_handleAny:function(a){this._forcedCurrent=a.current,this._handler.invoke(this._emitter,a),this._forcedCurrent=!1}});var db={_init:function(a){this._fn=G(a[0],1)},_free:function(){this._fn=null}};C("map",e({_handleValue:function(a,b){this._send("value",this._fn.invoke(a),b)}},db)),C("filter",e({_handleValue:function(a,b){this._fn.invoke(a)&&this._send("value",a,b)}},db)),C("takeWhile",e({_handleValue:function(a,b){this._fn.invoke(a)?this._send("value",a,b):this._send("end",null,b)}},db)),C("take",{_init:function(a){this._n=a[0],this._n<=0&&this._send("end")},_handleValue:function(a,b){this._n--,this._send("value",a,b),0===this._n&&this._send("end")}}),C("skip",{_init:function(a){this._n=a[0]<0?0:a[0]},_handleValue:function(a,b){0===this._n?this._send("value",a,b):this._n--}}),C("skipDuplicates",{_init:function(a){this._fn=a[0]&&G(a[0],2),this._prev=Y},_free:function(){this._fn=null,this._prev=null},_isEqual:function(a,b){return this._fn?this._fn.invoke(a,b):a===b},_handleValue:function(a,b){this._prev!==Y&&this._isEqual(this._prev,a)||(this._send("value",a,b),this._prev=a)}}),C("skipWhile",{_init:function(a){this._fn=G(a[0],1),this._skip=!0},_free:function(){this._fn=null},_handleValue:function(a,b){return this._skip?void(this._fn.invoke(a)||(this._skip=!1,this._fn=null,this._send("value",a,b))):void this._send("value",a,b)}}),C("diff",{_init:function(a){this._prev=a[0],this._fn=G(a[1],2)},_free:function(){this._prev=null,this._fn=null},_handleValue:function(a,b){this._send("value",this._fn.invoke(this._prev,a),b),this._prev=a}}),C("scan",{_init:function(a){this._send("value",a[0],!0),this._fn=G(a[1],2)},_free:function(){this._fn=null},_handleValue:function(a,b){this._send("value",this._fn.invoke(this._current,a),b)}},{streamMethod:U}),C("reduce",{_init:function(a){this._result=a[0],this._fn=G(a[1],2)},_free:function(){this._fn=null,this._result=null},_handleValue:function(a){this._result=this._fn.invoke(this._result,a)},_handleEnd:function(a,b){this._send("value",this._result,b),this._send("end",null,b)}}),C("debounce",{_init:function(a){this._wait=Math.max(0,a[0]),this._immediate=b(a[1],"immediate",!1),this._lastAttempt=0,this._timeoutId=null,this._laterValue=null,this._endLater=!1;var c=this;this._$later=function(){c._later()}},_free:function(){this._laterValue=null,this._$later=null},_handleValue:function(a,b){b?this._send("value",a,b):(this._lastAttempt=Z(),this._immediate&&!this._timeoutId&&this._send("value",a),this._timeoutId||(this._timeoutId=setTimeout(this._$later,this._wait)),this._immediate||(this._laterValue=a))},_handleEnd:function(a,b){b?this._send("end",null,b):this._timeoutId&&!this._immediate?this._endLater=!0:this._send("end")},_later:function(){var a=Z()-this._lastAttempt;a<this._wait&&a>=0?this._timeoutId=setTimeout(this._$later,this._wait-a):(this._timeoutId=null,this._immediate||(this._send("value",this._laterValue),this._laterValue=null),this._endLater&&this._send("end"))}}),C("throttle",{_init:function(a){this._wait=Math.max(0,a[0]),this._leading=b(a[1],"leading",!0),this._trailing=b(a[1],"trailing",!0),this._trailingValue=null,this._timeoutId=null,this._endLater=!1,this._lastCallTime=0;var c=this;this._$trailingCall=function(){c._trailingCall()}},_free:function(){this._trailingValue=null,this._$trailingCall=null},_handleValue:function(a,b){if(b)this._send("value",a,b);else{var c=Z();0!==this._lastCallTime||this._leading||(this._lastCallTime=c);var d=this._wait-(c-this._lastCallTime);0>=d?(this._cancelTraling(),this._lastCallTime=c,this._send("value",a)):this._trailing&&(this._cancelTraling(),this._trailingValue=a,this._timeoutId=setTimeout(this._$trailingCall,d))}},_handleEnd:function(a,b){b?this._send("end",null,b):this._timeoutId?this._endLater=!0:this._send("end")},_cancelTraling:function(){null!==this._timeoutId&&(clearTimeout(this._timeoutId),this._timeoutId=null)},_trailingCall:function(){this._send("value",this._trailingValue),this._timeoutId=null,this._trailingValue=null,this._lastCallTime=this._leading?Z():0,this._endLater&&this._send("end")}}),C("delay",{_init:function(a){this._wait=Math.max(0,a[0]),this._buff=[];var b=this;this._$shiftBuff=function(){b._send("value",b._buff.shift())}},_free:function(){this._buff=null,this._$shiftBuff=null},_handleValue:function(a,b){b?this._send("value",a,b):(this._buff.push(a),setTimeout(this._$shiftBuff,this._wait))},_handleEnd:function(a,b){if(b)this._send("end",null,b);else{var c=this;setTimeout(function(){c._send("end")},this._wait)}}}),f(V,K,{_name:"fromBinder",_onActivation:function(){var a,b=this,c=!0,d={emit:function(a){b._send("value",a,c)},end:function(){b._send("end",null,c)}};a=this._fn.invoke(d),c=!1,a&&(this._unsubscribe=G(a,0))},_onDeactivation:function(){null!==this._unsubscribe&&(this._unsubscribe.invoke(),this._unsubscribe=null)},_clear:function(){K.prototype._clear.call(this),this._fn=null}}),ab.fromBinder=function(a){return new V(a)},f(W,K,{_name:"emitter",emit:function(a){this._send("value",a)},end:function(){this._send("end")}}),ab.emitter=function(){return new W};var eb=new K;eb._send("end"),eb._name="never",ab.never=function(){return eb},f(X,L,{_name:"constant"}),ab.constant=function(a){return new X(a)},J.prototype.setName=function(a,b){return this._name=b?a._name+"."+b:a,this},J.prototype.mapTo=function(a){return this.map(function(){return a}).setName(this,"mapTo")},J.prototype.pluck=function(a){return this.map(function(b){return b[a]}).setName(this,"pluck")},J.prototype.invoke=function(a){var b=v(arguments,1);return this.map(b?function(c){return i(c[a],c,b)}:function(b){return b[a]()}).setName(this,"invoke")},J.prototype.tap=function(a){return a=G(a,1),this.map(function(b){return a.invoke(b),b}).setName(this,"tap")},ab.and=function(a){return ab.combine(a,z).setName("and")},J.prototype.and=function(a){return this.combine(a,z).setName("and")},ab.or=function(a){return ab.combine(a,A).setName("or")},J.prototype.or=function(a){return this.combine(a,A).setName("or")},J.prototype.not=function(){return this.map(function(a){return!a}).setName(this,"not")},J.prototype.awaiting=function(a){return ab.merge([this.mapTo(!0),a.mapTo(!1)]).skipDuplicates().toProperty(!1).setName(this,"awaiting")},J.prototype.filterBy=function(a){return a.sampledBy(this).withHandler(function(a,b){"end"===b.type?a.end():b.value[0]&&a.emit(b.value[1])}).setName(this,"filterBy")},ab.fromCallback=function(a){a=G(a,1);var b=!1;return ab.fromBinder(function(c){b||(a.invoke(function(a){c.emit(a),c.end()}),b=!0)}).setName("fromCallback")},"function"==typeof define&&define.amd?(define([],function(){return ab}),a.Kefir=ab):"object"==typeof module&&"object"==typeof exports?(module.exports=ab,ab.Kefir=ab):a.Kefir=ab}(this);
!function(a){"use strict";function b(a,b,c){return a&&b in a?a[b]:c}function c(a,b){return Object.prototype.hasOwnProperty.call(a,b)}function d(a){var b=function(){};return b.prototype=a,new b}function e(a){var b,c,d=arguments.length;for(b=1;d>b;b++)for(c in arguments[b])a[c]=arguments[b][c];return a}function f(a,b){var c,f=arguments.length;for(a.prototype=d(b.prototype),a.prototype.constructor=a,c=2;f>c;c++)e(a.prototype,arguments[c]);return a}function g(a){return 1===a.length&&$(a[0])?a[0]:p(a)}function h(a,b){if(w(a))return a;if(null!=b&&w(b[a]))return b[a];throw new Error("Not a function: "+a+" in context: "+b)}function i(a,b,c){var d=c?c.length:0;if(null==b)switch(d){case 0:return a();case 1:return a(c[0]);case 2:return a(c[0],c[1]);case 3:return a(c[0],c[1],c[2]);case 4:return a(c[0],c[1],c[2],c[3]);default:return a.apply(null,c)}else switch(d){case 0:return a.call(b);default:return a.apply(b,c)}}function j(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3];switch(c){case 0:switch(b.length){case 0:return a;case 1:return function(){return a(d)};case 2:return function(){return a(d,e)};case 3:return function(){return a(d,e,f)};case 4:return function(){return a(d,e,f,g)};default:return function(){return a.apply(null,b)}}break;case 1:switch(b.length){case 0:return a;case 1:return function(b){return a(d,b)};case 2:return function(b){return a(d,e,b)};case 3:return function(b){return a(d,e,f,b)};case 4:return function(b){return a(d,e,f,g,b)};default:return function(c){return a.apply(null,m(b,[c]))}}break;case 2:switch(b.length){case 0:return a;case 1:return function(b,c){return a(d,b,c)};case 2:return function(b,c){return a(d,e,b,c)};case 3:return function(b,c){return a(d,e,f,b,c)};case 4:return function(b,c){return a(d,e,f,g,b,c)};default:return function(c,d){return a.apply(null,m(b,[c,d]))}}break;default:switch(b.length){case 0:return a;default:return function(){return i(a,null,m(b,arguments))}}}}function k(a,b,c,d){var e=c[0],f=c[1],g=c[2],h=c[3];switch(d){case 0:switch(c.length){case 0:return function(){return a.call(b)};default:return function(){return a.apply(b,c)}}break;case 1:switch(c.length){case 0:return function(c){return a.call(b,c)};case 1:return function(c){return a.call(b,e,c)};case 2:return function(c){return a.call(b,e,f,c)};case 3:return function(c){return a.call(b,e,f,g,c)};case 4:return function(c){return a.call(b,e,f,g,h,c)};default:return function(d){return a.apply(b,m(c,[d]))}}break;case 2:switch(c.length){case 0:return function(c,d){return a.call(b,c,d)};case 1:return function(c,d){return a.call(b,e,c,d)};case 2:return function(c,d){return a.call(b,e,f,c,d)};case 3:return function(c,d){return a.call(b,e,f,g,c,d)};case 4:return function(c,d){return a.call(b,e,f,g,h,c,d)};default:return function(d,e){return a.apply(b,m(c,[d,e]))}}break;default:switch(c.length){case 0:return function(){return a.apply(b,arguments)};default:return function(){return a.apply(b,m(c,arguments))}}}}function l(a,b,c,d){return null==b?j(a,c,d):k(a,b,c,d)}function m(a,b){var c,d,e=new Array(a.length+b.length),f=0;if(0===a.length)return b;if(0===b.length)return a;for(c=a.length,d=0;c>d;d++,f++)e[f]=a[d];for(c=b.length,d=0;c>d;d++,f++)e[f]=b[d];return e}function n(a,b){var c,d=a.length;for(c=0;d>c;c++)if(a[c]===b)return c;return-1}function o(a,b){var c,d=a.length;for(c=0;d>c;c++)if(b(a[c]))return c;return-1}function p(a){var b,c=a.length,d=new Array(c);for(b=0;c>b;b++)d[b]=a[b];return d}function q(a,b){var c,d,e,f=a.length;if(b>=0&&f>b){if(1===f)return[];for(c=new Array(f-1),d=0,e=0;f>d;d++)d!==b&&(c[e]=a[d],e++);return c}return a}function r(a,b){return q(a,o(a,b))}function s(a,b){var c,d=a.length;for(c=0;d>c;c++)b(a[c])}function t(a,b){var c,d=a.length;for(c=0;d>c;c++)a[c]=b}function u(a,b){return-1!==n(a,b)}function v(a,b,c){return a.length>b?Array.prototype.slice.call(a,b):c}function w(a){return"function"==typeof a}function x(a){return $(a)||_(a)}function y(a,b){var c,d;if(null==a&&null==b)return!0;if(null==a||null==b)return!1;if(a.length!==b.length)return!1;for(d=0,c=a.length;c>d;d++)if(a[d]!==b[d])return!1;return!0}function z(){for(var a=0;a<arguments.length;a++)if(!arguments[a])return arguments[a];return arguments[a-1]}function A(){for(var a=0;a<arguments.length;a++)if(arguments[a])return arguments[a];return arguments[a-1]}function B(a,b){function c(a,b){K.call(this),this._wait=a,this._intervalId=null;var c=this;this._$onTick=function(){c._onTick()},this._init(b)}f(c,K,{_name:a,_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(){K.prototype._clear.call(this),this._$onTick=null,this._free()}},b),ab[a]=function(a){return new c(a,v(arguments,1,[]))}}function C(a,b,c){function d(c){function d(b,d){c.call(this),this._source=b,this._name=b._name+"."+a,this._init(d)}return f(d,c,{_clear:function(){c.prototype._clear.call(this),this._source=null,this._free()}},b),d}c=e({streamMethod:function(a){return function(){return new a(this,arguments)}},propertyMethod:function(a,b){return function(){return new b(this,arguments)}}},c||{}),b=e({_init:function(){},_free:function(){},_handleValue:function(a,b){this._send("value",a,b)},_handleEnd:function(a,b){this._send("end",null,b)},_onActivationHook:function(){},_onDeactivationHook:function(){},_handleAny:function(a){switch(a.type){case"value":this._handleValue(a.value,a.current);break;case"end":this._handleEnd(a.value,a.current)}},_onActivation:function(){this._onActivationHook(),this._source.onAny([this._handleAny,this])},_onDeactivation:function(){this._onDeactivationHook(),this._source.offAny([this._handleAny,this])}},b||{});var g=d(K),h=d(L);c.streamMethod&&(K.prototype[a]=c.streamMethod(g,h)),c.propertyMethod&&(L.prototype[a]=c.propertyMethod(g,h))}function D(a){if(a instanceof F)return a;if(w(a))return{fn:a,context:null,args:[]};if(x(a))return{fn:h(a[0],a[1]),context:null==a[1]?null:a[1],args:v(a,2,[])};throw new Error("Object isn't a function, and can't be converted to it: "+a)}function E(a,b){return a=D(a),i(a.fn,a.context,m(a.args,b))}function F(a,b){this.context=a.context,this.fn=a.fn,this.args=a.args,this.invoke=l(this.fn,this.context,this.args,b)}function G(a,b){return a instanceof F?a:new F(D(a),null==b?100:b)}function H(){this._fns=[]}function I(a,b,c){return{type:a,value:b,current:!!c}}function J(){this._subscribers=new H,this._active=!1,this._alive=!0}function K(){J.call(this)}function L(){J.call(this),this._current=Y}function M(a,b){var c="<"+b.type+(b.current?":current":"")+">";"value"===b.type?console.log(a,c,b.value):console.log(a,c)}function N(a){if(K.call(this),this._queueLim=b(a,"queueLim",0),this._concurLim=b(a,"concurLim",-1),this._drop=b(a,"drop","new"),0===this._concurLim)throw new Error("options.concurLim can't be 0");this._queue=[],this._curSources=[],this._activating=!1}function O(a){N.call(this),0===a.length?this._send("end"):this._addAll(a),this._initialised=!0}function P(a){N.call(this,{concurLim:1,queueLim:-1}),0===a.length?this._send("end"):this._addAll(a),this._initialised=!0}function Q(){N.call(this)}function R(a,b,c){N.call(this,c),this._source=a,this._fn=b?G(b,1):null,this._mainEnded=!1,this._lastCurrent=null}function S(a,b,c){K.call(this),0===b.length?this._send("end"):(this._passiveCount=a.length,this._combinator=c?G(c):null,this._sources=m(a,b),this._aliveCount=0,this._currents=new Array(this._sources.length),t(this._currents,Y),this._activating=!1,this._emitAfterActivation=!1,this._endAfterActivation=!1)}function T(a){return function(){return new a(this,arguments)}}function U(a,b){return function(){return new b(this,arguments)}}function V(a){K.call(this),this._fn=G(a,1),this._unsubscribe=null}function W(){K.call(this)}function X(a){L.call(this),this._send("value",a),this._send("end")}var Y=["<nothing>"],Z=Date.now?function(){return Date.now()}:function(){return(new Date).getTime()},$=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},_=function(a){return"[object Arguments]"===Object.prototype.toString.call(a)};_(arguments)||(_=function(a){return!(!a||!c(a,"callee"))});var ab={};F.prototype.apply=function(a){return i(this.invoke,null,a)},F.prototype.applyWithContext=function(a,b){return null===this.context?i(this.fn,a,m(this.args,b)):this.apply(b)},G.isEqual=function(a,b){return a===b?!0:(a=G(a,null,!0),b=G(b,null,!0),a.fn===b.fn&&a.context===b.context&&y(a.args,b.args))},ab.Fn=G,e(H,{callOne:function(a,b){"any"===a.type?a.invoke(b):a.type===b.type&&("value"===a.type?a.invoke(b.value):a.invoke())},callOnce:function(a,b,c){"any"===a?E(b,[c]):a===c.type&&("value"===a?E(b,[c.value]):E(b,[]))}}),e(H.prototype,{add:function(a,b){b=G(b,"end"===a?0:1),b.type=a,this._fns=m(this._fns,[b])},remove:function(a,b){b=G(b),this._fns=r(this._fns,function(c){return c.type===a&&G.isEqual(c,b)})},callAll:function(a){for(var b=this._fns,c=0;c<b.length;c++)H.callOne(b[c],a)},isEmpty:function(){return 0===this._fns.length}});var bb=I("end",void 0,!0);ab.Observable=J,e(J.prototype,{_name:"observable",_onActivation:function(){},_onDeactivation:function(){},_setActive:function(a){this._active!==a&&(this._active=a,a?this._onActivation():this._onDeactivation())},_clear:function(){this._setActive(!1),this._alive=!1,this._subscribers=null},_send:function(a,b,c){this._alive&&(this._subscribers.callAll(I(a,b,c)),"end"===a&&this._clear())},on:function(a,b){return this._alive?(this._subscribers.add(a,b),this._setActive(!0)):H.callOnce(a,b,bb),this},off:function(a,b){return this._alive&&(this._subscribers.remove(a,b),this._subscribers.isEmpty()&&this._setActive(!1)),this},onValue:function(a){return this.on("value",a)},onEnd:function(a){return this.on("end",a)},onAny:function(a){return this.on("any",a)},offValue:function(a){return this.off("value",a)},offEnd:function(a){return this.off("end",a)},offAny:function(a){return this.off("any",a)}}),J.prototype.toString=function(){return"["+this._name+"]"},ab.Stream=K,f(K,J,{_name:"stream"}),ab.Property=L,f(L,J,{_name:"property",_send:function(a,b,c){this._alive&&(c||this._subscribers.callAll(I(a,b)),"value"===a&&(this._current=b),"end"===a&&this._clear())},on:function(a,b){return this._alive&&(this._subscribers.add(a,b),this._setActive(!0)),this._current!==Y&&H.callOnce(a,b,I("value",this._current,!0)),this._alive||H.callOnce(a,b,bb),this}}),J.prototype.log=function(a){return this.onAny([M,null,a||this.toString()]),this},J.prototype.offLog=function(a){return this.offAny([M,null,a||this.toString()]),this},B("withInterval",{_init:function(a){this._fn=G(a[0],1);var b=this;this._emitter={emit:function(a){b._send("value",a)},end:function(){b._send("end")}}},_free:function(){this._fn=null,this._emitter=null},_onTick:function(){this._fn.invoke(this._emitter)}}),B("fromPoll",{_init:function(a){this._fn=G(a[0],0)},_free:function(){this._fn=null},_onTick:function(){this._send("value",this._fn.invoke())}}),B("interval",{_init:function(a){this._x=a[0]},_free:function(){this._x=null},_onTick:function(){this._send("value",this._x)}}),B("sequentially",{_init:function(a){this._xs=p(a[0]),0===this._xs.length&&this._send("end")},_free:function(){this._xs=null},_onTick:function(){switch(this._xs.length){case 1:this._send("value",this._xs[0]),this._send("end");break;default:this._send("value",this._xs.shift())}}}),B("repeatedly",{_init:function(a){this._xs=p(a[0]),this._i=-1},_onTick:function(){this._xs.length>0&&(this._i=(this._i+1)%this._xs.length,this._send("value",this._xs[this._i]))}}),B("later",{_init:function(a){this._x=a[0]},_free:function(){this._x=null},_onTick:function(){this._send("value",this._x),this._send("end")}}),f(N,K,{_name:"abstractPool",_add:function(a){-1===this._concurLim||this._curSources.length<this._concurLim?this._addToCur(a):-1===this._queueLim||this._queue.length<this._queueLim?this._addToQueue(a):"old"===this._drop&&(this._removeOldest(),this._add(a))},_addAll:function(a){var b=this;s(a,function(a){b._add(a)})},_remove:function(a){-1===this._removeCur(a)&&this._removeQueue(a)},_addToQueue:function(a){this._queue=m(this._queue,[a])},_addToCur:function(a){this._curSources=m(this._curSources,[a]),this._active&&this._sub(a)},_sub:function(a){a.onAny([this._handleSubAny,this]),a.onEnd([this._removeCur,this,a])},_unsub:function(a){a.offAny([this._handleSubAny,this]),a.offEnd([this._removeCur,this,a])},_handleSubAny:function(a){"value"===a.type&&this._send("value",a.value,a.current&&this._activating)},_removeQueue:function(a){var b=n(this._queue,a);return this._queue=q(this._queue,b),b},_removeCur:function(a){this._active&&this._unsub(a);var b=n(this._curSources,a);return this._curSources=q(this._curSources,b),-1!==b&&(0!==this._queue.length?this._pullQueue():0===this._curSources.length&&this._onEmpty()),b},_removeOldest:function(){this._removeCur(this._curSources[0])},_pullQueue:function(){0!==this._queue.length&&(this._queue=p(this._queue),this._addToCur(this._queue.shift()))},_onActivation:function(){var a,b=this._curSources;for(this._activating=!0,a=0;a<b.length;a++)this._sub(b[a]);this._activating=!1},_onDeactivation:function(){var a,b=this._curSources;for(a=0;a<b.length;a++)this._unsub(b[a])},_isEmpty:function(){return 0===this._curSources.length},_onEmpty:function(){},_clear:function(){K.prototype._clear.call(this),this._queue=null,this._curSources=null}});var cb={_onEmpty:function(){this._initialised&&this._send("end",null,this._activating)}};f(O,N,e({_name:"merge"},cb)),ab.merge=function(){return new O(g(arguments))},J.prototype.merge=function(a){return ab.merge([this,a])},f(P,N,e({_name:"concat"},cb)),ab.concat=function(){return new P(g(arguments))},J.prototype.concat=function(a){return ab.concat([this,a])},f(Q,N,{_name:"pool",plug:function(a){return this._add(a),this},unplug:function(a){return this._remove(a),this}}),ab.pool=function(){return new Q},f(R,N,{_onActivation:function(){N.prototype._onActivation.call(this),this._activating=!0,this._source.onAny([this._handleMainSource,this]),this._activating=!1},_onDeactivation:function(){N.prototype._onDeactivation.call(this),this._source.offAny([this._handleMainSource,this])},_handleMainSource:function(a){"value"===a.type?(a.current&&this._lastCurrent===a.value||this._add(this._fn?this._fn.invoke(a.value):a.value),this._lastCurrent=a.value):this._isEmpty()?this._send("end",null,a.current):this._mainEnded=!0},_onEmpty:function(){this._mainEnded&&this._send("end")},_clear:function(){N.prototype._clear.call(this),this._source=null,this._lastCurrent=null}}),J.prototype.flatMap=function(a){return new R(this,a).setName(this,"flatMap")},J.prototype.flatMapLatest=function(a){return new R(this,a,{concurLim:1,drop:"old"}).setName(this,"flatMapLatest")},J.prototype.flatMapFirst=function(a){return new R(this,a,{concurLim:1}).setName(this,"flatMapFirst")},J.prototype.flatMapConcat=function(a){return new R(this,a,{queueLim:-1,concurLim:1}).setName(this,"flatMapConcat")},J.prototype.flatMapWithConcurrencyLimit=function(a,b){var c;return 0===b?c=ab.never():(0>b&&(b=-1),c=new R(this,a,{queueLim:-1,concurLim:b})),c.setName(this,"flatMapWithConcurrencyLimit")},f(S,K,{_name:"sampledBy",_onActivation:function(){var a,b=this._sources.length;for(this._aliveCount=b-this._passiveCount,this._activating=!0,a=0;b>a;a++)this._sources[a].onAny([this._handleAny,this,a]);this._activating=!1,this._emitAfterActivation&&(this._emitAfterActivation=!1,this._emitIfFull(!0)),this._endAfterActivation&&this._send("end",null,!0)},_onDeactivation:function(){var a,b=this._sources.length;for(a=0;b>a;a++)this._sources[a].offAny([this._handleAny,this,a])},_emitIfFull:function(a){if(!u(this._currents,Y)){var b=p(this._currents);this._combinator&&(b=this._combinator.apply(this._currents)),this._send("value",b,a)}},_handleAny:function(a,b){"value"===b.type?(this._currents[a]=b.value,a>=this._passiveCount&&(this._activating?this._emitAfterActivation=!0:this._emitIfFull(b.current))):a>=this._passiveCount&&(this._aliveCount--,0===this._aliveCount&&(this._activating?this._endAfterActivation=!0:this._send("end",null,b.current)))},_clear:function(){K.prototype._clear.call(this),this._sources=null,this._currents=null}}),ab.sampledBy=function(a,b,c){return new S(a,b,c)},J.prototype.sampledBy=function(a,b){return ab.sampledBy([this],[a],b)},ab.combine=function(a,b){var c=new S([],a,b);return c._name="combine",c},J.prototype.combine=function(a,b){return ab.combine([this,a],b)},C("toProperty",{_init:function(a){a.length>0&&this._send("value",a[0])}},{propertyMethod:null,streamMethod:U}),C("changes",{_handleValue:function(a,b){b||this._send("value",a)}},{streamMethod:null,propertyMethod:T}),C("withHandler",{_init:function(a){this._handler=G(a[0],2),this._forcedCurrent=!1;var b=this;this._emitter={emit:function(a){b._send("value",a,b._forcedCurrent)},end:function(){b._send("end",null,b._forcedCurrent)}}},_free:function(){this._handler=null,this._emitter=null},_handleAny:function(a){this._forcedCurrent=a.current,this._handler.invoke(this._emitter,a),this._forcedCurrent=!1}});var db={_init:function(a){this._fn=G(a[0],1)},_free:function(){this._fn=null}};C("map",e({_handleValue:function(a,b){this._send("value",this._fn.invoke(a),b)}},db)),C("filter",e({_handleValue:function(a,b){this._fn.invoke(a)&&this._send("value",a,b)}},db)),C("takeWhile",e({_handleValue:function(a,b){this._fn.invoke(a)?this._send("value",a,b):this._send("end",null,b)}},db)),C("take",{_init:function(a){this._n=a[0],this._n<=0&&this._send("end")},_handleValue:function(a,b){this._n--,this._send("value",a,b),0===this._n&&this._send("end")}}),C("skip",{_init:function(a){this._n=a[0]<0?0:a[0]},_handleValue:function(a,b){0===this._n?this._send("value",a,b):this._n--}}),C("skipDuplicates",{_init:function(a){this._fn=a[0]&&G(a[0],2),this._prev=Y},_free:function(){this._fn=null,this._prev=null},_isEqual:function(a,b){return this._fn?this._fn.invoke(a,b):a===b},_handleValue:function(a,b){this._prev!==Y&&this._isEqual(this._prev,a)||(this._send("value",a,b),this._prev=a)}}),C("skipWhile",{_init:function(a){this._fn=G(a[0],1),this._skip=!0},_free:function(){this._fn=null},_handleValue:function(a,b){return this._skip?void(this._fn.invoke(a)||(this._skip=!1,this._fn=null,this._send("value",a,b))):void this._send("value",a,b)}}),C("diff",{_init:function(a){this._prev=a[0],this._fn=G(a[1],2)},_free:function(){this._prev=null,this._fn=null},_handleValue:function(a,b){this._send("value",this._fn.invoke(this._prev,a),b),this._prev=a}}),C("scan",{_init:function(a){this._send("value",a[0],!0),this._fn=G(a[1],2)},_free:function(){this._fn=null},_handleValue:function(a,b){this._send("value",this._fn.invoke(this._current,a),b)}},{streamMethod:U}),C("reduce",{_init:function(a){this._result=a[0],this._fn=G(a[1],2)},_free:function(){this._fn=null,this._result=null},_handleValue:function(a){this._result=this._fn.invoke(this._result,a)},_handleEnd:function(a,b){this._send("value",this._result,b),this._send("end",null,b)}}),C("debounce",{_init:function(a){this._wait=Math.max(0,a[0]),this._immediate=b(a[1],"immediate",!1),this._lastAttempt=0,this._timeoutId=null,this._laterValue=null,this._endLater=!1;var c=this;this._$later=function(){c._later()}},_free:function(){this._laterValue=null,this._$later=null},_handleValue:function(a,b){b?this._send("value",a,b):(this._lastAttempt=Z(),this._immediate&&!this._timeoutId&&this._send("value",a),this._timeoutId||(this._timeoutId=setTimeout(this._$later,this._wait)),this._immediate||(this._laterValue=a))},_handleEnd:function(a,b){b?this._send("end",null,b):this._timeoutId&&!this._immediate?this._endLater=!0:this._send("end")},_later:function(){var a=Z()-this._lastAttempt;a<this._wait&&a>=0?this._timeoutId=setTimeout(this._$later,this._wait-a):(this._timeoutId=null,this._immediate||(this._send("value",this._laterValue),this._laterValue=null),this._endLater&&this._send("end"))}}),C("throttle",{_init:function(a){this._wait=Math.max(0,a[0]),this._leading=b(a[1],"leading",!0),this._trailing=b(a[1],"trailing",!0),this._trailingValue=null,this._timeoutId=null,this._endLater=!1,this._lastCallTime=0;var c=this;this._$trailingCall=function(){c._trailingCall()}},_free:function(){this._trailingValue=null,this._$trailingCall=null},_handleValue:function(a,b){if(b)this._send("value",a,b);else{var c=Z();0!==this._lastCallTime||this._leading||(this._lastCallTime=c);var d=this._wait-(c-this._lastCallTime);0>=d?(this._cancelTraling(),this._lastCallTime=c,this._send("value",a)):this._trailing&&(this._cancelTraling(),this._trailingValue=a,this._timeoutId=setTimeout(this._$trailingCall,d))}},_handleEnd:function(a,b){b?this._send("end",null,b):this._timeoutId?this._endLater=!0:this._send("end")},_cancelTraling:function(){null!==this._timeoutId&&(clearTimeout(this._timeoutId),this._timeoutId=null)},_trailingCall:function(){this._send("value",this._trailingValue),this._timeoutId=null,this._trailingValue=null,this._lastCallTime=this._leading?Z():0,this._endLater&&this._send("end")}}),C("delay",{_init:function(a){this._wait=Math.max(0,a[0]),this._buff=[];var b=this;this._$shiftBuff=function(){b._send("value",b._buff.shift())}},_free:function(){this._buff=null,this._$shiftBuff=null},_handleValue:function(a,b){b?this._send("value",a,b):(this._buff.push(a),setTimeout(this._$shiftBuff,this._wait))},_handleEnd:function(a,b){if(b)this._send("end",null,b);else{var c=this;setTimeout(function(){c._send("end")},this._wait)}}}),f(V,K,{_name:"fromBinder",_onActivation:function(){var a,b=this,c=!0,d={emit:function(a){b._send("value",a,c)},end:function(){b._send("end",null,c)}};a=this._fn.invoke(d),c=!1,a&&(this._unsubscribe=G(a,0))},_onDeactivation:function(){null!==this._unsubscribe&&(this._unsubscribe.invoke(),this._unsubscribe=null)},_clear:function(){K.prototype._clear.call(this),this._fn=null}}),ab.fromBinder=function(a){return new V(a)},f(W,K,{_name:"emitter",emit:function(a){return this._send("value",a),this},end:function(){return this._send("end"),this}}),ab.emitter=function(){return new W};var eb=new K;eb._send("end"),eb._name="never",ab.never=function(){return eb},f(X,L,{_name:"constant"}),ab.constant=function(a){return new X(a)},J.prototype.setName=function(a,b){return this._name=b?a._name+"."+b:a,this},J.prototype.mapTo=function(a){return this.map(function(){return a}).setName(this,"mapTo")},J.prototype.pluck=function(a){return this.map(function(b){return b[a]}).setName(this,"pluck")},J.prototype.invoke=function(a){var b=v(arguments,1);return this.map(b?function(c){return i(c[a],c,b)}:function(b){return b[a]()}).setName(this,"invoke")},J.prototype.tap=function(a){return a=G(a,1),this.map(function(b){return a.invoke(b),b}).setName(this,"tap")},ab.and=function(a){return ab.combine(a,z).setName("and")},J.prototype.and=function(a){return this.combine(a,z).setName("and")},ab.or=function(a){return ab.combine(a,A).setName("or")},J.prototype.or=function(a){return this.combine(a,A).setName("or")},J.prototype.not=function(){return this.map(function(a){return!a}).setName(this,"not")},J.prototype.awaiting=function(a){return ab.merge([this.mapTo(!0),a.mapTo(!1)]).skipDuplicates().toProperty(!1).setName(this,"awaiting")},J.prototype.filterBy=function(a){return a.sampledBy(this).withHandler(function(a,b){"end"===b.type?a.end():b.value[0]&&a.emit(b.value[1])}).setName(this,"filterBy")},ab.fromCallback=function(a){a=G(a,1);var b=!1;return ab.fromBinder(function(c){b||(a.invoke(function(a){c.emit(a),c.end()}),b=!0)}).setName("fromCallback")},ab.fromEvent=function(a,b,c){c=c&&G(c);var d=a.addEventListener||a.addListener||a.bind,e=a.removeEventListener||a.removeListener||a.unbind;return ab.fromBinder(function(f){var g=c?function(){f.emit(c.applyWithContext(this,arguments))}:f.emit;return d.call(a,b,g),function(){e.call(a,b,g)}}).setName("fromEvent")},"function"==typeof define&&define.amd?(define([],function(){return ab}),a.Kefir=ab):"object"==typeof module&&"object"==typeof exports?(module.exports=ab,ab.Kefir=ab):a.Kefir=ab}(this);
//# sourceMappingURL=kefir.min.js.map
{
"name": "kefir",
"version": "0.2.6",
"version": "0.2.7",
"description": "FRP library for JavaScript inspired by Bacon.js and RxJS with focus on high performance and low memory consumption",

@@ -5,0 +5,0 @@ "main": "dist/kefir.js",

function _AbstractPool(options) {
Stream.call(this);
this._queueLim = get(options, 'queueLim', 0); // -1...∞
this._concurLim = get(options, 'concurLim', -1); // -1, 1...∞
this._drop = get(options, 'drop', 'new'); // old, new
this._queueLim = get(options, 'queueLim', 0);
this._concurLim = get(options, 'concurLim', -1);
this._drop = get(options, 'drop', 'new');
if (this._concurLim === 0) {

@@ -180,7 +180,7 @@ throw new Error('options.concurLim can\'t be 0');

add: function(obs) {
plug: function(obs) {
this._add(obs);
return this;
},
remove: function(obs) {
unplug: function(obs) {
this._remove(obs);

@@ -187,0 +187,0 @@ return this;

@@ -58,4 +58,10 @@ // Kefir.fromBinder(fn)

_name: 'emitter',
emit: function(x) { this._send('value', x) },
end: function() { this._send('end') }
emit: function(x) {
this._send('value', x);
return this;
},
end: function() {
this._send('end');
return this;
}
});

@@ -62,0 +68,0 @@

@@ -128,1 +128,22 @@ // .setName

}
// .fromEvent
Kefir.fromEvent = function(target, eventName, transformer) {
transformer = transformer && Fn(transformer);
var sub = target.addEventListener || target.addListener || target.bind;
var unsub = target.removeEventListener || target.removeListener || target.unbind;
return Kefir.fromBinder(function(emitter) {
var handler = transformer ?
function() {
emitter.emit(transformer.applyWithContext(this, arguments));
} : emitter.emit;
sub.call(target, eventName, handler);
return function() {
unsub.call(target, eventName, handler);
}
}).setName('fromEvent');
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is 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