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

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.4.0 to 0.4.1

.npmignore

13

changelog.md

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

## 0.4.1
- New method `.bufferWhile`
- New method `.bufferBy`
- New method `.bufferWhileBy`
- New method `.withDefault`
- New method `.zip`
## 0.4.0

@@ -6,4 +15,4 @@

- The default `fn` in `obs.sampledBy(other, fn)` changed from `function(a, b) {return [a, b]}` to `function(a, b) {return a}`. The default `fn` for `Kefir.sampledBy` hasn't changed.
- New method `.mapEnd(fn)`
- New method `.skipEnd()`
- New method `.mapEnd`
- New method `.skipEnd`
- The `fn` argument in `.filter`, `.takeWhile`, and `.skipWhile` is now optional

@@ -10,0 +19,0 @@

2

dist/addons/kefir-jquery.js

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

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

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

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

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

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

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

/*! Kefir.js v0.4.0
/*! Kefir.js v0.4.1
* https://github.com/pozadi/kefir

@@ -352,5 +352,2 @@ */

_onActivationHook: function() {},
_onDeactivationHook: function() {},
_handleAny: function(event) {

@@ -364,7 +361,5 @@ switch (event.type) {

_onActivation: function() {
this._onActivationHook();
this._source.onAny(this._$handleAny);
},
_onDeactivation: function() {
this._onDeactivationHook();
this._source.offAny(this._$handleAny);

@@ -415,3 +410,3 @@ }

mixin = extend({
_init: function() {},
_init: function(args) {},
_free: function() {},

@@ -470,3 +465,3 @@

function buildClass(BaseClass) {
function AnonymousObservable(primary, secondary) {
function AnonymousObservable(primary, secondary, args) {
BaseClass.call(this);

@@ -480,3 +475,3 @@ this._primary = primary;

this._$handlePrimaryAny = function(event) { $._handlePrimaryAny(event) }
this._init();
this._init(args);
}

@@ -504,7 +499,7 @@

Stream.prototype[name] = function(secondary) {
return new AnonymousStream(this, secondary);
return new AnonymousStream(this, secondary, rest(arguments, 1, []));
}
Property.prototype[name] = function(secondary) {
return new AnonymousProperty(this, secondary);
return new AnonymousProperty(this, secondary, rest(arguments, 1, []));
}

@@ -550,3 +545,3 @@

fn: fn,
key: _key || NOTHING
key: _key || {}
}]);

@@ -742,3 +737,3 @@ },

}
}, '__logKey__' + name);
}, ['__logKey__', this, name]);
return this;

@@ -749,3 +744,3 @@ }

name = name || this.toString();
this.offAny(null, '__logKey__' + name);
this.offAny(null, ['__logKey__', this, name]);
return this;

@@ -1207,2 +1202,107 @@ }

// .zip()
function Zip(sources, combinator) {
Stream.call(this);
if (sources.length === 0) {
this._send(END);
} else {
this._buffers = map(sources, function(source) {
return isArray(source) ? cloneArray(source) : [];
});
this._sources = map(sources, function(source) {
return isArray(source) ? Kefir.never() : source;
});
this._combinator = combinator ? spread(combinator, this._sources.length) : id;
this._aliveCount = 0;
}
}
function bind_Zip_handleAny($, i) {
return function(event) { $._handleAny(i, event) };
}
inherit(Zip, Stream, {
_name: 'zip',
_onActivation: function() {
var i, length = this._sources.length;
this._drainArrays();
this._aliveCount = length;
for (i = 0; i < length; i++) {
this._sources[i].onAny(bind_Zip_handleAny(this, i), [this, i]);
}
},
_onDeactivation: function() {
for (var i = 0; i < this._sources.length; i++) {
this._sources[i].offAny(null, [this, i]);
}
},
_emit: function(isCurrent) {
var values = new Array(this._buffers.length);
for (var i = 0; i < this._buffers.length; i++) {
values[i] = this._buffers[i].shift();
}
this._send(VALUE, this._combinator(values), isCurrent);
},
_isFull: function() {
for (var i = 0; i < this._buffers.length; i++) {
if (this._buffers[i].length === 0) {
return false;
}
}
return true;
},
_emitIfFull: function(isCurrent) {
if (this._isFull()) {
this._emit(isCurrent);
}
},
_drainArrays: function() {
while (this._isFull()) {
this._emit(true);
}
},
_handleAny: function(i, event) {
if (event.type === VALUE) {
this._buffers[i].push(event.value);
this._emitIfFull(event.current);
} else {
this._aliveCount--;
if (this._aliveCount === 0) {
this._send(END, null, event.current);
}
}
},
_clear: function() {
Stream.prototype._clear.call(this);
this._sources = null;
this._buffers = null;
this._combinator = null;
}
});
Kefir.zip = function(sources, combinator) {
return new Zip(sources, combinator);
}
Observable.prototype.zip = function(other, combinator) {
return new Zip([this, other], combinator);
}
// .sampledBy()

@@ -1317,5 +1417,3 @@

Kefir.combine = function(sources, combinator) {
var result = new SampledBy([], sources, combinator);
result._name = 'combine';
return result;
return new SampledBy([], sources, combinator).setName('combine');
}

@@ -1349,2 +1447,13 @@

// .withDefault()
withOneSource('withDefault', {
_init: function(args) {
this._send(VALUE, args[0], true);
}
}, {propertyMethod: produceProperty, streamMethod: produceProperty});
// .changes()

@@ -1696,11 +1805,11 @@

