Socket
Socket
Sign inDemoInstall

kefir

Package Overview
Dependencies
0
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.11 to 0.3.0

10

changelog.md

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

## 0.3.0
- Removed undocumented feature of `.merge` and `.concat` that allowed to not wrap observables to array but pass them as individual arguments
- Changed arguments order in `.scan`, `.reduce`, and `.diff`
- Added support of on/off methods pair to `.fromEvent`
- Removed undocumented support of bind/unbind pair from `.fromEvent`
- Method `.waitFor` renamed to `.skipUntilBy`
- New method `.takeUntilBy`
- Method `source.flatMapFirst(fn)` now won't call `fn` when skiping values from `source`
## 0.2.11

@@ -2,0 +12,0 @@

2

dist/addons/kefir-jquery.js

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

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

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

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

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

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

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

/*! Kefir.js v0.2.11
/*! Kefir.js v0.3.0
* https://github.com/pozadi/kefir

@@ -28,2 +28,6 @@ */

function not(x) {
return !x;
}
function concat(a, b) {

@@ -403,10 +407,20 @@ var result = new Array(a.length + b.length)

var NOTHING = ['<nothing>'];
var END = 'end';
var VALUE = 'value';
var ANY = 'any';
function agrsToArray(args) {
if (args.length === 1 && isArray(args[0])) {
return args[0];
}
return cloneArray(args);
function noop() {}
function id(x) {
return x;
}
function strictEqual(a, b) {
return a === b;
}
function defaultDiff(a, b) {
return [a, b]
}
var now = Date.now ?

@@ -504,4 +518,4 @@ function() { return Date.now() } :

_handleValue: function(x, isCurrent) { this._send('value', x, isCurrent) },
_handleEnd: function(__, isCurrent) { this._send('end', null, isCurrent) },
_handleValue: function(x, isCurrent) { this._send(VALUE, x, isCurrent) },
_handleEnd: function(__, isCurrent) { this._send(END, null, isCurrent) },

@@ -513,4 +527,4 @@ _onActivationHook: function() {},

switch (event.type) {
case 'value': this._handleValue(event.value, event.current); break;
case 'end': this._handleEnd(event.value, event.current); break;
case VALUE: this._handleValue(event.value, event.current); break;
case END: this._handleEnd(event.value, event.current); break;
}

@@ -570,4 +584,4 @@ },

_handlePrimaryValue: function(x, isCurrent) {},
_handlePrimaryEnd: function(__, isCurrent) { this._send('end', null, isCurrent) },
_handlePrimaryValue: function(x, isCurrent) { this._send(VALUE, x, isCurrent) },
_handlePrimaryEnd: function(__, isCurrent) { this._send(END, null, isCurrent) },

@@ -579,4 +593,4 @@ _handleSecondaryValue: function(x, isCurrent) { this._lastSecondary = x },

switch (event.type) {
case 'value': this._handlePrimaryValue(event.value, event.current); break;
case 'end': this._handlePrimaryEnd(event.value, event.current); break;
case VALUE: this._handlePrimaryValue(event.value, event.current); break;
case END: this._handlePrimaryEnd(event.value, event.current); break;
}

@@ -586,4 +600,9 @@ },

switch (event.type) {
case 'value': this._handleSecondaryValue(event.value, event.current); break;
case 'end': this._handleSecondaryEnd(event.value, event.current); break;
case VALUE:
this._handleSecondaryValue(event.value, event.current);
break;
case END:
this._handleSecondaryEnd(event.value, event.current);
this._removeSecondary();
break;
}

@@ -593,9 +612,10 @@ },

