Socket
Socket
Sign inDemoInstall

kefir

Package Overview
Dependencies
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kefir - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

10

changelog.md

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

## 0.4.0
- The `seed` argument in `.scan`, `.reduce`, and `.diff` is now optional
- Removed support of ["array functions"](https://github.com/pozadi/kefir/blob/2edf32a82d5b24ecb6ed99c9bcbd2391b91c8715/docs-src/descriptions/about-callbacks.jade)
- 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()`
- The `fn` argument in `.filter`, `.takeWhile`, and `.skipWhile` is now optional
## 0.3.0

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

26

dist/addons/kefir-jquery.js

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

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

@@ -11,3 +11,2 @@ */

$.fn.asKefirStream = function(eventName, selector, transformer) {

@@ -19,15 +18,7 @@ var $el = this;

}
transformer = transformer && Kefir.Fn(transformer);
return Kefir.fromBinder(function(emitter) {
var onEvent;
if (transformer) {
onEvent = function() {
emitter.emit(transformer.applyWithContext(this, arguments));
};
} else {
onEvent = emitter.emit;
}
$el.on(eventName, selector, onEvent);
return ['off', $el, eventName, selector, onEvent];
}).setName('asKefirStream');
return Kefir._fromEvent(
function(handler) { $el.on(eventName, selector, handler) },
function(handler) { $el.off(eventName, selector, handler) },
transformer
).setName('asKefirStream');
}

@@ -37,3 +28,2 @@

$.fn.asKefirProperty = function(eventName, selector, getter) {

@@ -44,5 +34,4 @@ if (getter == null) {

}
getter = Kefir.Fn(getter);
return this.asKefirStream(eventName, selector, getter)
.toProperty(getter.invoke())
.toProperty(getter())
.setName('asKefirProperty');

@@ -53,3 +42,2 @@ }

}

@@ -56,0 +44,0 @@

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

/*! An addon for Kefir.js v0.3.0
/*! An addon for Kefir.js v0.4.0
* https://github.com/pozadi/kefir
*/
!function(a){"use strict";function b(a,b){b.fn.asKefirStream=function(b,c,d){var e=this;return null==d&&null!=c&&"string"!=typeof c&&(d=c,c=null),d=d&&a.Fn(d),a.fromBinder(function(a){var f;return f=d?function(){a.emit(d.applyWithContext(this,arguments))}:a.emit,e.on(b,c,f),["off",e,b,c,f]}).setName("asKefirStream")},b.fn.asKefirProperty=function(b,c,d){return null==d&&(d=c,c=null),d=a.Fn(d),this.asKefirStream(b,c,d).toProperty(d.invoke()).setName("asKefirProperty")}}if("function"==typeof define&&define.amd)define(["kefir","jquery"],b);else if("object"==typeof module&&"object"==typeof exports){var c=require("kefir"),d=require("jquery");b(c,d)}else b(a.Kefir,a.jQuery)}(this);
!function(a){"use strict";function b(a,b){b.fn.asKefirStream=function(b,c,d){var e=this;return null==d&&null!=c&&"string"!=typeof c&&(d=c,c=null),a._fromEvent(function(a){e.on(b,c,a)},function(a){e.off(b,c,a)},d).setName("asKefirStream")},b.fn.asKefirProperty=function(a,b,c){return null==c&&(c=b,b=null),this.asKefirStream(a,b,c).toProperty(c()).setName("asKefirProperty")}}if("function"==typeof define&&define.amd)define(["kefir","jquery"],b);else if("object"==typeof module&&"object"==typeof exports){var c=require("kefir"),d=require("jquery");b(c,d)}else b(a.Kefir,a.jQuery)}(this);
//# sourceMappingURL=kefir-jquery.min.js.map

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

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

@@ -33,7 +33,7 @@ */

function concat(a, b) {
var result = new Array(a.length + b.length)
, j = 0
, length, i;
var result, length, i, j;
if (a.length === 0) { return b }
if (b.length === 0) { return a }
j = 0;
result = new Array(a.length + b.length);
length = a.length;

@@ -169,2 +169,13 @@ for (i = 0; i < length; i++, j++) {

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

@@ -189,180 +200,2 @@ var aLength = a ? a.length : 0;

function bindWithoutContext(fn, a, length) {
var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3];
switch (length) {
case 0:
switch (a.length) {
case 0: return fn;
case 1: return function() {return fn(a0)}
case 2: return function() {return fn(a0, a1)}
case 3: return function() {return fn(a0, a1, a2)}
case 4: return function() {return fn(a0, a1, a2, a3)}
default: return function() {return fn.apply(null, a)}
}
break;
case 1:
switch (a.length) {
case 0: return fn;
case 1: return function(b0) {return fn(a0, b0)}
case 2: return function(b0) {return fn(a0, a1, b0)}
case 3: return function(b0) {return fn(a0, a1, a2, b0)}
case 4: return function(b0) {return fn(a0, a1, a2, a3, b0)}
default: return function(b0) {return fn.apply(null, concat(a, [b0]))}
}
break;
case 2:
switch (a.length) {
case 0: return fn;
case 1: return function(b0, b1) {return fn(a0, b0, b1)}
case 2: return function(b0, b1) {return fn(a0, a1, b0, b1)}
case 3: return function(b0, b1) {return fn(a0, a1, a2, b0, b1)}
case 4: return function(b0, b1) {return fn(a0, a1, a2, a3, b0, b1)}
default: return function(b0, b1) {return fn.apply(null, concat(a, [b0, b1]))}
}
break;
default:
switch (a.length) {
case 0: return fn;
default: return function() {return apply(fn, null, concat(a, arguments))}
}
}
}
function bindWithContext(fn, c, a, length) {
var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3];
switch (length) {
case 0:
switch (a.length) {
case 0: return function() {return fn.call(c)}
default: return function() {return fn.apply(c, a)}
}
break;
case 1:
switch (a.length) {
case 0: return function(b0) {return fn.call(c, b0)}
case 1: return function(b0) {return fn.call(c, a0, b0)}
case 2: return function(b0) {return fn.call(c, a0, a1, b0)}
case 3: return function(b0) {return fn.call(c, a0, a1, a2, b0)}
case 4: return function(b0) {return fn.call(c, a0, a1, a2, a3, b0)}
default: return function(b0) {return fn.apply(c, concat(a, [b0]))}
}
break;
case 2:
switch (a.length) {
case 0: return function(b0, b1) {return fn.call(c, b0, b1)}
case 1: return function(b0, b1) {return fn.call(c, a0, b0, b1)}
case 2: return function(b0, b1) {return fn.call(c, a0, a1, b0, b1)}
case 3: return function(b0, b1) {return fn.call(c, a0, a1, a2, b0, b1)}
case 4: return function(b0, b1) {return fn.call(c, a0, a1, a2, a3, b0, b1)}
default: return function(b0, b1) {return fn.apply(c, concat(a, [b0, b1]))}
}
break;
default:
switch (a.length) {
case 0: return function() {return fn.apply(c, arguments)}
default: return function() {return fn.apply(c, concat(a, arguments))}
}
}
}
function bind(fn, context, args, boundFunctionLength) {
if (context == null) {
return bindWithoutContext(fn, args, boundFunctionLength);
} else {
return bindWithContext(fn, context, args, boundFunctionLength);
}
}
// array functions (a.k.a fnMeta) helpers
function normFnMeta(fnMeta) {
var fn, context, args;
if (fnMeta instanceof _Fn) {
return fnMeta;
} else {
if (isFn(fnMeta)) {
return {fn: fnMeta, context: null, args: []};
} else {
if (isArrayLike(fnMeta)) {
context = (fnMeta[1] == null ? null : fnMeta[1]);
fn = fnMeta[0];
args = rest(fnMeta, 2, []);
if (!isFn(fn)) {
if (context !== null && isFn(context[fn])) {
fn = context[fn];
} else {
throw new Error('Object isn\'t a function, and can\'t be converted to it: ' + fnMeta);
}
}
return {fn: fn, context: context, args: args};
} else {
throw new Error('Object isn\'t a function, and can\'t be converted to it: ' + fnMeta);
}
}
}
}
function applyFnMeta(fnMeta, args) {
fnMeta = normFnMeta(fnMeta);
return apply(fnMeta.fn, fnMeta.context, concat(fnMeta.args, args));
}
function buildFn(fnMeta, length) {
fnMeta = normFnMeta(fnMeta);
return bind(fnMeta.fn, fnMeta.context, fnMeta.args, length);
}
// Fn class
function _Fn(fnMeta, length) {
this.context = fnMeta.context;
this.fn = fnMeta.fn;
this.args = fnMeta.args;
this.invoke = bind(this.fn, this.context, this.args, length);
}
_Fn.prototype.apply = function(args) {
return apply(this.invoke, null, args);
}
_Fn.prototype.applyWithContext = function(context, args) {
if (this.context === null) {
return apply(this.fn, context, concat(this.args, args));
} else {
return this.apply(args);
}
}
function Fn(fnMeta, length) {
if (fnMeta instanceof _Fn) {
return fnMeta;
} else {
return new _Fn(normFnMeta(fnMeta), length == null ? 100 : length);
}
}
Fn.isEqual = function(a, b) {
if (a === b) {
return true;
}
a = Fn(a);
b = Fn(b);
return a.fn === b.fn &&
a.context === b.context &&
isEqualArrays(a.args, b.args);
}
Kefir.Fn = Fn;
function get(map, key, notFound) {

@@ -534,7 +367,7 @@ if (map && key in map) {

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

@@ -551,2 +384,4 @@ }, mixin || {});

this._init(args);
var $ = this;
this._$handleAny = function(event) { $._handleAny(event) }
}

@@ -558,2 +393,3 @@

this._source = null;
this._$handleAny = null;
this._free();

@@ -612,3 +448,4 @@ }

if (this._secondary !== null) {
this._secondary.offAny([this._handleSecondaryAny, this]);
this._secondary.offAny(this._$handleSecondaryAny);
this._$handleSecondaryAny = null;
this._secondary = null;

@@ -620,6 +457,6 @@ }

if (this._secondary !== null) {
this._secondary.onAny([this._handleSecondaryAny, this]);
this._secondary.onAny(this._$handleSecondaryAny);
}
if (this._alive) {
this._primary.onAny([this._handlePrimaryAny, this]);
this._primary.onAny(this._$handlePrimaryAny);
}

@@ -629,5 +466,5 @@ },

if (this._secondary !== null) {
this._secondary.offAny([this._handleSecondaryAny, this]);
this._secondary.offAny(this._$handleSecondaryAny);
}
this._primary.offAny([this._handlePrimaryAny, this]);
this._primary.offAny(this._$handlePrimaryAny);
}

@@ -645,2 +482,5 @@ }, mixin || {});

this._lastSecondary = NOTHING;
var $ = this;
this._$handleSecondaryAny = function(event) { $._handleSecondaryAny(event) }
this._$handlePrimaryAny = function(event) { $._handlePrimaryAny(event) }
this._init();

@@ -655,2 +495,4 @@ }

this._lastSecondary = null;
this._$handleSecondaryAny = null;
this._$handlePrimaryAny = null;
this._free();

@@ -680,25 +522,25 @@ }

function Subscribers() {
this._fns = [];
this._items = [];
}
extend(Subscribers, {
callOne: function(fn, event) {
if (fn.type === ANY) {
fn.invoke(event);
} else if (fn.type === event.type) {
if (fn.type === VALUE) {
fn.invoke(event.value);
callOne: function(fnData, event) {
if (fnData.type === ANY) {
fnData.fn(event);
} else if (fnData.type === event.type) {
if (fnData.type === VALUE) {
fnData.fn(event.value);
} else {
fn.invoke();
fnData.fn();
}
}
},
callOnce: function(type, fnMeta, event) {
callOnce: function(type, fn, event) {
if (type === ANY) {
applyFnMeta(fnMeta, [event]);
fn(event);
} else if (type === event.type) {
if (type === VALUE) {
applyFnMeta(fnMeta, [event.value]);
fn(event.value);
} else {
applyFnMeta(fnMeta, []);
fn();
}

@@ -710,21 +552,23 @@ }

extend(Subscribers.prototype, {
add: function(type, fn) {
fn = Fn(fn, type === END ? 0 : 1);
fn.type = type;
this._fns = concat(this._fns, [fn]);
add: function(type, fn, _key) {
this._items = concat(this._items, [{
type: type,
fn: fn,
key: _key || NOTHING
}]);
},
remove: function(type, fn) {
fn = Fn(fn);
this._fns = removeByPred(this._fns, function(x) {
return x.type === type && Fn.isEqual(x, fn);
remove: function(type, fn, _key) {
this._items = removeByPred(this._items, function(fnData) {
return fnData.type === type &&
(fnData.fn === fn || isEqualArrays(fnData.key, _key));
});
},
callAll: function(event) {
var fns = this._fns;
for (var i = 0; i < fns.length; i++) {
Subscribers.callOne(fns[i], event);
var items = this._items;
for (var i = 0; i < items.length; i++) {
Subscribers.callOne(items[i], event);
}
},
isEmpty: function() {
return this._fns.length === 0;
return this._items.length === 0;
}

@@ -789,5 +633,5 @@ });

on: function(type, fn) {
on: function(type, fn, _key) {
if (this._alive) {
this._subscribers.add(type, fn);
this._subscribers.add(type, fn, _key);
this._setActive(true);

@@ -800,5 +644,5 @@ } else {

off: function(type, fn) {
off: function(type, fn, _key) {
if (this._alive) {
this._subscribers.remove(type, fn);
this._subscribers.remove(type, fn, _key);
if (this._subscribers.isEmpty()) {

@@ -811,9 +655,9 @@ this._setActive(false);

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, _key) { return this.on(VALUE, fn, _key) },
onEnd: function(fn, _key) { return this.on(END, fn, _key) },
onAny: function(fn, _key) { return this.on(ANY, fn, _key) },
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, _key) { return this.off(VALUE, fn, _key) },
offEnd: function(fn, _key) { return this.off(END, fn, _key) },
offAny: function(fn, _key) { return this.off(ANY, fn, _key) }

@@ -875,5 +719,5 @@ });

on: function(type, fn) {
on: function(type, fn, _key) {
if (this._alive) {
this._subscribers.add(type, fn);
this._subscribers.add(type, fn, _key);
this._setActive(true);

@@ -899,13 +743,12 @@ }

function logCb(name, event) {
var typeStr = '<' + event.type + (event.current ? ':current' : '') + '>';
if (event.type === VALUE) {
console.log(name, typeStr, event.value);
} else {
console.log(name, typeStr);
}
}
Observable.prototype.log = function(name) {
this.onAny([logCb, null, name || this.toString()]);
name = name || this.toString();
this.onAny(function(event) {
var typeStr = '<' + event.type + (event.current ? ':current' : '') + '>';
if (event.type === VALUE) {
console.log(name, typeStr, event.value);
} else {
console.log(name, typeStr);
}
}, '__logKey__' + name);
return this;

@@ -915,3 +758,4 @@ }

Observable.prototype.offLog = function(name) {
this.offAny([logCb, null, name || this.toString()]);
name = name || this.toString();
this.offAny(null, '__logKey__' + name);
return this;

@@ -926,3 +770,3 @@ }

_init: function(args) {
this._fn = buildFn(args[0], 1);
this._fn = args[0];
var $ = this;

@@ -951,3 +795,3 @@ this._emitter = {

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

@@ -1054,2 +898,5 @@ _free: function() {

var $ = this;
this._$handleSubAny = function(event) { $._handleSubAny(event) };
this._queue = [];

@@ -1095,8 +942,9 @@ this._curSources = [];

_sub: function(obs) {
obs.onAny([this._handleSubAny, this]);
obs.onEnd([this._removeCur, this, obs]);
var $ = this;
obs.onAny(this._$handleSubAny);
obs.onEnd(function() { $._removeCur(obs) }, [this, obs]);
},
_unsub: function(obs) {
obs.offAny([this._handleSubAny, this]);
obs.offEnd([this._removeCur, this, obs]);
obs.offAny(this._$handleSubAny);
obs.offEnd(null, [this, obs]);
},

@@ -1158,2 +1006,3 @@ _handleSubAny: function(event) {

this._curSources = null;
this._$handleSubAny = null;
}

@@ -1289,5 +1138,8 @@

this._source = source;
this._fn = fn ? buildFn(fn, 1) : id;
this._fn = fn || id;
this._mainEnded = false;
this._lastCurrent = null;
var $ = this;
this._$handleMainSource = function(event) { $._handleMainSource(event) };
}

@@ -1300,3 +1152,3 @@

this._activating = true;
this._source.onAny([this._handleMainSource, this]);
this._source.onAny(this._$handleMainSource);
this._activating = false;

@@ -1306,3 +1158,3 @@ },

_AbstractPool.prototype._onDeactivation.call(this);
this._source.offAny([this._handleMainSource, this]);
this._source.offAny(this._$handleMainSource);
},

@@ -1333,2 +1185,3 @@

this._lastCurrent = null;
this._$handleMainSource = null;
}

@@ -1381,4 +1234,4 @@

this._passiveCount = passive.length;
this._combinator = combinator ? Fn(combinator) : null;
this._sources = concat(passive, active);
this._combinator = combinator ? spread(combinator, this._sources.length) : id;
this._aliveCount = 0;

@@ -1393,2 +1246,7 @@ this._currents = new Array(this._sources.length);

function bind_SampledBy_handleAny($, i) {
return function(event) { $._handleAny(i, event) };
}
inherit(SampledBy, Stream, {

@@ -1404,3 +1262,3 @@

for (i = 0; i < length; i++) {
this._sources[i].onAny([this._handleAny, this, i]);
this._sources[i].onAny(bind_SampledBy_handleAny(this, i), [this, i]);
}

@@ -1421,3 +1279,3 @@ this._activating = false;

for (i = 0; i < length; i++) {
this._sources[i].offAny([this._handleAny, this, i]);
this._sources[i].offAny(null, [this, i]);
}

@@ -1429,5 +1287,3 @@ },

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

@@ -1465,2 +1321,3 @@ }

this._currents = null;
this._combinator = null;
}

@@ -1475,3 +1332,3 @@

Observable.prototype.sampledBy = function(other, combinator) {
return Kefir.sampledBy([this], [other], combinator);
return Kefir.sampledBy([this], [other], combinator || id);
}

@@ -1533,3 +1390,3 @@

_init: function(args) {
this._handler = buildFn(args[0], 2);
this._handler = args[0];
this._forcedCurrent = false;

@@ -1560,3 +1417,3 @@ var $ = this;

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

@@ -1621,3 +1478,3 @@ _free: function() {

var withFnArgMixin = {
_init: function(args) { this._fn = buildFn(args[0], 1) },
_init: function(args) { this._fn = args[0] || id },
_free: function() { this._fn = null }

@@ -1714,3 +1571,3 @@ };

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

@@ -1738,3 +1595,3 @@ },

_init: function(args) {
this._fn = buildFn(args[0], 1);
this._fn = args[0] || id;
this._skip = true;

@@ -1766,4 +1623,4 @@ },

_init: function(args) {
this._fn = args[0] ? buildFn(args[0], 2) : defaultDiff;
this._prev = args[1];
this._fn = args[0] || defaultDiff;
this._prev = args.length > 1 ? args[1] : NOTHING;
},

@@ -1775,3 +1632,5 @@ _free: function() {

_handleValue: function(x, isCurrent) {
this._send(VALUE, this._fn(this._prev, x), isCurrent);
if (this._prev !== NOTHING) {
this._send(VALUE, this._fn(this._prev, x), isCurrent);
}
this._prev = x;

@@ -1789,4 +1648,6 @@ }

_init: function(args) {
this._fn = buildFn(args[0], 2);
this._send(VALUE, args[1], true);
this._fn = args[0];
if (args.length > 1) {
this._send(VALUE, args[1], true);
}
},

@@ -1797,3 +1658,6 @@ _free: function() {

_handleValue: function(x, isCurrent) {
this._send(VALUE, this._fn(this._current, x), isCurrent);
if (this._current !== NOTHING) {
x = this._fn(this._current, x);
}
this._send(VALUE, x, isCurrent);
}

@@ -1810,4 +1674,4 @@ }, {streamMethod: produceProperty});

_init: function(args) {
this._fn = buildFn(args[0], 2);
this._result = args[1];
this._fn = args[0];
this._result = args.length > 1 ? args[1] : NOTHING;
},

@@ -1819,6 +1683,8 @@ _free: function() {

_handleValue: function(x) {
this._result = this._fn(this._result, x);
this._result = (this._result === NOTHING) ? x : this._fn(this._result, x);
},
_handleEnd: function(__, isCurrent) {
this._send(VALUE, this._result, isCurrent);
if (this._result !== NOTHING) {
this._send(VALUE, this._result, isCurrent);
}
this._send(END, null, isCurrent);

@@ -1831,2 +1697,29 @@ }

// .mapEnd(fn)
withOneSource('mapEnd', {
_init: function(args) {
this._fn = args[0];
},
_free: function() {
this._fn = null;
},
_handleEnd: function(__, isCurrent) {
this._send(VALUE, this._fn(), isCurrent);
this._send(END, null, isCurrent);
}
});
// .skipEnd()
withOneSource('skipEnd', {
_handleEnd: function(__, isCurrent) {}
});
// .slidingWindow(max[, min])

@@ -2025,3 +1918,3 @@

Stream.call(this);
this._fn = buildFn(fn, 1);
this._fn = fn;
this._unsubscribe = null;

@@ -2036,3 +1929,2 @@ }

var $ = this
, unsub
, isCurrent = true

@@ -2043,7 +1935,4 @@ , emitter = {

};
unsub = this._fn(emitter);
this._unsubscribe = this._fn(emitter) || null;
isCurrent = false;
if (unsub) {
this._unsubscribe = buildFn(unsub, 0);
}
},

@@ -2181,3 +2070,2 @@ _onDeactivation: function() {

Observable.prototype.tap = function(fn) {
fn = buildFn(fn, 1);
return this.map(function(x) {

@@ -2238,3 +2126,2 @@ fn(x);

Kefir.fromCallback = function(callbackConsumer) {
callbackConsumer = buildFn(callbackConsumer, 1);
var called = false;

@@ -2255,2 +2142,18 @@ return Kefir.fromBinder(function(emitter) {

// ._fromEvent
Kefir._fromEvent = function(sub, unsub, transformer) {
return Kefir.fromBinder(function(emitter) {
var handler = transformer ? function() {
emitter.emit(apply(transformer, this, arguments));
} : emitter.emit;
sub(handler);
return function() { unsub(handler) };
});
}
// .fromEvent

@@ -2264,13 +2167,5 @@

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);
for (var i = 0; i < subUnsubPairs.length; i++) {

@@ -2289,7 +2184,7 @@ pair = subUnsubPairs[i];

return Kefir.fromBinder(function(emitter) {
var handler = transformer ? wrapEmitter(emitter, transformer) : emitter.emit;
target[sub](eventName, handler);
return [unsub, target, eventName, handler];
}).setName('fromEvent');
return Kefir._fromEvent(
function(handler) { target[sub](eventName, handler) },
function(handler) { target[unsub](eventName, handler) },
transformer
).setName('fromEvent');
}

@@ -2296,0 +2191,0 @@

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

/*! Kefir.js v0.3.0
/*! Kefir.js v0.4.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){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);
!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);
//# sourceMappingURL=kefir.min.js.map
{
"name": "kefir",
"version": "0.3.0",
"description": "FRP library for JavaScript inspired by Bacon.js and RxJS with focus on high performance and low memory consumption",
"version": "0.4.0",
"description": "Reactive Programming library for JavaScript inspired by Bacon.js and RxJS with focus on high performance and low memory usage",
"main": "dist/kefir.js",

@@ -32,6 +32,6 @@ "scripts": {

"devDependencies": {
"baconjs": "~0.7.30",
"baconjs": "^0.7.35",
"benchmark": "~1.0.0",
"coffee-script": "~1.8.0",
"coffeeify": "~0.7.0",
"coffeeify": "^1.0.0",
"grunt": "~0.4.5",

@@ -55,3 +55,3 @@ "grunt-bower-task": "~0.4.0",

"shelljs": "~0.3.0",
"sinon": "~1.11.1",
"sinon": "^1.12.1",
"transducers-js": "~0.4.135",

@@ -58,0 +58,0 @@ "transducers.js": "~0.2.3"

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

Kefir — is an FRP (functional reactive programming) library for JavaScript
Kefir — is an Reactive Programming library for JavaScript
inspired by [Bacon.js](https://github.com/baconjs/bacon.js)

@@ -43,1 +43,10 @@ and [RxJS](https://github.com/Reactive-Extensions/RxJS)

coffee test/perf/perf-specs/[some spec].coffee
# SemVer
Kefir follows [Semantic Versioning](http://semver.org/).
But it still before `1.0.0`, and for now version number follows this rules:
* If major breaking changes introduced, then MINOR (middle) number is incremented
* If there are no breaking changes, or only minor, which probably won't affect anybody, then PATCH (last) number is incremented

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc