Comparing version 0.2.4 to 0.2.5
{ | ||
"name": "kefir", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"homepage": "https://github.com/pozadi/kefir", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -1,2 +0,2 @@ | ||
/*! kefir addon - 0.2.4 | ||
/*! kefir addon - 0.2.5 | ||
* https://github.com/pozadi/kefir | ||
@@ -12,3 +12,3 @@ */ | ||
$.fn.asKefirStream = function(event, selector, transformer) { | ||
$.fn.asKefirStream = function(eventName, selector, transformer) { | ||
var $el = this; | ||
@@ -20,9 +20,14 @@ if (transformer == null && selector != null && 'string' !== typeof selector) { | ||
transformer = transformer && Kefir.Fn(transformer); | ||
return Kefir.fromBinder(function(send) { | ||
function onEvent(e) { | ||
send('value', transformer ? transformer.apply(arguments) : e); | ||
return Kefir.fromBinder(function(emitter) { | ||
var onEvent; | ||
if (transformer) { | ||
onEvent = function() { | ||
emitter.emit(transformer.applyWithContext(this, arguments)); | ||
}; | ||
} else { | ||
onEvent = emitter.emit; | ||
} | ||
$el.on(event, selector, onEvent); | ||
return function() { $el.off(event, selector, onEvent) } | ||
}); | ||
$el.on(eventName, selector, onEvent); | ||
return ['off', $el, eventName, selector, onEvent]; | ||
}).setName('asKefirStream'); | ||
} | ||
@@ -29,0 +34,0 @@ |
@@ -1,6 +0,6 @@ | ||
/*! kefir addon - 0.2.4 | ||
/*! kefir addon - 0.2.5 | ||
* 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){function f(b){a("value",d?d.apply(arguments):b)}return e.on(b,c,f),function(){e.off(b,c,f)}})}}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),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")}}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 - 0.2.4 | ||
/*! kefir - 0.2.5 | ||
* https://github.com/pozadi/kefir | ||
@@ -27,20 +27,14 @@ */ | ||
function extend(/*target, mixin1, mixin2...*/) { | ||
function extend(target /*, mixin1, mixin2...*/) { | ||
var length = arguments.length | ||
, result, i, prop; | ||
if (length === 1) { | ||
return arguments[0]; | ||
} | ||
result = arguments[0]; | ||
, i, prop; | ||
for (i = 1; i < length; i++) { | ||
for (prop in arguments[i]) { | ||
if(own(arguments[i], prop)) { | ||
result[prop] = arguments[i][prop]; | ||
} | ||
target[prop] = arguments[i][prop]; | ||
} | ||
} | ||
return result; | ||
return target; | ||
} | ||
function inherit(Child, Parent/*[, mixin1, mixin2, ...]*/) { | ||
function inherit(Child, Parent /*, mixin1, mixin2...*/) { | ||
var length = arguments.length | ||
@@ -60,3 +54,3 @@ , i; | ||
} | ||
return toArray(args); | ||
return cloneArray(args); | ||
} | ||
@@ -76,93 +70,104 @@ | ||
function call(fn, context, args) { | ||
if (context != null) { | ||
if (!args || args.length === 0) { | ||
return fn.call(context); | ||
} else { | ||
return fn.apply(context, args); | ||
function apply(fn, c, a) { | ||
var aLength = a ? a.length : 0; | ||
if (c == null) { | ||
switch (aLength) { | ||
case 0: return fn(); | ||
case 1: return fn(a[0]); | ||
case 2: return fn(a[0], a[1]); | ||
case 3: return fn(a[0], a[1], a[2]); | ||
case 4: return fn(a[0], a[1], a[2], a[3]); | ||
default: return fn.apply(null, a); | ||
} | ||
} else { | ||
if (!args || args.length === 0) { | ||
return fn(); | ||
switch (aLength) { | ||
case 0: return fn.call(c); | ||
default: return fn.apply(c, a); | ||
} | ||
switch (args.length) { | ||
case 1: return fn(args[0]); | ||
case 2: return fn(args[0], args[1]); | ||
case 3: return fn(args[0], args[1], args[2]); | ||
} | ||
return fn.apply(null, args); | ||
} | ||
} | ||
function bind(fn, c, a, length) { | ||
if (c == null) { | ||
if (a.length === 0) { | ||
return fn; | ||
} | ||
switch (length) { | ||
case 0: | ||
switch (a.length) { | ||
case 1: return function() {return fn(a[0])} | ||
case 2: return function() {return fn(a[0], a[1])} | ||
case 3: return function() {return fn(a[0], a[1], a[3])} | ||
case 4: return function() {return fn(a[0], a[1], a[3], a[4])} | ||
default: return function() {return fn.apply(null, a)} | ||
} | ||
break; | ||
case 1: | ||
switch (a.length) { | ||
case 0: return function(b) {return fn(b)} | ||
case 1: return function(b) {return fn(a[0], b)} | ||
case 2: return function(b) {return fn(a[0], a[1], b)} | ||
case 3: return function(b) {return fn(a[0], a[1], a[3], b)} | ||
case 4: return function(b) {return fn(a[0], a[1], a[3], a[4], b)} | ||
default: return function(b) {return fn.apply(null, concat(a, [b]))} | ||
} | ||
break; | ||
case 2: | ||
switch (a.length) { | ||
case 0: return function(b, d) {return fn(b, d)} | ||
case 1: return function(b, d) {return fn(a[0], b, d)} | ||
case 2: return function(b, d) {return fn(a[0], a[1], b, d)} | ||
case 3: return function(b, d) {return fn(a[0], a[1], a[3], b, d)} | ||
case 4: return function(b, d) {return fn(a[0], a[1], a[3], a[4], b, d)} | ||
default: return function(b, d) {return fn.apply(null, concat(a, [b, d]))} | ||
} | ||
break; | ||
default: return function() {return fn.apply(null, concat(a, arguments))} | ||
} | ||
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 { | ||
switch (length) { | ||
case 0: | ||
switch (a.length) { | ||
case 0: return function() {return fn.call(c)} | ||
case 1: return function() {return fn.call(c, a[0])} | ||
case 2: return function() {return fn.call(c, a[0], a[1])} | ||
case 3: return function() {return fn.call(c, a[0], a[1], a[3])} | ||
case 4: return function() {return fn.call(c, a[0], a[1], a[3], a[4])} | ||
default: return function() {return fn.apply(c, a)} | ||
} | ||
break; | ||
case 1: | ||
switch (a.length) { | ||
case 0: return function(b) {return fn.call(c, b)} | ||
case 1: return function(b) {return fn.call(c, a[0], b)} | ||
case 2: return function(b) {return fn.call(c, a[0], a[1], b)} | ||
case 3: return function(b) {return fn.call(c, a[0], a[1], a[3], b)} | ||
case 4: return function(b) {return fn.call(c, a[0], a[1], a[3], a[4], b)} | ||
default: return function(b) {return fn.apply(c, concat(a, [b]))} | ||
} | ||
break; | ||
case 2: | ||
switch (a.length) { | ||
case 0: return function(b, d) {return fn.call(c, b, d)} | ||
case 1: return function(b, d) {return fn.call(c, a[0], b, d)} | ||
case 2: return function(b, d) {return fn.call(c, a[0], a[1], b, d)} | ||
case 3: return function(b, d) {return fn.call(c, a[0], a[1], a[3], b, d)} | ||
case 4: return function(b, d) {return fn.call(c, a[0], a[1], a[3], a[4], b, d)} | ||
default: return function(b, d) {return fn.apply(c, concat(a, [b, d]))} | ||
} | ||
break; | ||
default: return function() {return fn.apply(c, concat(a, arguments))} | ||
} | ||
return bindWithContext(fn, context, args, boundFunctionLength); | ||
} | ||
@@ -232,10 +237,2 @@ } | ||
function toArray(arrayLike) { | ||
if (isArray(arrayLike)) { | ||
return arrayLike; | ||
} else { | ||
return cloneArray(arrayLike); | ||
} | ||
} | ||
var now = Date.now ? | ||
@@ -315,4 +312,4 @@ function() { return Date.now() } : | ||
this._intervalId = null; | ||
var _this = this; | ||
this._bindedOnTick = function() { _this._onTick() } | ||
var $ = this; | ||
this._$onTick = function() { $._onTick() } | ||
this._init(args); | ||
@@ -331,3 +328,3 @@ } | ||
_onActivation: function() { | ||
this._intervalId = setInterval(this._bindedOnTick, this._wait); | ||
this._intervalId = setInterval(this._$onTick, this._wait); | ||
}, | ||
@@ -343,3 +340,3 @@ _onDeactivation: function() { | ||
Stream.prototype._clear.call(this); | ||
this._bindedOnTick = null; | ||
this._$onTick = null; | ||
this._free(); | ||
@@ -398,36 +395,25 @@ } | ||
function AnonymousStream(source, args) { | ||
Stream.call(this); | ||
this._source = source; | ||
this._name = source._name + '.' + name; | ||
this._init(args); | ||
} | ||
inherit(AnonymousStream, Stream, { | ||
_clear: function() { | ||
Stream.prototype._clear.call(this); | ||
this._source = null; | ||
this._free(); | ||
function buildClass(BaseClass) { | ||
function AnonymousObservable(source, args) { | ||
BaseClass.call(this); | ||
this._source = source; | ||
this._name = source._name + '.' + name; | ||
this._init(args); | ||
} | ||
}, mixin); | ||
inherit(AnonymousObservable, BaseClass, { | ||
_clear: function() { | ||
BaseClass.prototype._clear.call(this); | ||
this._source = null; | ||
this._free(); | ||
} | ||
}, mixin); | ||
function AnonymousProperty(source, args) { | ||
Property.call(this); | ||
this._source = source; | ||
this._name = source._name + '.' + name; | ||
this._init(args); | ||
return AnonymousObservable; | ||
} | ||
inherit(AnonymousProperty, Property, { | ||
_clear: function() { | ||
Property.prototype._clear.call(this); | ||
this._source = null; | ||
this._free(); | ||
} | ||
}, mixin); | ||
var AnonymousStream = buildClass(Stream); | ||
var AnonymousProperty = buildClass(Property); | ||
if (options.streamMethod) { | ||
@@ -453,15 +439,24 @@ Stream.prototype[name] = options.streamMethod(AnonymousStream, AnonymousProperty); | ||
function _Fn(fnMeta, length) { | ||
var fn = getFn(fnMeta[0], fnMeta[1]); | ||
var context = fnMeta[1]; | ||
var args = rest(fnMeta, 2, []); | ||
this.fn = fn; | ||
this.context = context; | ||
this.args = args; | ||
this.invoke = bind(fn, context, args, length); | ||
this.context = (fnMeta[1] == null) ? null : fnMeta[1]; | ||
this.fn = getFn(fnMeta[0], this.context); | ||
this.args = rest(fnMeta, 2, []); | ||
this.invoke = bind(this.fn, this.context, this.args, length); | ||
} | ||
_Fn.prototype.apply = function(args) { | ||
return call(this.invoke, null, args); | ||
return apply(this.invoke, null, args); | ||
} | ||
_Fn.prototype.applyWithContext = function(context, args) { | ||
if (this.context === null) { | ||
if (this.args.length === 0) { | ||
return apply(this.fn, context, args); | ||
} else { | ||
return apply(this.fn, context, concat(this.args, args)); | ||
} | ||
} else { | ||
return this.apply(args); | ||
} | ||
} | ||
function Fn(fnMeta, length) { | ||
@@ -725,3 +720,3 @@ if (fnMeta instanceof _Fn) { | ||
function logCb(name, event) { | ||
var typeStr = '<' + event.type + (event.isCurrent ? ':current' : '') + '>'; | ||
var typeStr = '<' + event.type + (event.current ? ':current' : '') + '>'; | ||
if (event.type === 'value') { | ||
@@ -751,11 +746,14 @@ console.log(name, typeStr, event.value); | ||
this._fn = Fn(args[0], 1); | ||
var _this = this; | ||
this._bindedSend = function(type, x) { _this._send(type, x) } | ||
var $ = this; | ||
this._emitter = { | ||
emit: function(x) { $._send('value', x) }, | ||
end: function() { $._send('end') } | ||
} | ||
}, | ||
_free: function() { | ||
this._fn = null; | ||
this._bindedSend = null; | ||
this._emitter = null; | ||
}, | ||
_onTick: function() { | ||
this._fn.invoke(this._bindedSend); | ||
this._fn.invoke(this._emitter); | ||
} | ||
@@ -1240,14 +1238,17 @@ }); | ||
_init: function(args) { | ||
var _this = this; | ||
this._handler = Fn(args[0], 2); | ||
this._forcedCurrent = false; | ||
this._bindedSend = function(type, x) { _this._send(type, x, _this._forcedCurrent) } | ||
var $ = this; | ||
this._emitter = { | ||
emit: function(x) { $._send('value', x, $._forcedCurrent) }, | ||
end: function() { $._send('end', null, $._forcedCurrent) } | ||
} | ||
}, | ||
_free: function() { | ||
this._handler = null; | ||
this._bindedSend = null; | ||
this._emitter = null; | ||
}, | ||
_handleAny: function(event) { | ||
this._forcedCurrent = event.current; | ||
this._handler.invoke(this._bindedSend, event); | ||
this._handler.invoke(this._emitter, event); | ||
this._forcedCurrent = false; | ||
@@ -1260,16 +1261,15 @@ } | ||
var withFnArgMixin = { | ||
_init: function(args) { this._fn = Fn(args[0], 1) }, | ||
_free: function() { this._fn = null } | ||
}; | ||
// .map(fn) | ||
withOneSource('map', { | ||
_init: function(args) { | ||
this._fn = Fn(args[0], 1); | ||
}, | ||
_free: function() { | ||
this._fn = null; | ||
}, | ||
withOneSource('map', extend({ | ||
_handleValue: function(x, isCurrent) { | ||
this._send('value', this._fn.invoke(x), isCurrent); | ||
} | ||
}); | ||
}, withFnArgMixin)); | ||
@@ -1282,9 +1282,3 @@ | ||
withOneSource('filter', { | ||
_init: function(args) { | ||
this._fn = Fn(args[0], 1); | ||
}, | ||
_free: function() { | ||
this._fn = null; | ||
}, | ||
withOneSource('filter', extend({ | ||
_handleValue: function(x, isCurrent) { | ||
@@ -1295,3 +1289,3 @@ if (this._fn.invoke(x)) { | ||
} | ||
}); | ||
}, withFnArgMixin)); | ||
@@ -1304,9 +1298,3 @@ | ||
withOneSource('takeWhile', { | ||
_init: function(args) { | ||
this._fn = Fn(args[0], 1); | ||
}, | ||
_free: function() { | ||
this._fn = null; | ||
}, | ||
withOneSource('takeWhile', extend({ | ||
_handleValue: function(x, isCurrent) { | ||
@@ -1319,3 +1307,3 @@ if (this._fn.invoke(x)) { | ||
} | ||
}); | ||
}, withFnArgMixin)); | ||
@@ -1368,11 +1356,5 @@ | ||
function strictlyEqual(a, b) { return a === b } | ||
withOneSource('skipDuplicates', { | ||
_init: function(args) { | ||
if (args.length > 0) { | ||
this._fn = Fn(args[0], 2); | ||
} else { | ||
this._fn = Fn(strictlyEqual); | ||
} | ||
this._fn = args[0] && Fn(args[0], 2); | ||
this._prev = NOTHING; | ||
@@ -1384,7 +1366,10 @@ }, | ||
}, | ||
_isEqual: function(a, b) { | ||
return this._fn ? this._fn.invoke(a, b) : a === b; | ||
}, | ||
_handleValue: function(x, isCurrent) { | ||
if (this._prev === NOTHING || !this._fn.invoke(this._prev, x)) { | ||
if (this._prev === NOTHING || !this._isEqual(this._prev, x)) { | ||
this._send('value', x, isCurrent); | ||
this._prev = x; | ||
} | ||
this._prev = x; | ||
} | ||
@@ -1499,8 +1484,8 @@ }); | ||
this._lastCallTime = 0; | ||
var _this = this; | ||
this._makeTrailingCallBinded = function() { _this._makeTrailingCall() }; | ||
var $ = this; | ||
this._$makeTrailingCall = function() { $._makeTrailingCall() }; | ||
}, | ||
_free: function() { | ||
this._trailingCallValue = null; | ||
this._makeTrailingCallBinded = null; | ||
this._$makeTrailingCall = null; | ||
}, | ||
@@ -1510,16 +1495,16 @@ _handleValue: function(x, isCurrent) { | ||
this._send('value', x, isCurrent); | ||
return; | ||
} else { | ||
var curTime = now(); | ||
if (this._lastCallTime === 0 && !this._leading) { | ||
this._lastCallTime = curTime; | ||
} | ||
var remaining = this._wait - (curTime - this._lastCallTime); | ||
if (remaining <= 0) { | ||
this._cancelTralingCall(); | ||
this._lastCallTime = curTime; | ||
this._send('value', x); | ||
} else if (this._trailing) { | ||
this._scheduleTralingCall(x, remaining); | ||
} | ||
} | ||
var curTime = now(); | ||
if (this._lastCallTime === 0 && !this._leading) { | ||
this._lastCallTime = curTime; | ||
} | ||
var remaining = this._wait - (curTime - this._lastCallTime); | ||
if (remaining <= 0) { | ||
this._cancelTralingCall(); | ||
this._lastCallTime = curTime; | ||
this._send('value', x); | ||
} else if (this._trailing) { | ||
this._scheduleTralingCall(x, remaining); | ||
} | ||
}, | ||
@@ -1529,8 +1514,8 @@ _handleEnd: function(__, isCurrent) { | ||
this._send('end', null, isCurrent); | ||
return; | ||
} | ||
if (this._trailingCallTimeoutId) { | ||
this._endAfterTrailingCall = true; | ||
} else { | ||
this._send('end'); | ||
if (this._trailingCallTimeoutId) { | ||
this._endAfterTrailingCall = true; | ||
} else { | ||
this._send('end'); | ||
} | ||
} | ||
@@ -1543,3 +1528,3 @@ }, | ||
this._trailingCallValue = value; | ||
this._trailingCallTimeoutId = setTimeout(this._makeTrailingCallBinded, wait); | ||
this._trailingCallTimeoutId = setTimeout(this._$makeTrailingCall, wait); | ||
}, | ||
@@ -1573,10 +1558,19 @@ _cancelTralingCall: function() { | ||
this._wait = args[0]; | ||
this._buff = []; | ||
var $ = this; | ||
this._shiftBuff = function() { | ||
$._send('value', $._buff.shift()); | ||
} | ||
}, | ||
_free: function() { | ||
this._buff = null; | ||
this._shiftBuff = null; | ||
}, | ||
_handleValue: function(x, isCurrent) { | ||
if (isCurrent) { | ||
this._send('value', x, isCurrent); | ||
return; | ||
} else { | ||
this._buff.push(x); | ||
setTimeout(this._shiftBuff, this._wait); | ||
} | ||
var _this = this; | ||
setTimeout(function() { _this._send('value', x) }, this._wait); | ||
}, | ||
@@ -1586,6 +1580,6 @@ _handleEnd: function(__, isCurrent) { | ||
this._send('end', null, isCurrent); | ||
return; | ||
} else { | ||
var $ = this; | ||
setTimeout(function() { $._send('end') }, this._wait); | ||
} | ||
var _this = this; | ||
setTimeout(function() { _this._send('end') }, this._wait); | ||
} | ||
@@ -1607,12 +1601,20 @@ }); | ||
_onActivation: function() { | ||
var _this = this; | ||
var isCurrent = true; | ||
this._unsubscribe = this._fn.invoke(function(type, x) { _this._send(type, x, isCurrent) }); | ||
var $ = this | ||
, unsub | ||
, isCurrent = true | ||
, emitter = { | ||
emit: function(x) { $._send('value', x, isCurrent) }, | ||
end: function() { $._send('end', null, isCurrent) } | ||
}; | ||
unsub = this._fn.invoke(emitter); | ||
isCurrent = false; | ||
if (unsub) { | ||
this._unsubscribe = Fn(unsub, 0); | ||
} | ||
}, | ||
_onDeactivation: function() { | ||
if (isFn(this._unsubscribe)) { | ||
this._unsubscribe(); | ||
if (this._unsubscribe !== null) { | ||
this._unsubscribe.invoke(); | ||
this._unsubscribe = null; | ||
} | ||
this._unsubscribe = null; | ||
}, | ||
@@ -1738,3 +1740,3 @@ | ||
return this.map(args ? | ||
function(x) { return call(x[methodName], x, args) } : | ||
function(x) { return apply(x[methodName], x, args) } : | ||
function(x) { return x[methodName]() } | ||
@@ -1793,3 +1795,3 @@ ).setName(this, 'invoke'); | ||
Observable.prototype.not = function() { | ||
return this.map(function(x) { return !x }).setName('not'); | ||
return this.map(function(x) { return !x }).setName(this, 'not'); | ||
} | ||
@@ -1815,7 +1817,7 @@ | ||
.sampledBy(this) | ||
.withHandler(function(send, e) { | ||
.withHandler(function(emitter, e) { | ||
if (e.type === 'end') { | ||
send('end'); | ||
emitter.end(); | ||
} else if (e.value[0]) { | ||
send('value', e.value[1]); | ||
emitter.emit(e.value[1]); | ||
} | ||
@@ -1822,0 +1824,0 @@ }) |
@@ -1,6 +0,6 @@ | ||
/*! kefir - 0.2.4 | ||
/*! kefir - 0.2.5 | ||
* https://github.com/pozadi/kefir | ||
*/ | ||
!function(a){"use strict";function b(a,b,c){return a&&b in a?a[b]:c}function c(a,b){return Object.prototype.hasOwnProperty.call(a,b)}function d(a){var b=function(){};return b.prototype=a,new b}function e(){var a,b,d,e=arguments.length;if(1===e)return arguments[0];for(a=arguments[0],b=1;e>b;b++)for(d in arguments[b])c(arguments[b],d)&&(a[d]=arguments[b][d]);return a}function f(a,b){var c,f=arguments.length;for(a.prototype=d(b.prototype),a.prototype.constructor=a,c=2;f>c;c++)e(a.prototype,arguments[c]);return a}function g(a){return 1===a.length&&S(a[0])?a[0]:p(a)}function h(a,b){if(q(a))return a;if(null!=b&&q(b[a]))return b[a];throw new Error("not a function: "+a+" in "+b)}function i(a,b,c){if(null!=b)return c&&0!==c.length?a.apply(b,c):a.call(b);if(!c||0===c.length)return a();switch(c.length){case 1:return a(c[0]);case 2:return a(c[0],c[1]);case 3:return a(c[0],c[1],c[2])}return a.apply(null,c)}function j(a,b,c,d){if(null==b){if(0===c.length)return a;switch(d){case 0:switch(c.length){case 1:return function(){return a(c[0])};case 2:return function(){return a(c[0],c[1])};case 3:return function(){return a(c[0],c[1],c[3])};case 4:return function(){return a(c[0],c[1],c[3],c[4])};default:return function(){return a.apply(null,c)}}break;case 1:switch(c.length){case 0:return function(b){return a(b)};case 1:return function(b){return a(c[0],b)};case 2:return function(b){return a(c[0],c[1],b)};case 3:return function(b){return a(c[0],c[1],c[3],b)};case 4:return function(b){return a(c[0],c[1],c[3],c[4],b)};default:return function(b){return a.apply(null,k(c,[b]))}}break;case 2:switch(c.length){case 0:return function(b,c){return a(b,c)};case 1:return function(b,d){return a(c[0],b,d)};case 2:return function(b,d){return a(c[0],c[1],b,d)};case 3:return function(b,d){return a(c[0],c[1],c[3],b,d)};case 4:return function(b,d){return a(c[0],c[1],c[3],c[4],b,d)};default:return function(b,d){return a.apply(null,k(c,[b,d]))}}break;default:return function(){return a.apply(null,k(c,arguments))}}}else switch(d){case 0:switch(c.length){case 0:return function(){return a.call(b)};case 1:return function(){return a.call(b,c[0])};case 2:return function(){return a.call(b,c[0],c[1])};case 3:return function(){return a.call(b,c[0],c[1],c[3])};case 4:return function(){return a.call(b,c[0],c[1],c[3],c[4])};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(d){return a.call(b,c[0],d)};case 2:return function(d){return a.call(b,c[0],c[1],d)};case 3:return function(d){return a.call(b,c[0],c[1],c[3],d)};case 4:return function(d){return a.call(b,c[0],c[1],c[3],c[4],d)};default:return function(d){return a.apply(b,k(c,[d]))}}break;case 2:switch(c.length){case 0:return function(c,d){return a.call(b,c,d)};case 1:return function(d,e){return a.call(b,c[0],d,e)};case 2:return function(d,e){return a.call(b,c[0],c[1],d,e)};case 3:return function(d,e){return a.call(b,c[0],c[1],c[3],d,e)};case 4:return function(d,e){return a.call(b,c[0],c[1],c[3],c[4],d,e)};default:return function(d,e){return a.apply(b,k(c,[d,e]))}}break;default:return function(){return a.apply(b,k(c,arguments))}}}function k(a,b){var c,d,e=new Array(a.length+b.length),f=0;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 l(a){var b,c=a.length,d=new Array(c);for(b=0;c>b;b++)d[b]=a[b];return d}function m(a,b){var c,d=a.length;for(c=0;d>c;c++)a[c]=b}function n(a,b){var c,d=a.length;for(c=0;d>c;c++)if(a[c]===b)return!0;return!1}function o(a,b,c){return a.length>b?Array.prototype.slice.call(a,b):c}function p(a){return S(a)?a:l(a)}function q(a){return"function"==typeof a}function r(a){return S(a)||T(a)}function s(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 t(){for(var a=0;a<arguments.length;a++)if(!arguments[a])return arguments[a];return arguments[a-1]}function u(){for(var a=0;a<arguments.length;a++)if(arguments[a])return arguments[a];return arguments[a-1]}function v(a,b){function c(a,b){B.call(this),this._wait=a,this._intervalId=null;var c=this;this._bindedOnTick=function(){c._onTick()},this._init(b)}f(c,B,{_name:a,_init:function(){},_free:function(){},_onTick:function(){},_onActivation:function(){this._intervalId=setInterval(this._bindedOnTick,this._wait)},_onDeactivation:function(){null!==this._intervalId&&(clearInterval(this._intervalId),this._intervalId=null)},_clear:function(){B.prototype._clear.call(this),this._bindedOnTick=null,this._free()}},b),U[a]=function(a){return new c(a,o(arguments,1,[]))}}function w(a,b,c){function d(b,c){B.call(this),this._source=b,this._name=b._name+"."+a,this._init(c)}function g(b,c){C.call(this),this._source=b,this._name=b._name+"."+a,this._init(c)}c=e({streamMethod:function(a){return function(){return new a(this,arguments)}},propertyMethod:function(a,b){return function(){return new b(this,arguments)}}},c||{}),b=e({_init:function(){},_free:function(){},_handleValue:function(a,b){this._send("value",a,b)},_handleEnd:function(a,b){this._send("end",null,b)},_onActivationHook:function(){},_onDeactivationHook:function(){},_handleAny:function(a){switch(a.type){case"value":this._handleValue(a.value,a.current);break;case"end":this._handleEnd(a.value,a.current)}},_onActivation:function(){this._onActivationHook(),this._source.onAny([this._handleAny,this])},_onDeactivation:function(){this._onDeactivationHook(),this._source.offAny([this._handleAny,this])}},b||{}),f(d,B,{_clear:function(){B.prototype._clear.call(this),this._source=null,this._free()}},b),f(g,C,{_clear:function(){C.prototype._clear.call(this),this._source=null,this._free()}},b),c.streamMethod&&(B.prototype[a]=c.streamMethod(d,g)),c.propertyMethod&&(C.prototype[a]=c.propertyMethod(d,g))}function x(a,b){var c=h(a[0],a[1]),d=a[1],e=o(a,2,[]);this.fn=c,this.context=d,this.args=e,this.invoke=j(c,d,e,b)}function y(a,b){if(a instanceof x)return a;if(null==b&&(b=100),q(a))return new x([a],b);if(r(a))return new x(a,b);throw new Error("can't convert to Fn "+a)}function z(){this.value=[],this.end=[],this.any=[],this.total=0}function A(){this._subscribers=new z,this._active=!1,this._alive=!0}function B(){A.call(this)}function C(){A.call(this),this._current=Q}function D(a,b){var c="<"+b.type+(b.isCurrent?":current":"")+">";"value"===b.type?console.log(a,c,b.value):console.log(a,c)}function E(a){B.call(this),0===a.length?this._send("end"):(this._sources=a,this._aliveCount=0)}function F(a,b,c){B.call(this),0===b.length?this._send("end"):(this._passiveCount=a.length,this._combinator=c?y(c):null,this._sources=k(a,b),this._aliveCount=0,this._currents=new Array(this._sources.length),m(this._currents,Q),this._activating=!1,this._emitAfterActivation=!1,this._endAfterActivation=!1)}function G(){B.call(this),this._sources=[]}function H(){G.call(this)}function I(a,b){G.call(this),this._source=a,this._name=a._name+".flatMap",this._fn=b?y(b,1):null,this._mainEnded=!1,this._lastValue=null}function J(a){return function(){return new a(this,arguments)}}function K(a,b){return function(){return new b(this,arguments)}}function L(a,b){return a===b}function M(a){B.call(this),this._fn=y(a,1),this._unsubscribe=null}function N(){B.call(this)}function O(a){C.call(this),this._send("value",a),this._send("end")}function P(a){B.call(this),this._value=a}var Q=["<nothing>"],R=Date.now?function(){return Date.now()}:function(){return(new Date).getTime()},S=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},T=function(a){return"[object Arguments]"===Object.prototype.toString.call(a)};T(arguments)||(T=function(a){return!(!a||!c(a,"callee"))});var U={};x.prototype.apply=function(a){return i(this.invoke,null,a)},y.isEqual=function(a,b){return a===b?!0:(a=y(a,null,!0),b=y(b,null,!0),a.fn===b.fn&&a.context===b.context&&s(a.args,b.args))},U.Fn=y,e(z.prototype,{add:function(a,b){var c="end"===a?0:1;this[a].push(y(b,c,!0)),this.total++},remove:function(a,b){var c,d=this[a],e=d.length;for(b=y(b),c=0;e>c;c++)if(y.isEqual(d[c],b))return d.splice(c,1),void this.total--},call:function(a,b){var c,d=this[a],e=d.length;if(0!==e)if(1===e)"end"===a?d[0].invoke():d[0].invoke(b);else for(d=l(d),c=0;e>c;c++)"end"===a?d[c].invoke():d[c].invoke(b)},isEmpty:function(){return 0===this.total}}),U.Observable=A,e(A.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.call(a,b),this._subscribers.call("any",{type:a,value:b,current:!!c}),"end"===a&&this._clear())},_callWithCurrent:function(a,b,c,d){b=y(b),a===c?"value"===a?b.invoke(d):b.invoke():"any"===a&&b.invoke({type:c,value:d,current:!0})},on:function(a,b){return this._alive?(this._subscribers.add(a,b),this._setActive(!0)):this._callWithCurrent(a,b,"end"),this},off:function(a,b){return this._alive&&(this._subscribers.remove(a,b),this._subscribers.isEmpty()&&this._setActive(!1)),this},onValue:function(a){this.on("value",a)},onEnd:function(a){this.on("end",a)},onAny:function(a){this.on("any",a)},offValue:function(a){this.off("value",a)},offEnd:function(a){this.off("end",a)},offAny:function(a){this.off("any",a)}}),A.prototype.toString=function(){return"["+this._name+"]"},U.Stream=B,f(B,A,{_name:"stream"}),U.Property=C,f(C,A,{_name:"property",_send:function(a,b,c){this._alive&&(c||(this._subscribers.call(a,b),this._subscribers.call("any",{type:a,value:b,current:!1})),"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!==Q&&this._callWithCurrent(a,b,"value",this._current),this._alive||this._callWithCurrent(a,b,"end"),this}}),A.prototype.log=function(a){return this.onAny([D,null,a||this.toString()]),this},A.prototype.offLog=function(a){return this.offAny([D,null,a||this.toString()]),this},v("withInterval",{_init:function(a){this._fn=y(a[0],1);var b=this;this._bindedSend=function(a,c){b._send(a,c)}},_free:function(){this._fn=null,this._bindedSend=null},_onTick:function(){this._fn.invoke(this._bindedSend)}}),v("fromPoll",{_init:function(a){this._fn=y(a[0],0)},_free:function(){this._fn=null},_onTick:function(){this._send("value",this._fn.invoke())}}),v("interval",{_init:function(a){this._x=a[0]},_free:function(){this._x=null},_onTick:function(){this._send("value",this._x)}}),v("sequentially",{_init:function(a){this._xs=l(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())}}}),v("repeatedly",{_init:function(a){this._xs=l(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]))}}),v("later",{_init:function(a){this._x=a[0]},_free:function(){this._x=null},_onTick:function(){this._send("value",this._x),this._send("end")}}),f(E,B,{_name:"merge",_onActivation:function(){var a,b=this._sources.length;for(this._aliveCount=b,a=0;b>a;a++)this._sources[a].onAny([this._handleAny,this])},_onDeactivation:function(){var a,b=this._sources.length;for(a=0;b>a;a++)this._sources[a].offAny([this._handleAny,this])},_handleAny:function(a){"value"===a.type?this._send("value",a.value,a.current):(this._aliveCount--,0===this._aliveCount&&this._send("end",null,a.current))},_clear:function(){B.prototype._clear.call(this),this._sources=null}}),U.merge=function(){return new E(g(arguments))},A.prototype.merge=function(a){return U.merge([this,a])},f(F,B,{_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(!n(this._currents,Q)){var b=l(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(){B.prototype._clear.call(this),this._sources=null,this._currents=null}}),U.sampledBy=function(a,b,c){return new F(a,b,c)},A.prototype.sampledBy=function(a,b){return U.sampledBy([this],[a],b)},U.combine=function(a,b){var c=new F([],a,b);return c._name="combine",c},A.prototype.combine=function(a,b){return U.combine([this,a],b)},f(G,B,{_name:"abstractPool",_sub:function(a){a.onAny([this._handleSubAny,this]),a.onEnd([this._remove,this,a])},_unsub:function(a){a.offAny([this._handleSubAny,this]),a.offEnd([this._remove,this,a])},_handleSubAny:function(a){"value"===a.type&&this._send("value",a.value,a.current)},_add:function(a){this._sources.push(a),this._active&&this._sub(a)},_remove:function(a){this._active&&this._unsub(a);for(var b=0;b<this._sources.length;b++)if(this._sources[b]===a)return void this._sources.splice(b,1)},_onActivation:function(){for(var a=l(this._sources),b=0;b<a.length;b++)this._sub(a[b])},_onDeactivation:function(){for(var a=0;a<this._sources.length;a++)this._unsub(this._sources[a])}}),f(H,G,{_name:"pool",add:function(a){return this._add(a),this},remove:function(a){return this._remove(a),this}}),U.pool=function(){return new H},f(I,G,{_onActivation:function(){G.prototype._onActivation.call(this),this._source.onAny([this._handleMainSource,this])},_onDeactivation:function(){G.prototype._onDeactivation.call(this),this._source.offAny([this._handleMainSource,this])},_handleMainSource:function(a){"value"===a.type?(a.current&&this._lastValue===a.value||this._add(this._fn?this._fn.invoke(a.value):a.value),this._lastValue=a.value):0===this._sources.length?this._send("end",null,a.current):this._mainEnded=!0},_remove:function(a){G.prototype._remove.call(this,a),this._mainEnded&&0===this._sources.length&&this._send("end")},_clear:function(){G.prototype._clear.call(this),this._source=null,this._lastValue=null}}),A.prototype.flatMap=function(a){return new I(this,a)},w("toProperty",{_init:function(a){a.length>0&&this._send("value",a[0])}},{propertyMethod:null,streamMethod:K}),w("changes",{_handleValue:function(a,b){b||this._send("value",a)}},{streamMethod:null,propertyMethod:J}),w("withHandler",{_init:function(a){var b=this;this._handler=y(a[0],2),this._forcedCurrent=!1,this._bindedSend=function(a,c){b._send(a,c,b._forcedCurrent)}},_free:function(){this._handler=null,this._bindedSend=null},_handleAny:function(a){this._forcedCurrent=a.current,this._handler.invoke(this._bindedSend,a),this._forcedCurrent=!1}}),w("map",{_init:function(a){this._fn=y(a[0],1)},_free:function(){this._fn=null},_handleValue:function(a,b){this._send("value",this._fn.invoke(a),b)}}),w("filter",{_init:function(a){this._fn=y(a[0],1)},_free:function(){this._fn=null},_handleValue:function(a,b){this._fn.invoke(a)&&this._send("value",a,b)}}),w("takeWhile",{_init:function(a){this._fn=y(a[0],1)},_free:function(){this._fn=null},_handleValue:function(a,b){this._fn.invoke(a)?this._send("value",a,b):this._send("end",null,b)}}),w("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")}}),w("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--}}),w("skipDuplicates",{_init:function(a){this._fn=a.length>0?y(a[0],2):y(L),this._prev=Q},_free:function(){this._fn=null,this._prev=null},_handleValue:function(a,b){this._prev!==Q&&this._fn.invoke(this._prev,a)||this._send("value",a,b),this._prev=a}}),w("skipWhile",{_init:function(a){this._fn=y(a[0],1),this._skip=!0},_free:function(){this._fn=null},_handleValue:function(a,b){return this._skip?void(this._fn.invoke(a)||(this._skip=!1,this._fn=null,this._send("value",a,b))):void this._send("value",a,b)}}),w("diff",{_init:function(a){this._prev=a[0],this._fn=y(a[1],2)},_free:function(){this._prev=null,this._fn=null},_handleValue:function(a,b){this._send("value",this._fn.invoke(this._prev,a),b),this._prev=a}}),w("scan",{_init:function(a){this._send("value",a[0],!0),this._fn=y(a[1],2)},_free:function(){this._fn=null},_handleValue:function(a,b){this._send("value",this._fn.invoke(this._current,a),b)}},{streamMethod:K}),w("reduce",{_init:function(a){this._result=a[0],this._fn=y(a[1],2)},_free:function(){this._fn=null,this._result=null},_handleValue:function(a){this._result=this._fn.invoke(this._result,a)},_handleEnd:function(a,b){this._send("value",this._result,b),this._send("end",null,b)}}),w("throttle",{_init:function(a){this._wait=a[0],this._leading=b(a[1],"leading",!0),this._trailing=b(a[1],"trailing",!0),this._trailingCallValue=null,this._trailingCallTimeoutId=null,this._endAfterTrailingCall=!1,this._lastCallTime=0;var c=this;this._makeTrailingCallBinded=function(){c._makeTrailingCall()}},_free:function(){this._trailingCallValue=null,this._makeTrailingCallBinded=null},_handleValue:function(a,b){if(b)return void this._send("value",a,b);var c=R();0!==this._lastCallTime||this._leading||(this._lastCallTime=c);var d=this._wait-(c-this._lastCallTime);0>=d?(this._cancelTralingCall(),this._lastCallTime=c,this._send("value",a)):this._trailing&&this._scheduleTralingCall(a,d)},_handleEnd:function(a,b){return b?void this._send("end",null,b):void(this._trailingCallTimeoutId?this._endAfterTrailingCall=!0:this._send("end"))},_scheduleTralingCall:function(a,b){this._trailingCallTimeoutId&&this._cancelTralingCall(),this._trailingCallValue=a,this._trailingCallTimeoutId=setTimeout(this._makeTrailingCallBinded,b)},_cancelTralingCall:function(){null!==this._trailingCallTimeoutId&&(clearTimeout(this._trailingCallTimeoutId),this._trailingCallTimeoutId=null)},_makeTrailingCall:function(){this._send("value",this._trailingCallValue),this._trailingCallTimeoutId=null,this._trailingCallValue=null,this._lastCallTime=this._leading?R():0,this._endAfterTrailingCall&&this._send("end")}}),w("delay",{_init:function(a){this._wait=a[0]},_handleValue:function(a,b){if(b)return void this._send("value",a,b);var c=this;setTimeout(function(){c._send("value",a)},this._wait)},_handleEnd:function(a,b){if(b)return void this._send("end",null,b);var c=this;setTimeout(function(){c._send("end")},this._wait)}}),f(M,B,{_name:"fromBinder",_onActivation:function(){var a=this,b=!0;this._unsubscribe=this._fn.invoke(function(c,d){a._send(c,d,b)}),b=!1},_onDeactivation:function(){q(this._unsubscribe)&&this._unsubscribe(),this._unsubscribe=null},_clear:function(){B.prototype._clear.call(this),this._fn=null}}),U.fromBinder=function(a){return new M(a)},f(N,B,{_name:"emitter",emit:function(a){this._send("value",a)},end:function(){this._send("end")}}),U.emitter=function(){return new N};var V=new B;V._send("end"),V._name="never",U.never=function(){return V},f(O,C,{_name:"constant"}),U.constant=function(a){return new O(a)},f(P,B,{_name:"once",_onActivation:function(){this._send("value",this._value),this._send("end")}}),U.once=function(a){return new P(a)},A.prototype.setName=function(a,b){return this._name=b?a._name+"."+b:a,this},A.prototype.mapTo=function(a){return this.map(function(){return a}).setName(this,"mapTo")},A.prototype.pluck=function(a){return this.map(function(b){return b[a]}).setName(this,"pluck")},A.prototype.invoke=function(a){var b=o(arguments,1);return this.map(b?function(c){return i(c[a],c,b)}:function(b){return b[a]()}).setName(this,"invoke")},A.prototype.tap=function(a){return a=y(a,1),this.map(function(b){return a.invoke(b),b}).setName(this,"tap")},A.prototype.defer=function(){return this.delay(0).setName(this,"defer")},U.and=function(a){return U.combine(a,t).setName("and")},A.prototype.and=function(a){return this.combine(a,t).setName("and")},U.or=function(a){return U.combine(a,u).setName("or")},A.prototype.or=function(a){return this.combine(a,u).setName("or")},A.prototype.not=function(){return this.map(function(a){return!a}).setName("not")},A.prototype.awaiting=function(a){return U.merge([this.mapTo(!0),a.mapTo(!1)]).skipDuplicates().toProperty(!1).setName(this,"awaiting")},A.prototype.filterBy=function(a){return a.sampledBy(this).withHandler(function(a,b){"end"===b.type?a("end"):b.value[0]&&a("value",b.value[1])}).setName(this,"filterBy")},"function"==typeof define&&define.amd?(define([],function(){return U}),a.Kefir=U):"object"==typeof module&&"object"==typeof exports?(module.exports=U,U.Kefir=U):a.Kefir=U}(this); | ||
!function(a){"use strict";function b(a,b,c){return a&&b in a?a[b]:c}function c(a,b){return Object.prototype.hasOwnProperty.call(a,b)}function d(a){var b=function(){};return b.prototype=a,new b}function e(a){var b,c,d=arguments.length;for(b=1;d>b;b++)for(c in arguments[b])a[c]=arguments[b][c];return a}function f(a,b){var c,f=arguments.length;for(a.prototype=d(b.prototype),a.prototype.constructor=a,c=2;f>c;c++)e(a.prototype,arguments[c]);return a}function g(a){return 1===a.length&&S(a[0])?a[0]:n(a)}function h(a,b){if(r(a))return a;if(null!=b&&r(b[a]))return b[a];throw new Error("not a function: "+a+" in "+b)}function i(a,b,c){var d=c?c.length:0;if(null==b)switch(d){case 0:return a();case 1:return a(c[0]);case 2:return a(c[0],c[1]);case 3:return a(c[0],c[1],c[2]);case 4:return a(c[0],c[1],c[2],c[3]);default:return a.apply(null,c)}else switch(d){case 0:return a.call(b);default:return a.apply(b,c)}}function j(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3];switch(c){case 0:switch(b.length){case 0:return a;case 1:return function(){return a(d)};case 2:return function(){return a(d,e)};case 3:return function(){return a(d,e,f)};case 4:return function(){return a(d,e,f,g)};default:return function(){return a.apply(null,b)}}break;case 1:switch(b.length){case 0:return a;case 1:return function(b){return a(d,b)};case 2:return function(b){return a(d,e,b)};case 3:return function(b){return a(d,e,f,b)};case 4:return function(b){return a(d,e,f,g,b)};default:return function(c){return a.apply(null,m(b,[c]))}}break;case 2:switch(b.length){case 0:return a;case 1:return function(b,c){return a(d,b,c)};case 2:return function(b,c){return a(d,e,b,c)};case 3:return function(b,c){return a(d,e,f,b,c)};case 4:return function(b,c){return a(d,e,f,g,b,c)};default:return function(c,d){return a.apply(null,m(b,[c,d]))}}break;default:switch(b.length){case 0:return a;default:return function(){return i(a,null,m(b,arguments))}}}}function k(a,b,c,d){var e=c[0],f=c[1],g=c[2],h=c[3];switch(d){case 0:switch(c.length){case 0:return function(){return a.call(b)};default:return function(){return a.apply(b,c)}}break;case 1:switch(c.length){case 0:return function(c){return a.call(b,c)};case 1:return function(c){return a.call(b,e,c)};case 2:return function(c){return a.call(b,e,f,c)};case 3:return function(c){return a.call(b,e,f,g,c)};case 4:return function(c){return a.call(b,e,f,g,h,c)};default:return function(d){return a.apply(b,m(c,[d]))}}break;case 2:switch(c.length){case 0:return function(c,d){return a.call(b,c,d)};case 1:return function(c,d){return a.call(b,e,c,d)};case 2:return function(c,d){return a.call(b,e,f,c,d)};case 3:return function(c,d){return a.call(b,e,f,g,c,d)};case 4:return function(c,d){return a.call(b,e,f,g,h,c,d)};default:return function(d,e){return a.apply(b,m(c,[d,e]))}}break;default:switch(c.length){case 0:return function(){return a.apply(b,arguments)};default:return function(){return a.apply(b,m(c,arguments))}}}}function l(a,b,c,d){return null==b?j(a,c,d):k(a,b,c,d)}function m(a,b){var c,d,e=new Array(a.length+b.length),f=0;for(c=a.length,d=0;c>d;d++,f++)e[f]=a[d];for(c=b.length,d=0;c>d;d++,f++)e[f]=b[d];return e}function n(a){var b,c=a.length,d=new Array(c);for(b=0;c>b;b++)d[b]=a[b];return d}function o(a,b){var c,d=a.length;for(c=0;d>c;c++)a[c]=b}function p(a,b){var c,d=a.length;for(c=0;d>c;c++)if(a[c]===b)return!0;return!1}function q(a,b,c){return a.length>b?Array.prototype.slice.call(a,b):c}function r(a){return"function"==typeof a}function s(a){return S(a)||T(a)}function t(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 u(){for(var a=0;a<arguments.length;a++)if(!arguments[a])return arguments[a];return arguments[a-1]}function v(){for(var a=0;a<arguments.length;a++)if(arguments[a])return arguments[a];return arguments[a-1]}function w(a,b){function c(a,b){C.call(this),this._wait=a,this._intervalId=null;var c=this;this._$onTick=function(){c._onTick()},this._init(b)}f(c,C,{_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(){C.prototype._clear.call(this),this._$onTick=null,this._free()}},b),U[a]=function(a){return new c(a,q(arguments,1,[]))}}function x(a,b,c){function d(c){function d(b,d){c.call(this),this._source=b,this._name=b._name+"."+a,this._init(d)}return f(d,c,{_clear:function(){c.prototype._clear.call(this),this._source=null,this._free()}},b),d}c=e({streamMethod:function(a){return function(){return new a(this,arguments)}},propertyMethod:function(a,b){return function(){return new b(this,arguments)}}},c||{}),b=e({_init:function(){},_free:function(){},_handleValue:function(a,b){this._send("value",a,b)},_handleEnd:function(a,b){this._send("end",null,b)},_onActivationHook:function(){},_onDeactivationHook:function(){},_handleAny:function(a){switch(a.type){case"value":this._handleValue(a.value,a.current);break;case"end":this._handleEnd(a.value,a.current)}},_onActivation:function(){this._onActivationHook(),this._source.onAny([this._handleAny,this])},_onDeactivation:function(){this._onDeactivationHook(),this._source.offAny([this._handleAny,this])}},b||{});var g=d(C),h=d(D);c.streamMethod&&(C.prototype[a]=c.streamMethod(g,h)),c.propertyMethod&&(D.prototype[a]=c.propertyMethod(g,h))}function y(a,b){this.context=null==a[1]?null:a[1],this.fn=h(a[0],this.context),this.args=q(a,2,[]),this.invoke=l(this.fn,this.context,this.args,b)}function z(a,b){if(a instanceof y)return a;if(null==b&&(b=100),r(a))return new y([a],b);if(s(a))return new y(a,b);throw new Error("can't convert to Fn "+a)}function A(){this.value=[],this.end=[],this.any=[],this.total=0}function B(){this._subscribers=new A,this._active=!1,this._alive=!0}function C(){B.call(this)}function D(){B.call(this),this._current=Q}function E(a,b){var c="<"+b.type+(b.current?":current":"")+">";"value"===b.type?console.log(a,c,b.value):console.log(a,c)}function F(a){C.call(this),0===a.length?this._send("end"):(this._sources=a,this._aliveCount=0)}function G(a,b,c){C.call(this),0===b.length?this._send("end"):(this._passiveCount=a.length,this._combinator=c?z(c):null,this._sources=m(a,b),this._aliveCount=0,this._currents=new Array(this._sources.length),o(this._currents,Q),this._activating=!1,this._emitAfterActivation=!1,this._endAfterActivation=!1)}function H(){C.call(this),this._sources=[]}function I(){H.call(this)}function J(a,b){H.call(this),this._source=a,this._name=a._name+".flatMap",this._fn=b?z(b,1):null,this._mainEnded=!1,this._lastValue=null}function K(a){return function(){return new a(this,arguments)}}function L(a,b){return function(){return new b(this,arguments)}}function M(a){C.call(this),this._fn=z(a,1),this._unsubscribe=null}function N(){C.call(this)}function O(a){D.call(this),this._send("value",a),this._send("end")}function P(a){C.call(this),this._value=a}var Q=["<nothing>"],R=Date.now?function(){return Date.now()}:function(){return(new Date).getTime()},S=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},T=function(a){return"[object Arguments]"===Object.prototype.toString.call(a)};T(arguments)||(T=function(a){return!(!a||!c(a,"callee"))});var U={};y.prototype.apply=function(a){return i(this.invoke,null,a)},y.prototype.applyWithContext=function(a,b){return null===this.context?0===this.args.length?i(this.fn,a,b):i(this.fn,a,m(this.args,b)):this.apply(b)},z.isEqual=function(a,b){return a===b?!0:(a=z(a,null,!0),b=z(b,null,!0),a.fn===b.fn&&a.context===b.context&&t(a.args,b.args))},U.Fn=z,e(A.prototype,{add:function(a,b){var c="end"===a?0:1;this[a].push(z(b,c,!0)),this.total++},remove:function(a,b){var c,d=this[a],e=d.length;for(b=z(b),c=0;e>c;c++)if(z.isEqual(d[c],b))return d.splice(c,1),void this.total--},call:function(a,b){var c,d=this[a],e=d.length;if(0!==e)if(1===e)"end"===a?d[0].invoke():d[0].invoke(b);else for(d=n(d),c=0;e>c;c++)"end"===a?d[c].invoke():d[c].invoke(b)},isEmpty:function(){return 0===this.total}}),U.Observable=B,e(B.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.call(a,b),this._subscribers.call("any",{type:a,value:b,current:!!c}),"end"===a&&this._clear())},_callWithCurrent:function(a,b,c,d){b=z(b),a===c?"value"===a?b.invoke(d):b.invoke():"any"===a&&b.invoke({type:c,value:d,current:!0})},on:function(a,b){return this._alive?(this._subscribers.add(a,b),this._setActive(!0)):this._callWithCurrent(a,b,"end"),this},off:function(a,b){return this._alive&&(this._subscribers.remove(a,b),this._subscribers.isEmpty()&&this._setActive(!1)),this},onValue:function(a){this.on("value",a)},onEnd:function(a){this.on("end",a)},onAny:function(a){this.on("any",a)},offValue:function(a){this.off("value",a)},offEnd:function(a){this.off("end",a)},offAny:function(a){this.off("any",a)}}),B.prototype.toString=function(){return"["+this._name+"]"},U.Stream=C,f(C,B,{_name:"stream"}),U.Property=D,f(D,B,{_name:"property",_send:function(a,b,c){this._alive&&(c||(this._subscribers.call(a,b),this._subscribers.call("any",{type:a,value:b,current:!1})),"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!==Q&&this._callWithCurrent(a,b,"value",this._current),this._alive||this._callWithCurrent(a,b,"end"),this}}),B.prototype.log=function(a){return this.onAny([E,null,a||this.toString()]),this},B.prototype.offLog=function(a){return this.offAny([E,null,a||this.toString()]),this},w("withInterval",{_init:function(a){this._fn=z(a[0],1);var b=this;this._emitter={emit:function(a){b._send("value",a)},end:function(){b._send("end")}}},_free:function(){this._fn=null,this._emitter=null},_onTick:function(){this._fn.invoke(this._emitter)}}),w("fromPoll",{_init:function(a){this._fn=z(a[0],0)},_free:function(){this._fn=null},_onTick:function(){this._send("value",this._fn.invoke())}}),w("interval",{_init:function(a){this._x=a[0]},_free:function(){this._x=null},_onTick:function(){this._send("value",this._x)}}),w("sequentially",{_init:function(a){this._xs=n(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())}}}),w("repeatedly",{_init:function(a){this._xs=n(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]))}}),w("later",{_init:function(a){this._x=a[0]},_free:function(){this._x=null},_onTick:function(){this._send("value",this._x),this._send("end")}}),f(F,C,{_name:"merge",_onActivation:function(){var a,b=this._sources.length;for(this._aliveCount=b,a=0;b>a;a++)this._sources[a].onAny([this._handleAny,this])},_onDeactivation:function(){var a,b=this._sources.length;for(a=0;b>a;a++)this._sources[a].offAny([this._handleAny,this])},_handleAny:function(a){"value"===a.type?this._send("value",a.value,a.current):(this._aliveCount--,0===this._aliveCount&&this._send("end",null,a.current))},_clear:function(){C.prototype._clear.call(this),this._sources=null}}),U.merge=function(){return new F(g(arguments))},B.prototype.merge=function(a){return U.merge([this,a])},f(G,C,{_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(!p(this._currents,Q)){var b=n(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(){C.prototype._clear.call(this),this._sources=null,this._currents=null}}),U.sampledBy=function(a,b,c){return new G(a,b,c)},B.prototype.sampledBy=function(a,b){return U.sampledBy([this],[a],b)},U.combine=function(a,b){var c=new G([],a,b);return c._name="combine",c},B.prototype.combine=function(a,b){return U.combine([this,a],b)},f(H,C,{_name:"abstractPool",_sub:function(a){a.onAny([this._handleSubAny,this]),a.onEnd([this._remove,this,a])},_unsub:function(a){a.offAny([this._handleSubAny,this]),a.offEnd([this._remove,this,a])},_handleSubAny:function(a){"value"===a.type&&this._send("value",a.value,a.current)},_add:function(a){this._sources.push(a),this._active&&this._sub(a)},_remove:function(a){this._active&&this._unsub(a);for(var b=0;b<this._sources.length;b++)if(this._sources[b]===a)return void this._sources.splice(b,1)},_onActivation:function(){for(var a=n(this._sources),b=0;b<a.length;b++)this._sub(a[b])},_onDeactivation:function(){for(var a=0;a<this._sources.length;a++)this._unsub(this._sources[a])}}),f(I,H,{_name:"pool",add:function(a){return this._add(a),this},remove:function(a){return this._remove(a),this}}),U.pool=function(){return new I},f(J,H,{_onActivation:function(){H.prototype._onActivation.call(this),this._source.onAny([this._handleMainSource,this])},_onDeactivation:function(){H.prototype._onDeactivation.call(this),this._source.offAny([this._handleMainSource,this])},_handleMainSource:function(a){"value"===a.type?(a.current&&this._lastValue===a.value||this._add(this._fn?this._fn.invoke(a.value):a.value),this._lastValue=a.value):0===this._sources.length?this._send("end",null,a.current):this._mainEnded=!0},_remove:function(a){H.prototype._remove.call(this,a),this._mainEnded&&0===this._sources.length&&this._send("end")},_clear:function(){H.prototype._clear.call(this),this._source=null,this._lastValue=null}}),B.prototype.flatMap=function(a){return new J(this,a)},x("toProperty",{_init:function(a){a.length>0&&this._send("value",a[0])}},{propertyMethod:null,streamMethod:L}),x("changes",{_handleValue:function(a,b){b||this._send("value",a)}},{streamMethod:null,propertyMethod:K}),x("withHandler",{_init:function(a){this._handler=z(a[0],2),this._forcedCurrent=!1;var b=this;this._emitter={emit:function(a){b._send("value",a,b._forcedCurrent)},end:function(){b._send("end",null,b._forcedCurrent)}}},_free:function(){this._handler=null,this._emitter=null},_handleAny:function(a){this._forcedCurrent=a.current,this._handler.invoke(this._emitter,a),this._forcedCurrent=!1}});var V={_init:function(a){this._fn=z(a[0],1)},_free:function(){this._fn=null}};x("map",e({_handleValue:function(a,b){this._send("value",this._fn.invoke(a),b)}},V)),x("filter",e({_handleValue:function(a,b){this._fn.invoke(a)&&this._send("value",a,b)}},V)),x("takeWhile",e({_handleValue:function(a,b){this._fn.invoke(a)?this._send("value",a,b):this._send("end",null,b)}},V)),x("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")}}),x("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--}}),x("skipDuplicates",{_init:function(a){this._fn=a[0]&&z(a[0],2),this._prev=Q},_free:function(){this._fn=null,this._prev=null},_isEqual:function(a,b){return this._fn?this._fn.invoke(a,b):a===b},_handleValue:function(a,b){this._prev!==Q&&this._isEqual(this._prev,a)||(this._send("value",a,b),this._prev=a)}}),x("skipWhile",{_init:function(a){this._fn=z(a[0],1),this._skip=!0},_free:function(){this._fn=null},_handleValue:function(a,b){return this._skip?void(this._fn.invoke(a)||(this._skip=!1,this._fn=null,this._send("value",a,b))):void this._send("value",a,b)}}),x("diff",{_init:function(a){this._prev=a[0],this._fn=z(a[1],2)},_free:function(){this._prev=null,this._fn=null},_handleValue:function(a,b){this._send("value",this._fn.invoke(this._prev,a),b),this._prev=a}}),x("scan",{_init:function(a){this._send("value",a[0],!0),this._fn=z(a[1],2)},_free:function(){this._fn=null},_handleValue:function(a,b){this._send("value",this._fn.invoke(this._current,a),b)}},{streamMethod:L}),x("reduce",{_init:function(a){this._result=a[0],this._fn=z(a[1],2)},_free:function(){this._fn=null,this._result=null},_handleValue:function(a){this._result=this._fn.invoke(this._result,a)},_handleEnd:function(a,b){this._send("value",this._result,b),this._send("end",null,b)}}),x("throttle",{_init:function(a){this._wait=a[0],this._leading=b(a[1],"leading",!0),this._trailing=b(a[1],"trailing",!0),this._trailingCallValue=null,this._trailingCallTimeoutId=null,this._endAfterTrailingCall=!1,this._lastCallTime=0;var c=this;this._$makeTrailingCall=function(){c._makeTrailingCall()}},_free:function(){this._trailingCallValue=null,this._$makeTrailingCall=null},_handleValue:function(a,b){if(b)this._send("value",a,b);else{var c=R();0!==this._lastCallTime||this._leading||(this._lastCallTime=c);var d=this._wait-(c-this._lastCallTime);0>=d?(this._cancelTralingCall(),this._lastCallTime=c,this._send("value",a)):this._trailing&&this._scheduleTralingCall(a,d)}},_handleEnd:function(a,b){b?this._send("end",null,b):this._trailingCallTimeoutId?this._endAfterTrailingCall=!0:this._send("end")},_scheduleTralingCall:function(a,b){this._trailingCallTimeoutId&&this._cancelTralingCall(),this._trailingCallValue=a,this._trailingCallTimeoutId=setTimeout(this._$makeTrailingCall,b)},_cancelTralingCall:function(){null!==this._trailingCallTimeoutId&&(clearTimeout(this._trailingCallTimeoutId),this._trailingCallTimeoutId=null)},_makeTrailingCall:function(){this._send("value",this._trailingCallValue),this._trailingCallTimeoutId=null,this._trailingCallValue=null,this._lastCallTime=this._leading?R():0,this._endAfterTrailingCall&&this._send("end")}}),x("delay",{_init:function(a){this._wait=a[0],this._buff=[];var b=this;this._shiftBuff=function(){b._send("value",b._buff.shift())}},_free:function(){this._buff=null,this._shiftBuff=null},_handleValue:function(a,b){b?this._send("value",a,b):(this._buff.push(a),setTimeout(this._shiftBuff,this._wait))},_handleEnd:function(a,b){if(b)this._send("end",null,b);else{var c=this;setTimeout(function(){c._send("end")},this._wait)}}}),f(M,C,{_name:"fromBinder",_onActivation:function(){var a,b=this,c=!0,d={emit:function(a){b._send("value",a,c)},end:function(){b._send("end",null,c)}};a=this._fn.invoke(d),c=!1,a&&(this._unsubscribe=z(a,0))},_onDeactivation:function(){null!==this._unsubscribe&&(this._unsubscribe.invoke(),this._unsubscribe=null)},_clear:function(){C.prototype._clear.call(this),this._fn=null}}),U.fromBinder=function(a){return new M(a)},f(N,C,{_name:"emitter",emit:function(a){this._send("value",a)},end:function(){this._send("end")}}),U.emitter=function(){return new N};var W=new C;W._send("end"),W._name="never",U.never=function(){return W},f(O,D,{_name:"constant"}),U.constant=function(a){return new O(a)},f(P,C,{_name:"once",_onActivation:function(){this._send("value",this._value),this._send("end")}}),U.once=function(a){return new P(a)},B.prototype.setName=function(a,b){return this._name=b?a._name+"."+b:a,this},B.prototype.mapTo=function(a){return this.map(function(){return a}).setName(this,"mapTo")},B.prototype.pluck=function(a){return this.map(function(b){return b[a]}).setName(this,"pluck")},B.prototype.invoke=function(a){var b=q(arguments,1);return this.map(b?function(c){return i(c[a],c,b)}:function(b){return b[a]()}).setName(this,"invoke")},B.prototype.tap=function(a){return a=z(a,1),this.map(function(b){return a.invoke(b),b}).setName(this,"tap")},B.prototype.defer=function(){return this.delay(0).setName(this,"defer")},U.and=function(a){return U.combine(a,u).setName("and")},B.prototype.and=function(a){return this.combine(a,u).setName("and")},U.or=function(a){return U.combine(a,v).setName("or")},B.prototype.or=function(a){return this.combine(a,v).setName("or")},B.prototype.not=function(){return this.map(function(a){return!a}).setName(this,"not")},B.prototype.awaiting=function(a){return U.merge([this.mapTo(!0),a.mapTo(!1)]).skipDuplicates().toProperty(!1).setName(this,"awaiting")},B.prototype.filterBy=function(a){return a.sampledBy(this).withHandler(function(a,b){"end"===b.type?a.end():b.value[0]&&a.emit(b.value[1])}).setName(this,"filterBy")},"function"==typeof define&&define.amd?(define([],function(){return U}),a.Kefir=U):"object"==typeof module&&"object"==typeof exports?(module.exports=U,U.Kefir=U):a.Kefir=U}(this); | ||
//# sourceMappingURL=kefir.min.js.map |
{ | ||
"name": "kefir", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"description": "FRP library for JavaScript inspired by Bacon.js and RxJS with focus on high performance and low memory consumption", | ||
@@ -5,0 +5,0 @@ "main": "dist/kefir.js", |
@@ -9,3 +9,3 @@ ;(function(global){ | ||
$.fn.asKefirStream = function(event, selector, transformer) { | ||
$.fn.asKefirStream = function(eventName, selector, transformer) { | ||
var $el = this; | ||
@@ -17,9 +17,14 @@ if (transformer == null && selector != null && 'string' !== typeof selector) { | ||
transformer = transformer && Kefir.Fn(transformer); | ||
return Kefir.fromBinder(function(send) { | ||
function onEvent(e) { | ||
send('value', transformer ? transformer.apply(arguments) : e); | ||
return Kefir.fromBinder(function(emitter) { | ||
var onEvent; | ||
if (transformer) { | ||
onEvent = function() { | ||
emitter.emit(transformer.applyWithContext(this, arguments)); | ||
}; | ||
} else { | ||
onEvent = emitter.emit; | ||
} | ||
$el.on(event, selector, onEvent); | ||
return function() { $el.off(event, selector, onEvent) } | ||
}); | ||
$el.on(eventName, selector, onEvent); | ||
return ['off', $el, eventName, selector, onEvent]; | ||
}).setName('asKefirStream'); | ||
} | ||
@@ -26,0 +31,0 @@ |
@@ -11,15 +11,24 @@ | ||
function _Fn(fnMeta, length) { | ||
var fn = getFn(fnMeta[0], fnMeta[1]); | ||
var context = fnMeta[1]; | ||
var args = rest(fnMeta, 2, []); | ||
this.fn = fn; | ||
this.context = context; | ||
this.args = args; | ||
this.invoke = bind(fn, context, args, length); | ||
this.context = (fnMeta[1] == null) ? null : fnMeta[1]; | ||
this.fn = getFn(fnMeta[0], this.context); | ||
this.args = rest(fnMeta, 2, []); | ||
this.invoke = bind(this.fn, this.context, this.args, length); | ||
} | ||
_Fn.prototype.apply = function(args) { | ||
return call(this.invoke, null, args); | ||
return apply(this.invoke, null, args); | ||
} | ||
_Fn.prototype.applyWithContext = function(context, args) { | ||
if (this.context === null) { | ||
if (this.args.length === 0) { | ||
return apply(this.fn, context, args); | ||
} else { | ||
return apply(this.fn, context, concat(this.args, args)); | ||
} | ||
} else { | ||
return this.apply(args); | ||
} | ||
} | ||
function Fn(fnMeta, length) { | ||
@@ -283,3 +292,3 @@ if (fnMeta instanceof _Fn) { | ||
function logCb(name, event) { | ||
var typeStr = '<' + event.type + (event.isCurrent ? ':current' : '') + '>'; | ||
var typeStr = '<' + event.type + (event.current ? ':current' : '') + '>'; | ||
if (event.type === 'value') { | ||
@@ -286,0 +295,0 @@ console.log(name, typeStr, event.value); |
@@ -8,11 +8,14 @@ | ||
this._fn = Fn(args[0], 1); | ||
var _this = this; | ||
this._bindedSend = function(type, x) { _this._send(type, x) } | ||
var $ = this; | ||
this._emitter = { | ||
emit: function(x) { $._send('value', x) }, | ||
end: function() { $._send('end') } | ||
} | ||
}, | ||
_free: function() { | ||
this._fn = null; | ||
this._bindedSend = null; | ||
this._emitter = null; | ||
}, | ||
_onTick: function() { | ||
this._fn.invoke(this._bindedSend); | ||
this._fn.invoke(this._emitter); | ||
} | ||
@@ -19,0 +22,0 @@ }); |
@@ -39,14 +39,17 @@ function produceStream(StreamClass, PropertyClass) { | ||
_init: function(args) { | ||
var _this = this; | ||
this._handler = Fn(args[0], 2); | ||
this._forcedCurrent = false; | ||
this._bindedSend = function(type, x) { _this._send(type, x, _this._forcedCurrent) } | ||
var $ = this; | ||
this._emitter = { | ||
emit: function(x) { $._send('value', x, $._forcedCurrent) }, | ||
end: function() { $._send('end', null, $._forcedCurrent) } | ||
} | ||
}, | ||
_free: function() { | ||
this._handler = null; | ||
this._bindedSend = null; | ||
this._emitter = null; | ||
}, | ||
_handleAny: function(event) { | ||
this._forcedCurrent = event.current; | ||
this._handler.invoke(this._bindedSend, event); | ||
this._handler.invoke(this._emitter, event); | ||
this._forcedCurrent = false; | ||
@@ -59,16 +62,15 @@ } | ||
var withFnArgMixin = { | ||
_init: function(args) { this._fn = Fn(args[0], 1) }, | ||
_free: function() { this._fn = null } | ||
}; | ||
// .map(fn) | ||
withOneSource('map', { | ||
_init: function(args) { | ||
this._fn = Fn(args[0], 1); | ||
}, | ||
_free: function() { | ||
this._fn = null; | ||
}, | ||
withOneSource('map', extend({ | ||
_handleValue: function(x, isCurrent) { | ||
this._send('value', this._fn.invoke(x), isCurrent); | ||
} | ||
}); | ||
}, withFnArgMixin)); | ||
@@ -81,9 +83,3 @@ | ||
withOneSource('filter', { | ||
_init: function(args) { | ||
this._fn = Fn(args[0], 1); | ||
}, | ||
_free: function() { | ||
this._fn = null; | ||
}, | ||
withOneSource('filter', extend({ | ||
_handleValue: function(x, isCurrent) { | ||
@@ -94,3 +90,3 @@ if (this._fn.invoke(x)) { | ||
} | ||
}); | ||
}, withFnArgMixin)); | ||
@@ -103,9 +99,3 @@ | ||
withOneSource('takeWhile', { | ||
_init: function(args) { | ||
this._fn = Fn(args[0], 1); | ||
}, | ||
_free: function() { | ||
this._fn = null; | ||
}, | ||
withOneSource('takeWhile', extend({ | ||
_handleValue: function(x, isCurrent) { | ||
@@ -118,3 +108,3 @@ if (this._fn.invoke(x)) { | ||
} | ||
}); | ||
}, withFnArgMixin)); | ||
@@ -167,11 +157,5 @@ | ||
function strictlyEqual(a, b) { return a === b } | ||
withOneSource('skipDuplicates', { | ||
_init: function(args) { | ||
if (args.length > 0) { | ||
this._fn = Fn(args[0], 2); | ||
} else { | ||
this._fn = Fn(strictlyEqual); | ||
} | ||
this._fn = args[0] && Fn(args[0], 2); | ||
this._prev = NOTHING; | ||
@@ -183,7 +167,10 @@ }, | ||
}, | ||
_isEqual: function(a, b) { | ||
return this._fn ? this._fn.invoke(a, b) : a === b; | ||
}, | ||
_handleValue: function(x, isCurrent) { | ||
if (this._prev === NOTHING || !this._fn.invoke(this._prev, x)) { | ||
if (this._prev === NOTHING || !this._isEqual(this._prev, x)) { | ||
this._send('value', x, isCurrent); | ||
this._prev = x; | ||
} | ||
this._prev = x; | ||
} | ||
@@ -298,8 +285,8 @@ }); | ||
this._lastCallTime = 0; | ||
var _this = this; | ||
this._makeTrailingCallBinded = function() { _this._makeTrailingCall() }; | ||
var $ = this; | ||
this._$makeTrailingCall = function() { $._makeTrailingCall() }; | ||
}, | ||
_free: function() { | ||
this._trailingCallValue = null; | ||
this._makeTrailingCallBinded = null; | ||
this._$makeTrailingCall = null; | ||
}, | ||
@@ -309,16 +296,16 @@ _handleValue: function(x, isCurrent) { | ||
this._send('value', x, isCurrent); | ||
return; | ||
} else { | ||
var curTime = now(); | ||
if (this._lastCallTime === 0 && !this._leading) { | ||
this._lastCallTime = curTime; | ||
} | ||
var remaining = this._wait - (curTime - this._lastCallTime); | ||
if (remaining <= 0) { | ||
this._cancelTralingCall(); | ||
this._lastCallTime = curTime; | ||
this._send('value', x); | ||
} else if (this._trailing) { | ||
this._scheduleTralingCall(x, remaining); | ||
} | ||
} | ||
var curTime = now(); | ||
if (this._lastCallTime === 0 && !this._leading) { | ||
this._lastCallTime = curTime; | ||
} | ||
var remaining = this._wait - (curTime - this._lastCallTime); | ||
if (remaining <= 0) { | ||
this._cancelTralingCall(); | ||
this._lastCallTime = curTime; | ||
this._send('value', x); | ||
} else if (this._trailing) { | ||
this._scheduleTralingCall(x, remaining); | ||
} | ||
}, | ||
@@ -328,8 +315,8 @@ _handleEnd: function(__, isCurrent) { | ||
this._send('end', null, isCurrent); | ||
return; | ||
} | ||
if (this._trailingCallTimeoutId) { | ||
this._endAfterTrailingCall = true; | ||
} else { | ||
this._send('end'); | ||
if (this._trailingCallTimeoutId) { | ||
this._endAfterTrailingCall = true; | ||
} else { | ||
this._send('end'); | ||
} | ||
} | ||
@@ -342,3 +329,3 @@ }, | ||
this._trailingCallValue = value; | ||
this._trailingCallTimeoutId = setTimeout(this._makeTrailingCallBinded, wait); | ||
this._trailingCallTimeoutId = setTimeout(this._$makeTrailingCall, wait); | ||
}, | ||
@@ -372,10 +359,19 @@ _cancelTralingCall: function() { | ||
this._wait = args[0]; | ||
this._buff = []; | ||
var $ = this; | ||
this._shiftBuff = function() { | ||
$._send('value', $._buff.shift()); | ||
} | ||
}, | ||
_free: function() { | ||
this._buff = null; | ||
this._shiftBuff = null; | ||
}, | ||
_handleValue: function(x, isCurrent) { | ||
if (isCurrent) { | ||
this._send('value', x, isCurrent); | ||
return; | ||
} else { | ||
this._buff.push(x); | ||
setTimeout(this._shiftBuff, this._wait); | ||
} | ||
var _this = this; | ||
setTimeout(function() { _this._send('value', x) }, this._wait); | ||
}, | ||
@@ -385,7 +381,7 @@ _handleEnd: function(__, isCurrent) { | ||
this._send('end', null, isCurrent); | ||
return; | ||
} else { | ||
var $ = this; | ||
setTimeout(function() { $._send('end') }, this._wait); | ||
} | ||
var _this = this; | ||
setTimeout(function() { _this._send('end') }, this._wait); | ||
} | ||
}); |
@@ -14,12 +14,20 @@ // Kefir.fromBinder(fn) | ||
_onActivation: function() { | ||
var _this = this; | ||
var isCurrent = true; | ||
this._unsubscribe = this._fn.invoke(function(type, x) { _this._send(type, x, isCurrent) }); | ||
var $ = this | ||
, unsub | ||
, isCurrent = true | ||
, emitter = { | ||
emit: function(x) { $._send('value', x, isCurrent) }, | ||
end: function() { $._send('end', null, isCurrent) } | ||
}; | ||
unsub = this._fn.invoke(emitter); | ||
isCurrent = false; | ||
if (unsub) { | ||
this._unsubscribe = Fn(unsub, 0); | ||
} | ||
}, | ||
_onDeactivation: function() { | ||
if (isFn(this._unsubscribe)) { | ||
this._unsubscribe(); | ||
if (this._unsubscribe !== null) { | ||
this._unsubscribe.invoke(); | ||
this._unsubscribe = null; | ||
} | ||
this._unsubscribe = null; | ||
}, | ||
@@ -26,0 +34,0 @@ |
@@ -33,3 +33,3 @@ // .setName | ||
return this.map(args ? | ||
function(x) { return call(x[methodName], x, args) } : | ||
function(x) { return apply(x[methodName], x, args) } : | ||
function(x) { return x[methodName]() } | ||
@@ -88,3 +88,3 @@ ).setName(this, 'invoke'); | ||
Observable.prototype.not = function() { | ||
return this.map(function(x) { return !x }).setName('not'); | ||
return this.map(function(x) { return !x }).setName(this, 'not'); | ||
} | ||
@@ -110,7 +110,7 @@ | ||
.sampledBy(this) | ||
.withHandler(function(send, e) { | ||
.withHandler(function(emitter, e) { | ||
if (e.type === 'end') { | ||
send('end'); | ||
emitter.end(); | ||
} else if (e.value[0]) { | ||
send('value', e.value[1]); | ||
emitter.emit(e.value[1]); | ||
} | ||
@@ -117,0 +117,0 @@ }) |
@@ -7,4 +7,4 @@ function withInterval(name, mixin) { | ||
this._intervalId = null; | ||
var _this = this; | ||
this._bindedOnTick = function() { _this._onTick() } | ||
var $ = this; | ||
this._$onTick = function() { $._onTick() } | ||
this._init(args); | ||
@@ -23,3 +23,3 @@ } | ||
_onActivation: function() { | ||
this._intervalId = setInterval(this._bindedOnTick, this._wait); | ||
this._intervalId = setInterval(this._$onTick, this._wait); | ||
}, | ||
@@ -35,3 +35,3 @@ _onDeactivation: function() { | ||
Stream.prototype._clear.call(this); | ||
this._bindedOnTick = null; | ||
this._$onTick = null; | ||
this._free(); | ||
@@ -38,0 +38,0 @@ } |
@@ -44,36 +44,25 @@ function withOneSource(name, mixin, options) { | ||
function AnonymousStream(source, args) { | ||
Stream.call(this); | ||
this._source = source; | ||
this._name = source._name + '.' + name; | ||
this._init(args); | ||
} | ||
inherit(AnonymousStream, Stream, { | ||
_clear: function() { | ||
Stream.prototype._clear.call(this); | ||
this._source = null; | ||
this._free(); | ||
function buildClass(BaseClass) { | ||
function AnonymousObservable(source, args) { | ||
BaseClass.call(this); | ||
this._source = source; | ||
this._name = source._name + '.' + name; | ||
this._init(args); | ||
} | ||
}, mixin); | ||
inherit(AnonymousObservable, BaseClass, { | ||
_clear: function() { | ||
BaseClass.prototype._clear.call(this); | ||
this._source = null; | ||
this._free(); | ||
} | ||
}, mixin); | ||
function AnonymousProperty(source, args) { | ||
Property.call(this); | ||
this._source = source; | ||
this._name = source._name + '.' + name; | ||
this._init(args); | ||
return AnonymousObservable; | ||
} | ||
inherit(AnonymousProperty, Property, { | ||
_clear: function() { | ||
Property.prototype._clear.call(this); | ||
this._source = null; | ||
this._free(); | ||
} | ||
}, mixin); | ||
var AnonymousStream = buildClass(Stream); | ||
var AnonymousProperty = buildClass(Property); | ||
if (options.streamMethod) { | ||
@@ -80,0 +69,0 @@ Stream.prototype[name] = options.streamMethod(AnonymousStream, AnonymousProperty); |
@@ -21,20 +21,14 @@ var NOTHING = ['<nothing>']; | ||
function extend(/*target, mixin1, mixin2...*/) { | ||
function extend(target /*, mixin1, mixin2...*/) { | ||
var length = arguments.length | ||
, result, i, prop; | ||
if (length === 1) { | ||
return arguments[0]; | ||
} | ||
result = arguments[0]; | ||
, i, prop; | ||
for (i = 1; i < length; i++) { | ||
for (prop in arguments[i]) { | ||
if(own(arguments[i], prop)) { | ||
result[prop] = arguments[i][prop]; | ||
} | ||
target[prop] = arguments[i][prop]; | ||
} | ||
} | ||
return result; | ||
return target; | ||
} | ||
function inherit(Child, Parent/*[, mixin1, mixin2, ...]*/) { | ||
function inherit(Child, Parent /*, mixin1, mixin2...*/) { | ||
var length = arguments.length | ||
@@ -54,3 +48,3 @@ , i; | ||
} | ||
return toArray(args); | ||
return cloneArray(args); | ||
} | ||
@@ -70,93 +64,104 @@ | ||
function call(fn, context, args) { | ||
if (context != null) { | ||
if (!args || args.length === 0) { | ||
return fn.call(context); | ||
} else { | ||
return fn.apply(context, args); | ||
function apply(fn, c, a) { | ||
var aLength = a ? a.length : 0; | ||
if (c == null) { | ||
switch (aLength) { | ||
case 0: return fn(); | ||
case 1: return fn(a[0]); | ||
case 2: return fn(a[0], a[1]); | ||
case 3: return fn(a[0], a[1], a[2]); | ||
case 4: return fn(a[0], a[1], a[2], a[3]); | ||
default: return fn.apply(null, a); | ||
} | ||
} else { | ||
if (!args || args.length === 0) { | ||
return fn(); | ||
switch (aLength) { | ||
case 0: return fn.call(c); | ||
default: return fn.apply(c, a); | ||
} | ||
switch (args.length) { | ||
case 1: return fn(args[0]); | ||
case 2: return fn(args[0], args[1]); | ||
case 3: return fn(args[0], args[1], args[2]); | ||
} | ||
return fn.apply(null, args); | ||
} | ||
} | ||
function bind(fn, c, a, length) { | ||
if (c == null) { | ||
if (a.length === 0) { | ||
return fn; | ||
} | ||
switch (length) { | ||
case 0: | ||
switch (a.length) { | ||
case 1: return function() {return fn(a[0])} | ||
case 2: return function() {return fn(a[0], a[1])} | ||
case 3: return function() {return fn(a[0], a[1], a[3])} | ||
case 4: return function() {return fn(a[0], a[1], a[3], a[4])} | ||
default: return function() {return fn.apply(null, a)} | ||
} | ||
break; | ||
case 1: | ||
switch (a.length) { | ||
case 0: return function(b) {return fn(b)} | ||
case 1: return function(b) {return fn(a[0], b)} | ||
case 2: return function(b) {return fn(a[0], a[1], b)} | ||
case 3: return function(b) {return fn(a[0], a[1], a[3], b)} | ||
case 4: return function(b) {return fn(a[0], a[1], a[3], a[4], b)} | ||
default: return function(b) {return fn.apply(null, concat(a, [b]))} | ||
} | ||
break; | ||
case 2: | ||
switch (a.length) { | ||
case 0: return function(b, d) {return fn(b, d)} | ||
case 1: return function(b, d) {return fn(a[0], b, d)} | ||
case 2: return function(b, d) {return fn(a[0], a[1], b, d)} | ||
case 3: return function(b, d) {return fn(a[0], a[1], a[3], b, d)} | ||
case 4: return function(b, d) {return fn(a[0], a[1], a[3], a[4], b, d)} | ||
default: return function(b, d) {return fn.apply(null, concat(a, [b, d]))} | ||
} | ||
break; | ||
default: return function() {return fn.apply(null, concat(a, arguments))} | ||
} | ||
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 { | ||
switch (length) { | ||
case 0: | ||
switch (a.length) { | ||
case 0: return function() {return fn.call(c)} | ||
case 1: return function() {return fn.call(c, a[0])} | ||
case 2: return function() {return fn.call(c, a[0], a[1])} | ||
case 3: return function() {return fn.call(c, a[0], a[1], a[3])} | ||
case 4: return function() {return fn.call(c, a[0], a[1], a[3], a[4])} | ||
default: return function() {return fn.apply(c, a)} | ||
} | ||
break; | ||
case 1: | ||
switch (a.length) { | ||
case 0: return function(b) {return fn.call(c, b)} | ||
case 1: return function(b) {return fn.call(c, a[0], b)} | ||
case 2: return function(b) {return fn.call(c, a[0], a[1], b)} | ||
case 3: return function(b) {return fn.call(c, a[0], a[1], a[3], b)} | ||
case 4: return function(b) {return fn.call(c, a[0], a[1], a[3], a[4], b)} | ||
default: return function(b) {return fn.apply(c, concat(a, [b]))} | ||
} | ||
break; | ||
case 2: | ||
switch (a.length) { | ||
case 0: return function(b, d) {return fn.call(c, b, d)} | ||
case 1: return function(b, d) {return fn.call(c, a[0], b, d)} | ||
case 2: return function(b, d) {return fn.call(c, a[0], a[1], b, d)} | ||
case 3: return function(b, d) {return fn.call(c, a[0], a[1], a[3], b, d)} | ||
case 4: return function(b, d) {return fn.call(c, a[0], a[1], a[3], a[4], b, d)} | ||
default: return function(b, d) {return fn.apply(c, concat(a, [b, d]))} | ||
} | ||
break; | ||
default: return function() {return fn.apply(c, concat(a, arguments))} | ||
} | ||
return bindWithContext(fn, context, args, boundFunctionLength); | ||
} | ||
@@ -226,10 +231,2 @@ } | ||
function toArray(arrayLike) { | ||
if (isArray(arrayLike)) { | ||
return arrayLike; | ||
} else { | ||
return cloneArray(arrayLike); | ||
} | ||
} | ||
var now = Date.now ? | ||
@@ -236,0 +233,0 @@ function() { return Date.now() } : |
very base stream (1000 samples) | ||
---------------------------------------------------------------- | ||
Kefir w/o subscr. 0.38 KiB w/ subscr. +0.59 KiB sum 0.96 KiB | ||
Kefir w/o subscr. 0.38 KiB w/ subscr. +0.62 KiB sum 1.00 KiB | ||
Bacon w/o subscr. 1.93 KiB w/ subscr. +0.92 KiB sum 2.85 KiB | ||
Rx w/o subscr. 1.48 KiB w/ subscr. +1.25 KiB sum 2.73 KiB | ||
----------------------- | ||
Kefir 1.00 1.00 1.00 Bacon 5.12 1.56 2.95 Rx 3.94 2.13 2.84 | ||
Kefir 1.00 1.00 1.00 Bacon 5.14 1.48 2.86 Rx 3.95 2.02 2.75 | ||
@@ -14,5 +14,5 @@ | ||
Kefir w/o subscr. 0.20 KiB w/ subscr. +0.24 KiB sum 0.44 KiB | ||
Bacon w/o subscr. 2.69 KiB w/ subscr. +0.76 KiB sum 3.45 KiB | ||
Bacon w/o subscr. 2.65 KiB w/ subscr. +0.76 KiB sum 3.41 KiB | ||
----------------------- | ||
Kefir 1.00 1.00 1.00 Bacon 13.61 3.13 7.85 | ||
Kefir 1.00 1.00 1.00 Bacon 13.47 3.13 7.78 | ||
@@ -23,5 +23,5 @@ | ||
Kefir w/o subscr. 0.24 KiB w/ subscr. +0.25 KiB sum 0.49 KiB | ||
Bacon w/o subscr. 2.67 KiB w/ subscr. +0.75 KiB sum 3.43 KiB | ||
Bacon w/o subscr. 2.68 KiB w/ subscr. +0.75 KiB sum 3.43 KiB | ||
----------------------- | ||
Kefir 1.00 1.00 1.00 Bacon 11.22 3.02 7.02 | ||
Kefir 1.00 1.00 1.00 Bacon 11.22 3.03 7.05 | ||
@@ -31,7 +31,7 @@ | ||
---------------------------------------------------------------- | ||
Kefir w/o subscr. 0.46 KiB w/ subscr. +1.30 KiB sum 1.76 KiB | ||
Kefir w/o subscr. 0.45 KiB w/ subscr. +1.43 KiB sum 1.88 KiB | ||
Bacon w/o subscr. 6.46 KiB w/ subscr. +5.27 KiB sum 11.73 KiB | ||
Rx w/o subscr. 0.34 KiB w/ subscr. +3.61 KiB sum 3.94 KiB | ||
Rx w/o subscr. 0.34 KiB w/ subscr. +3.61 KiB sum 3.95 KiB | ||
----------------------- | ||
Kefir 1.00 1.00 1.00 Bacon 14.16 4.06 6.68 Rx 0.74 2.77 2.25 | ||
Kefir 1.00 1.00 1.00 Bacon 14.23 3.69 6.23 Rx 0.75 2.52 2.09 | ||
@@ -41,7 +41,7 @@ | ||
---------------------------------------------------------------- | ||
Kefir w/o subscr. 0.55 KiB w/ subscr. +0.75 KiB sum 1.30 KiB | ||
Bacon w/o subscr. 8.85 KiB w/ subscr. +4.28 KiB sum 13.13 KiB | ||
Kefir w/o subscr. 0.55 KiB w/ subscr. +0.82 KiB sum 1.37 KiB | ||
Bacon w/o subscr. 8.85 KiB w/ subscr. +4.28 KiB sum 13.12 KiB | ||
Rx w/o subscr. 0.42 KiB w/ subscr. +2.88 KiB sum 3.30 KiB | ||
----------------------- | ||
Kefir 1.00 1.00 1.00 Bacon 16.12 5.72 10.12 Rx 0.76 3.84 2.54 | ||
Kefir 1.00 1.00 1.00 Bacon 16.12 5.24 9.61 Rx 0.77 3.52 2.41 | ||
@@ -51,6 +51,6 @@ | ||
---------------------------------------------------------------- | ||
Kefir w/o subscr. 0.08 KiB w/ subscr. +0.01 KiB sum 0.10 KiB | ||
Bacon w/o subscr. 2.48 KiB w/ subscr. +1.06 KiB sum 3.54 KiB | ||
Kefir w/o subscr. 0.08 KiB w/ subscr. +0.00 KiB sum 0.09 KiB | ||
Bacon w/o subscr. 2.47 KiB w/ subscr. +1.07 KiB sum 3.55 KiB | ||
----------------------- | ||
Kefir 1.00 1.00 1.00 Bacon 29.57 86.58 36.86 | ||
Kefir 1.00 1.00 1.00 Bacon 29.42 558.32 41.23 | ||
@@ -60,7 +60,7 @@ | ||
---------------------------------------------------------------- | ||
Kefir w/o subscr. 0.30 KiB w/ subscr. +0.47 KiB sum 0.77 KiB | ||
Kefir w/o subscr. 0.48 KiB w/ subscr. +0.50 KiB sum 0.97 KiB | ||
Bacon w/o subscr. 2.41 KiB w/ subscr. +2.32 KiB sum 4.72 KiB | ||
Rx w/o subscr. 0.33 KiB w/ subscr. +3.06 KiB sum 3.40 KiB | ||
----------------------- | ||
Kefir 1.00 1.00 1.00 Bacon 7.90 4.97 6.13 Rx 1.10 6.57 4.41 | ||
Kefir 1.00 1.00 1.00 Bacon 5.05 4.66 4.85 Rx 0.70 6.16 3.49 | ||
@@ -70,7 +70,7 @@ | ||
---------------------------------------------------------------- | ||
Kefir w/o subscr. 0.46 KiB w/ subscr. +0.47 KiB sum 0.93 KiB | ||
Kefir w/o subscr. 0.48 KiB w/ subscr. +0.50 KiB sum 0.97 KiB | ||
Bacon w/o subscr. 3.46 KiB w/ subscr. +1.35 KiB sum 4.82 KiB | ||
Rx w/o subscr. 0.37 KiB w/ subscr. +1.45 KiB sum 1.83 KiB | ||
----------------------- | ||
Kefir 1.00 1.00 1.00 Bacon 7.46 2.89 5.17 Rx 0.80 3.11 1.96 | ||
Kefir 1.00 1.00 1.00 Bacon 7.26 2.73 4.95 Rx 0.78 2.93 1.88 | ||
@@ -80,7 +80,7 @@ | ||
---------------------------------------------------------------- | ||
Kefir w/o subscr. 0.47 KiB w/ subscr. +0.47 KiB sum 0.95 KiB | ||
Kefir w/o subscr. 0.48 KiB w/ subscr. +0.50 KiB sum 0.98 KiB | ||
Bacon w/o subscr. 2.23 KiB w/ subscr. +2.31 KiB sum 4.54 KiB | ||
Rx w/o subscr. 0.79 KiB w/ subscr. +2.48 KiB sum 3.27 KiB | ||
Rx w/o subscr. 0.79 KiB w/ subscr. +2.49 KiB sum 3.27 KiB | ||
----------------------- | ||
Kefir 1.00 1.00 1.00 Bacon 4.69 4.90 4.79 Rx 1.66 5.27 3.46 | ||
Kefir 1.00 1.00 1.00 Bacon 4.68 4.59 4.64 Rx 1.66 4.94 3.34 | ||
@@ -90,6 +90,6 @@ | ||
---------------------------------------------------------------- | ||
Kefir w/o subscr. 0.37 KiB w/ subscr. +0.56 KiB sum 0.94 KiB | ||
Bacon w/o subscr. 2.42 KiB w/ subscr. +1.40 KiB sum 3.82 KiB | ||
Kefir w/o subscr. 0.37 KiB w/ subscr. +0.55 KiB sum 0.92 KiB | ||
Bacon w/o subscr. 2.42 KiB w/ subscr. +1.41 KiB sum 3.83 KiB | ||
----------------------- | ||
Kefir 1.00 1.00 1.00 Bacon 6.47 2.49 4.08 | ||
Kefir 1.00 1.00 1.00 Bacon 6.51 2.56 4.15 | ||
@@ -99,7 +99,7 @@ | ||
---------------------------------------------------------------- | ||
Kefir w/o subscr. 0.46 KiB w/ subscr. +0.47 KiB sum 0.93 KiB | ||
Kefir w/o subscr. 0.47 KiB w/ subscr. +0.50 KiB sum 0.97 KiB | ||
Bacon w/o subscr. 3.46 KiB w/ subscr. +1.35 KiB sum 4.81 KiB | ||
Rx w/o subscr. 0.37 KiB w/ subscr. +1.45 KiB sum 1.82 KiB | ||
----------------------- | ||
Kefir 1.00 1.00 1.00 Bacon 7.56 2.86 5.18 Rx 0.81 3.07 1.96 | ||
Kefir 1.00 1.00 1.00 Bacon 7.35 2.68 4.94 Rx 0.79 2.88 1.87 | ||
@@ -109,7 +109,7 @@ | ||
---------------------------------------------------------------- | ||
Kefir w/o subscr. 0.21 KiB w/ subscr. +1.17 KiB sum 1.39 KiB | ||
Kefir w/o subscr. 0.21 KiB w/ subscr. +1.30 KiB sum 1.51 KiB | ||
Bacon w/o subscr. 2.03 KiB w/ subscr. +3.14 KiB sum 5.18 KiB | ||
Rx w/o subscr. 0.65 KiB w/ subscr. +5.26 KiB sum 5.92 KiB | ||
Rx w/o subscr. 0.65 KiB w/ subscr. +5.26 KiB sum 5.91 KiB | ||
----------------------- | ||
Kefir 1.00 1.00 1.00 Bacon 9.60 2.68 3.74 Rx 3.09 4.48 4.27 | ||
Kefir 1.00 1.00 1.00 Bacon 9.58 2.42 3.43 Rx 3.08 4.05 3.91 | ||
@@ -119,7 +119,7 @@ | ||
---------------------------------------------------------------- | ||
Kefir w/o subscr. -0.00 KiB w/ subscr. -0.01 KiB sum -0.01 KiB | ||
Bacon w/o subscr. 2.05 KiB w/ subscr. +0.88 KiB sum 2.93 KiB | ||
Kefir w/o subscr. -0.00 KiB w/ subscr. -0.01 KiB sum -0.02 KiB | ||
Bacon w/o subscr. 2.05 KiB w/ subscr. +0.89 KiB sum 2.94 KiB | ||
Rx w/o subscr. 0.23 KiB w/ subscr. -0.00 KiB sum 0.23 KiB | ||
----------------------- | ||
Kefir 1.00 1.00 1.00 Bacon -781.37 -106.29 -269.12 Rx -88.51 0.26 -21.15 | ||
Kefir 1.00 1.00 1.00 Bacon -595.95 -61.33 -164.20 Rx -67.46 0.15 -12.86 | ||
@@ -129,6 +129,6 @@ | ||
---------------------------------------------------------------- | ||
Kefir w/o subscr. 0.57 KiB w/ subscr. +0.74 KiB sum 1.31 KiB | ||
Bacon w/o subscr. 5.96 KiB w/ subscr. +3.86 KiB sum 9.83 KiB | ||
Kefir w/o subscr. 0.56 KiB w/ subscr. +0.81 KiB sum 1.37 KiB | ||
Bacon w/o subscr. 5.97 KiB w/ subscr. +3.86 KiB sum 9.83 KiB | ||
----------------------- | ||
Kefir 1.00 1.00 1.00 Bacon 10.54 5.20 7.51 | ||
Kefir 1.00 1.00 1.00 Bacon 10.57 4.80 7.17 | ||
@@ -138,7 +138,7 @@ | ||
---------------------------------------------------------------- | ||
Kefir w/o subscr. 0.45 KiB w/ subscr. +0.47 KiB sum 0.92 KiB | ||
Kefir w/o subscr. 0.46 KiB w/ subscr. +0.50 KiB sum 0.96 KiB | ||
Bacon w/o subscr. 2.96 KiB w/ subscr. +1.54 KiB sum 4.50 KiB | ||
Rx w/o subscr. 0.38 KiB w/ subscr. +1.15 KiB sum 1.53 KiB | ||
----------------------- | ||
Kefir 1.00 1.00 1.00 Bacon 6.53 3.29 4.88 Rx 0.85 2.46 1.67 | ||
Kefir 1.00 1.00 1.00 Bacon 6.44 3.09 4.70 Rx 0.84 2.30 1.60 | ||
@@ -148,6 +148,6 @@ | ||
---------------------------------------------------------------- | ||
Kefir w/o subscr. 0.43 KiB w/ subscr. +0.52 KiB sum 0.95 KiB | ||
Bacon w/o subscr. 2.38 KiB w/ subscr. +1.40 KiB sum 3.78 KiB | ||
Kefir w/o subscr. 0.43 KiB w/ subscr. +0.51 KiB sum 0.94 KiB | ||
Bacon w/o subscr. 2.38 KiB w/ subscr. +1.41 KiB sum 3.79 KiB | ||
----------------------- | ||
Kefir 1.00 1.00 1.00 Bacon 5.51 2.72 3.99 | ||
Kefir 1.00 1.00 1.00 Bacon 5.53 2.78 4.05 | ||
@@ -157,7 +157,7 @@ | ||
---------------------------------------------------------------- | ||
Kefir w/o subscr. 0.50 KiB w/ subscr. +0.47 KiB sum 0.97 KiB | ||
Kefir w/o subscr. 0.48 KiB w/ subscr. +0.50 KiB sum 0.98 KiB | ||
Bacon w/o subscr. 3.57 KiB w/ subscr. +1.35 KiB sum 4.92 KiB | ||
Rx w/o subscr. 0.38 KiB w/ subscr. +1.46 KiB sum 1.84 KiB | ||
----------------------- | ||
Kefir 1.00 1.00 1.00 Bacon 7.18 2.88 5.09 Rx 0.76 3.11 1.90 | ||
Kefir 1.00 1.00 1.00 Bacon 7.46 2.69 5.02 Rx 0.79 2.91 1.87 | ||
@@ -167,7 +167,7 @@ | ||
---------------------------------------------------------------- | ||
Kefir w/o subscr. 0.31 KiB w/ subscr. +0.47 KiB sum 0.77 KiB | ||
Kefir w/o subscr. 0.31 KiB w/ subscr. +0.50 KiB sum 0.81 KiB | ||
Bacon w/o subscr. 3.32 KiB w/ subscr. +1.35 KiB sum 4.67 KiB | ||
Rx w/o subscr. 0.29 KiB w/ subscr. +1.45 KiB sum 1.74 KiB | ||
----------------------- | ||
Kefir 1.00 1.00 1.00 Bacon 10.81 2.91 6.05 Rx 0.95 3.12 2.26 | ||
Kefir 1.00 1.00 1.00 Bacon 10.64 2.72 5.78 Rx 0.94 2.92 2.15 | ||
@@ -177,7 +177,7 @@ | ||
---------------------------------------------------------------- | ||
Kefir w/o subscr. 0.53 KiB w/ subscr. +0.47 KiB sum 1.00 KiB | ||
Kefir w/o subscr. 0.52 KiB w/ subscr. +0.50 KiB sum 1.02 KiB | ||
Bacon w/o subscr. 7.30 KiB w/ subscr. +2.18 KiB sum 9.47 KiB | ||
Rx w/o subscr. 0.43 KiB w/ subscr. +1.01 KiB sum 1.44 KiB | ||
----------------------- | ||
Kefir 1.00 1.00 1.00 Bacon 13.75 4.67 9.50 Rx 0.81 2.16 1.44 | ||
Kefir 1.00 1.00 1.00 Bacon 14.04 4.38 9.32 Rx 0.83 2.02 1.41 | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1621581
148
36293