_removeSecondary: function() {
this._secondary.offAny([this._handleSecondaryAny, this]);
this._secondary = null;
this._secondaryRemoved = true;
if (this._secondary !== null) {
this._secondary.offAny([this._handleSecondaryAny, this]);
this._secondary = null;
}
},
_onActivation: function() {
if (!this._secondaryRemoved) {
if (this._secondary !== null) {
this._secondary.onAny([this._handleSecondaryAny, this]);

@@ -608,3 +628,3 @@ }

_onDeactivation: function() {
if (!this._secondaryRemoved) {
if (this._secondary !== null) {
this._secondary.offAny([this._handleSecondaryAny, this]);

@@ -625,3 +645,2 @@ }

this._lastSecondary = NOTHING;
this._secondaryRemoved = false;
this._init();

@@ -665,6 +684,6 @@ }

callOne: function(fn, event) {
if (fn.type === 'any') {
if (fn.type === ANY) {
fn.invoke(event);
} else if (fn.type === event.type) {
if (fn.type === 'value') {
if (fn.type === VALUE) {
fn.invoke(event.value);

@@ -677,6 +696,6 @@ } else {

callOnce: function(type, fnMeta, event) {
if (type === 'any') {
if (type === ANY) {
applyFnMeta(fnMeta, [event]);
} else if (type === event.type) {
if (type === 'value') {
if (type === VALUE) {
applyFnMeta(fnMeta, [event.value]);

@@ -692,3 +711,3 @@ } else {

add: function(type, fn) {
fn = Fn(fn, type === 'end' ? 0 : 1);
fn = Fn(fn, type === END ? 0 : 1);
fn.type = type;

@@ -724,3 +743,3 @@ this._fns = concat(this._fns, [fn]);

var CURRENT_END = Event('end', undefined, true);
var CURRENT_END = Event(END, undefined, true);

@@ -767,3 +786,3 @@

this._subscribers.callAll(Event(type, x, isCurrent));
if (type === 'end') { this._clear() }
if (type === END) { this._clear() }
}

@@ -792,9 +811,9 @@ },

onValue: function(fn) { return this.on('value', fn) },
onEnd: function(fn) { return this.on('end', fn) },
onAny: function(fn) { return this.on('any', fn) },
onValue: function(fn) { return this.on(VALUE, fn) },
onEnd: function(fn) { return this.on(END, fn) },
onAny: function(fn) { return this.on(ANY, fn) },
offValue: function(fn) { return this.off('value', fn) },
offEnd: function(fn) { return this.off('end', fn) },
offAny: function(fn) { return this.off('any', fn) }
offValue: function(fn) { return this.off(VALUE, fn) },
offEnd: function(fn) { return this.off(END, fn) },
offAny: function(fn) { return this.off(ANY, fn) }

@@ -851,4 +870,4 @@ });

}
if (type === 'value') { this._current = x }
if (type === 'end') { this._clear() }
if (type === VALUE) { this._current = x }
if (type === END) { this._clear() }
}

@@ -863,3 +882,3 @@ },

if (this._current !== NOTHING) {
Subscribers.callOnce(type, fn, Event('value', this._current, true));
Subscribers.callOnce(type, fn, Event(VALUE, this._current, true));
}

@@ -883,3 +902,3 @@ if (!this._alive) {

var typeStr = '<' + event.type + (event.current ? ':current' : '') + '>';
if (event.type === 'value') {
if (event.type === VALUE) {
console.log(name, typeStr, event.value);

@@ -910,4 +929,4 @@ } else {

this._emitter = {
emit: function(x) { $._send('value', x) },
end: function() { $._send('end') }
emit: function(x) { $._send(VALUE, x) },
end: function() { $._send(END) }
}

@@ -938,3 +957,3 @@ },

_onTick: function() {
this._send('value', this._fn());
this._send(VALUE, this._fn());
}

@@ -957,3 +976,3 @@ });

_onTick: function() {
this._send('value', this._x);
this._send(VALUE, this._x);
}

@@ -971,3 +990,3 @@ });

if (this._xs.length === 0) {
this._send('end')
this._send(END)
}

@@ -981,7 +1000,7 @@ },

case 1:
this._send('value', this._xs[0]);
this._send('end');
this._send(VALUE, this._xs[0]);
this._send(END);
break;
default:
this._send('value', this._xs.shift());
this._send(VALUE, this._xs.shift());
}

@@ -1004,3 +1023,3 @@ }

this._i = (this._i + 1) % this._xs.length;
this._send('value', this._xs[this._i]);
this._send(VALUE, this._xs[this._i]);
}

@@ -1024,4 +1043,4 @@ }

_onTick: function() {
this._send('value', this._x);
this._send('end');
this._send(VALUE, this._x);
this._send(END);
}

@@ -1049,11 +1068,12 @@ });

