Comparing version 1.2.0 to 1.3.0
@@ -1,3 +0,9 @@ | ||
## next | ||
## 1.3.0 | ||
- Following methods are deprecated: | ||
`.repeatedly`, `.mapTo`, `.pluck`, `.invoke`, `.not`, `.timestamp`, `.tap`, `.and`, `.or` | ||
(see [#71](https://github.com/pozadi/kefir/issues/71)) | ||
## 1.2.0 | ||
- `Kefir.sampledBy` is deprecated in favor of 3 arity `Kefir.combine` | ||
@@ -4,0 +10,0 @@ |
@@ -1,2 +0,2 @@ | ||
/*! Kefir.js v1.2.0 | ||
/*! Kefir.js v1.3.0 | ||
* https://github.com/pozadi/kefir | ||
@@ -34,4 +34,8 @@ */ | ||
var result, length, i, j; | ||
if (a.length === 0) { return b } | ||
if (b.length === 0) { return a } | ||
if (a.length === 0) { | ||
return b; | ||
} | ||
if (b.length === 0) { | ||
return a; | ||
} | ||
j = 0; | ||
@@ -64,3 +68,5 @@ result = new Array(a.length + b.length); | ||
for (i = 0; i < length; i++) { | ||
if (arr[i] === value) { return i } | ||
if (arr[i] === value) { | ||
return i; | ||
} | ||
} | ||
@@ -74,3 +80,5 @@ return -1; | ||
for (i = 0; i < length; i++) { | ||
if (pred(arr[i])) { return i } | ||
if (pred(arr[i])) { | ||
return i; | ||
} | ||
} | ||
@@ -128,3 +136,5 @@ return -1; | ||
, i; | ||
for (i = 0; i < length; i++) { fn(arr[i]) } | ||
for (i = 0; i < length; i++) { | ||
fn(arr[i]); | ||
} | ||
} | ||
@@ -184,8 +194,8 @@ | ||
switch(length) { | ||
case 0: return function(a) { return fn() }; | ||
case 1: return function(a) { return fn(a[0]) }; | ||
case 2: return function(a) { return fn(a[0], a[1]) }; | ||
case 3: return function(a) { return fn(a[0], a[1], a[2]) }; | ||
case 4: return function(a) { return fn(a[0], a[1], a[2], a[3]) }; | ||
default: return function(a) { return fn.apply(null, a) }; | ||
case 0: return function(a) {return fn();}; | ||
case 1: return function(a) {return fn(a[0]);}; | ||
case 2: return function(a) {return fn(a[0], a[1]);}; | ||
case 3: return function(a) {return fn(a[0], a[1], a[2]);}; | ||
case 4: return function(a) {return fn(a[0], a[1], a[2], a[3]);}; | ||
default: return function(a) {return fn.apply(null, a);}; | ||
} | ||
@@ -198,7 +208,7 @@ } | ||
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]); | ||
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); | ||
@@ -208,3 +218,3 @@ } | ||
switch (aLength) { | ||
case 0: return fn.call(c); | ||
case 0: return fn.call(c); | ||
default: return fn.apply(c, a); | ||
@@ -276,13 +286,35 @@ } | ||
function defaultDiff(a, b) { | ||
return [a, b] | ||
return [a, b]; | ||
} | ||
var now = Date.now ? | ||
function() { return Date.now() } : | ||
function() { return new Date().getTime() }; | ||
function() { | ||
return Date.now(); | ||
} : | ||
function() { | ||
return new Date().getTime(); | ||
}; | ||
var log = ((typeof console !== undefined) && isFn(console.log)) ? | ||
function(m) {console.log(m)} : | ||
noop; | ||
function(m) { | ||
console.log(m); | ||
} : noop; | ||
Kefir.DEPRECATION_WARNINGS = true; | ||
function deprecated(name, alt, fn) { | ||
var message = 'Method `' + name + '` is deprecated, and to be removed in v3.0.0.'; | ||
if (alt) { | ||
message += '\nUse `' + alt + '` instead.'; | ||
} | ||
message += '\nTo disable all warnings like this set `Kefir.DEPRECATION_WARNINGS = false`.'; | ||
return function() { | ||
if (Kefir.DEPRECATION_WARNINGS) { | ||
log(message); | ||
} | ||
return fn.apply(this, arguments); | ||
}; | ||
} | ||
function isFn(fn) { | ||
@@ -302,7 +334,7 @@ return typeof fn === 'function'; | ||
return Object.prototype.toString.call(xs) === '[object Array]'; | ||
} | ||
}; | ||
var isArguments = function(xs) { | ||
return Object.prototype.toString.call(xs) === '[object Arguments]'; | ||
} | ||
}; | ||
@@ -313,3 +345,3 @@ // For IE | ||
return !!(obj && own(obj, 'callee')); | ||
} | ||
}; | ||
} | ||
@@ -324,3 +356,5 @@ | ||
var $ = this; | ||
this._$onTick = function() { $._onTick() } | ||
this._$onTick = function() { | ||
$._onTick(); | ||
}; | ||
this._init(args); | ||
@@ -358,3 +392,3 @@ } | ||
return new AnonymousStream(wait, rest(arguments, 1, [])); | ||
} | ||
}; | ||
} | ||
@@ -367,6 +401,10 @@ | ||
streamMethod: function(StreamClass, PropertyClass) { | ||
return function() { return new StreamClass(this, arguments) } | ||
return function() { | ||
return new StreamClass(this, arguments); | ||
}; | ||
}, | ||
propertyMethod: function(StreamClass, PropertyClass) { | ||
return function() { return new PropertyClass(this, arguments) } | ||
return function() { | ||
return new PropertyClass(this, arguments); | ||
}; | ||
} | ||
@@ -381,5 +419,11 @@ }, options || {}); | ||
_handleValue: function(x, isCurrent) { this._send(VALUE, x, isCurrent) }, | ||
_handleError: function(x, isCurrent) { this._send(ERROR, x, isCurrent) }, | ||
_handleEnd: function(__, isCurrent) { this._send(END, null, isCurrent) }, | ||
_handleValue: function(x, isCurrent) { | ||
this._send(VALUE, x, isCurrent); | ||
}, | ||
_handleError: function(x, isCurrent) { | ||
this._send(ERROR, x, isCurrent); | ||
}, | ||
_handleEnd: function(__, isCurrent) { | ||
this._send(END, null, isCurrent); | ||
}, | ||
@@ -411,3 +455,5 @@ _handleAny: function(event) { | ||
var $ = this; | ||
this._$handleAny = function(event) { $._handleAny(event) } | ||
this._$handleAny = function(event) { | ||
$._handleAny(event); | ||
}; | ||
} | ||
@@ -447,8 +493,18 @@ | ||
_handlePrimaryValue: function(x, isCurrent) { this._send(VALUE, x, isCurrent) }, | ||
_handlePrimaryError: function(x, isCurrent) { this._send(ERROR, x, isCurrent) }, | ||
_handlePrimaryEnd: function(__, isCurrent) { this._send(END, null, isCurrent) }, | ||
_handlePrimaryValue: function(x, isCurrent) { | ||
this._send(VALUE, x, isCurrent); | ||
}, | ||
_handlePrimaryError: function(x, isCurrent) { | ||
this._send(ERROR, x, isCurrent); | ||
}, | ||
_handlePrimaryEnd: function(__, isCurrent) { | ||
this._send(END, null, isCurrent); | ||
}, | ||
_handleSecondaryValue: function(x, isCurrent) { this._lastSecondary = x }, | ||
_handleSecondaryError: function(x, isCurrent) { this._send(ERROR, x, isCurrent) }, | ||
_handleSecondaryValue: function(x, isCurrent) { | ||
this._lastSecondary = x; | ||
}, | ||
_handleSecondaryError: function(x, isCurrent) { | ||
this._send(ERROR, x, isCurrent); | ||
}, | ||
_handleSecondaryEnd: function(__, isCurrent) {}, | ||
@@ -518,4 +574,8 @@ | ||
var $ = this; | ||
this._$handleSecondaryAny = function(event) { $._handleSecondaryAny(event) } | ||
this._$handlePrimaryAny = function(event) { $._handlePrimaryAny(event) } | ||
this._$handleSecondaryAny = function(event) { | ||
$._handleSecondaryAny(event); | ||
}; | ||
this._$handlePrimaryAny = function(event) { | ||
$._handlePrimaryAny(event); | ||
}; | ||
this._init(args); | ||
@@ -545,7 +605,7 @@ } | ||
return new AnonymousStream(this, secondary, rest(arguments, 1, [])); | ||
} | ||
}; | ||
Property.prototype[name] = function(secondary) { | ||
return new AnonymousProperty(this, secondary, rest(arguments, 1, [])); | ||
} | ||
}; | ||
@@ -573,15 +633,13 @@ } | ||
extend(Dispatcher.prototype, { | ||
add: function(type, fn, _key) { | ||
add: function(type, fn) { | ||
this._items = concat(this._items, [{ | ||
type: type, | ||
fn: fn, | ||
key: _key || null | ||
fn: fn | ||
}]); | ||
return this._items.length; | ||
}, | ||
remove: function(type, fn, _key) { | ||
var pred = isArray(_key) ? | ||
function(fnData) {return fnData.type === type && isEqualArrays(fnData.key, _key)} : | ||
function(fnData) {return fnData.type === type && fnData.fn === fn}; | ||
this._items = removeByPred(this._items, pred); | ||
remove: function(type, fn) { | ||
this._items = removeByPred(this._items, function(fnData) { | ||
return fnData.type === type && fnData.fn === fn; | ||
}); | ||
return this._items.length; | ||
@@ -652,9 +710,11 @@ }, | ||
this._dispatcher.dispatch(Event(type, x, isCurrent)); | ||
if (type === END) { this._clear() } | ||
if (type === END) { | ||
this._clear(); | ||
} | ||
} | ||
}, | ||
_on: function(type, fn, _key) { | ||
_on: function(type, fn) { | ||
if (this._alive) { | ||
this._dispatcher.add(type, fn, _key); | ||
this._dispatcher.add(type, fn); | ||
this._setActive(true); | ||
@@ -667,5 +727,5 @@ } else { | ||
_off: function(type, fn, _key) { | ||
_off: function(type, fn) { | ||
if (this._alive) { | ||
var count = this._dispatcher.remove(type, fn, _key); | ||
var count = this._dispatcher.remove(type, fn); | ||
if (count === 0) { | ||
@@ -678,11 +738,27 @@ this._setActive(false); | ||
onValue: function(fn, _key) { return this._on(VALUE, fn, _key) }, | ||
onError: function(fn, _key) { return this._on(ERROR, fn, _key) }, | ||
onEnd: function(fn, _key) { return this._on(END, fn, _key) }, | ||
onAny: function(fn, _key) { return this._on(ANY, fn, _key) }, | ||
onValue: function(fn) { | ||
return this._on(VALUE, fn); | ||
}, | ||
onError: function(fn) { | ||
return this._on(ERROR, fn); | ||
}, | ||
onEnd: function(fn) { | ||
return this._on(END, fn); | ||
}, | ||
onAny: function(fn) { | ||
return this._on(ANY, fn); | ||
}, | ||
offValue: function(fn, _key) { return this._off(VALUE, fn, _key) }, | ||
offError: function(fn, _key) { return this._off(ERROR, fn, _key) }, | ||
offEnd: function(fn, _key) { return this._off(END, fn, _key) }, | ||
offAny: function(fn, _key) { return this._off(ANY, fn, _key) } | ||
offValue: function(fn) { | ||
return this._off(VALUE, fn); | ||
}, | ||
offError: function(fn) { | ||
return this._off(ERROR, fn); | ||
}, | ||
offEnd: function(fn) { | ||
return this._off(END, fn); | ||
}, | ||
offAny: function(fn) { | ||
return this._off(ANY, fn); | ||
} | ||
@@ -693,3 +769,5 @@ }); | ||
// extend() can't handle `toString` in IE8 | ||
Observable.prototype.toString = function() { return '[' + this._name + ']' }; | ||
Observable.prototype.toString = function() { | ||
return '[' + this._name + ']'; | ||
}; | ||
@@ -741,11 +819,17 @@ | ||
} | ||
if (type === VALUE) { this._current = x } | ||
if (type === ERROR) { this._currentError = x } | ||
if (type === END) { this._clear() } | ||
if (type === VALUE) { | ||
this._current = x; | ||
} | ||
if (type === ERROR) { | ||
this._currentError = x; | ||
} | ||
if (type === END) { | ||
this._clear(); | ||
} | ||
} | ||
}, | ||
_on: function(type, fn, _key) { | ||
_on: function(type, fn) { | ||
if (this._alive) { | ||
this._dispatcher.add(type, fn, _key); | ||
this._dispatcher.add(type, fn); | ||
this._setActive(true); | ||
@@ -776,3 +860,4 @@ } | ||
name = name || this.toString(); | ||
this.onAny(function(event) { | ||
var handler = function(event) { | ||
var typeStr = '<' + event.type + (event.current ? ':current' : '') + '>'; | ||
@@ -784,11 +869,29 @@ if (event.type === VALUE || event.type === ERROR) { | ||
} | ||
}, ['__logKey__', this, name]); | ||
}; | ||
if (!this.__logHandlers) { | ||
this.__logHandlers = []; | ||
} | ||
this.__logHandlers.push({name: name, handler: handler}); | ||
this.onAny(handler); | ||
return this; | ||
} | ||
}; | ||
Observable.prototype.offLog = function(name) { | ||
name = name || this.toString(); | ||
this.offAny(null, ['__logKey__', this, name]); | ||
if (this.__logHandlers) { | ||
var handlerIndex = findByPred(this.__logHandlers, function(obj) { | ||
return obj.name === name; | ||
}); | ||
if (handlerIndex !== -1) { | ||
var handler = this.__logHandlers[handlerIndex].handler; | ||
this.__logHandlers.splice(handlerIndex, 1); | ||
this.offAny(handler); | ||
} | ||
} | ||
return this; | ||
} | ||
}; | ||
@@ -804,7 +907,15 @@ | ||
this._emitter = { | ||
emit: function(x) { $._send(VALUE, x) }, | ||
error: function(x) { $._send(ERROR, x) }, | ||
end: function() { $._send(END) }, | ||
emitEvent: function(e) { $._send(e.type, e.value) } | ||
} | ||
emit: function(x) { | ||
$._send(VALUE, x); | ||
}, | ||
error: function(x) { | ||
$._send(ERROR, x); | ||
}, | ||
end: function() { | ||
$._send(END); | ||
}, | ||
emitEvent: function(e) { | ||
$._send(e.type, e.value); | ||
} | ||
}; | ||
}, | ||
@@ -865,3 +976,3 @@ _free: function() { | ||
if (this._xs.length === 0) { | ||
this._send(END) | ||
this._send(END); | ||
} | ||
@@ -902,2 +1013,7 @@ }, | ||
Kefir.repeatedly = deprecated( | ||
'Kefir.repeatedly()', | ||
'Kefir.repeat(() => Kefir.sequentially(...)})', | ||
Kefir.repeatedly | ||
); | ||
@@ -907,2 +1023,3 @@ | ||
// Kefir.later() | ||
@@ -934,3 +1051,5 @@ | ||
var $ = this; | ||
this._$handleSubAny = function(event) { $._handleSubAny(event) }; | ||
this._$handleSubAny = function(event) { | ||
$._handleSubAny(event); | ||
}; | ||
@@ -940,2 +1059,4 @@ this._queue = []; | ||
this._activating = false; | ||
this._bindedEndHandlers = []; | ||
} | ||
@@ -962,3 +1083,5 @@ | ||
var $ = this; | ||
forEach(obss, function(obs) { $._add(obs) }); | ||
forEach(obss, function(obs) { | ||
$._add(obs); | ||
}); | ||
}, | ||
@@ -976,12 +1099,29 @@ _remove: function(obs) { | ||
this._curSources = concat(this._curSources, [obs]); | ||
if (this._active) { this._subscribe(obs) } | ||
if (this._active) { | ||
this._subscribe(obs); | ||
} | ||
}, | ||
_subscribe: function(obs) { | ||
var $ = this; | ||
var onEnd = function() { | ||
$._removeCur(obs); | ||
}; | ||
this._bindedEndHandlers.push({obs: obs, handler: onEnd}); | ||
obs.onAny(this._$handleSubAny); | ||
obs.onEnd(function() { $._removeCur(obs) }, [this, obs]); | ||
obs.onEnd(onEnd); | ||
}, | ||
_unsubscribe: function(obs) { | ||
obs.offAny(this._$handleSubAny); | ||
obs.offEnd(null, [this, obs]); | ||
var onEndI = findByPred(this._bindedEndHandlers, function(obj) { | ||
return obj.obs === obs; | ||
}); | ||
if (onEndI !== -1) { | ||
var onEnd = this._bindedEndHandlers[onEndI].handler; | ||
this._bindedEndHandlers.splice(onEndI, 1); | ||
obs.offEnd(onEnd); | ||
} | ||
}, | ||
@@ -1000,3 +1140,5 @@ _handleSubAny: function(event) { | ||
_removeCur: function(obs) { | ||
if (this._active) { this._unsubscribe(obs) } | ||
if (this._active) { | ||
this._unsubscribe(obs); | ||
} | ||
var index = find(this._curSources, obs); | ||
@@ -1038,6 +1180,10 @@ this._curSources = remove(this._curSources, index); | ||
, i; | ||
for (i = 0; i < sources.length; i++) { this._unsubscribe(sources[i]) } | ||
for (i = 0; i < sources.length; i++) { | ||
this._unsubscribe(sources[i]); | ||
} | ||
}, | ||
_isEmpty: function() { return this._curSources.length === 0 }, | ||
_isEmpty: function() { | ||
return this._curSources.length === 0; | ||
}, | ||
_onEmpty: function() {}, | ||
@@ -1050,2 +1196,3 @@ | ||
this._$handleSubAny = null; | ||
this._bindedEndHandlers = null; | ||
} | ||
@@ -1063,3 +1210,5 @@ | ||
_onEmpty: function() { | ||
if (this._initialised) { this._send(END, null, this._activating) } | ||
if (this._initialised) { | ||
this._send(END, null, this._activating); | ||
} | ||
} | ||
@@ -1070,3 +1219,7 @@ }; | ||
_AbstractPool.call(this); | ||
if (sources.length === 0) { this._send(END) } else { this._addAll(sources) } | ||
if (sources.length === 0) { | ||
this._send(END); | ||
} else { | ||
this._addAll(sources); | ||
} | ||
this._initialised = true; | ||
@@ -1079,7 +1232,7 @@ } | ||
return new Merge(obss); | ||
} | ||
}; | ||
Observable.prototype.merge = function(other) { | ||
return Kefir.merge([this, other]); | ||
} | ||
}; | ||
@@ -1093,3 +1246,7 @@ | ||
_AbstractPool.call(this, {concurLim: 1, queueLim: -1}); | ||
if (sources.length === 0) { this._send(END) } else { this._addAll(sources) } | ||
if (sources.length === 0) { | ||
this._send(END); | ||
} else { | ||
this._addAll(sources); | ||
} | ||
this._initialised = true; | ||
@@ -1102,7 +1259,7 @@ } | ||
return new Concat(obss); | ||
} | ||
}; | ||
Observable.prototype.concat = function(other) { | ||
return Kefir.concat([this, other]); | ||
} | ||
}; | ||
@@ -1138,3 +1295,3 @@ | ||
return new Pool(); | ||
} | ||
}; | ||
@@ -1185,3 +1342,3 @@ | ||
return new Bus(); | ||
} | ||
}; | ||
@@ -1202,3 +1359,5 @@ | ||
var $ = this; | ||
this._$handleMainSource = function(event) { $._handleMainSource(event) }; | ||
this._$handleMainSource = function(event) { | ||
$._handleMainSource(event); | ||
}; | ||
} | ||
@@ -1241,3 +1400,5 @@ | ||
_onEmpty: function() { | ||
if (this._mainEnded) { this._send(END) } | ||
if (this._mainEnded) { | ||
this._send(END); | ||
} | ||
}, | ||
@@ -1257,3 +1418,3 @@ | ||
.setName(this, 'flatMap'); | ||
} | ||
}; | ||
@@ -1263,3 +1424,3 @@ Observable.prototype.flatMapLatest = function(fn) { | ||
.setName(this, 'flatMapLatest'); | ||
} | ||
}; | ||
@@ -1269,3 +1430,3 @@ Observable.prototype.flatMapFirst = function(fn) { | ||
.setName(this, 'flatMapFirst'); | ||
} | ||
}; | ||
@@ -1275,3 +1436,3 @@ Observable.prototype.flatMapConcat = function(fn) { | ||
.setName(this, 'flatMapConcat'); | ||
} | ||
}; | ||
@@ -1283,7 +1444,9 @@ Observable.prototype.flatMapConcurLimit = function(fn, limit) { | ||
} else { | ||
if (limit < 0) { limit = -1 } | ||
if (limit < 0) { | ||
limit = -1; | ||
} | ||
result = new FlatMap(this, fn, {queueLim: -1, concurLim: limit}); | ||
} | ||
return result.setName(this, 'flatMapConcurLimit'); | ||
} | ||
}; | ||
@@ -1310,2 +1473,8 @@ | ||
this._aliveCount = 0; | ||
this._bindedHandlers = Array(this._sources.length); | ||
for (var i = 0; i < this._sources.length; i++) { | ||
this._bindedHandlers[i] = this._bindHandleAny(i); | ||
} | ||
} | ||
@@ -1325,3 +1494,3 @@ } | ||
if (this._active) { | ||
this._sources[i].onAny(this._bindHandleAny(i), [this, i]); | ||
this._sources[i].onAny(this._bindedHandlers[i]); | ||
} | ||
@@ -1333,3 +1502,3 @@ } | ||
for (var i = 0; i < this._sources.length; i++) { | ||
this._sources[i].offAny(null, [this, i]); | ||
this._sources[i].offAny(this._bindedHandlers[i]); | ||
} | ||
@@ -1369,3 +1538,5 @@ }, | ||
var $ = this; | ||
return function(event) { $._handleAny(i, event) }; | ||
return function(event) { | ||
$._handleAny(i, event); | ||
}; | ||
}, | ||
@@ -1394,2 +1565,3 @@ | ||
this._combinator = null; | ||
this._bindedHandlers = null; | ||
} | ||
@@ -1401,7 +1573,7 @@ | ||
return new Zip(sources, combinator); | ||
} | ||
}; | ||
Observable.prototype.zip = function(other, combinator) { | ||
return new Zip([this, other], combinator); | ||
} | ||
}; | ||
@@ -1429,2 +1601,8 @@ | ||
this._endAfterActivation = false; | ||
this._bindedHandlers = Array(this._sources.length); | ||
for (var i = 0; i < this._sources.length; i++) { | ||
this._bindedHandlers[i] = this._bindHandleAny(i); | ||
} | ||
} | ||
@@ -1444,3 +1622,3 @@ } | ||
for (i = 0; i < length; i++) { | ||
this._sources[i].onAny(this._bindHandleAny(i), [this, i]); | ||
this._sources[i].onAny(this._bindedHandlers[i]); | ||
} | ||
@@ -1461,3 +1639,3 @@ this._activating = false; | ||
for (i = 0; i < length; i++) { | ||
this._sources[i].offAny(null, [this, i]); | ||
this._sources[i].offAny(this._bindedHandlers[i]); | ||
} | ||
@@ -1476,3 +1654,5 @@ }, | ||
var $ = this; | ||
return function(event) { $._handleAny(i, event) }; | ||
return function(event) { | ||
$._handleAny(i, event); | ||
}; | ||
}, | ||
@@ -1513,2 +1693,3 @@ | ||
this._combinator = null; | ||
this._bindedHandlers = null; | ||
} | ||
@@ -1524,7 +1705,7 @@ | ||
return new Combine(active, passive || [], combinator); | ||
} | ||
}; | ||
Observable.prototype.combine = function(other, combinator) { | ||
return Kefir.combine([this, other], combinator); | ||
} | ||
}; | ||
@@ -1537,27 +1718,21 @@ | ||
// .sampledBy() | ||
Kefir.sampledBy = deprecated( | ||
'Kefir.sampledBy()', | ||
'Kefir.combine(active, passive, combinator)', | ||
function(passive, active, combinator) { | ||
Kefir.DISABLE_SAMPLEDBY_WARNING = false; | ||
// we need to flip `passive` and `active` in combinator function | ||
var _combinator = combinator; | ||
if (passive.length > 0) { | ||
var passiveLength = passive.length; | ||
_combinator = function() { | ||
var args = circleShift(arguments, passiveLength); | ||
return combinator ? apply(combinator, null, args) : args; | ||
}; | ||
} | ||
Kefir.sampledBy = function(passive, active, combinator) { | ||
if (!Kefir.DISABLE_SAMPLEDBY_WARNING) { | ||
log('Kefir.sampledBy() is deprecated, and to be removed in v3.0.0.\n' + | ||
'Use Kefir.combine(active, passive, combinator) instead, ' + | ||
'but note than active/passive order is different.\n' + | ||
'To disable this warning set Kefir.DISABLE_SAMPLEDBY_WARNING to true.'); | ||
return new Combine(active, passive, _combinator).setName('sampledBy'); | ||
} | ||
); | ||
// we need to flip `passive` and `active` in combinator function | ||
var _combinator = combinator; | ||
if (passive.length > 0) { | ||
var passiveLength = passive.length; | ||
_combinator = function() { | ||
var args = circleShift(arguments, passiveLength); | ||
return combinator ? apply(combinator, null, args) : args; | ||
} | ||
} | ||
return new Combine(active, passive, _combinator).setName('sampledBy'); | ||
} | ||
Observable.prototype.sampledBy = function(other, combinator) { | ||
@@ -1568,12 +1743,16 @@ var _combinator; | ||
return combinator(passive, active); | ||
} | ||
}; | ||
} | ||
return new Combine([other], [this], _combinator || id2).setName(this, 'sampledBy'); | ||
} | ||
}; | ||
function produceStream(StreamClass, PropertyClass) { | ||
return function() { return new StreamClass(this, arguments) } | ||
return function() { | ||
return new StreamClass(this, arguments); | ||
}; | ||
} | ||
function produceProperty(StreamClass, PropertyClass) { | ||
return function() { return new PropertyClass(this, arguments) } | ||
return function() { | ||
return new PropertyClass(this, arguments); | ||
}; | ||
} | ||
@@ -1614,3 +1793,3 @@ | ||
return this; | ||
} | ||
}; | ||
}, | ||
@@ -1631,7 +1810,15 @@ propertyMethod: produceStream | ||
this._emitter = { | ||
emit: function(x) { $._send(VALUE, x, $._forcedCurrent) }, | ||
error: function(x) { $._send(ERROR, x, $._forcedCurrent) }, | ||
end: function() { $._send(END, null, $._forcedCurrent) }, | ||
emitEvent: function(e) { $._send(e.type, e.value, $._forcedCurrent) } | ||
} | ||
emit: function(x) { | ||
$._send(VALUE, x, $._forcedCurrent); | ||
}, | ||
error: function(x) { | ||
$._send(ERROR, x, $._forcedCurrent); | ||
}, | ||
end: function() { | ||
$._send(END, null, $._forcedCurrent); | ||
}, | ||
emitEvent: function(e) { | ||
$._send(e.type, e.value, $._forcedCurrent); | ||
} | ||
}; | ||
}, | ||
@@ -1715,6 +1902,2 @@ _free: function() { | ||
var withFnArgMixin = { | ||
_init: function(args) { this._fn = args[0] || id }, | ||
_free: function() { this._fn = null } | ||
}; | ||
@@ -1725,7 +1908,13 @@ | ||
withOneSource('map', extend({ | ||
withOneSource('map', { | ||
_init: function(args) { | ||
this._fn = args[0] || id; | ||
}, | ||
_free: function() { | ||
this._fn = null; | ||
}, | ||
_handleValue: function(x, isCurrent) { | ||
this._send(VALUE, this._fn(x), isCurrent); | ||
} | ||
}, withFnArgMixin)); | ||
}); | ||
@@ -1737,7 +1926,13 @@ | ||
withOneSource('mapErrors', extend({ | ||
withOneSource('mapErrors', { | ||
_init: function(args) { | ||
this._fn = args[0] || id; | ||
}, | ||
_free: function() { | ||
this._fn = null; | ||
}, | ||
_handleError: function(x, isCurrent) { | ||
this._send(ERROR, this._fn(x), isCurrent); | ||
} | ||
}, withFnArgMixin)); | ||
}); | ||
@@ -1755,3 +1950,3 @@ | ||
withOneSource('errorsToValues', extend({ | ||
withOneSource('errorsToValues', { | ||
_init: function(args) { | ||
@@ -1769,3 +1964,3 @@ this._fn = args[0] || defaultErrorsToValuesHandler; | ||
} | ||
})); | ||
}); | ||
@@ -1783,3 +1978,3 @@ | ||
withOneSource('valuesToErrors', extend({ | ||
withOneSource('valuesToErrors', { | ||
_init: function(args) { | ||
@@ -1797,3 +1992,3 @@ this._fn = args[0] || defaultValuesToErrorsHandler; | ||
} | ||
})); | ||
}); | ||
@@ -1805,3 +2000,9 @@ | ||
withOneSource('filter', extend({ | ||
withOneSource('filter', { | ||
_init: function(args) { | ||
this._fn = args[0] || id; | ||
}, | ||
_free: function() { | ||
this._fn = null; | ||
}, | ||
_handleValue: function(x, isCurrent) { | ||
@@ -1812,3 +2013,3 @@ if (this._fn(x)) { | ||
} | ||
}, withFnArgMixin)); | ||
}); | ||
@@ -1820,3 +2021,9 @@ | ||
withOneSource('filterErrors', extend({ | ||
withOneSource('filterErrors', { | ||
_init: function(args) { | ||
this._fn = args[0] || id; | ||
}, | ||
_free: function() { | ||
this._fn = null; | ||
}, | ||
_handleError: function(x, isCurrent) { | ||
@@ -1827,3 +2034,3 @@ if (this._fn(x)) { | ||
} | ||
}, withFnArgMixin)); | ||
}); | ||
@@ -1835,3 +2042,9 @@ | ||
withOneSource('takeWhile', extend({ | ||
withOneSource('takeWhile', { | ||
_init: function(args) { | ||
this._fn = args[0] || id; | ||
}, | ||
_free: function() { | ||
this._fn = null; | ||
}, | ||
_handleValue: function(x, isCurrent) { | ||
@@ -1844,3 +2057,3 @@ if (this._fn(x)) { | ||
} | ||
}, withFnArgMixin)); | ||
}); | ||
@@ -2055,5 +2268,5 @@ | ||
// .endOnError(fn) | ||
// .endOnError() | ||
withOneSource('endOnError', extend({ | ||
withOneSource('endOnError', { | ||
_handleError: function(x, isCurrent) { | ||
@@ -2063,3 +2276,3 @@ this._send(ERROR, x, isCurrent); | ||
} | ||
})); | ||
}); | ||
@@ -2136,3 +2349,5 @@ | ||
var $ = this; | ||
this._$later = function() { $._later() }; | ||
this._$later = function() { | ||
$._later(); | ||
}; | ||
}, | ||
@@ -2203,3 +2418,5 @@ _free: function() { | ||
var $ = this; | ||
this._$trailingCall = function() { $._trailingCall() }; | ||
this._$trailingCall = function() { | ||
$._trailingCall(); | ||
}; | ||
}, | ||
@@ -2269,3 +2486,5 @@ _free: function() { | ||
var $ = this; | ||
this._$shiftBuff = function() { $._send(VALUE, $._buff.shift()) } | ||
this._$shiftBuff = function() { | ||
$._send(VALUE, $._buff.shift()); | ||
}; | ||
}, | ||
@@ -2289,3 +2508,5 @@ _free: function() { | ||
var $ = this; | ||
setTimeout(function() { $._send(END) }, this._wait); | ||
setTimeout(function() { | ||
$._send(END); | ||
}, this._wait); | ||
} | ||
@@ -2311,10 +2532,18 @@ } | ||
, emitter = { | ||
emit: function(x) { $._send(VALUE, x, isCurrent) }, | ||
error: function(x) { $._send(ERROR, x, isCurrent) }, | ||
end: function() { $._send(END, null, isCurrent) }, | ||
emitEvent: function(e) { $._send(e.type, e.value, isCurrent) } | ||
emit: function(x) { | ||
$._send(VALUE, x, isCurrent); | ||
}, | ||
error: function(x) { | ||
$._send(ERROR, x, isCurrent); | ||
}, | ||
end: function() { | ||
$._send(END, null, isCurrent); | ||
}, | ||
emitEvent: function(e) { | ||
$._send(e.type, e.value, isCurrent); | ||
} | ||
}; | ||
this._unsubscribe = this._fn(emitter) || null; | ||
// work around https://github.com/pozadi/kefir/issues/35 | ||
// fix https://github.com/pozadi/kefir/issues/35 | ||
if (!this._active && this._unsubscribe !== null) { | ||
@@ -2339,7 +2568,7 @@ this._unsubscribe(); | ||
}) | ||
}); | ||
Kefir.fromBinder = function(fn) { | ||
return new FromBinder(fn); | ||
} | ||
}; | ||
@@ -2378,3 +2607,3 @@ | ||
return new Emitter(); | ||
} | ||
}; | ||
@@ -2394,3 +2623,5 @@ Kefir.Emitter = Emitter; | ||
neverObj._name = 'never'; | ||
Kefir.never = function() { return neverObj } | ||
Kefir.never = function() { | ||
return neverObj; | ||
}; | ||
@@ -2411,7 +2642,7 @@ | ||
_name: 'constant' | ||
}) | ||
}); | ||
Kefir.constant = function(x) { | ||
return new Constant(x); | ||
} | ||
}; | ||
@@ -2431,7 +2662,7 @@ | ||
_name: 'constantError' | ||
}) | ||
}); | ||
Kefir.constantError = function(x) { | ||
return new ConstantError(x); | ||
} | ||
}; | ||
@@ -2512,3 +2743,3 @@ | ||
return new Repeat(generator); | ||
} | ||
}; | ||
@@ -2522,3 +2753,3 @@ | ||
return this; | ||
} | ||
}; | ||
@@ -2529,5 +2760,11 @@ | ||
Observable.prototype.mapTo = function(value) { | ||
return this.map(function() { return value }).setName(this, 'mapTo'); | ||
} | ||
Observable.prototype.mapTo = deprecated( | ||
'.mapTo()', | ||
'.map(() => value)', | ||
function(value) { | ||
return this.map(function() { | ||
return value; | ||
}).setName(this, 'mapTo'); | ||
} | ||
); | ||
@@ -2538,7 +2775,11 @@ | ||
Observable.prototype.pluck = function(propertyName) { | ||
return this.map(function(x) { | ||
return x[propertyName]; | ||
}).setName(this, 'pluck'); | ||
} | ||
Observable.prototype.pluck = deprecated( | ||
'.pluck()', | ||
'.map((v) => v.prop)', | ||
function(propertyName) { | ||
return this.map(function(x) { | ||
return x[propertyName]; | ||
}).setName(this, 'pluck'); | ||
} | ||
); | ||
@@ -2549,9 +2790,17 @@ | ||
Observable.prototype.invoke = function(methodName /*, arg1, arg2... */) { | ||
var args = rest(arguments, 1); | ||
return this.map(args ? | ||
function(x) { return apply(x[methodName], x, args) } : | ||
function(x) { return x[methodName]() } | ||
).setName(this, 'invoke'); | ||
} | ||
Observable.prototype.invoke = deprecated( | ||
'.invoke()', | ||
'.map((v) => v.method())', | ||
function(methodName /*, arg1, arg2... */) { | ||
var args = rest(arguments, 1); | ||
return this.map(args ? | ||
function(x) { | ||
return apply(x[methodName], x, args); | ||
} : | ||
function(x) { | ||
return x[methodName](); | ||
} | ||
).setName(this, 'invoke'); | ||
} | ||
); | ||
@@ -2563,5 +2812,11 @@ | ||
Observable.prototype.timestamp = function() { | ||
return this.map(function(x) { return {value: x, time: now()} }).setName(this, 'timestamp'); | ||
} | ||
Observable.prototype.timestamp = deprecated( | ||
'.timestamp()', | ||
'.map((v) => {value: v, time: (new Date).getTime()})', | ||
function() { | ||
return this.map(function(x) { | ||
return {value: x, time: now()}; | ||
}).setName(this, 'timestamp'); | ||
} | ||
); | ||
@@ -2573,20 +2828,33 @@ | ||
Observable.prototype.tap = function(fn) { | ||
return this.map(function(x) { | ||
fn(x); | ||
return x; | ||
}).setName(this, 'tap'); | ||
} | ||
Observable.prototype.tap = deprecated( | ||
'.tap()', | ||
'.map((v) => {fn(v); return v})', | ||
function(fn) { | ||
return this.map(function(x) { | ||
fn(x); | ||
return x; | ||
}).setName(this, 'tap'); | ||
} | ||
); | ||
// .and | ||
Kefir.and = function(observables) { | ||
return Kefir.combine(observables, and).setName('and'); | ||
} | ||
Kefir.and = deprecated( | ||
'Kefir.and()', | ||
'Kefir.combine([a, b], (a, b) => a && b)', | ||
function(observables) { | ||
return Kefir.combine(observables, and).setName('and'); | ||
} | ||
); | ||
Observable.prototype.and = function(other) { | ||
return this.combine(other, and).setName('and'); | ||
} | ||
Observable.prototype.and = deprecated( | ||
'.and()', | ||
'.combine(other, (a, b) => a && b)', | ||
function(other) { | ||
return this.combine(other, and).setName('and'); | ||
} | ||
); | ||
@@ -2597,9 +2865,17 @@ | ||
Kefir.or = function(observables) { | ||
return Kefir.combine(observables, or).setName('or'); | ||
} | ||
Kefir.or = deprecated( | ||
'Kefir.or()', | ||
'Kefir.combine([a, b], (a, b) => a || b)', | ||
function(observables) { | ||
return Kefir.combine(observables, or).setName('or'); | ||
} | ||
); | ||
Observable.prototype.or = function(other) { | ||
return this.combine(other, or).setName('or'); | ||
} | ||
Observable.prototype.or = deprecated( | ||
'.or()', | ||
'.combine(other, (a, b) => a || b)', | ||
function(other) { | ||
return this.combine(other, or).setName('or'); | ||
} | ||
); | ||
@@ -2610,5 +2886,9 @@ | ||
Observable.prototype.not = function() { | ||
return this.map(not).setName(this, 'not'); | ||
} | ||
Observable.prototype.not = deprecated( | ||
'.not()', | ||
'.map(v => !v)', | ||
function() { | ||
return this.map(not).setName(this, 'not'); | ||
} | ||
); | ||
@@ -2624,3 +2904,3 @@ | ||
]).skipDuplicates().toProperty(false).setName(this, 'awaiting'); | ||
} | ||
}; | ||
@@ -2643,3 +2923,3 @@ | ||
}).setName('fromCallback'); | ||
} | ||
}; | ||
@@ -2666,3 +2946,3 @@ | ||
}).setName('fromNodeCallback'); | ||
} | ||
}; | ||
@@ -2696,3 +2976,3 @@ | ||
}).toProperty().setName('fromPromise'); | ||
} | ||
}; | ||
@@ -2712,5 +2992,7 @@ | ||
sub(handler); | ||
return function() { unsub(handler) }; | ||
return function() { | ||
unsub(handler); | ||
}; | ||
}); | ||
} | ||
}; | ||
@@ -2746,7 +3028,11 @@ | ||
return Kefir.fromSubUnsub( | ||
function(handler) { target[sub](eventName, handler) }, | ||
function(handler) { target[unsub](eventName, handler) }, | ||
function(handler) { | ||
target[sub](eventName, handler); | ||
}, | ||
function(handler) { | ||
target[unsub](eventName, handler); | ||
}, | ||
transformer | ||
).setName('fromEvent'); | ||
} | ||
}; | ||
@@ -2753,0 +3039,0 @@ var withTwoSourcesAndBufferMixin = { |
@@ -1,7 +0,7 @@ | ||
/*! Kefir.js v1.2.0 | ||
/*! Kefir.js v1.3.0 | ||
* https://github.com/pozadi/kefir | ||
*/ | ||
!function(a){"use strict";function b(){for(var a=0;a<arguments.length;a++)if(!arguments[a])return arguments[a];return arguments[a-1]}function c(){for(var a=0;a<arguments.length;a++)if(arguments[a])return arguments[a];return arguments[a-1]}function d(a){return!a}function e(a,b){var c,d,e,f;if(0===a.length)return b;if(0===b.length)return a;for(f=0,c=new Array(a.length+b.length),d=a.length,e=0;d>e;e++,f++)c[f]=a[e];for(d=b.length,e=0;d>e;e++,f++)c[f]=b[e];return c}function f(a,b){var c,d=a.length,e=new Array(d);for(c=0;d>c;c++)e[(c+b)%d]=a[c];return e}function g(a,b){var c,d=a.length;for(c=0;d>c;c++)if(a[c]===b)return c;return-1}function h(a,b){var c,d=a.length;for(c=0;d>c;c++)if(b(a[c]))return c;return-1}function i(a){var b,c=a.length,d=new Array(c);for(b=0;c>b;b++)d[b]=a[b];return d}function j(a,b){var c,d,e,f=a.length;if(b>=0&&f>b){if(1===f)return[];for(c=new Array(f-1),d=0,e=0;f>d;d++)d!==b&&(c[e]=a[d],e++);return c}return a}function k(a,b){return j(a,h(a,b))}function l(a,b){var c,d=a.length,e=new Array(d);for(c=0;d>c;c++)e[c]=b(a[c]);return e}function m(a,b){var c,d=a.length;for(c=0;d>c;c++)b(a[c])}function n(a,b){var c,d=a.length;for(c=0;d>c;c++)a[c]=b}function o(a,b){return-1!==g(a,b)}function p(a,b,c){return a.length>b?Array.prototype.slice.call(a,b):c}function q(a,b,c){var d,e=Math.min(c,a.length+1),f=a.length-e+1,g=new Array(e);for(d=f;e>d;d++)g[d-f]=a[d];return g[e-1]=b,g}function r(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 s(a,b){switch(b){case 0:return function(){return a()};case 1:return function(b){return a(b[0])};case 2:return function(b){return a(b[0],b[1])};case 3:return function(b){return a(b[0],b[1],b[2])};case 4:return function(b){return a(b[0],b[1],b[2],b[3])};default:return function(b){return a.apply(null,b)}}}function t(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 u(a,b,c){return a&&b in a?a[b]:c}function v(a,b){return Object.prototype.hasOwnProperty.call(a,b)}function w(a){var b=function(){};return b.prototype=a,new b}function x(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 y(a,b){var c,d=arguments.length;for(a.prototype=w(b.prototype),a.prototype.constructor=a,c=2;d>c;c++)x(a.prototype,arguments[c]);return a}function z(){}function A(a){return a}function B(a,b){return b}function C(a,b){return a===b}function D(a,b){return[a,b]}function E(a){return"function"==typeof a}function F(a,b){function c(a,b){M.call(this),this._wait=a,this._intervalId=null;var c=this;this._$onTick=function(){c._onTick()},this._init(b)}y(c,M,{_name:a,_init:function(){},_free:function(){},_onTick:function(){},_onActivation:function(){this._intervalId=setInterval(this._$onTick,this._wait)},_onDeactivation:function(){null!==this._intervalId&&(clearInterval(this._intervalId),this._intervalId=null)},_clear:function(){M.prototype._clear.call(this),this._$onTick=null,this._free()}},b),eb[a]=function(a){return new c(a,p(arguments,1,[]))}}function G(a,b,c){function d(c){function d(b,d){c.call(this),this._source=b,this._name=b._name+"."+a,this._init(d);var e=this;this._$handleAny=function(a){e._handleAny(a)}}return y(d,c,{_clear:function(){c.prototype._clear.call(this),this._source=null,this._$handleAny=null,this._free()}},b),d}c=x({streamMethod:function(a){return function(){return new a(this,arguments)}},propertyMethod:function(a,b){return function(){return new b(this,arguments)}}},c||{}),b=x({_init:function(){},_free:function(){},_handleValue:function(a,b){this._send(hb,a,b)},_handleError:function(a,b){this._send(ib,a,b)},_handleEnd:function(a,b){this._send(gb,null,b)},_handleAny:function(a){switch(a.type){case hb:this._handleValue(a.value,a.current);break;case ib:this._handleError(a.value,a.current);break;case gb:this._handleEnd(a.value,a.current)}},_onActivation:function(){this._source.onAny(this._$handleAny)},_onDeactivation:function(){this._source.offAny(this._$handleAny)}},b||{});var e=d(M),f=d(N);c.streamMethod&&(M.prototype[a]=c.streamMethod(e,f)),c.propertyMethod&&(N.prototype[a]=c.propertyMethod(e,f))}function H(a,b){function c(c){function d(b,d,e){c.call(this),this._primary=b,this._secondary=d,this._name=b._name+"."+a,this._lastSecondary=fb;var f=this;this._$handleSecondaryAny=function(a){f._handleSecondaryAny(a)},this._$handlePrimaryAny=function(a){f._handlePrimaryAny(a)},this._init(e)}return y(d,c,{_clear:function(){c.prototype._clear.call(this),this._primary=null,this._secondary=null,this._lastSecondary=null,this._$handleSecondaryAny=null,this._$handlePrimaryAny=null,this._free()}},b),d}b=x({_init:function(){},_free:function(){},_handlePrimaryValue:function(a,b){this._send(hb,a,b)},_handlePrimaryError:function(a,b){this._send(ib,a,b)},_handlePrimaryEnd:function(a,b){this._send(gb,null,b)},_handleSecondaryValue:function(a){this._lastSecondary=a},_handleSecondaryError:function(a,b){this._send(ib,a,b)},_handleSecondaryEnd:function(){},_handlePrimaryAny:function(a){switch(a.type){case hb:this._handlePrimaryValue(a.value,a.current);break;case ib:this._handlePrimaryError(a.value,a.current);break;case gb:this._handlePrimaryEnd(a.value,a.current)}},_handleSecondaryAny:function(a){switch(a.type){case hb:this._handleSecondaryValue(a.value,a.current);break;case ib:this._handleSecondaryError(a.value,a.current);break;case gb:this._handleSecondaryEnd(a.value,a.current),this._removeSecondary()}},_removeSecondary:function(){null!==this._secondary&&(this._secondary.offAny(this._$handleSecondaryAny),this._$handleSecondaryAny=null,this._secondary=null)},_onActivation:function(){null!==this._secondary&&this._secondary.onAny(this._$handleSecondaryAny),this._alive&&this._primary.onAny(this._$handlePrimaryAny)},_onDeactivation:function(){null!==this._secondary&&this._secondary.offAny(this._$handleSecondaryAny),this._primary.offAny(this._$handlePrimaryAny)}},b||{});var d=c(M),e=c(N);M.prototype[a]=function(a){return new d(this,a,p(arguments,1,[]))},N.prototype[a]=function(a){return new e(this,a,p(arguments,1,[]))}}function I(a,b,c){a===jb?b(c):a===c.type&&(a===hb||a===ib?b(c.value):b())}function J(){this._items=[]}function K(a,b,c){return{type:a,value:b,current:!!c}}function L(){this._dispatcher=new J,this._active=!1,this._alive=!0}function M(){L.call(this)}function N(){L.call(this),this._current=fb,this._currentError=fb}function O(a){if(M.call(this),this._queueLim=u(a,"queueLim",0),this._concurLim=u(a,"concurLim",-1),this._drop=u(a,"drop","new"),0===this._concurLim)throw new Error("options.concurLim can't be 0");var b=this;this._$handleSubAny=function(a){b._handleSubAny(a)},this._queue=[],this._curSources=[],this._activating=!1}function P(a){O.call(this),0===a.length?this._send(gb):this._addAll(a),this._initialised=!0}function Q(a){O.call(this,{concurLim:1,queueLim:-1}),0===a.length?this._send(gb):this._addAll(a),this._initialised=!0}function R(){O.call(this)}function S(){O.call(this)}function T(a,b,c){O.call(this,c),this._source=a,this._fn=b||A,this._mainEnded=!1,this._lastCurrent=null;var d=this;this._$handleMainSource=function(a){d._handleMainSource(a)}}function U(a,b){M.call(this),0===a.length?this._send(gb):(this._buffers=l(a,function(a){return mb(a)?i(a):[]}),this._sources=l(a,function(a){return mb(a)?eb.never():a}),this._combinator=b?s(b,this._sources.length):A,this._aliveCount=0)}function V(a,b,c){M.call(this),0===a.length?this._send(gb):(this._activeCount=a.length,this._sources=e(a,b),this._combinator=c?s(c,this._sources.length):A,this._aliveCount=0,this._currents=new Array(this._sources.length),n(this._currents,fb),this._activating=!1,this._emitAfterActivation=!1,this._endAfterActivation=!1)}function W(a){return function(){return new a(this,arguments)}}function X(a,b){return function(){return new b(this,arguments)}}function Y(a){return{step:function(b,c){return a._send(hb,c,a._forcedCurrent),null},result:function(){return a._send(gb,null,a._forcedCurrent),null}}}function Z(a){return{convert:!0,value:a}}function $(a){return{convert:!0,error:a}}function _(a){M.call(this),this._fn=a,this._unsubscribe=null}function ab(){M.call(this)}function bb(a){N.call(this),this._send(hb,a),this._send(gb)}function cb(a){N.call(this),this._send(ib,a),this._send(gb)}function db(a){M.call(this),this._generator=a,this._source=null,this._inLoop=!1,this._activating=!1,this._iteration=0;var b=this;this._$handleAny=function(a){b._handleAny(a)}}var eb={},fb=["<nothing>"],gb="end",hb="value",ib="error",jb="any",kb=Date.now?function(){return Date.now()}:function(){return(new Date).getTime()},lb=void 0!==typeof console&&E(console.log)?function(a){console.log(a)}:z,mb=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},nb=function(a){return"[object Arguments]"===Object.prototype.toString.call(a)};nb(arguments)||(nb=function(a){return!(!a||!v(a,"callee"))}),x(J.prototype,{add:function(a,b,c){return this._items=e(this._items,[{type:a,fn:b,key:c||null}]),this._items.length},remove:function(a,b,c){var d=mb(c)?function(b){return b.type===a&&r(b.key,c)}:function(c){return c.type===a&&c.fn===b};return this._items=k(this._items,d),this._items.length},dispatch:function(a){for(var b=this._items,c=0;c<b.length;c++)I(b[c].type,b[c].fn,a)}});var ob=K(gb,void 0,!0);eb.Observable=L,x(L.prototype,{_name:"observable",_onActivation:function(){},_onDeactivation:function(){},_setActive:function(a){this._active!==a&&(this._active=a,a?this._onActivation():this._onDeactivation())},_clear:function(){this._setActive(!1),this._alive=!1,this._dispatcher=null},_send:function(a,b,c){this._alive&&(this._dispatcher.dispatch(K(a,b,c)),a===gb&&this._clear())},_on:function(a,b,c){return this._alive?(this._dispatcher.add(a,b,c),this._setActive(!0)):I(a,b,ob),this},_off:function(a,b,c){if(this._alive){var d=this._dispatcher.remove(a,b,c);0===d&&this._setActive(!1)}return this},onValue:function(a,b){return this._on(hb,a,b)},onError:function(a,b){return this._on(ib,a,b)},onEnd:function(a,b){return this._on(gb,a,b)},onAny:function(a,b){return this._on(jb,a,b)},offValue:function(a,b){return this._off(hb,a,b)},offError:function(a,b){return this._off(ib,a,b)},offEnd:function(a,b){return this._off(gb,a,b)},offAny:function(a,b){return this._off(jb,a,b)}}),L.prototype.toString=function(){return"["+this._name+"]"},eb.Stream=M,y(M,L,{_name:"stream"}),eb.Property=N,y(N,L,{_name:"property",_send:function(a,b,c){this._alive&&(c||this._dispatcher.dispatch(K(a,b)),a===hb&&(this._current=b),a===ib&&(this._currentError=b),a===gb&&this._clear())},_on:function(a,b,c){return this._alive&&(this._dispatcher.add(a,b,c),this._setActive(!0)),this._current!==fb&&I(a,b,K(hb,this._current,!0)),this._currentError!==fb&&I(a,b,K(ib,this._currentError,!0)),this._alive||I(a,b,ob),this}}),L.prototype.log=function(a){return a=a||this.toString(),this.onAny(function(b){var c="<"+b.type+(b.current?":current":"")+">";b.type===hb||b.type===ib?console.log(a,c,b.value):console.log(a,c)},["__logKey__",this,a]),this},L.prototype.offLog=function(a){return a=a||this.toString(),this.offAny(null,["__logKey__",this,a]),this},F("withInterval",{_init:function(a){this._fn=a[0];var b=this;this._emitter={emit:function(a){b._send(hb,a)},error:function(a){b._send(ib,a)},end:function(){b._send(gb)},emitEvent:function(a){b._send(a.type,a.value)}}},_free:function(){this._fn=null,this._emitter=null},_onTick:function(){this._fn(this._emitter)}}),F("fromPoll",{_init:function(a){this._fn=a[0]},_free:function(){this._fn=null},_onTick:function(){this._send(hb,this._fn())}}),F("interval",{_init:function(a){this._x=a[0]},_free:function(){this._x=null},_onTick:function(){this._send(hb,this._x)}}),F("sequentially",{_init:function(a){this._xs=i(a[0]),0===this._xs.length&&this._send(gb)},_free:function(){this._xs=null},_onTick:function(){switch(this._xs.length){case 1:this._send(hb,this._xs[0]),this._send(gb);break;default:this._send(hb,this._xs.shift())}}}),F("repeatedly",{_init:function(a){this._xs=i(a[0]),this._i=-1},_onTick:function(){this._xs.length>0&&(this._i=(this._i+1)%this._xs.length,this._send(hb,this._xs[this._i]))}}),F("later",{_init:function(a){this._x=a[0]},_free:function(){this._x=null},_onTick:function(){this._send(hb,this._x),this._send(gb)}}),y(O,M,{_name:"abstractPool",_add:function(a,b){b=b||A,-1===this._concurLim||this._curSources.length<this._concurLim?this._addToCur(b(a)):-1===this._queueLim||this._queue.length<this._queueLim?this._addToQueue(b(a)):"old"===this._drop&&(this._removeOldest(),this._add(b(a)))},_addAll:function(a){var b=this;m(a,function(a){b._add(a)})},_remove:function(a){-1===this._removeCur(a)&&this._removeQueue(a)},_addToQueue:function(a){this._queue=e(this._queue,[a])},_addToCur:function(a){this._curSources=e(this._curSources,[a]),this._active&&this._subscribe(a)},_subscribe:function(a){var b=this;a.onAny(this._$handleSubAny),a.onEnd(function(){b._removeCur(a)},[this,a])},_unsubscribe:function(a){a.offAny(this._$handleSubAny),a.offEnd(null,[this,a])},_handleSubAny:function(a){(a.type===hb||a.type===ib)&&this._send(a.type,a.value,a.current&&this._activating)},_removeQueue:function(a){var b=g(this._queue,a);return this._queue=j(this._queue,b),b},_removeCur:function(a){this._active&&this._unsubscribe(a);var b=g(this._curSources,a);return this._curSources=j(this._curSources,b),-1!==b&&(0!==this._queue.length?this._pullQueue():0===this._curSources.length&&this._onEmpty()),b},_removeOldest:function(){this._removeCur(this._curSources[0])},_pullQueue:function(){0!==this._queue.length&&(this._queue=i(this._queue),this._addToCur(this._queue.shift()))},_onActivation:function(){var a,b=this._curSources;for(this._activating=!0,a=0;a<b.length;a++)this._active&&this._subscribe(b[a]);this._activating=!1},_onDeactivation:function(){var a,b=this._curSources;for(a=0;a<b.length;a++)this._unsubscribe(b[a])},_isEmpty:function(){return 0===this._curSources.length},_onEmpty:function(){},_clear:function(){M.prototype._clear.call(this),this._queue=null,this._curSources=null,this._$handleSubAny=null}});var pb={_onEmpty:function(){this._initialised&&this._send(gb,null,this._activating)}};y(P,O,x({_name:"merge"},pb)),eb.merge=function(a){return new P(a)},L.prototype.merge=function(a){return eb.merge([this,a])},y(Q,O,x({_name:"concat"},pb)),eb.concat=function(a){return new Q(a)},L.prototype.concat=function(a){return eb.concat([this,a])},eb.Pool=R,y(R,O,{_name:"pool",plug:function(a){return this._add(a),this},unplug:function(a){return this._remove(a),this}}),eb.pool=function(){return new R},eb.Bus=S,y(S,O,{_name:"bus",plug:function(a){return this._add(a),this},unplug:function(a){return this._remove(a),this},emit:function(a){return this._send(hb,a),this},error:function(a){return this._send(ib,a),this},end:function(){return this._send(gb),this},emitEvent:function(a){this._send(a.type,a.value)}}),eb.bus=function(){return new S},y(T,O,{_onActivation:function(){O.prototype._onActivation.call(this),this._active&&(this._activating=!0,this._source.onAny(this._$handleMainSource),this._activating=!1)},_onDeactivation:function(){O.prototype._onDeactivation.call(this),this._source.offAny(this._$handleMainSource)},_handleMainSource:function(a){a.type===hb&&(a.current&&this._lastCurrent===a.value||this._add(a.value,this._fn),this._lastCurrent=a.value),a.type===ib&&this._send(ib,a.value,a.current),a.type===gb&&(this._isEmpty()?this._send(gb,null,a.current):this._mainEnded=!0)},_onEmpty:function(){this._mainEnded&&this._send(gb)},_clear:function(){O.prototype._clear.call(this),this._source=null,this._lastCurrent=null,this._$handleMainSource=null}}),L.prototype.flatMap=function(a){return new T(this,a).setName(this,"flatMap")},L.prototype.flatMapLatest=function(a){return new T(this,a,{concurLim:1,drop:"old"}).setName(this,"flatMapLatest")},L.prototype.flatMapFirst=function(a){return new T(this,a,{concurLim:1}).setName(this,"flatMapFirst")},L.prototype.flatMapConcat=function(a){return new T(this,a,{queueLim:-1,concurLim:1}).setName(this,"flatMapConcat")},L.prototype.flatMapConcurLimit=function(a,b){var c;return 0===b?c=eb.never():(0>b&&(b=-1),c=new T(this,a,{queueLim:-1,concurLim:b})),c.setName(this,"flatMapConcurLimit")},y(U,M,{_name:"zip",_onActivation:function(){var a,b=this._sources.length;for(this._drainArrays(),this._aliveCount=b,a=0;b>a;a++)this._active&&this._sources[a].onAny(this._bindHandleAny(a),[this,a])},_onDeactivation:function(){for(var a=0;a<this._sources.length;a++)this._sources[a].offAny(null,[this,a])},_emit:function(a){for(var b=new Array(this._buffers.length),c=0;c<this._buffers.length;c++)b[c]=this._buffers[c].shift();this._send(hb,this._combinator(b),a)},_isFull:function(){for(var a=0;a<this._buffers.length;a++)if(0===this._buffers[a].length)return!1;return!0},_emitIfFull:function(a){this._isFull()&&this._emit(a)},_drainArrays:function(){for(;this._isFull();)this._emit(!0)},_bindHandleAny:function(a){var b=this;return function(c){b._handleAny(a,c)}},_handleAny:function(a,b){b.type===hb&&(this._buffers[a].push(b.value),this._emitIfFull(b.current)),b.type===ib&&this._send(ib,b.value,b.current),b.type===gb&&(this._aliveCount--,0===this._aliveCount&&this._send(gb,null,b.current))},_clear:function(){M.prototype._clear.call(this),this._sources=null,this._buffers=null,this._combinator=null}}),eb.zip=function(a,b){return new U(a,b)},L.prototype.zip=function(a,b){return new U([this,a],b)},y(V,M,{_name:"combine",_onActivation:function(){var a,b=this._sources.length;for(this._aliveCount=this._activeCount,this._activating=!0,a=0;b>a;a++)this._sources[a].onAny(this._bindHandleAny(a),[this,a]);this._activating=!1,this._emitAfterActivation&&(this._emitAfterActivation=!1,this._emitIfFull(!0)),this._endAfterActivation&&this._send(gb,null,!0)},_onDeactivation:function(){var a,b=this._sources.length;for(a=0;b>a;a++)this._sources[a].offAny(null,[this,a])},_emitIfFull:function(a){if(!o(this._currents,fb)){var b=i(this._currents);b=this._combinator(b),this._send(hb,b,a)}},_bindHandleAny:function(a){var b=this;return function(c){b._handleAny(a,c)}},_handleAny:function(a,b){b.type===hb&&(this._currents[a]=b.value,a<this._activeCount&&(this._activating?this._emitAfterActivation=!0:this._emitIfFull(b.current))),b.type===ib&&this._send(ib,b.value,b.current),b.type===gb&&a<this._activeCount&&(this._aliveCount--,0===this._aliveCount&&(this._activating?this._endAfterActivation=!0:this._send(gb,null,b.current)))},_clear:function(){M.prototype._clear.call(this),this._sources=null,this._currents=null,this._combinator=null}}),eb.combine=function(a,b,c){return E(b)&&(c=b,b=null),new V(a,b||[],c)},L.prototype.combine=function(a,b){return eb.combine([this,a],b)},eb.DISABLE_SAMPLEDBY_WARNING=!1,eb.sampledBy=function(a,b,c){eb.DISABLE_SAMPLEDBY_WARNING||lb("Kefir.sampledBy() is deprecated, and to be removed in v3.0.0.\nUse Kefir.combine(active, passive, combinator) instead, but note than active/passive order is different.\nTo disable this warning set Kefir.DISABLE_SAMPLEDBY_WARNING to true.");var d=c;if(a.length>0){var e=a.length;d=function(){var a=f(arguments,e);return c?t(c,null,a):a}}return new V(b,a,d).setName("sampledBy")},L.prototype.sampledBy=function(a,b){var c;return b&&(c=function(a,c){return b(c,a)}),new V([a],[this],c||B).setName(this,"sampledBy")},G("toProperty",{_init:function(a){a.length>0&&this._send(hb,a[0])}},{propertyMethod:X,streamMethod:X}),G("changes",{_handleValue:function(a,b){b||this._send(hb,a)},_handleError:function(a,b){b||this._send(ib,a)}},{streamMethod:function(){return function(){return this}},propertyMethod:W}),G("withHandler",{_init:function(a){this._handler=a[0],this._forcedCurrent=!1;var b=this;this._emitter={emit:function(a){b._send(hb,a,b._forcedCurrent)},error:function(a){b._send(ib,a,b._forcedCurrent)},end:function(){b._send(gb,null,b._forcedCurrent)},emitEvent:function(a){b._send(a.type,a.value,b._forcedCurrent)}}},_free:function(){this._handler=null,this._emitter=null},_handleAny:function(a){this._forcedCurrent=a.current,this._handler(this._emitter,a),this._forcedCurrent=!1}}),G("flatten",{_init:function(a){this._fn=a[0]?a[0]:A},_free:function(){this._fn=null},_handleValue:function(a,b){for(var c=this._fn(a),d=0;d<c.length;d++)this._send(hb,c[d],b)}}),G("transduce",{_init:function(a){this._xform=a[0](Y(this))},_free:function(){this._xform=null},_handleValue:function(a,b){this._forcedCurrent=b,null!==this._xform.step(null,a)&&this._xform.result(null),this._forcedCurrent=!1},_handleEnd:function(a,b){this._forcedCurrent=b,this._xform.result(null),this._forcedCurrent=!1}});var qb={_init:function(a){this._fn=a[0]||A},_free:function(){this._fn=null}};G("map",x({_handleValue:function(a,b){this._send(hb,this._fn(a),b)}},qb)),G("mapErrors",x({_handleError:function(a,b){this._send(ib,this._fn(a),b)}},qb)),G("errorsToValues",x({_init:function(a){this._fn=a[0]||Z},_free:function(){this._fn=null},_handleError:function(a,b){var c=this._fn(a),d=c.convert?hb:ib,e=c.convert?c.value:a;this._send(d,e,b)}})),G("valuesToErrors",x({_init:function(a){this._fn=a[0]||$},_free:function(){this._fn=null},_handleValue:function(a,b){var c=this._fn(a),d=c.convert?ib:hb,e=c.convert?c.error:a;this._send(d,e,b)}})),G("filter",x({_handleValue:function(a,b){this._fn(a)&&this._send(hb,a,b)}},qb)),G("filterErrors",x({_handleError:function(a,b){this._fn(a)&&this._send(ib,a,b)}},qb)),G("takeWhile",x({_handleValue:function(a,b){this._fn(a)?this._send(hb,a,b):this._send(gb,null,b)}},qb)),G("take",{_init:function(a){this._n=a[0],this._n<=0&&this._send(gb)},_handleValue:function(a,b){this._n--,this._send(hb,a,b),0===this._n&&this._send(gb,null,b)}}),G("skip",{_init:function(a){this._n=Math.max(0,a[0])},_handleValue:function(a,b){0===this._n?this._send(hb,a,b):this._n--}}),G("skipDuplicates",{_init:function(a){this._fn=a[0]||C,this._prev=fb},_free:function(){this._fn=null,this._prev=null},_handleValue:function(a,b){this._prev!==fb&&this._fn(this._prev,a)||(this._prev=a,this._send(hb,a,b))}}),G("skipWhile",{_init:function(a){this._fn=a[0]||A,this._skip=!0},_free:function(){this._fn=null},_handleValue:function(a,b){return this._skip?void(this._fn(a)||(this._skip=!1,this._fn=null,this._send(hb,a,b))):void this._send(hb,a,b)}}),G("diff",{_init:function(a){this._fn=a[0]||D,this._prev=a.length>1?a[1]:fb},_free:function(){this._prev=null,this._fn=null},_handleValue:function(a,b){this._prev!==fb&&this._send(hb,this._fn(this._prev,a),b),this._prev=a}}),G("scan",{_init:function(a){this._fn=a[0],a.length>1&&this._send(hb,a[1],!0)},_free:function(){this._fn=null},_handleValue:function(a,b){this._current!==fb&&(a=this._fn(this._current,a)),this._send(hb,a,b)}},{streamMethod:X}),G("reduce",{_init:function(a){this._fn=a[0],this._result=a.length>1?a[1]:fb},_free:function(){this._fn=null,this._result=null},_handleValue:function(a){this._result=this._result===fb?a:this._fn(this._result,a)},_handleEnd:function(a,b){this._result!==fb&&this._send(hb,this._result,b),this._send(gb,null,b)}}),G("mapEnd",{_init:function(a){this._fn=a[0]},_free:function(){this._fn=null},_handleEnd:function(a,b){this._send(hb,this._fn(),b),this._send(gb,null,b)}}),G("skipValues",{_handleValue:function(){}}),G("skipErrors",{_handleError:function(){}}),G("skipEnd",{_handleEnd:function(){}}),G("endOnError",x({_handleError:function(a,b){this._send(ib,a,b),this._send(gb,null,b)}})),G("slidingWindow",{_init:function(a){this._max=a[0],this._min=a[1]||0,this._buff=[]},_free:function(){this._buff=null},_handleValue:function(a,b){this._buff=q(this._buff,a,this._max),this._buff.length>=this._min&&this._send(hb,this._buff,b)}}),G("bufferWhile",{_init:function(a){this._fn=a[0]||A,this._flushOnEnd=u(a[1],"flushOnEnd",!0),this._buff=[]},_free:function(){this._buff=null},_flush:function(a){null!==this._buff&&0!==this._buff.length&&(this._send(hb,this._buff,a),this._buff=[])},_handleValue:function(a,b){this._buff.push(a),this._fn(a)||this._flush(b)},_handleEnd:function(a,b){this._flushOnEnd&&this._flush(b),this._send(gb,null,b)}}),G("debounce",{_init:function(a){this._wait=Math.max(0,a[0]),this._immediate=u(a[1],"immediate",!1),this._lastAttempt=0,this._timeoutId=null,this._laterValue=null,this._endLater=!1;var b=this;this._$later=function(){b._later()}},_free:function(){this._laterValue=null,this._$later=null},_handleValue:function(a,b){b?this._send(hb,a,b):(this._lastAttempt=kb(),this._immediate&&!this._timeoutId&&this._send(hb,a),this._timeoutId||(this._timeoutId=setTimeout(this._$later,this._wait)),this._immediate||(this._laterValue=a))},_handleEnd:function(a,b){b?this._send(gb,null,b):this._timeoutId&&!this._immediate?this._endLater=!0:this._send(gb)},_later:function(){var a=kb()-this._lastAttempt;a<this._wait&&a>=0?this._timeoutId=setTimeout(this._$later,this._wait-a):(this._timeoutId=null,this._immediate||(this._send(hb,this._laterValue),this._laterValue=null),this._endLater&&this._send(gb))}}),G("throttle",{_init:function(a){this._wait=Math.max(0,a[0]),this._leading=u(a[1],"leading",!0),this._trailing=u(a[1],"trailing",!0),this._trailingValue=null,this._timeoutId=null,this._endLater=!1,this._lastCallTime=0;var b=this;this._$trailingCall=function(){b._trailingCall()}},_free:function(){this._trailingValue=null,this._$trailingCall=null},_handleValue:function(a,b){if(b)this._send(hb,a,b);else{var c=kb();0!==this._lastCallTime||this._leading||(this._lastCallTime=c);var d=this._wait-(c-this._lastCallTime);0>=d?(this._cancelTraling(),this._lastCallTime=c,this._send(hb,a)):this._trailing&&(this._cancelTraling(),this._trailingValue=a,this._timeoutId=setTimeout(this._$trailingCall,d))}},_handleEnd:function(a,b){b?this._send(gb,null,b):this._timeoutId?this._endLater=!0:this._send(gb)},_cancelTraling:function(){null!==this._timeoutId&&(clearTimeout(this._timeoutId),this._timeoutId=null)},_trailingCall:function(){this._send(hb,this._trailingValue),this._timeoutId=null,this._trailingValue=null,this._lastCallTime=this._leading?kb():0,this._endLater&&this._send(gb)}}),G("delay",{_init:function(a){this._wait=Math.max(0,a[0]),this._buff=[];var b=this;this._$shiftBuff=function(){b._send(hb,b._buff.shift())}},_free:function(){this._buff=null,this._$shiftBuff=null},_handleValue:function(a,b){b?this._send(hb,a,b):(this._buff.push(a),setTimeout(this._$shiftBuff,this._wait))},_handleEnd:function(a,b){if(b)this._send(gb,null,b);else{var c=this;setTimeout(function(){c._send(gb)},this._wait)}}}),y(_,M,{_name:"fromBinder",_onActivation:function(){var a=this,b=!0,c={emit:function(c){a._send(hb,c,b)},error:function(c){a._send(ib,c,b)},end:function(){a._send(gb,null,b)},emitEvent:function(c){a._send(c.type,c.value,b)}};this._unsubscribe=this._fn(c)||null,this._active||null===this._unsubscribe||(this._unsubscribe(),this._unsubscribe=null),b=!1},_onDeactivation:function(){null!==this._unsubscribe&&(this._unsubscribe(),this._unsubscribe=null)},_clear:function(){M.prototype._clear.call(this),this._fn=null}}),eb.fromBinder=function(a){return new _(a)},y(ab,M,{_name:"emitter",emit:function(a){return this._send(hb,a),this},error:function(a){return this._send(ib,a),this},end:function(){return this._send(gb),this},emitEvent:function(a){this._send(a.type,a.value)}}),eb.emitter=function(){return new ab},eb.Emitter=ab;var rb=new M;rb._send(gb),rb._name="never",eb.never=function(){return rb},y(bb,N,{_name:"constant"}),eb.constant=function(a){return new bb(a)},y(cb,N,{_name:"constantError"}),eb.constantError=function(a){return new cb(a)},y(db,M,{_name:"repeat",_handleAny:function(a){a.type===gb?(this._source=null,this._startLoop()):this._send(a.type,a.value,this._activating)},_startLoop:function(){if(!this._inLoop){for(this._inLoop=!0;null===this._source&&this._alive&&this._active;)this._source=this._generator(this._iteration++),this._source?this._source.onAny(this._$handleAny):this._send(gb);this._inLoop=!1}},_onActivation:function(){this._activating=!0,this._source?this._source.onAny(this._$handleAny):this._startLoop(),this._activating=!1},_onDeactivation:function(){this._source&&this._source.offAny(this._$handleAny)},_clear:function(){M.prototype._clear.call(this),this._generator=null,this._source=null,this._$handleAny=null}}),eb.repeat=function(a){return new db(a)},L.prototype.setName=function(a,b){return this._name=b?a._name+"."+b:a,this},L.prototype.mapTo=function(a){return this.map(function(){return a}).setName(this,"mapTo")},L.prototype.pluck=function(a){return this.map(function(b){return b[a]}).setName(this,"pluck")},L.prototype.invoke=function(a){var b=p(arguments,1);return this.map(b?function(c){return t(c[a],c,b)}:function(b){return b[a]()}).setName(this,"invoke")},L.prototype.timestamp=function(){return this.map(function(a){return{value:a,time:kb()}}).setName(this,"timestamp")},L.prototype.tap=function(a){return this.map(function(b){return a(b),b}).setName(this,"tap")},eb.and=function(a){return eb.combine(a,b).setName("and")},L.prototype.and=function(a){return this.combine(a,b).setName("and")},eb.or=function(a){return eb.combine(a,c).setName("or")},L.prototype.or=function(a){return this.combine(a,c).setName("or")},L.prototype.not=function(){return this.map(d).setName(this,"not")},L.prototype.awaiting=function(a){return eb.merge([this.mapTo(!0),a.mapTo(!1)]).skipDuplicates().toProperty(!1).setName(this,"awaiting")},eb.fromCallback=function(a){var b=!1;return eb.fromBinder(function(c){b||(a(function(a){c.emit(a),c.end()}),b=!0)}).setName("fromCallback")},eb.fromNodeCallback=function(a){var b=!1;return eb.fromBinder(function(c){b||(a(function(a,b){a?c.error(a):c.emit(b),c.end()}),b=!0)}).setName("fromNodeCallback")},eb.fromPromise=function(a){var b=!1;return eb.fromBinder(function(c){if(!b){var d=function(a){c.emit(a),c.end()},e=function(a){c.error(a),c.end()},f=a.then(d,e);f&&E(f.done)&&f.done(),b=!0}}).toProperty().setName("fromPromise")},eb.fromSubUnsub=function(a,b,c){return eb.fromBinder(function(d){var e=c?function(){d.emit(t(c,this,arguments))}:d.emit;return a(e),function(){b(e)}})};var sb=[["addEventListener","removeEventListener"],["addListener","removeListener"],["on","off"]];eb.fromEvent=function(a,b,c){for(var d,e,f,g=0;g<sb.length;g++)if(d=sb[g],E(a[d[0]])&&E(a[d[1]])){e=d[0],f=d[1];break}if(void 0===e)throw new Error("target don't support any of addEventListener/removeEventListener, addListener/removeListener, on/off method pair");return eb.fromSubUnsub(function(c){a[e](b,c)},function(c){a[f](b,c)},c).setName("fromEvent")};var tb={_init:function(a){this._buff=[],this._flushOnEnd=u(a[0],"flushOnEnd",!0)},_free:function(){this._buff=null},_flush:function(a){null!==this._buff&&0!==this._buff.length&&(this._send(hb,this._buff,a),this._buff=[])},_handlePrimaryEnd:function(a,b){this._flushOnEnd&&this._flush(b),this._send(gb,null,b)}};H("bufferBy",x({_onActivation:function(){this._primary.onAny(this._$handlePrimaryAny),this._alive&&null!==this._secondary&&this._secondary.onAny(this._$handleSecondaryAny)},_handlePrimaryValue:function(a){this._buff.push(a)},_handleSecondaryValue:function(a,b){this._flush(b)},_handleSecondaryEnd:function(a,b){this._flushOnEnd||this._send(gb,null,b)}},tb)),H("bufferWhileBy",x({_handlePrimaryValue:function(a,b){this._buff.push(a),this._lastSecondary===fb||this._lastSecondary||this._flush(b)},_handleSecondaryEnd:function(a,b){this._flushOnEnd||this._lastSecondary!==fb&&!this._lastSecondary||this._send(gb,null,b)}},tb)),H("filterBy",{_handlePrimaryValue:function(a,b){this._lastSecondary!==fb&&this._lastSecondary&&this._send(hb,a,b)},_handleSecondaryEnd:function(a,b){this._lastSecondary!==fb&&this._lastSecondary||this._send(gb,null,b)}}),H("skipUntilBy",{_handlePrimaryValue:function(a,b){this._lastSecondary!==fb&&this._send(hb,a,b)},_handleSecondaryEnd:function(a,b){this._lastSecondary===fb&&this._send(gb,null,b)}}),H("takeUntilBy",{_handleSecondaryValue:function(a,b){this._send(gb,null,b) | ||
}}),H("takeWhileBy",{_handlePrimaryValue:function(a,b){this._lastSecondary!==fb&&this._send(hb,a,b)},_handleSecondaryValue:function(a,b){this._lastSecondary=a,this._lastSecondary||this._send(gb,null,b)},_handleSecondaryEnd:function(a,b){this._lastSecondary===fb&&this._send(gb,null,b)}}),H("skipWhileBy",{_init:function(){this._hasFalseyFromSecondary=!1},_handlePrimaryValue:function(a,b){this._hasFalseyFromSecondary&&this._send(hb,a,b)},_handleSecondaryValue:function(a){this._hasFalseyFromSecondary=this._hasFalseyFromSecondary||!a},_handleSecondaryEnd:function(a,b){this._hasFalseyFromSecondary||this._send(gb,null,b)}}),"function"==typeof define&&define.amd?(define([],function(){return eb}),a.Kefir=eb):"object"==typeof module&&"object"==typeof exports?(module.exports=eb,eb.Kefir=eb):a.Kefir=eb}(this); | ||
!function(a){"use strict";function b(){for(var a=0;a<arguments.length;a++)if(!arguments[a])return arguments[a];return arguments[a-1]}function c(){for(var a=0;a<arguments.length;a++)if(arguments[a])return arguments[a];return arguments[a-1]}function d(a){return!a}function e(a,b){var c,d,e,f;if(0===a.length)return b;if(0===b.length)return a;for(f=0,c=new Array(a.length+b.length),d=a.length,e=0;d>e;e++,f++)c[f]=a[e];for(d=b.length,e=0;d>e;e++,f++)c[f]=b[e];return c}function f(a,b){var c,d=a.length,e=new Array(d);for(c=0;d>c;c++)e[(c+b)%d]=a[c];return e}function g(a,b){var c,d=a.length;for(c=0;d>c;c++)if(a[c]===b)return c;return-1}function h(a,b){var c,d=a.length;for(c=0;d>c;c++)if(b(a[c]))return c;return-1}function i(a){var b,c=a.length,d=new Array(c);for(b=0;c>b;b++)d[b]=a[b];return d}function j(a,b){var c,d,e,f=a.length;if(b>=0&&f>b){if(1===f)return[];for(c=new Array(f-1),d=0,e=0;f>d;d++)d!==b&&(c[e]=a[d],e++);return c}return a}function k(a,b){return j(a,h(a,b))}function l(a,b){var c,d=a.length,e=new Array(d);for(c=0;d>c;c++)e[c]=b(a[c]);return e}function m(a,b){var c,d=a.length;for(c=0;d>c;c++)b(a[c])}function n(a,b){var c,d=a.length;for(c=0;d>c;c++)a[c]=b}function o(a,b){return-1!==g(a,b)}function p(a,b,c){return a.length>b?Array.prototype.slice.call(a,b):c}function q(a,b,c){var d,e=Math.min(c,a.length+1),f=a.length-e+1,g=new Array(e);for(d=f;e>d;d++)g[d-f]=a[d];return g[e-1]=b,g}function r(a,b){switch(b){case 0:return function(){return a()};case 1:return function(b){return a(b[0])};case 2:return function(b){return a(b[0],b[1])};case 3:return function(b){return a(b[0],b[1],b[2])};case 4:return function(b){return a(b[0],b[1],b[2],b[3])};default:return function(b){return a.apply(null,b)}}}function s(a,b,c){var d=c?c.length:0;if(null==b)switch(d){case 0:return a();case 1:return a(c[0]);case 2:return a(c[0],c[1]);case 3:return a(c[0],c[1],c[2]);case 4:return a(c[0],c[1],c[2],c[3]);default:return a.apply(null,c)}else switch(d){case 0:return a.call(b);default:return a.apply(b,c)}}function t(a,b,c){return a&&b in a?a[b]:c}function u(a,b){return Object.prototype.hasOwnProperty.call(a,b)}function v(a){var b=function(){};return b.prototype=a,new b}function w(a){var b,c,d=arguments.length;for(b=1;d>b;b++)for(c in arguments[b])a[c]=arguments[b][c];return a}function x(a,b){var c,d=arguments.length;for(a.prototype=v(b.prototype),a.prototype.constructor=a,c=2;d>c;c++)w(a.prototype,arguments[c]);return a}function y(){}function z(a){return a}function A(a,b){return b}function B(a,b){return a===b}function C(a,b){return[a,b]}function D(a,b,c){var d="Method `"+a+"` is deprecated, and to be removed in v3.0.0.";return b&&(d+="\nUse `"+b+"` instead."),d+="\nTo disable all warnings like this set `Kefir.DEPRECATION_WARNINGS = false`.",function(){return eb.DEPRECATION_WARNINGS&&lb(d),c.apply(this,arguments)}}function E(a){return"function"==typeof a}function F(a,b){function c(a,b){M.call(this),this._wait=a,this._intervalId=null;var c=this;this._$onTick=function(){c._onTick()},this._init(b)}x(c,M,{_name:a,_init:function(){},_free:function(){},_onTick:function(){},_onActivation:function(){this._intervalId=setInterval(this._$onTick,this._wait)},_onDeactivation:function(){null!==this._intervalId&&(clearInterval(this._intervalId),this._intervalId=null)},_clear:function(){M.prototype._clear.call(this),this._$onTick=null,this._free()}},b),eb[a]=function(a){return new c(a,p(arguments,1,[]))}}function G(a,b,c){function d(c){function d(b,d){c.call(this),this._source=b,this._name=b._name+"."+a,this._init(d);var e=this;this._$handleAny=function(a){e._handleAny(a)}}return x(d,c,{_clear:function(){c.prototype._clear.call(this),this._source=null,this._$handleAny=null,this._free()}},b),d}c=w({streamMethod:function(a){return function(){return new a(this,arguments)}},propertyMethod:function(a,b){return function(){return new b(this,arguments)}}},c||{}),b=w({_init:function(){},_free:function(){},_handleValue:function(a,b){this._send(hb,a,b)},_handleError:function(a,b){this._send(ib,a,b)},_handleEnd:function(a,b){this._send(gb,null,b)},_handleAny:function(a){switch(a.type){case hb:this._handleValue(a.value,a.current);break;case ib:this._handleError(a.value,a.current);break;case gb:this._handleEnd(a.value,a.current)}},_onActivation:function(){this._source.onAny(this._$handleAny)},_onDeactivation:function(){this._source.offAny(this._$handleAny)}},b||{});var e=d(M),f=d(N);c.streamMethod&&(M.prototype[a]=c.streamMethod(e,f)),c.propertyMethod&&(N.prototype[a]=c.propertyMethod(e,f))}function H(a,b){function c(c){function d(b,d,e){c.call(this),this._primary=b,this._secondary=d,this._name=b._name+"."+a,this._lastSecondary=fb;var f=this;this._$handleSecondaryAny=function(a){f._handleSecondaryAny(a)},this._$handlePrimaryAny=function(a){f._handlePrimaryAny(a)},this._init(e)}return x(d,c,{_clear:function(){c.prototype._clear.call(this),this._primary=null,this._secondary=null,this._lastSecondary=null,this._$handleSecondaryAny=null,this._$handlePrimaryAny=null,this._free()}},b),d}b=w({_init:function(){},_free:function(){},_handlePrimaryValue:function(a,b){this._send(hb,a,b)},_handlePrimaryError:function(a,b){this._send(ib,a,b)},_handlePrimaryEnd:function(a,b){this._send(gb,null,b)},_handleSecondaryValue:function(a){this._lastSecondary=a},_handleSecondaryError:function(a,b){this._send(ib,a,b)},_handleSecondaryEnd:function(){},_handlePrimaryAny:function(a){switch(a.type){case hb:this._handlePrimaryValue(a.value,a.current);break;case ib:this._handlePrimaryError(a.value,a.current);break;case gb:this._handlePrimaryEnd(a.value,a.current)}},_handleSecondaryAny:function(a){switch(a.type){case hb:this._handleSecondaryValue(a.value,a.current);break;case ib:this._handleSecondaryError(a.value,a.current);break;case gb:this._handleSecondaryEnd(a.value,a.current),this._removeSecondary()}},_removeSecondary:function(){null!==this._secondary&&(this._secondary.offAny(this._$handleSecondaryAny),this._$handleSecondaryAny=null,this._secondary=null)},_onActivation:function(){null!==this._secondary&&this._secondary.onAny(this._$handleSecondaryAny),this._alive&&this._primary.onAny(this._$handlePrimaryAny)},_onDeactivation:function(){null!==this._secondary&&this._secondary.offAny(this._$handleSecondaryAny),this._primary.offAny(this._$handlePrimaryAny)}},b||{});var d=c(M),e=c(N);M.prototype[a]=function(a){return new d(this,a,p(arguments,1,[]))},N.prototype[a]=function(a){return new e(this,a,p(arguments,1,[]))}}function I(a,b,c){a===jb?b(c):a===c.type&&(a===hb||a===ib?b(c.value):b())}function J(){this._items=[]}function K(a,b,c){return{type:a,value:b,current:!!c}}function L(){this._dispatcher=new J,this._active=!1,this._alive=!0}function M(){L.call(this)}function N(){L.call(this),this._current=fb,this._currentError=fb}function O(a){if(M.call(this),this._queueLim=t(a,"queueLim",0),this._concurLim=t(a,"concurLim",-1),this._drop=t(a,"drop","new"),0===this._concurLim)throw new Error("options.concurLim can't be 0");var b=this;this._$handleSubAny=function(a){b._handleSubAny(a)},this._queue=[],this._curSources=[],this._activating=!1,this._bindedEndHandlers=[]}function P(a){O.call(this),0===a.length?this._send(gb):this._addAll(a),this._initialised=!0}function Q(a){O.call(this,{concurLim:1,queueLim:-1}),0===a.length?this._send(gb):this._addAll(a),this._initialised=!0}function R(){O.call(this)}function S(){O.call(this)}function T(a,b,c){O.call(this,c),this._source=a,this._fn=b||z,this._mainEnded=!1,this._lastCurrent=null;var d=this;this._$handleMainSource=function(a){d._handleMainSource(a)}}function U(a,b){if(M.call(this),0===a.length)this._send(gb);else{this._buffers=l(a,function(a){return mb(a)?i(a):[]}),this._sources=l(a,function(a){return mb(a)?eb.never():a}),this._combinator=b?r(b,this._sources.length):z,this._aliveCount=0,this._bindedHandlers=Array(this._sources.length);for(var c=0;c<this._sources.length;c++)this._bindedHandlers[c]=this._bindHandleAny(c)}}function V(a,b,c){if(M.call(this),0===a.length)this._send(gb);else{this._activeCount=a.length,this._sources=e(a,b),this._combinator=c?r(c,this._sources.length):z,this._aliveCount=0,this._currents=new Array(this._sources.length),n(this._currents,fb),this._activating=!1,this._emitAfterActivation=!1,this._endAfterActivation=!1,this._bindedHandlers=Array(this._sources.length);for(var d=0;d<this._sources.length;d++)this._bindedHandlers[d]=this._bindHandleAny(d)}}function W(a){return function(){return new a(this,arguments)}}function X(a,b){return function(){return new b(this,arguments)}}function Y(a){return{step:function(b,c){return a._send(hb,c,a._forcedCurrent),null},result:function(){return a._send(gb,null,a._forcedCurrent),null}}}function Z(a){return{convert:!0,value:a}}function $(a){return{convert:!0,error:a}}function _(a){M.call(this),this._fn=a,this._unsubscribe=null}function ab(){M.call(this)}function bb(a){N.call(this),this._send(hb,a),this._send(gb)}function cb(a){N.call(this),this._send(ib,a),this._send(gb)}function db(a){M.call(this),this._generator=a,this._source=null,this._inLoop=!1,this._activating=!1,this._iteration=0;var b=this;this._$handleAny=function(a){b._handleAny(a)}}var eb={},fb=["<nothing>"],gb="end",hb="value",ib="error",jb="any",kb=Date.now?function(){return Date.now()}:function(){return(new Date).getTime()},lb=void 0!==typeof console&&E(console.log)?function(a){console.log(a)}:y;eb.DEPRECATION_WARNINGS=!0;var mb=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},nb=function(a){return"[object Arguments]"===Object.prototype.toString.call(a)};nb(arguments)||(nb=function(a){return!(!a||!u(a,"callee"))}),w(J.prototype,{add:function(a,b){return this._items=e(this._items,[{type:a,fn:b}]),this._items.length},remove:function(a,b){return this._items=k(this._items,function(c){return c.type===a&&c.fn===b}),this._items.length},dispatch:function(a){for(var b=this._items,c=0;c<b.length;c++)I(b[c].type,b[c].fn,a)}});var ob=K(gb,void 0,!0);eb.Observable=L,w(L.prototype,{_name:"observable",_onActivation:function(){},_onDeactivation:function(){},_setActive:function(a){this._active!==a&&(this._active=a,a?this._onActivation():this._onDeactivation())},_clear:function(){this._setActive(!1),this._alive=!1,this._dispatcher=null},_send:function(a,b,c){this._alive&&(this._dispatcher.dispatch(K(a,b,c)),a===gb&&this._clear())},_on:function(a,b){return this._alive?(this._dispatcher.add(a,b),this._setActive(!0)):I(a,b,ob),this},_off:function(a,b){if(this._alive){var c=this._dispatcher.remove(a,b);0===c&&this._setActive(!1)}return this},onValue:function(a){return this._on(hb,a)},onError:function(a){return this._on(ib,a)},onEnd:function(a){return this._on(gb,a)},onAny:function(a){return this._on(jb,a)},offValue:function(a){return this._off(hb,a)},offError:function(a){return this._off(ib,a)},offEnd:function(a){return this._off(gb,a)},offAny:function(a){return this._off(jb,a)}}),L.prototype.toString=function(){return"["+this._name+"]"},eb.Stream=M,x(M,L,{_name:"stream"}),eb.Property=N,x(N,L,{_name:"property",_send:function(a,b,c){this._alive&&(c||this._dispatcher.dispatch(K(a,b)),a===hb&&(this._current=b),a===ib&&(this._currentError=b),a===gb&&this._clear())},_on:function(a,b){return this._alive&&(this._dispatcher.add(a,b),this._setActive(!0)),this._current!==fb&&I(a,b,K(hb,this._current,!0)),this._currentError!==fb&&I(a,b,K(ib,this._currentError,!0)),this._alive||I(a,b,ob),this}}),L.prototype.log=function(a){a=a||this.toString();var b=function(b){var c="<"+b.type+(b.current?":current":"")+">";b.type===hb||b.type===ib?console.log(a,c,b.value):console.log(a,c)};return this.__logHandlers||(this.__logHandlers=[]),this.__logHandlers.push({name:a,handler:b}),this.onAny(b),this},L.prototype.offLog=function(a){if(a=a||this.toString(),this.__logHandlers){var b=h(this.__logHandlers,function(b){return b.name===a});if(-1!==b){var c=this.__logHandlers[b].handler;this.__logHandlers.splice(b,1),this.offAny(c)}}return this},F("withInterval",{_init:function(a){this._fn=a[0];var b=this;this._emitter={emit:function(a){b._send(hb,a)},error:function(a){b._send(ib,a)},end:function(){b._send(gb)},emitEvent:function(a){b._send(a.type,a.value)}}},_free:function(){this._fn=null,this._emitter=null},_onTick:function(){this._fn(this._emitter)}}),F("fromPoll",{_init:function(a){this._fn=a[0]},_free:function(){this._fn=null},_onTick:function(){this._send(hb,this._fn())}}),F("interval",{_init:function(a){this._x=a[0]},_free:function(){this._x=null},_onTick:function(){this._send(hb,this._x)}}),F("sequentially",{_init:function(a){this._xs=i(a[0]),0===this._xs.length&&this._send(gb)},_free:function(){this._xs=null},_onTick:function(){switch(this._xs.length){case 1:this._send(hb,this._xs[0]),this._send(gb);break;default:this._send(hb,this._xs.shift())}}}),F("repeatedly",{_init:function(a){this._xs=i(a[0]),this._i=-1},_onTick:function(){this._xs.length>0&&(this._i=(this._i+1)%this._xs.length,this._send(hb,this._xs[this._i]))}}),eb.repeatedly=D("Kefir.repeatedly()","Kefir.repeat(() => Kefir.sequentially(...)})",eb.repeatedly),F("later",{_init:function(a){this._x=a[0]},_free:function(){this._x=null},_onTick:function(){this._send(hb,this._x),this._send(gb)}}),x(O,M,{_name:"abstractPool",_add:function(a,b){b=b||z,-1===this._concurLim||this._curSources.length<this._concurLim?this._addToCur(b(a)):-1===this._queueLim||this._queue.length<this._queueLim?this._addToQueue(b(a)):"old"===this._drop&&(this._removeOldest(),this._add(b(a)))},_addAll:function(a){var b=this;m(a,function(a){b._add(a)})},_remove:function(a){-1===this._removeCur(a)&&this._removeQueue(a)},_addToQueue:function(a){this._queue=e(this._queue,[a])},_addToCur:function(a){this._curSources=e(this._curSources,[a]),this._active&&this._subscribe(a)},_subscribe:function(a){var b=this,c=function(){b._removeCur(a)};this._bindedEndHandlers.push({obs:a,handler:c}),a.onAny(this._$handleSubAny),a.onEnd(c)},_unsubscribe:function(a){a.offAny(this._$handleSubAny);var b=h(this._bindedEndHandlers,function(b){return b.obs===a});if(-1!==b){var c=this._bindedEndHandlers[b].handler;this._bindedEndHandlers.splice(b,1),a.offEnd(c)}},_handleSubAny:function(a){(a.type===hb||a.type===ib)&&this._send(a.type,a.value,a.current&&this._activating)},_removeQueue:function(a){var b=g(this._queue,a);return this._queue=j(this._queue,b),b},_removeCur:function(a){this._active&&this._unsubscribe(a);var b=g(this._curSources,a);return this._curSources=j(this._curSources,b),-1!==b&&(0!==this._queue.length?this._pullQueue():0===this._curSources.length&&this._onEmpty()),b},_removeOldest:function(){this._removeCur(this._curSources[0])},_pullQueue:function(){0!==this._queue.length&&(this._queue=i(this._queue),this._addToCur(this._queue.shift()))},_onActivation:function(){var a,b=this._curSources;for(this._activating=!0,a=0;a<b.length;a++)this._active&&this._subscribe(b[a]);this._activating=!1},_onDeactivation:function(){var a,b=this._curSources;for(a=0;a<b.length;a++)this._unsubscribe(b[a])},_isEmpty:function(){return 0===this._curSources.length},_onEmpty:function(){},_clear:function(){M.prototype._clear.call(this),this._queue=null,this._curSources=null,this._$handleSubAny=null,this._bindedEndHandlers=null}});var pb={_onEmpty:function(){this._initialised&&this._send(gb,null,this._activating)}};x(P,O,w({_name:"merge"},pb)),eb.merge=function(a){return new P(a)},L.prototype.merge=function(a){return eb.merge([this,a])},x(Q,O,w({_name:"concat"},pb)),eb.concat=function(a){return new Q(a)},L.prototype.concat=function(a){return eb.concat([this,a])},eb.Pool=R,x(R,O,{_name:"pool",plug:function(a){return this._add(a),this},unplug:function(a){return this._remove(a),this}}),eb.pool=function(){return new R},eb.Bus=S,x(S,O,{_name:"bus",plug:function(a){return this._add(a),this},unplug:function(a){return this._remove(a),this},emit:function(a){return this._send(hb,a),this},error:function(a){return this._send(ib,a),this},end:function(){return this._send(gb),this},emitEvent:function(a){this._send(a.type,a.value)}}),eb.bus=function(){return new S},x(T,O,{_onActivation:function(){O.prototype._onActivation.call(this),this._active&&(this._activating=!0,this._source.onAny(this._$handleMainSource),this._activating=!1)},_onDeactivation:function(){O.prototype._onDeactivation.call(this),this._source.offAny(this._$handleMainSource)},_handleMainSource:function(a){a.type===hb&&(a.current&&this._lastCurrent===a.value||this._add(a.value,this._fn),this._lastCurrent=a.value),a.type===ib&&this._send(ib,a.value,a.current),a.type===gb&&(this._isEmpty()?this._send(gb,null,a.current):this._mainEnded=!0)},_onEmpty:function(){this._mainEnded&&this._send(gb)},_clear:function(){O.prototype._clear.call(this),this._source=null,this._lastCurrent=null,this._$handleMainSource=null}}),L.prototype.flatMap=function(a){return new T(this,a).setName(this,"flatMap")},L.prototype.flatMapLatest=function(a){return new T(this,a,{concurLim:1,drop:"old"}).setName(this,"flatMapLatest")},L.prototype.flatMapFirst=function(a){return new T(this,a,{concurLim:1}).setName(this,"flatMapFirst")},L.prototype.flatMapConcat=function(a){return new T(this,a,{queueLim:-1,concurLim:1}).setName(this,"flatMapConcat")},L.prototype.flatMapConcurLimit=function(a,b){var c;return 0===b?c=eb.never():(0>b&&(b=-1),c=new T(this,a,{queueLim:-1,concurLim:b})),c.setName(this,"flatMapConcurLimit")},x(U,M,{_name:"zip",_onActivation:function(){var a,b=this._sources.length;for(this._drainArrays(),this._aliveCount=b,a=0;b>a;a++)this._active&&this._sources[a].onAny(this._bindedHandlers[a])},_onDeactivation:function(){for(var a=0;a<this._sources.length;a++)this._sources[a].offAny(this._bindedHandlers[a])},_emit:function(a){for(var b=new Array(this._buffers.length),c=0;c<this._buffers.length;c++)b[c]=this._buffers[c].shift();this._send(hb,this._combinator(b),a)},_isFull:function(){for(var a=0;a<this._buffers.length;a++)if(0===this._buffers[a].length)return!1;return!0},_emitIfFull:function(a){this._isFull()&&this._emit(a)},_drainArrays:function(){for(;this._isFull();)this._emit(!0)},_bindHandleAny:function(a){var b=this;return function(c){b._handleAny(a,c)}},_handleAny:function(a,b){b.type===hb&&(this._buffers[a].push(b.value),this._emitIfFull(b.current)),b.type===ib&&this._send(ib,b.value,b.current),b.type===gb&&(this._aliveCount--,0===this._aliveCount&&this._send(gb,null,b.current))},_clear:function(){M.prototype._clear.call(this),this._sources=null,this._buffers=null,this._combinator=null,this._bindedHandlers=null}}),eb.zip=function(a,b){return new U(a,b)},L.prototype.zip=function(a,b){return new U([this,a],b)},x(V,M,{_name:"combine",_onActivation:function(){var a,b=this._sources.length;for(this._aliveCount=this._activeCount,this._activating=!0,a=0;b>a;a++)this._sources[a].onAny(this._bindedHandlers[a]);this._activating=!1,this._emitAfterActivation&&(this._emitAfterActivation=!1,this._emitIfFull(!0)),this._endAfterActivation&&this._send(gb,null,!0)},_onDeactivation:function(){var a,b=this._sources.length;for(a=0;b>a;a++)this._sources[a].offAny(this._bindedHandlers[a])},_emitIfFull:function(a){if(!o(this._currents,fb)){var b=i(this._currents);b=this._combinator(b),this._send(hb,b,a)}},_bindHandleAny:function(a){var b=this;return function(c){b._handleAny(a,c)}},_handleAny:function(a,b){b.type===hb&&(this._currents[a]=b.value,a<this._activeCount&&(this._activating?this._emitAfterActivation=!0:this._emitIfFull(b.current))),b.type===ib&&this._send(ib,b.value,b.current),b.type===gb&&a<this._activeCount&&(this._aliveCount--,0===this._aliveCount&&(this._activating?this._endAfterActivation=!0:this._send(gb,null,b.current)))},_clear:function(){M.prototype._clear.call(this),this._sources=null,this._currents=null,this._combinator=null,this._bindedHandlers=null}}),eb.combine=function(a,b,c){return E(b)&&(c=b,b=null),new V(a,b||[],c)},L.prototype.combine=function(a,b){return eb.combine([this,a],b)},eb.sampledBy=D("Kefir.sampledBy()","Kefir.combine(active, passive, combinator)",function(a,b,c){var d=c;if(a.length>0){var e=a.length;d=function(){var a=f(arguments,e);return c?s(c,null,a):a}}return new V(b,a,d).setName("sampledBy")}),L.prototype.sampledBy=function(a,b){var c;return b&&(c=function(a,c){return b(c,a)}),new V([a],[this],c||A).setName(this,"sampledBy")},G("toProperty",{_init:function(a){a.length>0&&this._send(hb,a[0])}},{propertyMethod:X,streamMethod:X}),G("changes",{_handleValue:function(a,b){b||this._send(hb,a)},_handleError:function(a,b){b||this._send(ib,a)}},{streamMethod:function(){return function(){return this}},propertyMethod:W}),G("withHandler",{_init:function(a){this._handler=a[0],this._forcedCurrent=!1;var b=this;this._emitter={emit:function(a){b._send(hb,a,b._forcedCurrent)},error:function(a){b._send(ib,a,b._forcedCurrent)},end:function(){b._send(gb,null,b._forcedCurrent)},emitEvent:function(a){b._send(a.type,a.value,b._forcedCurrent)}}},_free:function(){this._handler=null,this._emitter=null},_handleAny:function(a){this._forcedCurrent=a.current,this._handler(this._emitter,a),this._forcedCurrent=!1}}),G("flatten",{_init:function(a){this._fn=a[0]?a[0]:z},_free:function(){this._fn=null},_handleValue:function(a,b){for(var c=this._fn(a),d=0;d<c.length;d++)this._send(hb,c[d],b)}}),G("transduce",{_init:function(a){this._xform=a[0](Y(this))},_free:function(){this._xform=null},_handleValue:function(a,b){this._forcedCurrent=b,null!==this._xform.step(null,a)&&this._xform.result(null),this._forcedCurrent=!1},_handleEnd:function(a,b){this._forcedCurrent=b,this._xform.result(null),this._forcedCurrent=!1}}),G("map",{_init:function(a){this._fn=a[0]||z},_free:function(){this._fn=null},_handleValue:function(a,b){this._send(hb,this._fn(a),b)}}),G("mapErrors",{_init:function(a){this._fn=a[0]||z},_free:function(){this._fn=null},_handleError:function(a,b){this._send(ib,this._fn(a),b)}}),G("errorsToValues",{_init:function(a){this._fn=a[0]||Z},_free:function(){this._fn=null},_handleError:function(a,b){var c=this._fn(a),d=c.convert?hb:ib,e=c.convert?c.value:a;this._send(d,e,b)}}),G("valuesToErrors",{_init:function(a){this._fn=a[0]||$},_free:function(){this._fn=null},_handleValue:function(a,b){var c=this._fn(a),d=c.convert?ib:hb,e=c.convert?c.error:a;this._send(d,e,b)}}),G("filter",{_init:function(a){this._fn=a[0]||z},_free:function(){this._fn=null},_handleValue:function(a,b){this._fn(a)&&this._send(hb,a,b)}}),G("filterErrors",{_init:function(a){this._fn=a[0]||z},_free:function(){this._fn=null},_handleError:function(a,b){this._fn(a)&&this._send(ib,a,b)}}),G("takeWhile",{_init:function(a){this._fn=a[0]||z},_free:function(){this._fn=null},_handleValue:function(a,b){this._fn(a)?this._send(hb,a,b):this._send(gb,null,b)}}),G("take",{_init:function(a){this._n=a[0],this._n<=0&&this._send(gb)},_handleValue:function(a,b){this._n--,this._send(hb,a,b),0===this._n&&this._send(gb,null,b)}}),G("skip",{_init:function(a){this._n=Math.max(0,a[0])},_handleValue:function(a,b){0===this._n?this._send(hb,a,b):this._n--}}),G("skipDuplicates",{_init:function(a){this._fn=a[0]||B,this._prev=fb},_free:function(){this._fn=null,this._prev=null},_handleValue:function(a,b){this._prev!==fb&&this._fn(this._prev,a)||(this._prev=a,this._send(hb,a,b))}}),G("skipWhile",{_init:function(a){this._fn=a[0]||z,this._skip=!0},_free:function(){this._fn=null},_handleValue:function(a,b){return this._skip?void(this._fn(a)||(this._skip=!1,this._fn=null,this._send(hb,a,b))):void this._send(hb,a,b)}}),G("diff",{_init:function(a){this._fn=a[0]||C,this._prev=a.length>1?a[1]:fb},_free:function(){this._prev=null,this._fn=null},_handleValue:function(a,b){this._prev!==fb&&this._send(hb,this._fn(this._prev,a),b),this._prev=a}}),G("scan",{_init:function(a){this._fn=a[0],a.length>1&&this._send(hb,a[1],!0)},_free:function(){this._fn=null},_handleValue:function(a,b){this._current!==fb&&(a=this._fn(this._current,a)),this._send(hb,a,b)}},{streamMethod:X}),G("reduce",{_init:function(a){this._fn=a[0],this._result=a.length>1?a[1]:fb},_free:function(){this._fn=null,this._result=null},_handleValue:function(a){this._result=this._result===fb?a:this._fn(this._result,a)},_handleEnd:function(a,b){this._result!==fb&&this._send(hb,this._result,b),this._send(gb,null,b)}}),G("mapEnd",{_init:function(a){this._fn=a[0]},_free:function(){this._fn=null},_handleEnd:function(a,b){this._send(hb,this._fn(),b),this._send(gb,null,b)}}),G("skipValues",{_handleValue:function(){}}),G("skipErrors",{_handleError:function(){}}),G("skipEnd",{_handleEnd:function(){}}),G("endOnError",{_handleError:function(a,b){this._send(ib,a,b),this._send(gb,null,b)}}),G("slidingWindow",{_init:function(a){this._max=a[0],this._min=a[1]||0,this._buff=[]},_free:function(){this._buff=null},_handleValue:function(a,b){this._buff=q(this._buff,a,this._max),this._buff.length>=this._min&&this._send(hb,this._buff,b)}}),G("bufferWhile",{_init:function(a){this._fn=a[0]||z,this._flushOnEnd=t(a[1],"flushOnEnd",!0),this._buff=[]},_free:function(){this._buff=null},_flush:function(a){null!==this._buff&&0!==this._buff.length&&(this._send(hb,this._buff,a),this._buff=[])},_handleValue:function(a,b){this._buff.push(a),this._fn(a)||this._flush(b)},_handleEnd:function(a,b){this._flushOnEnd&&this._flush(b),this._send(gb,null,b)}}),G("debounce",{_init:function(a){this._wait=Math.max(0,a[0]),this._immediate=t(a[1],"immediate",!1),this._lastAttempt=0,this._timeoutId=null,this._laterValue=null,this._endLater=!1;var b=this;this._$later=function(){b._later()}},_free:function(){this._laterValue=null,this._$later=null},_handleValue:function(a,b){b?this._send(hb,a,b):(this._lastAttempt=kb(),this._immediate&&!this._timeoutId&&this._send(hb,a),this._timeoutId||(this._timeoutId=setTimeout(this._$later,this._wait)),this._immediate||(this._laterValue=a))},_handleEnd:function(a,b){b?this._send(gb,null,b):this._timeoutId&&!this._immediate?this._endLater=!0:this._send(gb)},_later:function(){var a=kb()-this._lastAttempt;a<this._wait&&a>=0?this._timeoutId=setTimeout(this._$later,this._wait-a):(this._timeoutId=null,this._immediate||(this._send(hb,this._laterValue),this._laterValue=null),this._endLater&&this._send(gb))}}),G("throttle",{_init:function(a){this._wait=Math.max(0,a[0]),this._leading=t(a[1],"leading",!0),this._trailing=t(a[1],"trailing",!0),this._trailingValue=null,this._timeoutId=null,this._endLater=!1,this._lastCallTime=0;var b=this;this._$trailingCall=function(){b._trailingCall()}},_free:function(){this._trailingValue=null,this._$trailingCall=null},_handleValue:function(a,b){if(b)this._send(hb,a,b);else{var c=kb();0!==this._lastCallTime||this._leading||(this._lastCallTime=c);var d=this._wait-(c-this._lastCallTime);0>=d?(this._cancelTraling(),this._lastCallTime=c,this._send(hb,a)):this._trailing&&(this._cancelTraling(),this._trailingValue=a,this._timeoutId=setTimeout(this._$trailingCall,d))}},_handleEnd:function(a,b){b?this._send(gb,null,b):this._timeoutId?this._endLater=!0:this._send(gb)},_cancelTraling:function(){null!==this._timeoutId&&(clearTimeout(this._timeoutId),this._timeoutId=null)},_trailingCall:function(){this._send(hb,this._trailingValue),this._timeoutId=null,this._trailingValue=null,this._lastCallTime=this._leading?kb():0,this._endLater&&this._send(gb)}}),G("delay",{_init:function(a){this._wait=Math.max(0,a[0]),this._buff=[];var b=this;this._$shiftBuff=function(){b._send(hb,b._buff.shift())}},_free:function(){this._buff=null,this._$shiftBuff=null},_handleValue:function(a,b){b?this._send(hb,a,b):(this._buff.push(a),setTimeout(this._$shiftBuff,this._wait))},_handleEnd:function(a,b){if(b)this._send(gb,null,b);else{var c=this;setTimeout(function(){c._send(gb)},this._wait)}}}),x(_,M,{_name:"fromBinder",_onActivation:function(){var a=this,b=!0,c={emit:function(c){a._send(hb,c,b)},error:function(c){a._send(ib,c,b)},end:function(){a._send(gb,null,b)},emitEvent:function(c){a._send(c.type,c.value,b)}};this._unsubscribe=this._fn(c)||null,this._active||null===this._unsubscribe||(this._unsubscribe(),this._unsubscribe=null),b=!1},_onDeactivation:function(){null!==this._unsubscribe&&(this._unsubscribe(),this._unsubscribe=null)},_clear:function(){M.prototype._clear.call(this),this._fn=null}}),eb.fromBinder=function(a){return new _(a)},x(ab,M,{_name:"emitter",emit:function(a){return this._send(hb,a),this},error:function(a){return this._send(ib,a),this},end:function(){return this._send(gb),this},emitEvent:function(a){this._send(a.type,a.value)}}),eb.emitter=function(){return new ab},eb.Emitter=ab;var qb=new M;qb._send(gb),qb._name="never",eb.never=function(){return qb},x(bb,N,{_name:"constant"}),eb.constant=function(a){return new bb(a)},x(cb,N,{_name:"constantError"}),eb.constantError=function(a){return new cb(a)},x(db,M,{_name:"repeat",_handleAny:function(a){a.type===gb?(this._source=null,this._startLoop()):this._send(a.type,a.value,this._activating)},_startLoop:function(){if(!this._inLoop){for(this._inLoop=!0;null===this._source&&this._alive&&this._active;)this._source=this._generator(this._iteration++),this._source?this._source.onAny(this._$handleAny):this._send(gb);this._inLoop=!1}},_onActivation:function(){this._activating=!0,this._source?this._source.onAny(this._$handleAny):this._startLoop(),this._activating=!1},_onDeactivation:function(){this._source&&this._source.offAny(this._$handleAny)},_clear:function(){M.prototype._clear.call(this),this._generator=null,this._source=null,this._$handleAny=null}}),eb.repeat=function(a){return new db(a)},L.prototype.setName=function(a,b){return this._name=b?a._name+"."+b:a,this},L.prototype.mapTo=D(".mapTo()",".map(() => value)",function(a){return this.map(function(){return a}).setName(this,"mapTo")}),L.prototype.pluck=D(".pluck()",".map((v) => v.prop)",function(a){return this.map(function(b){return b[a]}).setName(this,"pluck")}),L.prototype.invoke=D(".invoke()",".map((v) => v.method())",function(a){var b=p(arguments,1);return this.map(b?function(c){return s(c[a],c,b)}:function(b){return b[a]()}).setName(this,"invoke")}),L.prototype.timestamp=D(".timestamp()",".map((v) => {value: v, time: (new Date).getTime()})",function(){return this.map(function(a){return{value:a,time:kb()}}).setName(this,"timestamp")}),L.prototype.tap=D(".tap()",".map((v) => {fn(v); return v})",function(a){return this.map(function(b){return a(b),b}).setName(this,"tap")}),eb.and=D("Kefir.and()","Kefir.combine([a, b], (a, b) => a && b)",function(a){return eb.combine(a,b).setName("and")}),L.prototype.and=D(".and()",".combine(other, (a, b) => a && b)",function(a){return this.combine(a,b).setName("and")}),eb.or=D("Kefir.or()","Kefir.combine([a, b], (a, b) => a || b)",function(a){return eb.combine(a,c).setName("or")}),L.prototype.or=D(".or()",".combine(other, (a, b) => a || b)",function(a){return this.combine(a,c).setName("or")}),L.prototype.not=D(".not()",".map(v => !v)",function(){return this.map(d).setName(this,"not")}),L.prototype.awaiting=function(a){return eb.merge([this.mapTo(!0),a.mapTo(!1)]).skipDuplicates().toProperty(!1).setName(this,"awaiting")},eb.fromCallback=function(a){var b=!1;return eb.fromBinder(function(c){b||(a(function(a){c.emit(a),c.end()}),b=!0)}).setName("fromCallback")},eb.fromNodeCallback=function(a){var b=!1;return eb.fromBinder(function(c){b||(a(function(a,b){a?c.error(a):c.emit(b),c.end()}),b=!0)}).setName("fromNodeCallback")},eb.fromPromise=function(a){var b=!1;return eb.fromBinder(function(c){if(!b){var d=function(a){c.emit(a),c.end()},e=function(a){c.error(a),c.end()},f=a.then(d,e);f&&E(f.done)&&f.done(),b=!0}}).toProperty().setName("fromPromise")},eb.fromSubUnsub=function(a,b,c){return eb.fromBinder(function(d){var e=c?function(){d.emit(s(c,this,arguments))}:d.emit;return a(e),function(){b(e)}})};var rb=[["addEventListener","removeEventListener"],["addListener","removeListener"],["on","off"]];eb.fromEvent=function(a,b,c){for(var d,e,f,g=0;g<rb.length;g++)if(d=rb[g],E(a[d[0]])&&E(a[d[1]])){e=d[0],f=d[1];break}if(void 0===e)throw new Error("target don't support any of addEventListener/removeEventListener, addListener/removeListener, on/off method pair");return eb.fromSubUnsub(function(c){a[e](b,c)},function(c){a[f](b,c)},c).setName("fromEvent")};var sb={_init:function(a){this._buff=[],this._flushOnEnd=t(a[0],"flushOnEnd",!0) | ||
},_free:function(){this._buff=null},_flush:function(a){null!==this._buff&&0!==this._buff.length&&(this._send(hb,this._buff,a),this._buff=[])},_handlePrimaryEnd:function(a,b){this._flushOnEnd&&this._flush(b),this._send(gb,null,b)}};H("bufferBy",w({_onActivation:function(){this._primary.onAny(this._$handlePrimaryAny),this._alive&&null!==this._secondary&&this._secondary.onAny(this._$handleSecondaryAny)},_handlePrimaryValue:function(a){this._buff.push(a)},_handleSecondaryValue:function(a,b){this._flush(b)},_handleSecondaryEnd:function(a,b){this._flushOnEnd||this._send(gb,null,b)}},sb)),H("bufferWhileBy",w({_handlePrimaryValue:function(a,b){this._buff.push(a),this._lastSecondary===fb||this._lastSecondary||this._flush(b)},_handleSecondaryEnd:function(a,b){this._flushOnEnd||this._lastSecondary!==fb&&!this._lastSecondary||this._send(gb,null,b)}},sb)),H("filterBy",{_handlePrimaryValue:function(a,b){this._lastSecondary!==fb&&this._lastSecondary&&this._send(hb,a,b)},_handleSecondaryEnd:function(a,b){this._lastSecondary!==fb&&this._lastSecondary||this._send(gb,null,b)}}),H("skipUntilBy",{_handlePrimaryValue:function(a,b){this._lastSecondary!==fb&&this._send(hb,a,b)},_handleSecondaryEnd:function(a,b){this._lastSecondary===fb&&this._send(gb,null,b)}}),H("takeUntilBy",{_handleSecondaryValue:function(a,b){this._send(gb,null,b)}}),H("takeWhileBy",{_handlePrimaryValue:function(a,b){this._lastSecondary!==fb&&this._send(hb,a,b)},_handleSecondaryValue:function(a,b){this._lastSecondary=a,this._lastSecondary||this._send(gb,null,b)},_handleSecondaryEnd:function(a,b){this._lastSecondary===fb&&this._send(gb,null,b)}}),H("skipWhileBy",{_init:function(){this._hasFalseyFromSecondary=!1},_handlePrimaryValue:function(a,b){this._hasFalseyFromSecondary&&this._send(hb,a,b)},_handleSecondaryValue:function(a){this._hasFalseyFromSecondary=this._hasFalseyFromSecondary||!a},_handleSecondaryEnd:function(a,b){this._hasFalseyFromSecondary||this._send(gb,null,b)}}),"function"==typeof define&&define.amd?(define([],function(){return eb}),a.Kefir=eb):"object"==typeof module&&"object"==typeof exports?(module.exports=eb,eb.Kefir=eb):a.Kefir=eb}(this); | ||
//# sourceMappingURL=kefir.min.js.map |
{ | ||
"name": "kefir", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Reactive Programming library for JavaScript inspired by Bacon.js and RxJS with focus on high performance and low memory usage", | ||
@@ -5,0 +5,0 @@ "main": "dist/kefir.js", |
@@ -11,2 +11,3 @@ # <a href="http://pozadi.github.io/kefir/"><img src="http://pozadi.github.io/kefir/Kefir-with-bg.svg" width="60" height="60"></a> Kefir | ||
For docs visit [pozadi.github.io/kefir](http://pozadi.github.io/kefir). | ||
See also [Deprecated API docs](https://github.com/pozadi/kefir/blob/master/deprecated-api-docs.md). | ||
@@ -41,3 +42,3 @@ | ||
See [downloads](https://pozadi.github.io/kefir/#downloads) section in the docs. | ||
See [downloads](https://pozadi.github.io/kefir/#downloads) section in the docs. | ||
@@ -44,0 +45,0 @@ |
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
163930
9
2573
61