this._min = args[1] || 0;
this._cache = [];
this._buff = [];
},
_free: function() {
this._cache = null;
this._buff = null;
},
_handleValue: function(x, isCurrent) {
this._cache = slide(this._cache, x, this._max);
if (this._cache.length >= this._min) {
this._send(VALUE, this._cache, isCurrent);
this._buff = slide(this._buff, x, this._max);
if (this._buff.length >= this._min) {
this._send(VALUE, this._buff, isCurrent);
}

@@ -1713,3 +1822,37 @@ }

// .bufferWhile([predicate], [options])
withOneSource('bufferWhile', {
_init: function(args) {
this._fn = args[0] || id;
this._flushOnEnd = get(args[1], 'flushOnEnd', true);
this._buff = [];
},
_free: function() {
this._buff = null;
},
_flush: function(isCurrent) {
if (this._buff !== null && this._buff.length !== 0) {
this._send(VALUE, this._buff, isCurrent);
this._buff = [];
}
},
_handleValue: function(x, isCurrent) {
this._buff.push(x);
if (!this._fn(x)) {
this._flush(isCurrent);
}
},
_handleEnd: function(x, isCurrent) {
if (this._flushOnEnd) {
this._flush(isCurrent);
}
this._send(END, null, isCurrent);
}
});
// .debounce(wait, {immediate})

@@ -1948,2 +2091,3 @@

Kefir.Emitter = Emitter;

@@ -1955,2 +2099,3 @@

// Kefir.never()

@@ -2153,2 +2298,76 @@

var withTwoSourcesAndBufferMixin = {
_init: function(args) {
this._buff = [];
this._flushOnEnd = get(args[0], 'flushOnEnd', true);
},
_free: function() {
this._buff = null;
},
_flush: function(isCurrent) {
if (this._buff !== null && this._buff.length !== 0) {
this._send(VALUE, this._buff, isCurrent);
this._buff = [];
}
},
_handlePrimaryEnd: function(__, isCurrent) {
if (this._flushOnEnd) {
this._flush(isCurrent);
}
this._send(END, null, isCurrent);
}
};
withTwoSources('bufferBy', extend({
_onActivation: function() {
this._primary.onAny(this._$handlePrimaryAny);
if (this._alive && this._secondary !== null) {
this._secondary.onAny(this._$handleSecondaryAny);
}
},
_handlePrimaryValue: function(x, isCurrent) {
this._buff.push(x);
},
_handleSecondaryValue: function(x, isCurrent) {
this._flush(isCurrent);
},
_handleSecondaryEnd: function(x, isCurrent) {
if (!this._flushOnEnd) {
this._send(END, null, isCurrent);
}
}
}, withTwoSourcesAndBufferMixin));
withTwoSources('bufferWhileBy', extend({
_handlePrimaryValue: function(x, isCurrent) {
this._buff.push(x);
if (this._lastSecondary !== NOTHING && !this._lastSecondary) {
this._flush(isCurrent);
}
},
_handleSecondaryEnd: function(x, isCurrent) {
if (!this._flushOnEnd && (this._lastSecondary === NOTHING || this._lastSecondary)) {
this._send(END, null, isCurrent);
}
}
}, withTwoSourcesAndBufferMixin));
withTwoSources('filterBy', {

@@ -2155,0 +2374,0 @@

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

/*! Kefir.js v0.4.0
/*! Kefir.js v0.4.1
* https://github.com/pozadi/kefir
*/
!function(a){"use strict";function b(){for(var a=0;a<arguments.length;a++)if(!arguments[a])return arguments[a];return arguments[a-1]}function c(){for(var a=0;a<arguments.length;a++)if(arguments[a])return arguments[a];return arguments[a-1]}function d(a){return!a}function e(a,b){var c,d,e,f;if(0===a.length)return b;if(0===b.length)return a;for(f=0,c=new Array(a.length+b.length),d=a.length,e=0;d>e;e++,f++)c[f]=a[e];for(d=b.length,e=0;d>e;e++,f++)c[f]=b[e];return c}function f(a,b){var c,d=a.length;for(c=0;d>c;c++)if(a[c]===b)return c;return-1}function g(a,b){var c,d=a.length;for(c=0;d>c;c++)if(b(a[c]))return c;return-1}function h(a){var b,c=a.length,d=new Array(c);for(b=0;c>b;b++)d[b]=a[b];return d}function i(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 j(a,b){return i(a,g(a,b))}function k(a,b){var c,d=a.length;for(c=0;d>c;c++)b(a[c])}function l(a,b){var c,d=a.length;for(c=0;d>c;c++)a[c]=b}function m(a,b){return-1!==f(a,b)}function n(a,b,c){return a.length>b?Array.prototype.slice.call(a,b):c}function o(a,b,c){var d,e=Math.min(c,a.length+1),f=a.length-e+1,g=new Array(e);for(d=f;e>d;d++)g[d-f]=a[d];return g[e-1]=b,g}function p(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 q(a,b){switch(b){case 0:return function(){return a()};case 1:return function(b){return a(b[0])};case 2:return function(b){return a(b[0],b[1])};case 3:return function(b){return a(b[0],b[1],b[2])};case 4:return function(b){return a(b[0],b[1],b[2],b[3])};default:return function(b){return a.apply(null,b)}}}function r(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 s(a,b,c){return a&&b in a?a[b]:c}function t(a,b){return Object.prototype.hasOwnProperty.call(a,b)}function u(a){var b=function(){};return b.prototype=a,new b}function v(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 w(a,b){var c,d=arguments.length;for(a.prototype=u(b.prototype),a.prototype.constructor=a,c=2;d>c;c++)v(a.prototype,arguments[c]);return a}function x(a){return a}function y(a,b){return a===b}function z(a,b){return[a,b]}function A(a){return"function"==typeof a}function B(a,b){function c(a,b){H.call(this),this._wait=a,this._intervalId=null;var c=this;this._$onTick=function(){c._onTick()},this._init(b)}w(c,H,{_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(){H.prototype._clear.call(this),this._$onTick=null,this._free()}},b),X[a]=function(a){return new c(a,n(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);var e=this;this._$handleAny=function(a){e._handleAny(a)}}return w(d,c,{_clear:function(){c.prototype._clear.call(this),this._source=null,this._$handleAny=null,this._free()}},b),d}c=v({streamMethod:function(a){return function(){return new a(this,arguments)}},propertyMethod:function(a,b){return function(){return new b(this,arguments)}}},c||{}),b=v({_init:function(){},_free:function(){},_handleValue:function(a,b){this._send($,a,b)},_handleEnd:function(a,b){this._send(Z,null,b)},_onActivationHook:function(){},_onDeactivationHook:function(){},_handleAny:function(a){switch(a.type){case $:this._handleValue(a.value,a.current);break;case Z:this._handleEnd(a.value,a.current)}},_onActivation:function(){this._onActivationHook(),this._source.onAny(this._$handleAny)},_onDeactivation:function(){this._onDeactivationHook(),this._source.offAny(this._$handleAny)}},b||{});var e=d(H),f=d(I);c.streamMethod&&(H.prototype[a]=c.streamMethod(e,f)),c.propertyMethod&&(I.prototype[a]=c.propertyMethod(e,f))}function D(a,b){function c(c){function d(b,d){c.call(this),this._primary=b,this._secondary=d,this._name=b._name+"."+a,this._lastSecondary=Y;var e=this;this._$handleSecondaryAny=function(a){e._handleSecondaryAny(a)},this._$handlePrimaryAny=function(a){e._handlePrimaryAny(a)},this._init()}return w(d,c,{_clear:function(){c.prototype._clear.call(this),this._primary=null,this._secondary=null,this._lastSecondary=null,this._$handleSecondaryAny=null,this._$handlePrimaryAny=null,this._free()}},b),d}b=v({_init:function(){},_free:function(){},_handlePrimaryValue:function(a,b){this._send($,a,b)},_handlePrimaryEnd:function(a,b){this._send(Z,null,b)},_handleSecondaryValue:function(a){this._lastSecondary=a},_handleSecondaryEnd:function(){},_handlePrimaryAny:function(a){switch(a.type){case $:this._handlePrimaryValue(a.value,a.current);break;case Z:this._handlePrimaryEnd(a.value,a.current)}},_handleSecondaryAny:function(a){switch(a.type){case $:this._handleSecondaryValue(a.value,a.current);break;case Z:this._handleSecondaryEnd(a.value,a.current),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._alive&&this._primary.onAny(this._$handlePrimaryAny)},_onDeactivation:function(){null!==this._secondary&&this._secondary.offAny(this._$handleSecondaryAny),this._primary.offAny(this._$handlePrimaryAny)}},b||{});var d=c(H),e=c(I);H.prototype[a]=function(a){return new d(this,a)},I.prototype[a]=function(a){return new e(this,a)}}function E(){this._items=[]}function F(a,b,c){return{type:a,value:b,current:!!c}}function G(){this._subscribers=new E,this._active=!1,this._alive=!0}function H(){G.call(this)}function I(){G.call(this),this._current=Y}function J(a){if(H.call(this),this._queueLim=s(a,"queueLim",0),this._concurLim=s(a,"concurLim",-1),this._drop=s(a,"drop","new"),0===this._concurLim)throw new Error("options.concurLim can't be 0");var b=this;this._$handleSubAny=function(a){b._handleSubAny(a)},this._queue=[],this._curSources=[],this._activating=!1}function K(a){J.call(this),0===a.length?this._send(Z):this._addAll(a),this._initialised=!0}function L(a){J.call(this,{concurLim:1,queueLim:-1}),0===a.length?this._send(Z):this._addAll(a),this._initialised=!0}function M(){J.call(this)}function N(){J.call(this)}function O(a,b,c){J.call(this,c),this._source=a,this._fn=b||x,this._mainEnded=!1,this._lastCurrent=null;var d=this;this._$handleMainSource=function(a){d._handleMainSource(a)}}function P(a,b,c){H.call(this),0===b.length?this._send(Z):(this._passiveCount=a.length,this._sources=e(a,b),this._combinator=c?q(c,this._sources.length):x,this._aliveCount=0,this._currents=new Array(this._sources.length),l(this._currents,Y),this._activating=!1,this._emitAfterActivation=!1,this._endAfterActivation=!1)}function Q(a,b){return function(c){a._handleAny(b,c)}}function R(a){return function(){return new a(this,arguments)}}function S(a,b){return function(){return new b(this,arguments)}}function T(a){return{step:function(b,c){return a._send($,c,a._forcedCurrent),null},result:function(){return a._send(Z,null,a._forcedCurrent),null}}}function U(a){H.call(this),this._fn=a,this._unsubscribe=null}function V(){H.call(this)}function W(a){I.call(this),this._send($,a),this._send(Z)}var X={},Y=["<nothing>"],Z="end",$="value",_="any",ab=Date.now?function(){return Date.now()}:function(){return(new Date).getTime()},bb=(Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},function(a){return"[object Arguments]"===Object.prototype.toString.call(a)});bb(arguments)||(bb=function(a){return!(!a||!t(a,"callee"))}),v(E,{callOne:function(a,b){a.type===_?a.fn(b):a.type===b.type&&(a.type===$?a.fn(b.value):a.fn())},callOnce:function(a,b,c){a===_?b(c):a===c.type&&(a===$?b(c.value):b())}}),v(E.prototype,{add:function(a,b,c){this._items=e(this._items,[{type:a,fn:b,key:c||Y}])},remove:function(a,b,c){this._items=j(this._items,function(d){return d.type===a&&(d.fn===b||p(d.key,c))})},callAll:function(a){for(var b=this._items,c=0;c<b.length;c++)E.callOne(b[c],a)},isEmpty:function(){return 0===this._items.length}});var cb=F(Z,void 0,!0);X.Observable=G,v(G.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(F(a,b,c)),a===Z&&this._clear())},on:function(a,b,c){return this._alive?(this._subscribers.add(a,b,c),this._setActive(!0)):E.callOnce(a,b,cb),this},off:function(a,b,c){return this._alive&&(this._subscribers.remove(a,b,c),this._subscribers.isEmpty()&&this._setActive(!1)),this},onValue:function(a,b){return this.on($,a,b)},onEnd:function(a,b){return this.on(Z,a,b)},onAny:function(a,b){return this.on(_,a,b)},offValue:function(a,b){return this.off($,a,b)},offEnd:function(a,b){return this.off(Z,a,b)},offAny:function(a,b){return this.off(_,a,b)}}),G.prototype.toString=function(){return"["+this._name+"]"},X.Stream=H,w(H,G,{_name:"stream"}),X.Property=I,w(I,G,{_name:"property",_send:function(a,b,c){this._alive&&(c||this._subscribers.callAll(F(a,b)),a===$&&(this._current=b),a===Z&&this._clear())},on:function(a,b,c){return this._alive&&(this._subscribers.add(a,b,c),this._setActive(!0)),this._current!==Y&&E.callOnce(a,b,F($,this._current,!0)),this._alive||E.callOnce(a,b,cb),this}}),G.prototype.log=function(a){return a=a||this.toString(),this.onAny(function(b){var c="<"+b.type+(b.current?":current":"")+">";b.type===$?console.log(a,c,b.value):console.log(a,c)},"__logKey__"+a),this},G.prototype.offLog=function(a){return a=a||this.toString(),this.offAny(null,"__logKey__"+a),this},B("withInterval",{_init:function(a){this._fn=a[0];var b=this;this._emitter={emit:function(a){b._send($,a)},end:function(){b._send(Z)}}},_free:function(){this._fn=null,this._emitter=null},_onTick:function(){this._fn(this._emitter)}}),B("fromPoll",{_init:function(a){this._fn=a[0]},_free:function(){this._fn=null},_onTick:function(){this._send($,this._fn())}}),B("interval",{_init:function(a){this._x=a[0]},_free:function(){this._x=null},_onTick:function(){this._send($,this._x)}}),B("sequentially",{_init:function(a){this._xs=h(a[0]),0===this._xs.length&&this._send(Z)},_free:function(){this._xs=null},_onTick:function(){switch(this._xs.length){case 1:this._send($,this._xs[0]),this._send(Z);break;default:this._send($,this._xs.shift())}}}),B("repeatedly",{_init:function(a){this._xs=h(a[0]),this._i=-1},_onTick:function(){this._xs.length>0&&(this._i=(this._i+1)%this._xs.length,this._send($,this._xs[this._i]))}}),B("later",{_init:function(a){this._x=a[0]},_free:function(){this._x=null},_onTick:function(){this._send($,this._x),this._send(Z)}}),w(J,H,{_name:"abstractPool",_add:function(a,b){b=b||x,-1===this._concurLim||this._curSources.length<this._concurLim?this._addToCur(b(a)):-1===this._queueLim||this._queue.length<this._queueLim?this._addToQueue(b(a)):"old"===this._drop&&(this._removeOldest(),this._add(b(a)))},_addAll:function(a){var b=this;k(a,function(a){b._add(a)})},_remove:function(a){-1===this._removeCur(a)&&this._removeQueue(a)},_addToQueue:function(a){this._queue=e(this._queue,[a])},_addToCur:function(a){this._curSources=e(this._curSources,[a]),this._active&&this._sub(a)},_sub:function(a){var b=this;a.onAny(this._$handleSubAny),a.onEnd(function(){b._removeCur(a)},[this,a])},_unsub:function(a){a.offAny(this._$handleSubAny),a.offEnd(null,[this,a])},_handleSubAny:function(a){a.type===$&&this._send($,a.value,a.current&&this._activating)},_removeQueue:function(a){var b=f(this._queue,a);return this._queue=i(this._queue,b),b},_removeCur:function(a){this._active&&this._unsub(a);var b=f(this._curSources,a);return this._curSources=i(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=h(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(){H.prototype._clear.call(this),this._queue=null,this._curSources=null,this._$handleSubAny=null}});var db={_onEmpty:function(){this._initialised&&this._send(Z,null,this._activating)}};w(K,J,v({_name:"merge"},db)),X.merge=function(a){return new K(a)},G.prototype.merge=function(a){return X.merge([this,a])},w(L,J,v({_name:"concat"},db)),X.concat=function(a){return new L(a)},G.prototype.concat=function(a){return X.concat([this,a])},w(M,J,{_name:"pool",plug:function(a){return this._add(a),this},unplug:function(a){return this._remove(a),this}}),X.pool=function(){return new M},w(N,J,{_name:"bus",plug:function(a){return this._add(a),this},unplug:function(a){return this._remove(a),this},emit:function(a){return this._send($,a),this},end:function(){return this._send(Z),this}}),X.bus=function(){return new N},w(O,J,{_onActivation:function(){J.prototype._onActivation.call(this),this._activating=!0,this._source.onAny(this._$handleMainSource),this._activating=!1},_onDeactivation:function(){J.prototype._onDeactivation.call(this),this._source.offAny(this._$handleMainSource)},_handleMainSource:function(a){a.type===$?(a.current&&this._lastCurrent===a.value||this._add(a.value,this._fn),this._lastCurrent=a.value):this._isEmpty()?this._send(Z,null,a.current):this._mainEnded=!0},_onEmpty:function(){this._mainEnded&&this._send(Z)},_clear:function(){J.prototype._clear.call(this),this._source=null,this._lastCurrent=null,this._$handleMainSource=null}}),G.prototype.flatMap=function(a){return new O(this,a).setName(this,"flatMap")},G.prototype.flatMapLatest=function(a){return new O(this,a,{concurLim:1,drop:"old"}).setName(this,"flatMapLatest")},G.prototype.flatMapFirst=function(a){return new O(this,a,{concurLim:1}).setName(this,"flatMapFirst")},G.prototype.flatMapConcat=function(a){return new O(this,a,{queueLim:-1,concurLim:1}).setName(this,"flatMapConcat")},G.prototype.flatMapConcurLimit=function(a,b){var c;return 0===b?c=X.never():(0>b&&(b=-1),c=new O(this,a,{queueLim:-1,concurLim:b})),c.setName(this,"flatMapConcurLimit")},w(P,H,{_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(Q(this,a),[this,a]);this._activating=!1,this._emitAfterActivation&&(this._emitAfterActivation=!1,this._emitIfFull(!0)),this._endAfterActivation&&this._send(Z,null,!0)},_onDeactivation:function(){var a,b=this._sources.length;for(a=0;b>a;a++)this._sources[a].offAny(null,[this,a])},_emitIfFull:function(a){if(!m(this._currents,Y)){var b=h(this._currents);b=this._combinator(b),this._send($,b,a)}},_handleAny:function(a,b){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(Z,null,b.current)))},_clear:function(){H.prototype._clear.call(this),this._sources=null,this._currents=null,this._combinator=null}}),X.sampledBy=function(a,b,c){return new P(a,b,c)},G.prototype.sampledBy=function(a,b){return X.sampledBy([this],[a],b||x)},X.combine=function(a,b){var c=new P([],a,b);return c._name="combine",c},G.prototype.combine=function(a,b){return X.combine([this,a],b)},C("toProperty",{_init:function(a){a.length>0&&this._send($,a[0])}},{propertyMethod:null,streamMethod:S}),C("changes",{_handleValue:function(a,b){b||this._send($,a)}},{streamMethod:null,propertyMethod:R}),C("withHandler",{_init:function(a){this._handler=a[0],this._forcedCurrent=!1;var b=this;this._emitter={emit:function(a){b._send($,a,b._forcedCurrent)},end:function(){b._send(Z,null,b._forcedCurrent)}}},_free:function(){this._handler=null,this._emitter=null},_handleAny:function(a){this._forcedCurrent=a.current,this._handler(this._emitter,a),this._forcedCurrent=!1}}),C("flatten",{_init:function(a){this._fn=a[0]?a[0]:x},_free:function(){this._fn=null},_handleValue:function(a,b){for(var c=this._fn(a),d=0;d<c.length;d++)this._send($,c[d],b)}}),C("transduce",{_init:function(a){this._xform=a[0](T(this))},_free:function(){this._xform=null},_handleValue:function(a,b){this._forcedCurrent=b,null!==this._xform.step(null,a)&&this._xform.result(null),this._forcedCurrent=!1},_handleEnd:function(a,b){this._forcedCurrent=b,this._xform.result(null),this._forcedCurrent=!1}});var eb={_init:function(a){this._fn=a[0]||x},_free:function(){this._fn=null}};C("map",v({_handleValue:function(a,b){this._send($,this._fn(a),b)}},eb)),C("filter",v({_handleValue:function(a,b){this._fn(a)&&this._send($,a,b)}},eb)),C("takeWhile",v({_handleValue:function(a,b){this._fn(a)?this._send($,a,b):this._send(Z,null,b)}},eb)),C("take",{_init:function(a){this._n=a[0],this._n<=0&&this._send(Z)},_handleValue:function(a,b){this._n--,this._send($,a,b),0===this._n&&this._send(Z,null,b)}}),C("skip",{_init:function(a){this._n=Math.max(0,a[0])},_handleValue:function(a,b){0===this._n?this._send($,a,b):this._n--}}),C("skipDuplicates",{_init:function(a){this._fn=a[0]||y,this._prev=Y},_free:function(){this._fn=null,this._prev=null},_handleValue:function(a,b){this._prev!==Y&&this._fn(this._prev,a)||(this._send($,a,b),this._prev=a)}}),C("skipWhile",{_init:function(a){this._fn=a[0]||x,this._skip=!0},_free:function(){this._fn=null},_handleValue:function(a,b){return this._skip?void(this._fn(a)||(this._skip=!1,this._fn=null,this._send($,a,b))):void this._send($,a,b)}}),C("diff",{_init:function(a){this._fn=a[0]||z,this._prev=a.length>1?a[1]:Y},_free:function(){this._prev=null,this._fn=null},_handleValue:function(a,b){this._prev!==Y&&this._send($,this._fn(this._prev,a),b),this._prev=a}}),C("scan",{_init:function(a){this._fn=a[0],a.length>1&&this._send($,a[1],!0)},_free:function(){this._fn=null},_handleValue:function(a,b){this._current!==Y&&(a=this._fn(this._current,a)),this._send($,a,b)}},{streamMethod:S}),C("reduce",{_init:function(a){this._fn=a[0],this._result=a.length>1?a[1]:Y},_free:function(){this._fn=null,this._result=null},_handleValue:function(a){this._result=this._result===Y?a:this._fn(this._result,a)},_handleEnd:function(a,b){this._result!==Y&&this._send($,this._result,b),this._send(Z,null,b)}}),C("mapEnd",{_init:function(a){this._fn=a[0]},_free:function(){this._fn=null},_handleEnd:function(a,b){this._send($,this._fn(),b),this._send(Z,null,b)}}),C("skipEnd",{_handleEnd:function(){}}),C("slidingWindow",{_init:function(a){this._max=a[0],this._min=a[1]||0,this._cache=[]},_free:function(){this._cache=null},_handleValue:function(a,b){this._cache=o(this._cache,a,this._max),this._cache.length>=this._min&&this._send($,this._cache,b)}}),C("debounce",{_init:function(a){this._wait=Math.max(0,a[0]),this._immediate=s(a[1],"immediate",!1),this._lastAttempt=0,this._timeoutId=null,this._laterValue=null,this._endLater=!1;var b=this;this._$later=function(){b._later()}},_free:function(){this._laterValue=null,this._$later=null},_handleValue:function(a,b){b?this._send($,a,b):(this._lastAttempt=ab(),this._immediate&&!this._timeoutId&&this._send($,a),this._timeoutId||(this._timeoutId=setTimeout(this._$later,this._wait)),this._immediate||(this._laterValue=a))},_handleEnd:function(a,b){b?this._send(Z,null,b):this._timeoutId&&!this._immediate?this._endLater=!0:this._send(Z)},_later:function(){var a=ab()-this._lastAttempt;a<this._wait&&a>=0?this._timeoutId=setTimeout(this._$later,this._wait-a):(this._timeoutId=null,this._immediate||(this._send($,this._laterValue),this._laterValue=null),this._endLater&&this._send(Z))}}),C("throttle",{_init:function(a){this._wait=Math.max(0,a[0]),this._leading=s(a[1],"leading",!0),this._trailing=s(a[1],"trailing",!0),this._trailingValue=null,this._timeoutId=null,this._endLater=!1,this._lastCallTime=0;var b=this;this._$trailingCall=function(){b._trailingCall()}},_free:function(){this._trailingValue=null,this._$trailingCall=null},_handleValue:function(a,b){if(b)this._send($,a,b);else{var c=ab();0!==this._lastCallTime||this._leading||(this._lastCallTime=c);var d=this._wait-(c-this._lastCallTime);0>=d?(this._cancelTraling(),this._lastCallTime=c,this._send($,a)):this._trailing&&(this._cancelTraling(),this._trailingValue=a,this._timeoutId=setTimeout(this._$trailingCall,d))}},_handleEnd:function(a,b){b?this._send(Z,null,b):this._timeoutId?this._endLater=!0:this._send(Z)},_cancelTraling:function(){null!==this._timeoutId&&(clearTimeout(this._timeoutId),this._timeoutId=null)},_trailingCall:function(){this._send($,this._trailingValue),this._timeoutId=null,this._trailingValue=null,this._lastCallTime=this._leading?ab():0,this._endLater&&this._send(Z)}}),C("delay",{_init:function(a){this._wait=Math.max(0,a[0]),this._buff=[];var b=this;this._$shiftBuff=function(){b._send($,b._buff.shift())}},_free:function(){this._buff=null,this._$shiftBuff=null},_handleValue:function(a,b){b?this._send($,a,b):(this._buff.push(a),setTimeout(this._$shiftBuff,this._wait))},_handleEnd:function(a,b){if(b)this._send(Z,null,b);else{var c=this;setTimeout(function(){c._send(Z)},this._wait)}}}),w(U,H,{_name:"fromBinder",_onActivation:function(){var a=this,b=!0,c={emit:function(c){a._send($,c,b)},end:function(){a._send(Z,null,b)}};this._unsubscribe=this._fn(c)||null,b=!1},_onDeactivation:function(){null!==this._unsubscribe&&(this._unsubscribe(),this._unsubscribe=null)},_clear:function(){H.prototype._clear.call(this),this._fn=null}}),X.fromBinder=function(a){return new U(a)},w(V,H,{_name:"emitter",emit:function(a){return this._send($,a),this},end:function(){return this._send(Z),this}}),X.emitter=function(){return new V};var fb=new H;fb._send(Z),fb._name="never",X.never=function(){return fb},w(W,I,{_name:"constant"}),X.constant=function(a){return new W(a)},G.prototype.setName=function(a,b){return this._name=b?a._name+"."+b:a,this},G.prototype.mapTo=function(a){return this.map(function(){return a}).setName(this,"mapTo")},G.prototype.pluck=function(a){return this.map(function(b){return b[a]}).setName(this,"pluck")},G.prototype.invoke=function(a){var b=n(arguments,1);return this.map(b?function(c){return r(c[a],c,b)}:function(b){return b[a]()}).setName(this,"invoke")},G.prototype.timestamp=function(){return this.map(function(a){return{value:a,time:ab()}}).setName(this,"timestamp")},G.prototype.tap=function(a){return this.map(function(b){return a(b),b}).setName(this,"tap")},X.and=function(a){return X.combine(a,b).setName("and")},G.prototype.and=function(a){return this.combine(a,b).setName("and")},X.or=function(a){return X.combine(a,c).setName("or")},G.prototype.or=function(a){return this.combine(a,c).setName("or")},G.prototype.not=function(){return this.map(d).setName(this,"not")},G.prototype.awaiting=function(a){return X.merge([this.mapTo(!0),a.mapTo(!1)]).skipDuplicates().toProperty(!1).setName(this,"awaiting")},X.fromCallback=function(a){var b=!1;return X.fromBinder(function(c){b||(a(function(a){c.emit(a),c.end()}),b=!0)}).setName("fromCallback")},X._fromEvent=function(a,b,c){return X.fromBinder(function(d){var e=c?function(){d.emit(r(c,this,arguments))}:d.emit;return a(e),function(){b(e)}})};var gb=[["addEventListener","removeEventListener"],["addListener","removeListener"],["on","off"]];X.fromEvent=function(a,b,c){for(var d,e,f,g=0;g<gb.length;g++)if(d=gb[g],A(a[d[0]])&&A(a[d[1]])){e=d[0],f=d[1];break}if(void 0===e)throw new Error("target don't support any of addEventListener/removeEventListener, addListener/removeListener, on/off method pair");return X._fromEvent(function(c){a[e](b,c)},function(c){a[f](b,c)},c).setName("fromEvent")},D("filterBy",{_handlePrimaryValue:function(a,b){this._lastSecondary!==Y&&this._lastSecondary&&this._send($,a,b)},_handleSecondaryEnd:function(a,b){this._lastSecondary!==Y&&this._lastSecondary||this._send(Z,null,b)}}),D("skipUntilBy",{_handlePrimaryValue:function(a,b){this._lastSecondary!==Y&&this._send($,a,b)},_handleSecondaryValue:function(a){this._lastSecondary=a,this._removeSecondary()},_handleSecondaryEnd:function(a,b){this._lastSecondary===Y&&this._send(Z,null,b)}}),D("takeUntilBy",{_handleSecondaryValue:function(a,b){this._send(Z,null,b)}}),D("takeWhileBy",{_handlePrimaryValue:function(a,b){this._lastSecondary!==Y&&this._send($,a,b)},_handleSecondaryValue:function(a,b){this._lastSecondary=a,this._lastSecondary||this._send(Z,null,b)},_handleSecondaryEnd:function(a,b){this._lastSecondary===Y&&this._send(Z,null,b)}}),D("skipWhileBy",{_handlePrimaryValue:function(a,b){this._lastSecondary===Y||this._lastSecondary||this._send($,a,b)},_handleSecondaryValue:function(a){this._lastSecondary=a,this._lastSecondary||this._removeSecondary()},_handleSecondaryEnd:function(a,b){(this._lastSecondary===Y||this._lastSecondary)&&this._send(Z,null,b)}}),"function"==typeof define&&define.amd?(define([],function(){return X}),a.Kefir=X):"object"==typeof module&&"object"==typeof exports?(module.exports=X,X.Kefir=X):a.Kefir=X}(this);
!function(a){"use strict";function b(){for(var a=0;a<arguments.length;a++)if(!arguments[a])return arguments[a];return arguments[a-1]}function c(){for(var a=0;a<arguments.length;a++)if(arguments[a])return arguments[a];return arguments[a-1]}function d(a){return!a}function e(a,b){var c,d,e,f;if(0===a.length)return b;if(0===b.length)return a;for(f=0,c=new Array(a.length+b.length),d=a.length,e=0;d>e;e++,f++)c[f]=a[e];for(d=b.length,e=0;d>e;e++,f++)c[f]=b[e];return c}function f(a,b){var c,d=a.length;for(c=0;d>c;c++)if(a[c]===b)return c;return-1}function g(a,b){var c,d=a.length;for(c=0;d>c;c++)if(b(a[c]))return c;return-1}function h(a){var b,c=a.length,d=new Array(c);for(b=0;c>b;b++)d[b]=a[b];return d}function i(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 j(a,b){return i(a,g(a,b))}function k(a,b){var c,d=a.length,e=new Array(d);for(c=0;d>c;c++)e[c]=b(a[c]);return e}function l(a,b){var c,d=a.length;for(c=0;d>c;c++)b(a[c])}function m(a,b){var c,d=a.length;for(c=0;d>c;c++)a[c]=b}function n(a,b){return-1!==f(a,b)}function o(a,b,c){return a.length>b?Array.prototype.slice.call(a,b):c}function p(a,b,c){var d,e=Math.min(c,a.length+1),f=a.length-e+1,g=new Array(e);for(d=f;e>d;d++)g[d-f]=a[d];return g[e-1]=b,g}function q(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 r(a,b){switch(b){case 0:return function(){return a()};case 1:return function(b){return a(b[0])};case 2:return function(b){return a(b[0],b[1])};case 3:return function(b){return a(b[0],b[1],b[2])};case 4:return function(b){return a(b[0],b[1],b[2],b[3])};default:return function(b){return a.apply(null,b)}}}function s(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 t(a,b,c){return a&&b in a?a[b]:c}function u(a,b){return Object.prototype.hasOwnProperty.call(a,b)}function v(a){var b=function(){};return b.prototype=a,new b}function w(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 x(a,b){var c,d=arguments.length;for(a.prototype=v(b.prototype),a.prototype.constructor=a,c=2;d>c;c++)w(a.prototype,arguments[c]);return a}function y(a){return a}function z(a,b){return a===b}function A(a,b){return[a,b]}function B(a){return"function"==typeof a}function C(a,b){function c(a,b){I.call(this),this._wait=a,this._intervalId=null;var c=this;this._$onTick=function(){c._onTick()},this._init(b)}x(c,I,{_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(){I.prototype._clear.call(this),this._$onTick=null,this._free()}},b),$[a]=function(a){return new c(a,o(arguments,1,[]))}}function D(a,b,c){function d(c){function d(b,d){c.call(this),this._source=b,this._name=b._name+"."+a,this._init(d);var e=this;this._$handleAny=function(a){e._handleAny(a)}}return x(d,c,{_clear:function(){c.prototype._clear.call(this),this._source=null,this._$handleAny=null,this._free()}},b),d}c=w({streamMethod:function(a){return function(){return new a(this,arguments)}},propertyMethod:function(a,b){return function(){return new b(this,arguments)}}},c||{}),b=w({_init:function(){},_free:function(){},_handleValue:function(a,b){this._send(bb,a,b)},_handleEnd:function(a,b){this._send(ab,null,b)},_handleAny:function(a){switch(a.type){case bb:this._handleValue(a.value,a.current);break;case ab:this._handleEnd(a.value,a.current)}},_onActivation:function(){this._source.onAny(this._$handleAny)},_onDeactivation:function(){this._source.offAny(this._$handleAny)}},b||{});var e=d(I),f=d(J);c.streamMethod&&(I.prototype[a]=c.streamMethod(e,f)),c.propertyMethod&&(J.prototype[a]=c.propertyMethod(e,f))}function E(a,b){function c(c){function d(b,d,e){c.call(this),this._primary=b,this._secondary=d,this._name=b._name+"."+a,this._lastSecondary=_;var f=this;this._$handleSecondaryAny=function(a){f._handleSecondaryAny(a)},this._$handlePrimaryAny=function(a){f._handlePrimaryAny(a)},this._init(e)}return x(d,c,{_clear:function(){c.prototype._clear.call(this),this._primary=null,this._secondary=null,this._lastSecondary=null,this._$handleSecondaryAny=null,this._$handlePrimaryAny=null,this._free()}},b),d}b=w({_init:function(){},_free:function(){},_handlePrimaryValue:function(a,b){this._send(bb,a,b)},_handlePrimaryEnd:function(a,b){this._send(ab,null,b)},_handleSecondaryValue:function(a){this._lastSecondary=a},_handleSecondaryEnd:function(){},_handlePrimaryAny:function(a){switch(a.type){case bb:this._handlePrimaryValue(a.value,a.current);break;case ab:this._handlePrimaryEnd(a.value,a.current)}},_handleSecondaryAny:function(a){switch(a.type){case bb:this._handleSecondaryValue(a.value,a.current);break;case ab:this._handleSecondaryEnd(a.value,a.current),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._alive&&this._primary.onAny(this._$handlePrimaryAny)},_onDeactivation:function(){null!==this._secondary&&this._secondary.offAny(this._$handleSecondaryAny),this._primary.offAny(this._$handlePrimaryAny)}},b||{});var d=c(I),e=c(J);I.prototype[a]=function(a){return new d(this,a,o(arguments,1,[]))},J.prototype[a]=function(a){return new e(this,a,o(arguments,1,[]))}}function F(){this._items=[]}function G(a,b,c){return{type:a,value:b,current:!!c}}function H(){this._subscribers=new F,this._active=!1,this._alive=!0}function I(){H.call(this)}function J(){H.call(this),this._current=_}function K(a){if(I.call(this),this._queueLim=t(a,"queueLim",0),this._concurLim=t(a,"concurLim",-1),this._drop=t(a,"drop","new"),0===this._concurLim)throw new Error("options.concurLim can't be 0");var b=this;this._$handleSubAny=function(a){b._handleSubAny(a)},this._queue=[],this._curSources=[],this._activating=!1}function L(a){K.call(this),0===a.length?this._send(ab):this._addAll(a),this._initialised=!0}function M(a){K.call(this,{concurLim:1,queueLim:-1}),0===a.length?this._send(ab):this._addAll(a),this._initialised=!0}function N(){K.call(this)}function O(){K.call(this)}function P(a,b,c){K.call(this,c),this._source=a,this._fn=b||y,this._mainEnded=!1,this._lastCurrent=null;var d=this;this._$handleMainSource=function(a){d._handleMainSource(a)}}function Q(a,b){I.call(this),0===a.length?this._send(ab):(this._buffers=k(a,function(a){return eb(a)?h(a):[]}),this._sources=k(a,function(a){return eb(a)?$.never():a}),this._combinator=b?r(b,this._sources.length):y,this._aliveCount=0)}function R(a,b){return function(c){a._handleAny(b,c)}}function S(a,b,c){I.call(this),0===b.length?this._send(ab):(this._passiveCount=a.length,this._sources=e(a,b),this._combinator=c?r(c,this._sources.length):y,this._aliveCount=0,this._currents=new Array(this._sources.length),m(this._currents,_),this._activating=!1,this._emitAfterActivation=!1,this._endAfterActivation=!1)}function T(a,b){return function(c){a._handleAny(b,c)}}function U(a){return function(){return new a(this,arguments)}}function V(a,b){return function(){return new b(this,arguments)}}function W(a){return{step:function(b,c){return a._send(bb,c,a._forcedCurrent),null},result:function(){return a._send(ab,null,a._forcedCurrent),null}}}function X(a){I.call(this),this._fn=a,this._unsubscribe=null}function Y(){I.call(this)}function Z(a){J.call(this),this._send(bb,a),this._send(ab)}var $={},_=["<nothing>"],ab="end",bb="value",cb="any",db=Date.now?function(){return Date.now()}:function(){return(new Date).getTime()},eb=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},fb=function(a){return"[object Arguments]"===Object.prototype.toString.call(a)};fb(arguments)||(fb=function(a){return!(!a||!u(a,"callee"))}),w(F,{callOne:function(a,b){a.type===cb?a.fn(b):a.type===b.type&&(a.type===bb?a.fn(b.value):a.fn())},callOnce:function(a,b,c){a===cb?b(c):a===c.type&&(a===bb?b(c.value):b())}}),w(F.prototype,{add:function(a,b,c){this._items=e(this._items,[{type:a,fn:b,key:c||{}}])},remove:function(a,b,c){this._items=j(this._items,function(d){return d.type===a&&(d.fn===b||q(d.key,c))})},callAll:function(a){for(var b=this._items,c=0;c<b.length;c++)F.callOne(b[c],a)},isEmpty:function(){return 0===this._items.length}});var gb=G(ab,void 0,!0);$.Observable=H,w(H.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(G(a,b,c)),a===ab&&this._clear())},on:function(a,b,c){return this._alive?(this._subscribers.add(a,b,c),this._setActive(!0)):F.callOnce(a,b,gb),this},off:function(a,b,c){return this._alive&&(this._subscribers.remove(a,b,c),this._subscribers.isEmpty()&&this._setActive(!1)),this},onValue:function(a,b){return this.on(bb,a,b)},onEnd:function(a,b){return this.on(ab,a,b)},onAny:function(a,b){return this.on(cb,a,b)},offValue:function(a,b){return this.off(bb,a,b)},offEnd:function(a,b){return this.off(ab,a,b)},offAny:function(a,b){return this.off(cb,a,b)}}),H.prototype.toString=function(){return"["+this._name+"]"},$.Stream=I,x(I,H,{_name:"stream"}),$.Property=J,x(J,H,{_name:"property",_send:function(a,b,c){this._alive&&(c||this._subscribers.callAll(G(a,b)),a===bb&&(this._current=b),a===ab&&this._clear())},on:function(a,b,c){return this._alive&&(this._subscribers.add(a,b,c),this._setActive(!0)),this._current!==_&&F.callOnce(a,b,G(bb,this._current,!0)),this._alive||F.callOnce(a,b,gb),this}}),H.prototype.log=function(a){return a=a||this.toString(),this.onAny(function(b){var c="<"+b.type+(b.current?":current":"")+">";b.type===bb?console.log(a,c,b.value):console.log(a,c)},["__logKey__",this,a]),this},H.prototype.offLog=function(a){return a=a||this.toString(),this.offAny(null,["__logKey__",this,a]),this},C("withInterval",{_init:function(a){this._fn=a[0];var b=this;this._emitter={emit:function(a){b._send(bb,a)},end:function(){b._send(ab)}}},_free:function(){this._fn=null,this._emitter=null},_onTick:function(){this._fn(this._emitter)}}),C("fromPoll",{_init:function(a){this._fn=a[0]},_free:function(){this._fn=null},_onTick:function(){this._send(bb,this._fn())}}),C("interval",{_init:function(a){this._x=a[0]},_free:function(){this._x=null},_onTick:function(){this._send(bb,this._x)}}),C("sequentially",{_init:function(a){this._xs=h(a[0]),0===this._xs.length&&this._send(ab)},_free:function(){this._xs=null},_onTick:function(){switch(this._xs.length){case 1:this._send(bb,this._xs[0]),this._send(ab);break;default:this._send(bb,this._xs.shift())}}}),C("repeatedly",{_init:function(a){this._xs=h(a[0]),this._i=-1},_onTick:function(){this._xs.length>0&&(this._i=(this._i+1)%this._xs.length,this._send(bb,this._xs[this._i]))}}),C("later",{_init:function(a){this._x=a[0]},_free:function(){this._x=null},_onTick:function(){this._send(bb,this._x),this._send(ab)}}),x(K,I,{_name:"abstractPool",_add:function(a,b){b=b||y,-1===this._concurLim||this._curSources.length<this._concurLim?this._addToCur(b(a)):-1===this._queueLim||this._queue.length<this._queueLim?this._addToQueue(b(a)):"old"===this._drop&&(this._removeOldest(),this._add(b(a)))},_addAll:function(a){var b=this;l(a,function(a){b._add(a)})},_remove:function(a){-1===this._removeCur(a)&&this._removeQueue(a)},_addToQueue:function(a){this._queue=e(this._queue,[a])},_addToCur:function(a){this._curSources=e(this._curSources,[a]),this._active&&this._sub(a)},_sub:function(a){var b=this;a.onAny(this._$handleSubAny),a.onEnd(function(){b._removeCur(a)},[this,a])},_unsub:function(a){a.offAny(this._$handleSubAny),a.offEnd(null,[this,a])},_handleSubAny:function(a){a.type===bb&&this._send(bb,a.value,a.current&&this._activating)},_removeQueue:function(a){var b=f(this._queue,a);return this._queue=i(this._queue,b),b},_removeCur:function(a){this._active&&this._unsub(a);var b=f(this._curSources,a);return this._curSources=i(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=h(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(){I.prototype._clear.call(this),this._queue=null,this._curSources=null,this._$handleSubAny=null}});var hb={_onEmpty:function(){this._initialised&&this._send(ab,null,this._activating)}};x(L,K,w({_name:"merge"},hb)),$.merge=function(a){return new L(a)},H.prototype.merge=function(a){return $.merge([this,a])},x(M,K,w({_name:"concat"},hb)),$.concat=function(a){return new M(a)},H.prototype.concat=function(a){return $.concat([this,a])},x(N,K,{_name:"pool",plug:function(a){return this._add(a),this},unplug:function(a){return this._remove(a),this}}),$.pool=function(){return new N},x(O,K,{_name:"bus",plug:function(a){return this._add(a),this},unplug:function(a){return this._remove(a),this},emit:function(a){return this._send(bb,a),this},end:function(){return this._send(ab),this}}),$.bus=function(){return new O},x(P,K,{_onActivation:function(){K.prototype._onActivation.call(this),this._activating=!0,this._source.onAny(this._$handleMainSource),this._activating=!1},_onDeactivation:function(){K.prototype._onDeactivation.call(this),this._source.offAny(this._$handleMainSource)},_handleMainSource:function(a){a.type===bb?(a.current&&this._lastCurrent===a.value||this._add(a.value,this._fn),this._lastCurrent=a.value):this._isEmpty()?this._send(ab,null,a.current):this._mainEnded=!0},_onEmpty:function(){this._mainEnded&&this._send(ab)},_clear:function(){K.prototype._clear.call(this),this._source=null,this._lastCurrent=null,this._$handleMainSource=null}}),H.prototype.flatMap=function(a){return new P(this,a).setName(this,"flatMap")},H.prototype.flatMapLatest=function(a){return new P(this,a,{concurLim:1,drop:"old"}).setName(this,"flatMapLatest")},H.prototype.flatMapFirst=function(a){return new P(this,a,{concurLim:1}).setName(this,"flatMapFirst")},H.prototype.flatMapConcat=function(a){return new P(this,a,{queueLim:-1,concurLim:1}).setName(this,"flatMapConcat")},H.prototype.flatMapConcurLimit=function(a,b){var c;return 0===b?c=$.never():(0>b&&(b=-1),c=new P(this,a,{queueLim:-1,concurLim:b})),c.setName(this,"flatMapConcurLimit")},x(Q,I,{_name:"zip",_onActivation:function(){var a,b=this._sources.length;for(this._drainArrays(),this._aliveCount=b,a=0;b>a;a++)this._sources[a].onAny(R(this,a),[this,a])},_onDeactivation:function(){for(var a=0;a<this._sources.length;a++)this._sources[a].offAny(null,[this,a])},_emit:function(a){for(var b=new Array(this._buffers.length),c=0;c<this._buffers.length;c++)b[c]=this._buffers[c].shift();this._send(bb,this._combinator(b),a)},_isFull:function(){for(var a=0;a<this._buffers.length;a++)if(0===this._buffers[a].length)return!1;return!0},_emitIfFull:function(a){this._isFull()&&this._emit(a)},_drainArrays:function(){for(;this._isFull();)this._emit(!0)},_handleAny:function(a,b){b.type===bb?(this._buffers[a].push(b.value),this._emitIfFull(b.current)):(this._aliveCount--,0===this._aliveCount&&this._send(ab,null,b.current))},_clear:function(){I.prototype._clear.call(this),this._sources=null,this._buffers=null,this._combinator=null}}),$.zip=function(a,b){return new Q(a,b)},H.prototype.zip=function(a,b){return new Q([this,a],b)},x(S,I,{_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(T(this,a),[this,a]);this._activating=!1,this._emitAfterActivation&&(this._emitAfterActivation=!1,this._emitIfFull(!0)),this._endAfterActivation&&this._send(ab,null,!0)},_onDeactivation:function(){var a,b=this._sources.length;for(a=0;b>a;a++)this._sources[a].offAny(null,[this,a])},_emitIfFull:function(a){if(!n(this._currents,_)){var b=h(this._currents);b=this._combinator(b),this._send(bb,b,a)}},_handleAny:function(a,b){b.type===bb?(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(ab,null,b.current)))},_clear:function(){I.prototype._clear.call(this),this._sources=null,this._currents=null,this._combinator=null}}),$.sampledBy=function(a,b,c){return new S(a,b,c)},H.prototype.sampledBy=function(a,b){return $.sampledBy([this],[a],b||y)},$.combine=function(a,b){return new S([],a,b).setName("combine")},H.prototype.combine=function(a,b){return $.combine([this,a],b)},D("toProperty",{_init:function(a){a.length>0&&this._send(bb,a[0])}},{propertyMethod:null,streamMethod:V}),D("withDefault",{_init:function(a){this._send(bb,a[0],!0)}},{propertyMethod:V,streamMethod:V}),D("changes",{_handleValue:function(a,b){b||this._send(bb,a)}},{streamMethod:null,propertyMethod:U}),D("withHandler",{_init:function(a){this._handler=a[0],this._forcedCurrent=!1;var b=this;this._emitter={emit:function(a){b._send(bb,a,b._forcedCurrent)},end:function(){b._send(ab,null,b._forcedCurrent)}}},_free:function(){this._handler=null,this._emitter=null},_handleAny:function(a){this._forcedCurrent=a.current,this._handler(this._emitter,a),this._forcedCurrent=!1}}),D("flatten",{_init:function(a){this._fn=a[0]?a[0]:y},_free:function(){this._fn=null},_handleValue:function(a,b){for(var c=this._fn(a),d=0;d<c.length;d++)this._send(bb,c[d],b)}}),D("transduce",{_init:function(a){this._xform=a[0](W(this))},_free:function(){this._xform=null},_handleValue:function(a,b){this._forcedCurrent=b,null!==this._xform.step(null,a)&&this._xform.result(null),this._forcedCurrent=!1},_handleEnd:function(a,b){this._forcedCurrent=b,this._xform.result(null),this._forcedCurrent=!1}});var ib={_init:function(a){this._fn=a[0]||y},_free:function(){this._fn=null}};D("map",w({_handleValue:function(a,b){this._send(bb,this._fn(a),b)}},ib)),D("filter",w({_handleValue:function(a,b){this._fn(a)&&this._send(bb,a,b)}},ib)),D("takeWhile",w({_handleValue:function(a,b){this._fn(a)?this._send(bb,a,b):this._send(ab,null,b)}},ib)),D("take",{_init:function(a){this._n=a[0],this._n<=0&&this._send(ab)},_handleValue:function(a,b){this._n--,this._send(bb,a,b),0===this._n&&this._send(ab,null,b)}}),D("skip",{_init:function(a){this._n=Math.max(0,a[0])},_handleValue:function(a,b){0===this._n?this._send(bb,a,b):this._n--}}),D("skipDuplicates",{_init:function(a){this._fn=a[0]||z,this._prev=_},_free:function(){this._fn=null,this._prev=null},_handleValue:function(a,b){this._prev!==_&&this._fn(this._prev,a)||(this._send(bb,a,b),this._prev=a)}}),D("skipWhile",{_init:function(a){this._fn=a[0]||y,this._skip=!0},_free:function(){this._fn=null},_handleValue:function(a,b){return this._skip?void(this._fn(a)||(this._skip=!1,this._fn=null,this._send(bb,a,b))):void this._send(bb,a,b)}}),D("diff",{_init:function(a){this._fn=a[0]||A,this._prev=a.length>1?a[1]:_},_free:function(){this._prev=null,this._fn=null},_handleValue:function(a,b){this._prev!==_&&this._send(bb,this._fn(this._prev,a),b),this._prev=a}}),D("scan",{_init:function(a){this._fn=a[0],a.length>1&&this._send(bb,a[1],!0)},_free:function(){this._fn=null},_handleValue:function(a,b){this._current!==_&&(a=this._fn(this._current,a)),this._send(bb,a,b)}},{streamMethod:V}),D("reduce",{_init:function(a){this._fn=a[0],this._result=a.length>1?a[1]:_},_free:function(){this._fn=null,this._result=null},_handleValue:function(a){this._result=this._result===_?a:this._fn(this._result,a)},_handleEnd:function(a,b){this._result!==_&&this._send(bb,this._result,b),this._send(ab,null,b)}}),D("mapEnd",{_init:function(a){this._fn=a[0]},_free:function(){this._fn=null},_handleEnd:function(a,b){this._send(bb,this._fn(),b),this._send(ab,null,b)}}),D("skipEnd",{_handleEnd:function(){}}),D("slidingWindow",{_init:function(a){this._max=a[0],this._min=a[1]||0,this._buff=[]},_free:function(){this._buff=null},_handleValue:function(a,b){this._buff=p(this._buff,a,this._max),this._buff.length>=this._min&&this._send(bb,this._buff,b)}}),D("bufferWhile",{_init:function(a){this._fn=a[0]||y,this._flushOnEnd=t(a[1],"flushOnEnd",!0),this._buff=[]},_free:function(){this._buff=null},_flush:function(a){null!==this._buff&&0!==this._buff.length&&(this._send(bb,this._buff,a),this._buff=[])},_handleValue:function(a,b){this._buff.push(a),this._fn(a)||this._flush(b)},_handleEnd:function(a,b){this._flushOnEnd&&this._flush(b),this._send(ab,null,b)}}),D("debounce",{_init:function(a){this._wait=Math.max(0,a[0]),this._immediate=t(a[1],"immediate",!1),this._lastAttempt=0,this._timeoutId=null,this._laterValue=null,this._endLater=!1;var b=this;this._$later=function(){b._later()}},_free:function(){this._laterValue=null,this._$later=null},_handleValue:function(a,b){b?this._send(bb,a,b):(this._lastAttempt=db(),this._immediate&&!this._timeoutId&&this._send(bb,a),this._timeoutId||(this._timeoutId=setTimeout(this._$later,this._wait)),this._immediate||(this._laterValue=a))},_handleEnd:function(a,b){b?this._send(ab,null,b):this._timeoutId&&!this._immediate?this._endLater=!0:this._send(ab)},_later:function(){var a=db()-this._lastAttempt;a<this._wait&&a>=0?this._timeoutId=setTimeout(this._$later,this._wait-a):(this._timeoutId=null,this._immediate||(this._send(bb,this._laterValue),this._laterValue=null),this._endLater&&this._send(ab))}}),D("throttle",{_init:function(a){this._wait=Math.max(0,a[0]),this._leading=t(a[1],"leading",!0),this._trailing=t(a[1],"trailing",!0),this._trailingValue=null,this._timeoutId=null,this._endLater=!1,this._lastCallTime=0;var b=this;this._$trailingCall=function(){b._trailingCall()}},_free:function(){this._trailingValue=null,this._$trailingCall=null},_handleValue:function(a,b){if(b)this._send(bb,a,b);else{var c=db();0!==this._lastCallTime||this._leading||(this._lastCallTime=c);var d=this._wait-(c-this._lastCallTime);0>=d?(this._cancelTraling(),this._lastCallTime=c,this._send(bb,a)):this._trailing&&(this._cancelTraling(),this._trailingValue=a,this._timeoutId=setTimeout(this._$trailingCall,d))}},_handleEnd:function(a,b){b?this._send(ab,null,b):this._timeoutId?this._endLater=!0:this._send(ab)},_cancelTraling:function(){null!==this._timeoutId&&(clearTimeout(this._timeoutId),this._timeoutId=null)},_trailingCall:function(){this._send(bb,this._trailingValue),this._timeoutId=null,this._trailingValue=null,this._lastCallTime=this._leading?db():0,this._endLater&&this._send(ab)}}),D("delay",{_init:function(a){this._wait=Math.max(0,a[0]),this._buff=[];var b=this;this._$shiftBuff=function(){b._send(bb,b._buff.shift())}},_free:function(){this._buff=null,this._$shiftBuff=null},_handleValue:function(a,b){b?this._send(bb,a,b):(this._buff.push(a),setTimeout(this._$shiftBuff,this._wait))},_handleEnd:function(a,b){if(b)this._send(ab,null,b);else{var c=this;setTimeout(function(){c._send(ab)},this._wait)}}}),x(X,I,{_name:"fromBinder",_onActivation:function(){var a=this,b=!0,c={emit:function(c){a._send(bb,c,b)},end:function(){a._send(ab,null,b)}};this._unsubscribe=this._fn(c)||null,b=!1},_onDeactivation:function(){null!==this._unsubscribe&&(this._unsubscribe(),this._unsubscribe=null)},_clear:function(){I.prototype._clear.call(this),this._fn=null}}),$.fromBinder=function(a){return new X(a)},x(Y,I,{_name:"emitter",emit:function(a){return this._send(bb,a),this},end:function(){return this._send(ab),this}}),$.emitter=function(){return new Y},$.Emitter=Y;var jb=new I;jb._send(ab),jb._name="never",$.never=function(){return jb},x(Z,J,{_name:"constant"}),$.constant=function(a){return new Z(a)},H.prototype.setName=function(a,b){return this._name=b?a._name+"."+b:a,this},H.prototype.mapTo=function(a){return this.map(function(){return a}).setName(this,"mapTo")},H.prototype.pluck=function(a){return this.map(function(b){return b[a]}).setName(this,"pluck")},H.prototype.invoke=function(a){var b=o(arguments,1);return this.map(b?function(c){return s(c[a],c,b)}:function(b){return b[a]()}).setName(this,"invoke")},H.prototype.timestamp=function(){return this.map(function(a){return{value:a,time:db()}}).setName(this,"timestamp")},H.prototype.tap=function(a){return this.map(function(b){return a(b),b}).setName(this,"tap")},$.and=function(a){return $.combine(a,b).setName("and")},H.prototype.and=function(a){return this.combine(a,b).setName("and")},$.or=function(a){return $.combine(a,c).setName("or")},H.prototype.or=function(a){return this.combine(a,c).setName("or")},H.prototype.not=function(){return this.map(d).setName(this,"not")},H.prototype.awaiting=function(a){return $.merge([this.mapTo(!0),a.mapTo(!1)]).skipDuplicates().toProperty(!1).setName(this,"awaiting")},$.fromCallback=function(a){var b=!1;return $.fromBinder(function(c){b||(a(function(a){c.emit(a),c.end()}),b=!0)}).setName("fromCallback")},$._fromEvent=function(a,b,c){return $.fromBinder(function(d){var e=c?function(){d.emit(s(c,this,arguments))}:d.emit;return a(e),function(){b(e)}})};var kb=[["addEventListener","removeEventListener"],["addListener","removeListener"],["on","off"]];$.fromEvent=function(a,b,c){for(var d,e,f,g=0;g<kb.length;g++)if(d=kb[g],B(a[d[0]])&&B(a[d[1]])){e=d[0],f=d[1];break}if(void 0===e)throw new Error("target don't support any of addEventListener/removeEventListener, addListener/removeListener, on/off method pair");return $._fromEvent(function(c){a[e](b,c)},function(c){a[f](b,c)},c).setName("fromEvent")};var lb={_init:function(a){this._buff=[],this._flushOnEnd=t(a[0],"flushOnEnd",!0)},_free:function(){this._buff=null},_flush:function(a){null!==this._buff&&0!==this._buff.length&&(this._send(bb,this._buff,a),this._buff=[])},_handlePrimaryEnd:function(a,b){this._flushOnEnd&&this._flush(b),this._send(ab,null,b)}};E("bufferBy",w({_onActivation:function(){this._primary.onAny(this._$handlePrimaryAny),this._alive&&null!==this._secondary&&this._secondary.onAny(this._$handleSecondaryAny)},_handlePrimaryValue:function(a){this._buff.push(a)},_handleSecondaryValue:function(a,b){this._flush(b)},_handleSecondaryEnd:function(a,b){this._flushOnEnd||this._send(ab,null,b)}},lb)),E("bufferWhileBy",w({_handlePrimaryValue:function(a,b){this._buff.push(a),this._lastSecondary===_||this._lastSecondary||this._flush(b)},_handleSecondaryEnd:function(a,b){this._flushOnEnd||this._lastSecondary!==_&&!this._lastSecondary||this._send(ab,null,b)}},lb)),E("filterBy",{_handlePrimaryValue:function(a,b){this._lastSecondary!==_&&this._lastSecondary&&this._send(bb,a,b)},_handleSecondaryEnd:function(a,b){this._lastSecondary!==_&&this._lastSecondary||this._send(ab,null,b)}}),E("skipUntilBy",{_handlePrimaryValue:function(a,b){this._lastSecondary!==_&&this._send(bb,a,b)},_handleSecondaryValue:function(a){this._lastSecondary=a,this._removeSecondary()},_handleSecondaryEnd:function(a,b){this._lastSecondary===_&&this._send(ab,null,b)}}),E("takeUntilBy",{_handleSecondaryValue:function(a,b){this._send(ab,null,b)}}),E("takeWhileBy",{_handlePrimaryValue:function(a,b){this._lastSecondary!==_&&this._send(bb,a,b)},_handleSecondaryValue:function(a,b){this._lastSecondary=a,this._lastSecondary||this._send(ab,null,b)},_handleSecondaryEnd:function(a,b){this._lastSecondary===_&&this._send(ab,null,b)}}),E("skipWhileBy",{_handlePrimaryValue:function(a,b){this._lastSecondary===_||this._lastSecondary||this._send(bb,a,b)},_handleSecondaryValue:function(a){this._lastSecondary=a,this._lastSecondary||this._removeSecondary()},_handleSecondaryEnd:function(a,b){(this._lastSecondary===_||this._lastSecondary)&&this._send(ab,null,b)}}),"function"==typeof define&&define.amd?(define([],function(){return $}),a.Kefir=$):"object"==typeof module&&"object"==typeof exports?(module.exports=$,$.Kefir=$):a.Kefir=$}(this);
//# sourceMappingURL=kefir.min.js.map
{
"name": "kefir",
"version": "0.4.0",
"version": "0.4.1",
"description": "Reactive Programming library for JavaScript inspired by Bacon.js and RxJS with focus on high performance and low memory usage",

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

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