_add: function(obs) {
_add: function(obj, toObs) {
toObs = toObs || id;
if (this._concurLim === -1 || this._curSources.length < this._concurLim) {
this._addToCur(obs);
this._addToCur(toObs(obj));
} else {
if (this._queueLim === -1 || this._queue.length < this._queueLim) {
this._addToQueue(obs);
this._addToQueue(toObs(obj));
} else if (this._drop === 'old') {
this._removeOldest();
this._add(obs);
this._add(toObs(obj));
}

@@ -1088,4 +1108,4 @@ }

_handleSubAny: function(event) {
if (event.type === 'value') {
this._send('value', event.value, event.current && this._activating);
if (event.type === VALUE) {
this._send(VALUE, event.value, event.current && this._activating);
}

@@ -1155,3 +1175,3 @@ },

_onEmpty: function() {
if (this._initialised) { this._send('end', null, this._activating) }
if (this._initialised) { this._send(END, null, this._activating) }
}

@@ -1162,3 +1182,3 @@ };

_AbstractPool.call(this);
if (sources.length === 0) { this._send('end') } else { this._addAll(sources) }
if (sources.length === 0) { this._send(END) } else { this._addAll(sources) }
this._initialised = true;

@@ -1169,4 +1189,4 @@ }

Kefir.merge = function() {
return new Merge(agrsToArray(arguments));
Kefir.merge = function(obss) {
return new Merge(obss);
}

@@ -1185,3 +1205,3 @@

_AbstractPool.call(this, {concurLim: 1, queueLim: -1});
if (sources.length === 0) { this._send('end') } else { this._addAll(sources) }
if (sources.length === 0) { this._send(END) } else { this._addAll(sources) }
this._initialised = true;

@@ -1192,4 +1212,4 @@ }

Kefir.concat = function() {
return new Concat(agrsToArray(arguments));
Kefir.concat = function(obss) {
return new Concat(obss);
}

@@ -1255,7 +1275,7 @@

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

@@ -1279,3 +1299,3 @@ }

this._source = source;
this._fn = fn ? buildFn(fn, 1) : null;
this._fn = fn ? buildFn(fn, 1) : id;
this._mainEnded = false;

@@ -1299,5 +1319,5 @@ this._lastCurrent = null;

_handleMainSource: function(event) {
if (event.type === 'value') {
if (event.type === VALUE) {
if (!event.current || this._lastCurrent !== event.value) {
this._add(this._fn ? this._fn(event.value) : event.value);
this._add(event.value, this._fn);
}

@@ -1307,3 +1327,3 @@ this._lastCurrent = event.value;

if (this._isEmpty()) {
this._send('end', null, event.current);
this._send(END, null, event.current);
} else {

@@ -1316,3 +1336,3 @@ this._mainEnded = true;

_onEmpty: function() {
if (this._mainEnded) { this._send('end') }
if (this._mainEnded) { this._send(END) }
},

@@ -1368,3 +1388,3 @@

if (active.length === 0) {
this._send('end');
this._send(END);
} else {

@@ -1401,3 +1421,3 @@ this._passiveCount = passive.length;

if (this._endAfterActivation) {
this._send('end', null, true);
this._send(END, null, true);
}

@@ -1417,6 +1437,6 @@ },

var combined = cloneArray(this._currents);
if (this._combinator) {
if (this._combinator !== null) {
combined = this._combinator.apply(this._currents);
}
this._send('value', combined, isCurrent);
this._send(VALUE, combined, isCurrent);
}

@@ -1426,3 +1446,3 @@ },

_handleAny: function(i, event) {
if (event.type === 'value') {
if (event.type === VALUE) {
this._currents[i] = event.value;

@@ -1443,3 +1463,3 @@ if (i >= this._passiveCount) {

} else {
this._send('end', null, event.current);
this._send(END, null, event.current);
}

@@ -1496,3 +1516,3 @@ }

if (args.length > 0) {
this._send('value', args[0]);
this._send(VALUE, args[0]);
}

@@ -1510,3 +1530,3 @@ }

if (!isCurrent) {
this._send('value', x);
this._send(VALUE, x);
}

@@ -1527,4 +1547,4 @@ }

this._emitter = {
emit: function(x) { $._send('value', x, $._forcedCurrent) },
end: function() { $._send('end', null, $._forcedCurrent) }
emit: function(x) { $._send(VALUE, x, $._forcedCurrent) },
end: function() { $._send(END, null, $._forcedCurrent) }
}

@@ -1550,3 +1570,3 @@ },

_init: function(args) {
this._fn = args[0] ? buildFn(args[0], 1) : null;
this._fn = args[0] ? buildFn(args[0], 1) : id;
},

@@ -1557,5 +1577,5 @@ _free: function() {

_handleValue: function(x, isCurrent) {
var xs = this._fn === null ? x : this._fn(x);
var xs = this._fn(x);
for (var i = 0; i < xs.length; i++) {
this._send('value', xs[i], isCurrent);
this._send(VALUE, xs[i], isCurrent);
}

@@ -1575,11 +1595,8 @@ }

return {
init: function() {
return null;
},
step: function(res, input) {
obs._send('value', input, obs._forcedCurrent);
obs._send(VALUE, input, obs._forcedCurrent);
return null;
},
result: function(res) {
obs._send('end', null, obs._forcedCurrent);
obs._send(END, null, obs._forcedCurrent);
return null;

@@ -1593,5 +1610,2 @@ }

this._xform = args[0](xformForObs(this));
this._forcedCurrent = true;
this._endIfReduced(this._xform.init());
this._forcedCurrent = false;
},

@@ -1601,10 +1615,7 @@ _free: function() {

},
_endIfReduced: function(obj) {
if (obj !== null) {
_handleValue: function(x, isCurrent) {
this._forcedCurrent = isCurrent;
if (this._xform.step(null, x) !== null) {
this._xform.result(null);
}
},
_handleValue: function(x, isCurrent) {
this._forcedCurrent = isCurrent;
this._endIfReduced(this._xform.step(null, x));
this._forcedCurrent = false;

@@ -1634,3 +1645,3 @@ },

_handleValue: function(x, isCurrent) {
this._send('value', this._fn(x), isCurrent);
this._send(VALUE, this._fn(x), isCurrent);
}

@@ -1648,3 +1659,3 @@ }, withFnArgMixin));

if (this._fn(x)) {
this._send('value', x, isCurrent);
this._send(VALUE, x, isCurrent);
}

@@ -1663,5 +1674,5 @@ }

if (this._fn(x)) {
this._send('value', x, isCurrent);
this._send(VALUE, x, isCurrent);
} else {
this._send('end', null, isCurrent);
this._send(END, null, isCurrent);
}

@@ -1681,3 +1692,3 @@ }

if (this._n <= 0) {
this._send('end');
this._send(END);
}

@@ -1687,5 +1698,5 @@ },

this._n--;
this._send('value', x, isCurrent);
this._send(VALUE, x, isCurrent);
if (this._n === 0) {
this._send('end', null, isCurrent);
this._send(END, null, isCurrent);
}

@@ -1703,7 +1714,7 @@ }

_init: function(args) {
this._n = args[0] < 0 ? 0 : args[0];
this._n = Math.max(0, args[0]);
},
_handleValue: function(x, isCurrent) {
if (this._n === 0) {
this._send('value', x, isCurrent);
this._send(VALUE, x, isCurrent);
} else {

@@ -1722,3 +1733,3 @@ this._n--;

_init: function(args) {
this._fn = args[0] ? buildFn(args[0], 2) : null;
this._fn = args[0] ? buildFn(args[0], 2) : strictEqual;
this._prev = NOTHING;

@@ -1730,8 +1741,5 @@ },

},
_isEqual: function(a, b) {
return this._fn === null ? a === b : this._fn(a, b);
},
_handleValue: function(x, isCurrent) {
if (this._prev === NOTHING || !this._isEqual(this._prev, x)) {
this._send('value', x, isCurrent);
if (this._prev === NOTHING || !this._fn(this._prev, x)) {
this._send(VALUE, x, isCurrent);
this._prev = x;

@@ -1758,3 +1766,3 @@ }

if (!this._skip) {
this._send('value', x, isCurrent);
this._send(VALUE, x, isCurrent);
return;

@@ -1765,3 +1773,3 @@ }

this._fn = null;
this._send('value', x, isCurrent);
this._send(VALUE, x, isCurrent);
}

@@ -1775,8 +1783,8 @@ }

// .diff(seed, fn)
// .diff(fn, seed)
withOneSource('diff', {
_init: function(args) {
this._prev = args[0];
this._fn = args[1] ? buildFn(args[1], 2) : null;
this._fn = args[0] ? buildFn(args[0], 2) : defaultDiff;
this._prev = args[1];
},

@@ -1788,6 +1796,3 @@ _free: function() {

_handleValue: function(x, isCurrent) {
var result = (this._fn === null) ?
[this._prev, x] :
this._fn(this._prev, x);
this._send('value', result, isCurrent);
this._send(VALUE, this._fn(this._prev, x), isCurrent);
this._prev = x;

@@ -1801,8 +1806,8 @@ }

// .scan(seed, fn)
// .scan(fn, seed)
withOneSource('scan', {
_init: function(args) {
this._send('value', args[0], true);
this._fn = buildFn(args[1], 2);
this._fn = buildFn(args[0], 2);
this._send(VALUE, args[1], true);
},

@@ -1813,3 +1818,3 @@ _free: function() {

_handleValue: function(x, isCurrent) {
this._send('value', this._fn(this._current, x), isCurrent);
this._send(VALUE, this._fn(this._current, x), isCurrent);
}

@@ -1822,8 +1827,8 @@ }, {streamMethod: produceProperty});

// .reduce(seed, fn)
// .reduce(fn, seed)
withOneSource('reduce', {
_init: function(args) {
this._result = args[0];
this._fn = buildFn(args[1], 2);
this._fn = buildFn(args[0], 2);
this._result = args[1];
},

@@ -1838,4 +1843,4 @@ _free: function() {

_handleEnd: function(__, isCurrent) {
this._send('value', this._result, isCurrent);
this._send('end', null, isCurrent);
this._send(VALUE, this._result, isCurrent);
this._send(END, null, isCurrent);
}

@@ -1861,3 +1866,3 @@ });

if (this._cache.length >= this._min) {
this._send('value', this._cache, isCurrent);
this._send(VALUE, this._cache, isCurrent);
}

@@ -1890,7 +1895,7 @@ }

if (isCurrent) {
this._send('value', x, isCurrent);
this._send(VALUE, x, isCurrent);
} else {
this._lastAttempt = now();
if (this._immediate && !this._timeoutId) {
this._send('value', x);
this._send(VALUE, x);
}

@@ -1907,3 +1912,3 @@ if (!this._timeoutId) {

if (isCurrent) {
this._send('end', null, isCurrent);
this._send(END, null, isCurrent);
} else {

@@ -1913,3 +1918,3 @@ if (this._timeoutId && !this._immediate) {

} else {
this._send('end');
this._send(END);
}

@@ -1925,7 +1930,7 @@ }

if (!this._immediate) {
this._send('value', this._laterValue);
this._send(VALUE, this._laterValue);
this._laterValue = null;
}
if (this._endLater) {
this._send('end');
this._send(END);
}

@@ -1960,3 +1965,3 @@ }

if (isCurrent) {
this._send('value', x, isCurrent);
this._send(VALUE, x, isCurrent);
} else {

@@ -1971,3 +1976,3 @@ var curTime = now();

this._lastCallTime = curTime;
this._send('value', x);
this._send(VALUE, x);
} else if (this._trailing) {

@@ -1982,3 +1987,3 @@ this._cancelTraling();

if (isCurrent) {
this._send('end', null, isCurrent);
this._send(END, null, isCurrent);
} else {

@@ -1988,3 +1993,3 @@ if (this._timeoutId) {

} else {
this._send('end');
this._send(END);
}

@@ -2000,3 +2005,3 @@ }

_trailingCall: function() {
this._send('value', this._trailingValue);
this._send(VALUE, this._trailingValue);
this._timeoutId = null;

@@ -2006,3 +2011,3 @@ this._trailingValue = null;

if (this._endLater) {
this._send('end');
this._send(END);
}

@@ -2023,3 +2028,3 @@ }

var $ = this;
this._$shiftBuff = function() { $._send('value', $._buff.shift()) }
this._$shiftBuff = function() { $._send(VALUE, $._buff.shift()) }
},

@@ -2032,3 +2037,3 @@ _free: function() {

if (isCurrent) {
this._send('value', x, isCurrent);
this._send(VALUE, x, isCurrent);
} else {

@@ -2041,6 +2046,6 @@ this._buff.push(x);

if (isCurrent) {
this._send('end', null, isCurrent);
this._send(END, null, isCurrent);
} else {
var $ = this;
setTimeout(function() { $._send('end') }, this._wait);
setTimeout(function() { $._send(END) }, this._wait);
}

@@ -2067,4 +2072,4 @@ }

, emitter = {
emit: function(x) { $._send('value', x, isCurrent) },
end: function() { $._send('end', null, isCurrent) }
emit: function(x) { $._send(VALUE, x, isCurrent) },
end: function() { $._send(END, null, isCurrent) }
};

@@ -2109,7 +2114,7 @@ unsub = this._fn(emitter);

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

@@ -2132,3 +2137,3 @@ }

var neverObj = new Stream();
neverObj._send('end');
neverObj._send(END);
neverObj._name = 'never';

@@ -2145,4 +2150,4 @@ Kefir.never = function() { return neverObj }

Property.call(this);
this._send('value', x);
this._send('end');
this._send(VALUE, x);
this._send(END);
}

@@ -2247,3 +2252,3 @@

Observable.prototype.not = function() {
return this.map(function(x) { return !x }).setName(this, 'not');
return this.map(not).setName(this, 'not');
}

@@ -2286,15 +2291,36 @@

var subUnsubPairs = [
['addEventListener', 'removeEventListener'],
['addListener', 'removeListener'],
['on', 'off']
];
function wrapEmitter(emitter, transformer) {
return function() {
emitter.emit(transformer.applyWithContext(this, arguments));
}
}
Kefir.fromEvent = function(target, eventName, transformer) {
var pair, sub, unsub;
transformer = transformer && Fn(transformer);
var sub = target.addEventListener || target.addListener || target.bind;
var unsub = target.removeEventListener || target.removeListener || target.unbind;
for (var i = 0; i < subUnsubPairs.length; i++) {
pair = subUnsubPairs[i];
if (isFn(target[pair[0]]) && isFn(target[pair[1]])) {
sub = pair[0];
unsub = pair[1];
break;
}
}
if (sub === undefined) {
throw new Error('target don\'t support any of addEventListener/removeEventListener, addListener/removeListener, on/off method pair');
}
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);
}
var handler = transformer ? wrapEmitter(emitter, transformer) : emitter.emit;
target[sub](eventName, handler);
return [unsub, target, eventName, handler];
}).setName('fromEvent');

@@ -2307,3 +2333,3 @@ }

if (this._lastSecondary !== NOTHING && this._lastSecondary) {
this._send('value', x, isCurrent);
this._send(VALUE, x, isCurrent);
}

@@ -2314,3 +2340,3 @@ },

if (this._lastSecondary === NOTHING || !this._lastSecondary) {
this._send('end', null, isCurrent);
this._send(END, null, isCurrent);
}

@@ -2323,7 +2349,7 @@ }

withTwoSources('waitFor', {
withTwoSources('skipUntilBy', {
_handlePrimaryValue: function(x, isCurrent) {
if (this._lastSecondary !== NOTHING) {
this._send('value', x, isCurrent);
this._send(VALUE, x, isCurrent);
}

@@ -2339,3 +2365,3 @@ },

if (this._lastSecondary === NOTHING) {
this._send('end', null, isCurrent);
this._send(END, null, isCurrent);
}

@@ -2348,2 +2374,12 @@ }

withTwoSources('takeUntilBy', {
_handleSecondaryValue: function(x, isCurrent) {
this._send(END, null, isCurrent);
}
});
withTwoSources('takeWhileBy', {

@@ -2353,3 +2389,3 @@

if (this._lastSecondary !== NOTHING) {
this._send('value', x, isCurrent);
this._send(VALUE, x, isCurrent);
}

@@ -2361,3 +2397,3 @@ },

if (!this._lastSecondary) {
this._send('end', null, isCurrent);
this._send(END, null, isCurrent);
}

@@ -2368,3 +2404,3 @@ },

if (this._lastSecondary === NOTHING) {
this._send('end', null, isCurrent);
this._send(END, null, isCurrent);
}

@@ -2382,3 +2418,3 @@ }

if (this._lastSecondary !== NOTHING && !this._lastSecondary) {
this._send('value', x, isCurrent);
this._send(VALUE, x, isCurrent);
}

@@ -2396,3 +2432,3 @@ },

if (this._lastSecondary === NOTHING || this._lastSecondary) {
this._send('end', null, isCurrent);
this._send(END, null, isCurrent);
}

@@ -2399,0 +2435,0 @@ }

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

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

@@ -32,9 +32,9 @@ "main": "dist/kefir.js",

"devDependencies": {
"baconjs": "~0.7.28",
"baconjs": "~0.7.30",
"benchmark": "~1.0.0",
"coffee-script": "~1.8.0",
"coffeeify": "~0.7.0",
"grunt": "~0.4.4",
"grunt": "~0.4.5",
"grunt-bower-task": "~0.4.0",
"grunt-browserify": "~3.1.0",
"grunt-browserify": "~3.2.0",
"grunt-cli": "~0.1.13",

@@ -52,7 +52,7 @@ "grunt-contrib-clean": "~0.6.0",

"marked": "~0.3.2",
"rx": "~2.3.3",
"rx": "~2.3.14",
"semver": "~2.3.0",
"shelljs": "~0.3.0",
"sinon": "~1.11.1",
"transducers-js": "0.4.135",
"transducers-js": "~0.4.135",
"transducers.js": "~0.2.3"

@@ -59,0 +59,0 @@ },

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc