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

baconjs

Package Overview
Dependencies
Maintainers
1
Versions
224
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

baconjs - npm Package Compare versions

Comparing version 0.1.8 to 0.1.9

2

component.json
{
"name": "baconjs",
"version": "0.1.8",
"version": "0.1.9",
"main": "./dist/Bacon.js"
}
(function() {
var Bacon, Bus, Dispatcher, End, Error, Event, EventStream, Initial, Next, None, Observable, Property, PropertyDispatcher, Some, addPropertyInitValueToStream, assert, assertArray, assertEvent, assertFunction, assertNoArguments, assertString, cloneArray, cloneObject, end, former, indexOf, initial, isEvent, isFieldKey, isFunction, latter, makeFunction, methodCall, next, nop, partiallyApplied, remove, sendWrapped, toCombinator, toEvent, toFieldExtractor, toFieldKey, toOption, toSimpleExtractor, _, _ref,
var Bacon, Bus, Dispatcher, End, Error, Event, EventStream, Initial, Next, None, Observable, Property, PropertyDispatcher, Some, addPropertyInitValueToStream, assert, assertArray, assertEvent, assertFunction, assertNoArguments, assertString, cloneArray, end, former, indexOf, initial, isFieldKey, isFunction, latter, makeFunction, methodCall, next, nop, partiallyApplied, remove, sendWrapped, toCombinator, toEvent, toFieldExtractor, toFieldKey, toOption, toSimpleExtractor, _, _ref,
__slice = [].slice,

@@ -15,3 +15,3 @@ __hasProp = {}.hasOwnProperty,

Bacon.asStream = function(binder, eventTransformer) {
Bacon.fromBinder = function(binder, eventTransformer) {
if (eventTransformer == null) {

@@ -21,9 +21,37 @@ eventTransformer = _.id;

return new EventStream(function(sink) {
var unbind;
return unbind = binder(function() {
var args;
var unbind, unbinder;
unbind = function() {
if (typeof unbinder !== "undefined" && unbinder !== null) {
return unbinder();
} else {
return setTimeout((function() {
return unbinder();
}), 0);
}
};
return unbinder = binder(function() {
var args, event, reply, value, _i, _len, _results;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
if (Bacon.noMore === sink(next(eventTransformer.apply(null, args)))) {
return unbind();
value = eventTransformer.apply(null, args);
if (!(value instanceof Array && _.last(value) instanceof Event)) {
value = [value];
}
try {
_results = [];
for (_i = 0, _len = value.length; _i < _len; _i++) {
event = value[_i];
reply = sink(event = toEvent(event));
if (reply === Bacon.noMore || event.isEnd()) {
_results.push(unbind());
} else {
_results.push(void 0);
}
}
return _results;
} catch (e) {
if (_.last(value).isEnd()) {
unbind();
}
throw e;
}
});

@@ -37,9 +65,6 @@ });

_this = this;
if (eventTransformer == null) {
eventTransformer = _.id;
}
if (isFunction(selector)) {
_ref = [selector, null], eventTransformer = _ref[0], selector = _ref[1];
}
return Bacon.asStream(function(handler) {
return Bacon.fromBinder(function(handler) {
_this.on(eventName, selector, handler);

@@ -49,3 +74,3 @@ return function() {

};
});
}, eventTransformer);
}

@@ -59,43 +84,18 @@ };

Bacon.fromEventTarget = function(target, eventName, eventTransformer) {
if (eventTransformer == null) {
eventTransformer = _.id;
}
return new EventStream(function(sink) {
var handler, unbind;
handler = function() {
var args, reply;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
reply = sink(next(eventTransformer.apply(null, args)));
if (reply === Bacon.noMore) {
return unbind();
}
var sub, unsub, _ref1, _ref2, _ref3, _ref4;
sub = (_ref1 = target.addEventListener) != null ? _ref1 : (_ref2 = target.addListener) != null ? _ref2 : target.bind;
unsub = (_ref3 = target.removeEventListener) != null ? _ref3 : (_ref4 = target.removeListener) != null ? _ref4 : target.unbind;
return Bacon.fromBinder(function(handler) {
sub.call(target, eventName, handler);
return function() {
return unsub.call(target, eventName, handler);
};
if (target.addEventListener) {
unbind = function() {
return target.removeEventListener(eventName, handler, false);
};
target.addEventListener(eventName, handler, false);
} else {
unbind = function() {
return target.removeListener(eventName, handler);
};
target.addListener(eventName, handler);
}
return unbind;
});
}, eventTransformer);
};
Bacon.fromPromise = function(promise) {
return new EventStream(function(sink) {
var onError, onSuccess;
onSuccess = function(value) {
sink(next(value));
return sink(end());
};
onError = function(e) {
sink(new Error(e));
return sink(end());
};
promise.then(onSuccess, onError);
return nop;
return Bacon.fromCallback(function(handler) {
return promise.then(handler, function(e) {
return handler(new Error(e));
});
});

@@ -113,25 +113,21 @@ };

Bacon.sequentially = function(delay, values) {
var index, poll;
index = -1;
poll = function() {
var valueEvent;
index++;
valueEvent = toEvent(values[index]);
if (index < values.length - 1) {
return valueEvent;
var index;
index = 0;
return Bacon.fromPoll(delay, function() {
var value;
value = values[index++];
if (index < values.length) {
return value;
} else {
return [valueEvent, end()];
return [value, end()];
}
};
return Bacon.fromPoll(delay, poll);
});
};
Bacon.repeatedly = function(delay, values) {
var index, poll;
index = -1;
poll = function() {
index++;
return toEvent(values[index % values.length]);
};
return Bacon.fromPoll(delay, poll);
var index;
index = 0;
return Bacon.fromPoll(delay, function() {
return values[index++ % values.length];
});
};

@@ -142,11 +138,7 @@

f = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
f = makeFunction(f, args);
return new EventStream(function(sink) {
var handler;
handler = function(value) {
sink(next(value));
return sink(end());
};
f(handler);
return Bacon.fromBinder(function(handler) {
makeFunction(f, args)(handler);
return nop;
}, function(value) {
return [value, end()];
});

@@ -156,37 +148,18 @@ };

Bacon.fromPoll = function(delay, poll) {
return new EventStream(function(sink) {
var handler, id, unbind;
id = void 0;
handler = function() {
var event, events, reply, _i, _len, _results;
events = _.toArray(poll());
_results = [];
for (_i = 0, _len = events.length; _i < _len; _i++) {
event = events[_i];
reply = sink(event);
if (reply === Bacon.noMore || event.isEnd()) {
_results.push(unbind());
} else {
_results.push(void 0);
}
}
return _results;
};
unbind = function() {
return Bacon.fromBinder(function(handler) {
var id;
id = setInterval(handler, delay);
return function() {
return clearInterval(id);
};
id = setInterval(handler, delay);
return unbind;
});
}, poll);
};
Bacon.interval = function(delay, value) {
var poll;
if (value == null) {
value = {};
}
poll = function() {
return Bacon.fromPoll(delay, function() {
return next(value);
};
return Bacon.fromPoll(delay, poll);
});
};

@@ -241,3 +214,4 @@

Bacon.combineAsArray = function() {
var more, next, stream, streams, _i, _len, _ref1;
var more, s, streams, values,
_this = this;
streams = arguments[0], more = 2 <= arguments.length ? __slice.call(arguments, 1) : [];

@@ -248,13 +222,109 @@ if (!(streams instanceof Array)) {

if (streams.length) {
stream = (_.head(streams)).toProperty().map(function(x) {
return [x];
values = (function() {
var _i, _len, _results;
_results = [];
for (_i = 0, _len = streams.length; _i < _len; _i++) {
s = streams[_i];
_results.push(None);
}
return _results;
})();
return new Property(function(sink) {
var checkEnd, combiningSink, ends, index, initialSent, sinkFor, stream, unsubAll, unsubs, unsubscribed, _i, _len;
unsubscribed = false;
unsubs = (function() {
var _i, _len, _results;
_results = [];
for (_i = 0, _len = streams.length; _i < _len; _i++) {
s = streams[_i];
_results.push(nop);
}
return _results;
})();
unsubAll = (function() {
var f, _i, _len;
for (_i = 0, _len = unsubs.length; _i < _len; _i++) {
f = unsubs[_i];
f();
}
return unsubscribed = true;
});
ends = (function() {
var _i, _len, _results;
_results = [];
for (_i = 0, _len = streams.length; _i < _len; _i++) {
s = streams[_i];
_results.push(false);
}
return _results;
})();
checkEnd = function() {
var reply;
if (_.all(ends)) {
reply = sink(end());
if (reply === Bacon.noMore) {
unsubAll();
}
return reply;
}
};
initialSent = false;
combiningSink = function(markEnd, setValue) {
return function(event) {
var reply, valueArrayF;
if (event.isEnd()) {
markEnd();
checkEnd();
return Bacon.noMore;
} else if (event.isError()) {
reply = sink(event);
if (reply === Bacon.noMore) {
unsubAll();
}
return reply;
} else {
setValue(event.value);
if (_.all(_.map((function(x) {
return x.isDefined;
}), values))) {
if (initialSent && event.isInitial()) {
return Bacon.more;
} else {
initialSent = true;
valueArrayF = function() {
var x, _i, _len, _results;
_results = [];
for (_i = 0, _len = values.length; _i < _len; _i++) {
x = values[_i];
_results.push(x.get()());
}
return _results;
};
reply = sink(event.apply(valueArrayF));
if (reply === Bacon.noMore) {
unsubAll();
}
return reply;
}
} else {
return Bacon.more;
}
}
};
};
sinkFor = function(index) {
return combiningSink((function() {
return ends[index] = true;
}), (function(x) {
return values[index] = new Some(x);
}));
};
for (index = _i = 0, _len = streams.length; _i < _len; index = ++_i) {
stream = streams[index];
if (!unsubscribed) {
unsubs[index] = stream.subscribe(sinkFor(index));
}
}
return unsubAll;
});
_ref1 = _.tail(streams);
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
next = _ref1[_i];
stream = stream.combine(next, function(xs, x) {
return xs.concat([x]);
});
}
return stream;
} else {

@@ -371,10 +441,2 @@ return Bacon.constant([]);

Event.prototype.getOriginalEvent = function() {
if (this.sourceEvent != null) {
return this.sourceEvent.getOriginalEvent();
} else {
return this;
}
};
Event.prototype.onDone = function(listener) {

@@ -392,4 +454,14 @@ return listener();

function Next(value, sourceEvent) {
this.value = isFunction(value) ? value : _.always(value);
function Next(valueF, sourceEvent) {
var _this = this;
if (isFunction(valueF)) {
this.value = function() {
var v;
v = valueF();
_this.value = _.always(v);
return v;
};
} else {
this.value = _.always(valueF);
}
}

@@ -406,7 +478,10 @@

Next.prototype.fmap = function(f) {
return this.apply(f(this.value()));
var _this = this;
return this.apply(function() {
return f(_this.value());
});
};
Next.prototype.apply = function(value) {
return next(value, this.getOriginalEvent());
return new Next(value);
};

@@ -443,7 +518,7 @@

Initial.prototype.apply = function(value) {
return initial(value, this.getOriginalEvent());
return new Initial(value);
};
Initial.prototype.toNext = function() {
return new Next(this.value, this.getOriginalEvent());
return new Next(this.value);
};

@@ -703,3 +778,3 @@

} else {
event.getOriginalEvent().onDone(function() {
event.onDone(function() {
var reply;

@@ -749,6 +824,2 @@ if (!unsubscribed) {

Observable.prototype.distinctUntilChanged = function() {
return this.skipDuplicates();
};
Observable.prototype.skipDuplicates = function(isEqual) {

@@ -777,5 +848,3 @@ if (isEqual == null) {

fromF = f(state, event);
assertArray(fromF);
newState = fromF[0], outputs = fromF[1];
assertArray(outputs);
state = newState;

@@ -809,3 +878,3 @@ reply = Bacon.more;

acc = new Some(f(acc.getOrElse(void 0), event.value()));
return sink(event.apply(acc.get()));
return sink(event.apply(_.always(acc.get())));
}

@@ -1215,3 +1284,3 @@ } else {

} else {
setValue(new Some(event.value()));
setValue(new Some(event.value));
if (myVal.isDefined && otherVal.isDefined) {

@@ -1252,8 +1321,7 @@ if (initialSent && event.isInitial()) {

this.combine = function(other, f) {
var combinator, combineAndPush;
var combinator;
combinator = toCombinator(f);
combineAndPush = function(sink, event, myVal, otherVal) {
return sink(event.apply(combinator(myVal, otherVal)));
};
return combine(other, combineAndPush, combineAndPush);
return Bacon.combineAsArray(_this, other).map(function(values) {
return combinator(values[0], values[1]);
});
};

@@ -1267,3 +1335,5 @@ this.sampledBy = function(sampler, combinator) {

pushPropertyValue = function(sink, event, propertyVal, streamVal) {
return sink(event.apply(combinator(propertyVal, streamVal)));
return sink(event.apply(function() {
return combinator(propertyVal(), streamVal());
}));
};

@@ -1381,3 +1451,3 @@ values = combine(sampler, nop, pushPropertyValue);

function Dispatcher(subscribe, handleEvent) {
var ended, removeSink, sinks, unsubscribeFromSource,
var addWaiter, done, ended, removeSink, sinks, unsubscribeFromSource, waiters,
_this = this;

@@ -1396,30 +1466,27 @@ if (subscribe == null) {

removeSink = function(sink) {
return remove(sink, sinks);
return sinks = _.without(sink, sinks);
};
waiters = [];
done = function(event) {
var w, ws, _i, _len;
if (waiters != null) {
ws = waiters;
waiters = void 0;
for (_i = 0, _len = ws.length; _i < _len; _i++) {
w = ws[_i];
w();
}
}
return event.onDone = Event.prototype.onDone;
};
addWaiter = function(listener) {
return waiters.push(listener);
};
this.push = function(event) {
var done, reply, sink, waiters, _i, _len, _ref1;
waiters = void 0;
done = function() {
var w, ws, _i, _len;
if (waiters != null) {
ws = waiters;
waiters = void 0;
for (_i = 0, _len = ws.length; _i < _len; _i++) {
w = ws[_i];
w();
}
}
return event.onDone = Event.prototype.onDone;
};
event.onDone = function(listener) {
if ((waiters != null) && !_.contains(waiters, listener)) {
return waiters.push(listener);
} else {
return waiters = [listener];
}
};
assertEvent(event);
_ref1 = cloneArray(sinks);
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
sink = _ref1[_i];
var reply, sink, tmpSinks, _i, _len;
waiters = [];
event.onDone = addWaiter;
tmpSinks = sinks;
for (_i = 0, _len = tmpSinks.length; _i < _len; _i++) {
sink = tmpSinks[_i];
reply = sink(event);

@@ -1430,3 +1497,3 @@ if (reply === Bacon.noMore || event.isEnd()) {

}
done();
done(event);
if (_this.hasSubscribers()) {

@@ -1444,3 +1511,2 @@ return Bacon.more;

this.handleEvent = function(event) {
assertEvent(event);
if (event.isEnd()) {

@@ -1457,3 +1523,3 @@ ended = true;

assertFunction(sink);
sinks.push(sink);
sinks = sinks.concat(sink);
if (sinks.length === 1) {

@@ -1718,8 +1784,4 @@ unsubscribeFromSource = subscribe(_this.handleEvent);

isEvent = function(x) {
return (x != null) && (x.isEvent != null) && x.isEvent();
};
toEvent = function(x) {
if (isEvent(x)) {
if (x instanceof Event) {
return x;

@@ -1735,12 +1797,2 @@ } else {

cloneObject = function(src) {
var clone, key, value;
clone = {};
for (key in src) {
value = src[key];
clone[key] = value;
}
return clone;
};
indexOf = Array.prototype.indexOf ? function(xs, x) {

@@ -1774,4 +1826,3 @@ return xs.indexOf(x);

assertEvent = function(event) {
assert("not an event : " + event, event.isEvent != null);
return assert("not event", event.isEvent());
return assert("not an event : " + event, event instanceof Event && event.isEvent());
};

@@ -1809,5 +1860,7 @@

partiallyApplied = function(f, args) {
return function(value) {
return f.apply(null, args.concat([value]));
partiallyApplied = function(f, applied) {
return function() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
return f.apply(null, applied.concat(args));
};

@@ -1959,2 +2012,17 @@ };

return xs[xs.length - 1];
},
all: function(xs) {
var x, _i, _len;
for (_i = 0, _len = xs.length; _i < _len; _i++) {
x = xs[_i];
if (!x) {
return false;
}
}
return true;
},
without: function(x, xs) {
return _.filter((function(y) {
return y !== x;
}), xs);
}

@@ -1961,0 +2029,0 @@ };

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

(function(){var e,t,n,r,i,s,o,u,a,f,l,c,h,p,d,v,m,g,y,b,w,E,S,x,T,N,C,k,L,A,O,M,_,D,P,H,B,j,F,I,q=[].slice,R={}.hasOwnProperty,U=function(e,t){function r(){this.constructor=e}for(var n in t)R.call(t,n)&&(e[n]=t[n]);return r.prototype=t.prototype,e.prototype=new r,e.__super__=t.prototype,e},z=function(e,t){return function(){return e.apply(t,arguments)}};typeof module!="undefined"&&module!==null?(module.exports=e={},e.Bacon=e):this.Bacon=e={},e.asStream=function(t,n){return n==null&&(n=F.id),new o(function(r){var i;return i=t(function(){var t;t=1<=arguments.length?q.call(arguments,0):[];if(e.noMore===r(k(n.apply(null,t))))return i()})})},e.$={asEventStream:function(t,n,r){var i,s=this;return r==null&&(r=F.id),x(n)&&(i=[n,null],r=i[0],n=i[1]),e.asStream(function(e){return s.on(t,n,e),function(){return s.off(t,n,e)}})}},(I=typeof jQuery!=="undefined"&&jQuery!==null?jQuery:typeof Zepto!=="undefined"&&Zepto!==null?Zepto:null)!=null&&(I.fn.asEventStream=e.$.asEventStream),e.fromEventTarget=function(t,n,r){return r==null&&(r=F.id),new o(function(i){var s,o;return s=function(){var t,n;t=1<=arguments.length?q.call(arguments,0):[],n=i(k(r.apply(null,t)));if(n===e.noMore)return o()},t.addEventListener?(o=function(){return t.removeEventListener(n,s,!1)},t.addEventListener(n,s,!1)):(o=function(){return t.removeListener(n,s)},t.addListener(n,s)),o})},e.fromPromise=function(e){return new o(function(t){var n,r;return r=function(e){return t(k(e)),t(g())},n=function(e){return t(new i(e)),t(g())},e.then(r,n),L})},e.noMore=["<no-more>"],e.more=["<more>"],e.later=function(t,n){return e.sequentially(t,[n])},e.sequentially=function(t,n){var r,i;return r=-1,i=function(){var e;return r++,e=D(n[r]),r<n.length-1?e:[e,g()]},e.fromPoll(t,i)},e.repeatedly=function(t,n){var r,i;return r=-1,i=function(){return r++,D(n[r%n.length])},e.fromPoll(t,i)},e.fromCallback=function(){var e,t;return t=arguments[0],e=2<=arguments.length?q.call(arguments,1):[],t=N(t,e),new o(function(e){var n;return n=function(t){return e(k(t)),e(g())},t(n),L})},e.fromPoll=function(t,n){return new o(function(r){var i,s,o;return s=void 0,i=function(){var t,i,s,u,a,f;i=F.toArray(n()),f=[];for(u=0,a=i.length;u<a;u++)t=i[u],s=r(t),s===e.noMore||t.isEnd()?f.push(o()):f.push(void 0);return f},o=function(){return clearInterval(s)},s=setInterval(i,t),o})},e.interval=function(t,n){var r;return n==null&&(n={}),r=function(){return k(n)},e.fromPoll(t,r)},e.constant=function(e){return new c(M([e],w))},e.never=function(){return e.fromArray([])},e.once=function(t){return e.fromArray([t])},e.fromArray=function(e){return new o(M(e,k))},M=function(e,t){return function(n){var r,i,s;for(i=0,s=e.length;i<s;i++)r=e[i],n(t(r));return n(g()),L}},e.combineAll=function(e,t){var n,r,i,s,o;r=F.head(e),o=F.tail(e);for(i=0,s=o.length;i<s;i++)n=o[i],r=t(r,n);return r},e.mergeAll=function(t){return e.combineAll(t,function(e,t){return e.merge(t)})},e.combineAsArray=function(){var t,n,r,i,s,o,u;i=arguments[0],t=2<=arguments.length?q.call(arguments,1):[],i instanceof Array||(i=[i].concat(t));if(i.length){r=F.head(i).toProperty().map(function(e){return[e]}),u=F.tail(i);for(s=0,o=u.length;s<o;s++)n=u[s],r=r.combine(n,function(e,t){return e.concat([t])});return r}return e.constant([])},e.combineWith=function(t,n){return e.combineAll(t,function(e,t){return e.toProperty().combine(t,n)})},e.combineTemplate=function(t){var n,r,i,s,o,u,a,f,c,h;return a=[],h=[],u=function(e){return e[e.length-1]},c=function(e,t,n){return u(e)[t]=n},n=function(e,t){return function(n,r){return c(n,e,r[t])}},o=function(e,t){return function(n,r){return c(n,e,t)}},f=function(e){return e instanceof Array?[]:{}},i=function(e,t){var r,i;return t instanceof l?(h.push(t),a.push(n(e,h.length-1))):typeof t=="object"?(i=function(e){return function(n,r){var i;return i=f(t),c(n,e,i),n.push(i)}},r=function(e,t){return e.pop()},a.push(i(e)),s(t),a.push(r)):a.push(o(e,t))},s=function(e){return F.each(e,i)},s(t),r=function(e){var n,r,i,s,o;i=f(t),n=[i];for(s=0,o=a.length;s<o;s++)r=a[s],r(n,e);return i},e.combineAsArray(h).map(r)},s=function(){function e(){}return e.prototype.isEvent=function(){return!0},e.prototype.isEnd=function(){return!1},e.prototype.isInitial=function(){return!1},e.prototype.isNext=function(){return!1},e.prototype.isError=function(){return!1},e.prototype.hasValue=function(){return!1},e.prototype.filter=function(e){return!0},e.prototype.getOriginalEvent=function(){return this.sourceEvent!=null?this.sourceEvent.getOriginalEvent():this},e.prototype.onDone=function(e){return e()},e}(),a=function(e){function t(e,t){this.value=x(e)?e:F.always(e)}return U(t,e),t.prototype.isNext=function(){return!0},t.prototype.hasValue=function(){return!0},t.prototype.fmap=function(e){return this.apply(e(this.value()))},t.prototype.apply=function(e){return k(e,this.getOriginalEvent())},t.prototype.filter=function(e){return e(this.value())},t.prototype.describe=function(){return this.value()},t}(s),u=function(e){function t(){return t.__super__.constructor.apply(this,arguments)}return U(t,e),t.prototype.isInitial=function(){return!0},t.prototype.isNext=function(){return!1},t.prototype.apply=function(e){return w(e,this.getOriginalEvent())},t.prototype.toNext=function(){return new a(this.value,this.getOriginalEvent())},t}(a),r=function(e){function t(){return t.__super__.constructor.apply(this,arguments)}return U(t,e),t.prototype.isEnd=function(){return!0},t.prototype.fmap=function(){return this},t.prototype.apply=function(){return this},t.prototype.describe=function(){return"<end>"},t}(s),i=function(e){function t(e){this.error=e}return U(t,e),t.prototype.isError=function(){return!0},t.prototype.fmap=function(){return this},t.prototype.apply=function(){return this},t.prototype.describe=function(){return"<error> "+this.error},t}(s),l=function(){function t(){this.flatMapLatest=z(this.flatMapLatest,this),this.scan=z(this.scan,this),this.takeUntil=z(this.takeUntil,this),this.assign=this.onValue}return t.prototype.onValue=function(){var e,t;return t=arguments[0],e=2<=arguments.length?q.call(arguments,1):[],t=N(t,e),this.subscribe(function(e){if(e.hasValue())return t(e.value())})},t.prototype.onValues=function(e){return this.onValue(function(t){return e.apply(null,t)})},t.prototype.onError=function(){var e,t;return t=arguments[0],e=2<=arguments.length?q.call(arguments,1):[],t=N(t,e),this.subscribe(function(e){if(e.isError())return t(e.error)})},t.prototype.onEnd=function(){var e,t;return t=arguments[0],e=2<=arguments.length?q.call(arguments,1):[],t=N(t,e),this.subscribe(function(e){if(e.isEnd())return t()})},t.prototype.errors=function(){return this.filter(function(){return!1})},t.prototype.filter=function(){var t,n;return n=arguments[0],t=2<=arguments.length?q.call(arguments,1):[],n instanceof c?n.sampledBy(this,function(e,t){return[e,t]}).filter(function(e){var t,n;return t=e[0],n=e[1],t}).map(function(e){var t,n;return t=e[0],n=e[1],n}):(n=N(n,t),this.withHandler(function(t){return t.filter(n)?this.push(t):e.more}))},t.prototype.takeWhile=function(){var t,n;return n=arguments[0],t=2<=arguments.length?q.call(arguments,1):[],n=N(n,t),this.withHandler(function(t){return t.filter(n)?this.push(t):(this.push(g()),e.noMore)})},t.prototype.endOnError=function(){return this.withHandler(function(e){return e.isError()?(this.push(e),this.push(g())):this.push(e)})},t.prototype.take=function(t){return this.withHandler(function(n){return n.hasValue()?t===1?(this.push(n),this.push(g()),e.noMore):(t--,this.push(n)):this.push(n)})},t.prototype.map=function(){var e,t;return t=arguments[0],e=2<=arguments.length?q.call(arguments,1):[],t=N(t,e),this.withHandler(function(e){return this.push(e.fmap(t))})},t.prototype.mapError=function(){var e,t;return t=arguments[0],e=2<=arguments.length?q.call(arguments,1):[],t=N(t,e),this.withHandler(function(e){return e.isError()?this.push(k(t(e.error))):this.push(e)})},t.prototype.mapEnd=function(){var t,n;return n=arguments[0],t=2<=arguments.length?q.call(arguments,1):[],n=N(n,t),this.withHandler(function(t){return t.isEnd()?(this.push(k(n(t))),this.push(g()),e.noMore):this.push(t)})},t.prototype.doAction=function(){var e,t;return t=arguments[0],e=2<=arguments.length?q.call(arguments,1):[],t=N(t,e),this.withHandler(function(e){return e.hasValue()&&t(e.value()),this.push(e)})},t.prototype.takeUntil=function(t){var n;return n=this,this.withSubscribe(function(r){var i,s,o,u,a,f;return f=!1,u=L,a=L,o=function(){return u(),a(),f=!0},i=function(t){return t.isEnd()?(a(),r(t),e.noMore):(t.getOriginalEvent().onDone(function(){var n;if(!f){n=r(t);if(n===e.noMore)return o()}}),e.more)},s=function(t){return t.isError()?e.more:t.isEnd()?e.noMore:(u(),r(g()),e.noMore)},u=n.subscribe(i),f||(a=t.subscribe(s)),o})},t.prototype.skip=function(t){return this.withHandler(function(n){return n.hasValue()?t>0?(t--,e.more):this.push(n):this.push(n)})},t.prototype.distinctUntilChanged=function(){return this.skipDuplicates()},t.prototype.skipDuplicates=function(e){return e==null&&(e=function(e,t){return e===t}),this.withStateMachine(f,function(t,n){return n.hasValue()?t===f||!e(t.get(),n.value())?[new p(n.value()),[n]]:[t,[]]:[t,[n]]})},t.prototype.withStateMachine=function(t,n){var r;return r=t,this.withHandler(function(t){var i,s,o,u,a,f,l;i=n(r,t),s=i[0],u=i[1],r=s,a=e.more;for(f=0,l=u.length;f<l;f++){o=u[f],a=this.push(o);if(a===e.noMore)return a}return a})},t.prototype.scan=function(t,n){var r,i,s=this;return n=_(n),r=B(t),i=function(t){var i,o;return i=!1,o=s.subscribe(function(s){return s.hasValue()?i&&s.isInitial()?e.more:(i=!0,r=new p(n(r.getOrElse(void 0),s.value())),t(s.apply(r.get()))):(s.isEnd()&&(i=!0),t(s))}),i||r.forEach(function(n){var r;r=t(w(n));if(r===e.noMore)return o(),o=L}),o},new c((new h(i)).subscribe)},t.prototype.diff=function(e,t){return t=_(t),this.scan([e],function(e,n){return[n,t(e[0],n)]}).filter(function(e){return e.length===2}).map(function(e){return e[1]})},t.prototype.flatMap=function(t){var n;return n=this,new o(function(r){var i,s,o,a,f,l;return s=[],o=!1,l=function(){},f=function(){var e,t,n;l();for(t=0,n=s.length;t<n;t++)e=s[t],e();return s=[]},i=function(){if(o&&s.length===0)return r(g())},a=function(n){var a,l,c,h,p;if(n.isEnd())return o=!0,i();if(n.isError())return r(n);a=t(n.value()),p=void 0,l=!1,h=function(){return p!=null&&O(p,s),i()},c=function(t){var n;return t.isEnd()?(h(),l=!0,e.noMore):(t instanceof u&&(t=t.toNext()),n=r(t),n===e.noMore&&f(),n)},p=a.subscribe(c);if(!l)return s.push(p)},l=n.subscribe(a),f})},t.prototype.flatMapLatest=function(e){var t,n=this;return t=this.toEventStream(),t.flatMap(function(n){return e(n).takeUntil(t)})},t.prototype.not=function(){return this.map(function(e){return!e})},t.prototype.log=function(){return this.subscribe(function(e){return console.log(e.describe())}),this},t.prototype.slidingWindow=function(e){return this.scan([],function(t,n){return t.concat([n]).slice(-e)})},t}(),o=function(t){function r(e){var t;r.__super__.constructor.call(this),t=new n(e),this.subscribe=t.subscribe,this.hasSubscribers=t.hasSubscribers}return U(r,t),r.prototype.map=function(){var e,t;return t=arguments[0],e=2<=arguments.length?q.call(arguments,1):[],t instanceof c?t.sampledBy(this,y):r.__super__.map.apply(this,[t].concat(q.call(e)))},r.prototype.delay=function(t){return this.flatMap(function(n){return e.later(t,n)})},r.prototype.throttle=function(t){return this.flatMapLatest(function(n){return e.later(t,n)})},r.prototype.throttle2=function(e){return this.bufferWithTime(e).map(function(e){return e[e.length-1]})},r.prototype.bufferWithTime=function(e){var t,n=this;return t=function(e){return e.schedule()},this.buffer(e,t,t)},r.prototype.bufferWithCount=function(e){var t;return t=function(t){if(t.values.length===e)return t.flush()},this.buffer(0,t)},r.prototype.buffer=function(t,n,r){var i,s,o;return n==null&&(n=function(){}),r==null&&(r=function(){}),i={scheduled:!1,end:null,values:[],flush:function(){var t;this.scheduled=!1;if(this.values.length>0){t=this.push(k(this.values)),this.values=[];if(this.end!=null)return this.push(this.end);if(t!==e.noMore)return r(this)}else if(this.end!=null)return this.push(this.end)},schedule:function(){var e=this;if(!this.scheduled)return this.scheduled=!0,t(function(){return e.flush()})}},o=e.more,x(t)||(s=t,t=function(e){return setTimeout(e,s)}),this.withHandler(function(e){return i.push=this.push,e.isError()?o=this.push(e):e.isEnd()?(i.end=e,i.scheduled||i.flush()):(i.values.push(e.value()),n(i)),o})},r.prototype.merge=function(t){var n;return n=this,new r(function(r){var i,s,o,u,a,f;return u=L,a=L,f=!1,o=function(){return u(),a(),f=!0},i=0,s=function(t){var n;return t.isEnd()?(i++,i===2?r(g()):e.more):(n=r(t),n===e.noMore&&o(),n)},u=n.subscribe(s),f||(a=t.subscribe(s)),o})},r.prototype.toProperty=function(e){return arguments.length===0&&(e=f),this.scan(e,T)},r.prototype.toEventStream=function(){return this},r.prototype.concat=function(e){var t;return t=this,new r(function(n){var r;return r=t.subscribe(function(t){return t.isEnd()?r=e.subscribe(n):n(t)}),function(){return r()}})},r.prototype.awaiting=function(e){return this.map(!0).merge(e.map(!1)).toProperty(!1)},r.prototype.startWith=function(t){return e.once(t).concat(this)},r.prototype.withHandler=function(e){var t;return t=new n(this.subscribe,e),new r(t.subscribe)},r.prototype.withSubscribe=function(e){return new r(e)},r}(l),c=function(t){function n(t){var r,i=this;this.subscribe=t,this.toEventStream=z(this.toEventStream,this),this.toProperty=z(this.toProperty,this),this.changes=z(this.changes,this),this.sample=z(this.sample,this),n.__super__.constructor.call(this),r=function(t,r,s){var o,u;return o=f,u=f,new n(function(n){var a,f,l,c,h,d,v,m,y,b,w;return w=!1,y=L,b=L,m=function(){return y(),b(),w=!0},c=!1,d=!1,a=function(){var t;if(c&&d)return t=n(g()),t===e.noMore&&m(),t},l=!1,f=function(t,r,i){return function(s){var f;return s.isEnd()?(t(),a(),e.noMore):s.isError()?(f=n(s),f===e.noMore&&m(),f):(r(new p(s.value())),o.isDefined&&u.isDefined?l&&s.isInitial()?e.more:(l=!0,f=i(n,s,o.value,u.value),f===e.noMore&&m(),f):e.more)}},h=f(function(){return c=!0},function(e){return o=e},r),v=f(function(){return d=!0},function(e){return u=e},s),y=i.subscribe(h),w||(b=t.subscribe(v)),m})},this.combine=function(e,t){var n,i;return n=_(t),i=function(e,t,r,i){return e(t.apply(n(r,i)))},r(e,i,i)},this.sampledBy=function(e,t){var n,i;return t==null&&(t=y),t=_(t),n=function(e,n,r,i){return e(n.apply(t(r,i)))},i=r(e,L,n),e instanceof o&&(i=i.changes()),i.takeUntil(e.filter(!1).mapEnd())}}return U(n,t),n.prototype.sample=function(t){return this.sampledBy(e.interval(t,{}))},n.prototype.changes=function(){var e=this;return new o(function(t){return e.subscribe(function(e){if(!e.isInitial())return t(e)})})},n.prototype.withHandler=function(e){return new n((new h(this.subscribe,e)).subscribe)},n.prototype.withSubscribe=function(e){return new n((new h(e)).subscribe)},n.prototype.toProperty=function(){return this},n.prototype.toEventStream=function(){var e=this;return new o(function(t){return e.subscribe(function(e){return e.isInitial()&&(e=e.toNext()),t(e)})})},n.prototype.and=function(e){return this.combine(e,function(e,t){return e&&t})},n.prototype.or=function(e){return this.combine(e,function(e,t){return e||t})},n.prototype.decode=function(t){return this.combine(e.combineTemplate(t),function(e,t){return t[e]})},n.prototype.delay=function(e){return this.delayChanges(function(t){return t.delay(e)})},n.prototype.throttle=function(e){return this.delayChanges(function(t){return t.throttle(e)})},n.prototype.throttle2=function(e){return this.delayChanges(function(t){return t.throttle2(e)})},n.prototype.delayChanges=function(e){return d(this,e(this.changes()))},n}(l),d=function(t,n){var r;return r=function(t){var n;return n=f,t.subscribe(function(t){return t.isInitial()&&(n=new p(t.value())),e.noMore}),n},n.toProperty(r(t))},n=function(){function t(t,n){var r,i,o,u,a=this;t==null&&(t=function(){return L}),o=[],r=!1,this.hasSubscribers=function(){return o.length>0},u=L,i=function(e){return O(e,o)},this.push=function(t){var n,r,u,f,l,c,h;f=void 0,n=function(){var e,n,r,i;if(f!=null){n=f,f=void 0;for(r=0,i=n.length;r<i;r++)e=n[r],e()}return t.onDone=s.prototype.onDone},t.onDone=function(e){return f!=null&&!F.contains(f,e)?f.push(e):f=[e]},h=v(o);for(l=0,c=h.length;l<c;l++)u=h[l],r=u(t),(r===e.noMore||t.isEnd())&&i(u);return n(),a.hasSubscribers()?e.more:e.noMore},n==null&&(n=function(e){return this.push(e)}),this.handleEvent=function(e){return e.isEnd()&&(r=!0),n.apply(a,[e])},this.subscribe=function(e){return r?(e(g()),L):(o.push(e),o.length===1&&(u=t(a.handleEvent)),function(){i(e);if(!a.hasSubscribers())return u()})}}return t}(),h=function(t){function n(t,r){var i,s,o,u=this;n.__super__.constructor.call(this,t,r),i=f,o=this.push,t=this.subscribe,s=!1,this.push=function(e){return e.isEnd()&&(s=!0),e.hasValue()&&(i=new p(e.value())),o.apply(u,[e])},this.subscribe=function(n){var r,o,a;return r=!1,a=function(){return u.hasSubscribers()||s},o=i.filter(a).map(function(e){return n(w(e))}),o.getOrElse(e.more)===e.noMore?L:s?(n(g()),L):t.apply(u,[n])}}return U(n,t),n}(n),t=function(t){function r(){var t,s,o,u,a,f,l,c,h,p,d=this;u=void 0,c=[],s=!1,o=function(t){return function(n){return n.isEnd()?(p(t),e.noMore):u(n)}},h=function(){var e,t,n;for(t=0,n=c.length;t<n;t++)e=c[t],e.unsub!=null&&e.unsub();return c=[]},f=function(e){return e.unsub=e.input.subscribe(o(e.input))},p=function(e){var t,n,r,i;for(t=r=0,i=c.length;r<i;t=++r){n=c[t];if(n.input===e){n.unsub!=null&&n.unsub(),c.splice(t,1);return}}},a=function(e){var t,n,r,i,s;u=e,n=[],s=v(c);for(r=0,i=s.length;r<i;r++)t=s[r],f(t);return h},t=new n(a),l=function(e){return t.subscribe(e)},r.__super__.constructor.call(this,l),this.plug=function(e){var t;if(s)return;return t={input:e},c.push(t),u!=null&&f(t),function(){return p(e)}},this.push=function(e){if(u!=null)return u(k(e))},this.error=function(e){if(u!=null)return u(new i(e))},this.end=function(){s=!0,h();if(u!=null)return u(g())}}return U(r,t),r}(o),p=function(){function e(e){this.value=e}return e.prototype.getOrElse=function(){return this.value},e.prototype.get=function(){return this.value},e.prototype.filter=function(t){return t(this.value)?new e(this.value):f},e.prototype.map=function(t){return new e(t(this.value))},e.prototype.forEach=function(e){return e(this.value)},e.prototype.isDefined=!0,e.prototype.toArray=function(){return[this.value]},e}(),f={getOrElse:function(e){return e},filter:function(){return f},map:function(){return f},forEach:function(){},isDefined:!1,toArray:function(){return[]}},e.EventStream=o,e.Property=c,e.Observable=l,e.Bus=t,e.Initial=u,e.Next=a,e.End=r,e.Error=i,L=function(){},T=function(e,t){return t},y=function(e,t){return e},w=function(e){return new u(F.always(e))},k=function(e){return new a(F.always(e))},g=function(){return new r},E=function(e){return e!=null&&e.isEvent!=null&&e.isEvent()},D=function(e){return E(e)?e:k(e)},v=function(e){return e.slice(0)},m=function(e){var t,n,r;t={};for(n in e)r=e[n],t[n]=r;return t},b=Array.prototype.indexOf?function(e,t){return e.indexOf(t)}:function(e,t){var n,r,i,s;for(n=i=0,s=e.length;i<s;n=++i){r=e[n];if(t===r)return n}return-1},O=function(e,t){var n;n=b(t,e);if(n>=0)return t.splice(n,1)},x=function(e){return typeof e=="function"},C=function(e,t,n){return n===void 0&&(n=[]),function(r){return e[t].apply(e,n.concat([r]))}},A=function(e,t){return function(n){return e.apply(null,t.concat([n]))}},N=function(e,t){return x(e)?t.length?A(e,t):e:S(e)?P(e,t):typeof e=="object"&&t.length?C(e,F.head(t),F.tail(t)):F.always(e)},S=function(e){return typeof e=="string"&&e.length>1&&e.charAt(0)==="."},e.isFieldKey=S,P=function(e,t){var n,r;return r=e.slice(1).split("."),n=F.map(j(t),r),function(t){var r,i;for(r=0,i=n.length;r<i;r++)e=n[r],t=e(t);return t}},j=function(e){return function(t){return function(n){var r;return r=n[t],x(r)?r.apply(n,e):r}}},H=function(e){return e.slice(1)},_=function(e){var t;if(x(e))return e;if(S(e))return t=H(e),function(e,n){return e[t](n)}},B=function(e){return e instanceof p||e===f?e:new p(e)},typeof define!="undefined"&&define!==null&&define.amd!=null&&typeof define=="function"&&define(function(){return e}),F={head:function(e){return e[0]},always:function(e){return function(){return e}},empty:function(e){return e.length===0},tail:function(e){return e.slice(1,e.length)},filter:function(e,t){var n,r,i,s;n=[];for(i=0,s=t.length;i<s;i++)r=t[i],e(r)&&n.push(r);return n},map:function(e,t){var n,r,i,s;s=[];for(r=0,i=t.length;r<i;r++)n=t[r],s.push(e(n));return s},each:function(e,t){var n,r,i;i=[];for(n in e)r=e[n],i.push(t(n,r));return i},toArray:function(e){return e instanceof Array?e:[e]},contains:function(e,t){return b(e,t)!==-1},id:function(e){return e},last:function(e){return e[e.length-1]}},e._=F}).call(this);
(function(){var e,t,n,r,i,s,o,u,a,f,l,c,h,p,d,v,m,g,y,b,w,E,S,x,T,N,C,k,L,A,O,M,_,D,P,H,B,j,F=[].slice,I={}.hasOwnProperty,q=function(e,t){function r(){this.constructor=e}for(var n in t)I.call(t,n)&&(e[n]=t[n]);return r.prototype=t.prototype,e.prototype=new r,e.__super__=t.prototype,e},R=function(e,t){return function(){return e.apply(t,arguments)}};typeof module!="undefined"&&module!==null?(module.exports=e={},e.Bacon=e):this.Bacon=e={},e.fromBinder=function(t,n){return n==null&&(n=B.id),new o(function(r){var i,o;return i=function(){return typeof o!="undefined"&&o!==null?o():setTimeout(function(){return o()},0)},o=t(function(){var t,o,u,a,f,l,c;t=1<=arguments.length?F.call(arguments,0):[],a=n.apply(null,t),a instanceof Array&&B.last(a)instanceof s||(a=[a]);try{c=[];for(f=0,l=a.length;f<l;f++)o=a[f],u=r(o=M(o)),u===e.noMore||o.isEnd()?c.push(i()):c.push(void 0);return c}catch(h){throw B.last(a).isEnd()&&i(),h}})})},e.$={asEventStream:function(t,n,r){var i,s=this;return E(n)&&(i=[n,null],r=i[0],n=i[1]),e.fromBinder(function(e){return s.on(t,n,e),function(){return s.off(t,n,e)}},r)}},(j=typeof jQuery!=="undefined"&&jQuery!==null?jQuery:typeof Zepto!=="undefined"&&Zepto!==null?Zepto:null)!=null&&(j.fn.asEventStream=e.$.asEventStream),e.fromEventTarget=function(t,n,r){var i,s,o,u,a,f;return i=(o=t.addEventListener)!=null?o:(u=t.addListener)!=null?u:t.bind,s=(a=t.removeEventListener)!=null?a:(f=t.removeListener)!=null?f:t.unbind,e.fromBinder(function(e){return i.call(t,n,e),function(){return s.call(t,n,e)}},r)},e.fromPromise=function(t){return e.fromCallback(function(e){return t.then(e,function(t){return e(new i(t))})})},e.noMore=["<no-more>"],e.more=["<more>"],e.later=function(t,n){return e.sequentially(t,[n])},e.sequentially=function(t,n){var r;return r=0,e.fromPoll(t,function(){var e;return e=n[r++],r<n.length?e:[e,m()]})},e.repeatedly=function(t,n){var r;return r=0,e.fromPoll(t,function(){return n[r++%n.length]})},e.fromCallback=function(){var t,n;return n=arguments[0],t=2<=arguments.length?F.call(arguments,1):[],e.fromBinder(function(e){return x(n,t)(e),C},function(e){return[e,m()]})},e.fromPoll=function(t,n){return e.fromBinder(function(e){var n;return n=setInterval(e,t),function(){return clearInterval(n)}},n)},e.interval=function(t,n){return n==null&&(n={}),e.fromPoll(t,function(){return N(n)})},e.constant=function(e){return new c(A([e],b))},e.never=function(){return e.fromArray([])},e.once=function(t){return e.fromArray([t])},e.fromArray=function(e){return new o(A(e,N))},A=function(e,t){return function(n){var r,i,s;for(i=0,s=e.length;i<s;i++)r=e[i],n(t(r));return n(m()),C}},e.combineAll=function(e,t){var n,r,i,s,o;r=B.head(e),o=B.tail(e);for(i=0,s=o.length;i<s;i++)n=o[i],r=t(r,n);return r},e.mergeAll=function(t){return e.combineAll(t,function(e,t){return e.merge(t)})},e.combineAsArray=function(){var t,n,r,i,s=this;return r=arguments[0],t=2<=arguments.length?F.call(arguments,1):[],r instanceof Array||(r=[r].concat(t)),r.length?(i=function(){var e,t,i;i=[];for(e=0,t=r.length;e<t;e++)n=r[e],i.push(f);return i}(),new c(function(t){var s,o,u,a,f,l,c,h,d,v,g,y;v=!1,d=function(){var e,t,i;i=[];for(e=0,t=r.length;e<t;e++)n=r[e],i.push(C);return i}(),h=function(){var e,t,n;for(t=0,n=d.length;t<n;t++)e=d[t],e();return v=!0},u=function(){var e,t,i;i=[];for(e=0,t=r.length;e<t;e++)n=r[e],i.push(!1);return i}(),s=function(){var n;if(B.all(u))return n=t(m()),n===e.noMore&&h(),n},f=!1,o=function(n,r){return function(o){var u,a;return o.isEnd()?(n(),s(),e.noMore):o.isError()?(u=t(o),u===e.noMore&&h(),u):(r(o.value),B.all(B.map(function(e){return e.isDefined},i))?f&&o.isInitial()?e.more:(f=!0,a=function(){var e,t,n,r;r=[];for(t=0,n=i.length;t<n;t++)e=i[t],r.push(e.get()());return r},u=t(o.apply(a)),u===e.noMore&&h(),u):e.more)}},l=function(e){return o(function(){return u[e]=!0},function(t){return i[e]=new p(t)})};for(a=g=0,y=r.length;g<y;a=++g)c=r[a],v||(d[a]=c.subscribe(l(a)));return h})):e.constant([])},e.combineWith=function(t,n){return e.combineAll(t,function(e,t){return e.toProperty().combine(t,n)})},e.combineTemplate=function(t){var n,r,i,s,o,u,a,f,c,h;return a=[],h=[],u=function(e){return e[e.length-1]},c=function(e,t,n){return u(e)[t]=n},n=function(e,t){return function(n,r){return c(n,e,r[t])}},o=function(e,t){return function(n,r){return c(n,e,t)}},f=function(e){return e instanceof Array?[]:{}},i=function(e,t){var r,i;return t instanceof l?(h.push(t),a.push(n(e,h.length-1))):typeof t=="object"?(i=function(e){return function(n,r){var i;return i=f(t),c(n,e,i),n.push(i)}},r=function(e,t){return e.pop()},a.push(i(e)),s(t),a.push(r)):a.push(o(e,t))},s=function(e){return B.each(e,i)},s(t),r=function(e){var n,r,i,s,o;i=f(t),n=[i];for(s=0,o=a.length;s<o;s++)r=a[s],r(n,e);return i},e.combineAsArray(h).map(r)},s=function(){function e(){}return e.prototype.isEvent=function(){return!0},e.prototype.isEnd=function(){return!1},e.prototype.isInitial=function(){return!1},e.prototype.isNext=function(){return!1},e.prototype.isError=function(){return!1},e.prototype.hasValue=function(){return!1},e.prototype.filter=function(e){return!0},e.prototype.onDone=function(e){return e()},e}(),a=function(e){function t(e,t){var n=this;E(e)?this.value=function(){var t;return t=e(),n.value=B.always(t),t}:this.value=B.always(e)}return q(t,e),t.prototype.isNext=function(){return!0},t.prototype.hasValue=function(){return!0},t.prototype.fmap=function(e){var t=this;return this.apply(function(){return e(t.value())})},t.prototype.apply=function(e){return new t(e)},t.prototype.filter=function(e){return e(this.value())},t.prototype.describe=function(){return this.value()},t}(s),u=function(e){function t(){return t.__super__.constructor.apply(this,arguments)}return q(t,e),t.prototype.isInitial=function(){return!0},t.prototype.isNext=function(){return!1},t.prototype.apply=function(e){return new t(e)},t.prototype.toNext=function(){return new a(this.value)},t}(a),r=function(e){function t(){return t.__super__.constructor.apply(this,arguments)}return q(t,e),t.prototype.isEnd=function(){return!0},t.prototype.fmap=function(){return this},t.prototype.apply=function(){return this},t.prototype.describe=function(){return"<end>"},t}(s),i=function(e){function t(e){this.error=e}return q(t,e),t.prototype.isError=function(){return!0},t.prototype.fmap=function(){return this},t.prototype.apply=function(){return this},t.prototype.describe=function(){return"<error> "+this.error},t}(s),l=function(){function t(){this.flatMapLatest=R(this.flatMapLatest,this),this.scan=R(this.scan,this),this.takeUntil=R(this.takeUntil,this),this.assign=this.onValue}return t.prototype.onValue=function(){var e,t;return t=arguments[0],e=2<=arguments.length?F.call(arguments,1):[],t=x(t,e),this.subscribe(function(e){if(e.hasValue())return t(e.value())})},t.prototype.onValues=function(e){return this.onValue(function(t){return e.apply(null,t)})},t.prototype.onError=function(){var e,t;return t=arguments[0],e=2<=arguments.length?F.call(arguments,1):[],t=x(t,e),this.subscribe(function(e){if(e.isError())return t(e.error)})},t.prototype.onEnd=function(){var e,t;return t=arguments[0],e=2<=arguments.length?F.call(arguments,1):[],t=x(t,e),this.subscribe(function(e){if(e.isEnd())return t()})},t.prototype.errors=function(){return this.filter(function(){return!1})},t.prototype.filter=function(){var t,n;return n=arguments[0],t=2<=arguments.length?F.call(arguments,1):[],n instanceof c?n.sampledBy(this,function(e,t){return[e,t]}).filter(function(e){var t,n;return t=e[0],n=e[1],t}).map(function(e){var t,n;return t=e[0],n=e[1],n}):(n=x(n,t),this.withHandler(function(t){return t.filter(n)?this.push(t):e.more}))},t.prototype.takeWhile=function(){var t,n;return n=arguments[0],t=2<=arguments.length?F.call(arguments,1):[],n=x(n,t),this.withHandler(function(t){return t.filter(n)?this.push(t):(this.push(m()),e.noMore)})},t.prototype.endOnError=function(){return this.withHandler(function(e){return e.isError()?(this.push(e),this.push(m())):this.push(e)})},t.prototype.take=function(t){return this.withHandler(function(n){return n.hasValue()?t===1?(this.push(n),this.push(m()),e.noMore):(t--,this.push(n)):this.push(n)})},t.prototype.map=function(){var e,t;return t=arguments[0],e=2<=arguments.length?F.call(arguments,1):[],t=x(t,e),this.withHandler(function(e){return this.push(e.fmap(t))})},t.prototype.mapError=function(){var e,t;return t=arguments[0],e=2<=arguments.length?F.call(arguments,1):[],t=x(t,e),this.withHandler(function(e){return e.isError()?this.push(N(t(e.error))):this.push(e)})},t.prototype.mapEnd=function(){var t,n;return n=arguments[0],t=2<=arguments.length?F.call(arguments,1):[],n=x(n,t),this.withHandler(function(t){return t.isEnd()?(this.push(N(n(t))),this.push(m()),e.noMore):this.push(t)})},t.prototype.doAction=function(){var e,t;return t=arguments[0],e=2<=arguments.length?F.call(arguments,1):[],t=x(t,e),this.withHandler(function(e){return e.hasValue()&&t(e.value()),this.push(e)})},t.prototype.takeUntil=function(t){var n;return n=this,this.withSubscribe(function(r){var i,s,o,u,a,f;return f=!1,u=C,a=C,o=function(){return u(),a(),f=!0},i=function(t){return t.isEnd()?(a(),r(t),e.noMore):(t.onDone(function(){var n;if(!f){n=r(t);if(n===e.noMore)return o()}}),e.more)},s=function(t){return t.isError()?e.more:t.isEnd()?e.noMore:(u(),r(m()),e.noMore)},u=n.subscribe(i),f||(a=t.subscribe(s)),o})},t.prototype.skip=function(t){return this.withHandler(function(n){return n.hasValue()?t>0?(t--,e.more):this.push(n):this.push(n)})},t.prototype.skipDuplicates=function(e){return e==null&&(e=function(e,t){return e===t}),this.withStateMachine(f,function(t,n){return n.hasValue()?t===f||!e(t.get(),n.value())?[new p(n.value()),[n]]:[t,[]]:[t,[n]]})},t.prototype.withStateMachine=function(t,n){var r;return r=t,this.withHandler(function(t){var i,s,o,u,a,f,l;i=n(r,t),s=i[0],u=i[1],r=s,a=e.more;for(f=0,l=u.length;f<l;f++){o=u[f],a=this.push(o);if(a===e.noMore)return a}return a})},t.prototype.scan=function(t,n){var r,i,s=this;return n=O(n),r=P(t),i=function(t){var i,o;return i=!1,o=s.subscribe(function(s){return s.hasValue()?i&&s.isInitial()?e.more:(i=!0,r=new p(n(r.getOrElse(void 0),s.value())),t(s.apply(B.always(r.get())))):(s.isEnd()&&(i=!0),t(s))}),i||r.forEach(function(n){var r;r=t(b(n));if(r===e.noMore)return o(),o=C}),o},new c((new h(i)).subscribe)},t.prototype.diff=function(e,t){return t=O(t),this.scan([e],function(e,n){return[n,t(e[0],n)]}).filter(function(e){return e.length===2}).map(function(e){return e[1]})},t.prototype.flatMap=function(t){var n;return n=this,new o(function(r){var i,s,o,a,f,l;return s=[],o=!1,l=function(){},f=function(){var e,t,n;l();for(t=0,n=s.length;t<n;t++)e=s[t],e();return s=[]},i=function(){if(o&&s.length===0)return r(m())},a=function(n){var a,l,c,h,p;if(n.isEnd())return o=!0,i();if(n.isError())return r(n);a=t(n.value()),p=void 0,l=!1,h=function(){return p!=null&&L(p,s),i()},c=function(t){var n;return t.isEnd()?(h(),l=!0,e.noMore):(t instanceof u&&(t=t.toNext()),n=r(t),n===e.noMore&&f(),n)},p=a.subscribe(c);if(!l)return s.push(p)},l=n.subscribe(a),f})},t.prototype.flatMapLatest=function(e){var t,n=this;return t=this.toEventStream(),t.flatMap(function(n){return e(n).takeUntil(t)})},t.prototype.not=function(){return this.map(function(e){return!e})},t.prototype.log=function(){return this.subscribe(function(e){return console.log(e.describe())}),this},t.prototype.slidingWindow=function(e){return this.scan([],function(t,n){return t.concat([n]).slice(-e)})},t}(),o=function(t){function r(e){var t;r.__super__.constructor.call(this),t=new n(e),this.subscribe=t.subscribe,this.hasSubscribers=t.hasSubscribers}return q(r,t),r.prototype.map=function(){var e,t;return t=arguments[0],e=2<=arguments.length?F.call(arguments,1):[],t instanceof c?t.sampledBy(this,g):r.__super__.map.apply(this,[t].concat(F.call(e)))},r.prototype.delay=function(t){return this.flatMap(function(n){return e.later(t,n)})},r.prototype.throttle=function(t){return this.flatMapLatest(function(n){return e.later(t,n)})},r.prototype.throttle2=function(e){return this.bufferWithTime(e).map(function(e){return e[e.length-1]})},r.prototype.bufferWithTime=function(e){var t,n=this;return t=function(e){return e.schedule()},this.buffer(e,t,t)},r.prototype.bufferWithCount=function(e){var t;return t=function(t){if(t.values.length===e)return t.flush()},this.buffer(0,t)},r.prototype.buffer=function(t,n,r){var i,s,o;return n==null&&(n=function(){}),r==null&&(r=function(){}),i={scheduled:!1,end:null,values:[],flush:function(){var t;this.scheduled=!1;if(this.values.length>0){t=this.push(N(this.values)),this.values=[];if(this.end!=null)return this.push(this.end);if(t!==e.noMore)return r(this)}else if(this.end!=null)return this.push(this.end)},schedule:function(){var e=this;if(!this.scheduled)return this.scheduled=!0,t(function(){return e.flush()})}},o=e.more,E(t)||(s=t,t=function(e){return setTimeout(e,s)}),this.withHandler(function(e){return i.push=this.push,e.isError()?o=this.push(e):e.isEnd()?(i.end=e,i.scheduled||i.flush()):(i.values.push(e.value()),n(i)),o})},r.prototype.merge=function(t){var n;return n=this,new r(function(r){var i,s,o,u,a,f;return u=C,a=C,f=!1,o=function(){return u(),a(),f=!0},i=0,s=function(t){var n;return t.isEnd()?(i++,i===2?r(m()):e.more):(n=r(t),n===e.noMore&&o(),n)},u=n.subscribe(s),f||(a=t.subscribe(s)),o})},r.prototype.toProperty=function(e){return arguments.length===0&&(e=f),this.scan(e,S)},r.prototype.toEventStream=function(){return this},r.prototype.concat=function(e){var t;return t=this,new r(function(n){var r;return r=t.subscribe(function(t){return t.isEnd()?r=e.subscribe(n):n(t)}),function(){return r()}})},r.prototype.awaiting=function(e){return this.map(!0).merge(e.map(!1)).toProperty(!1)},r.prototype.startWith=function(t){return e.once(t).concat(this)},r.prototype.withHandler=function(e){var t;return t=new n(this.subscribe,e),new r(t.subscribe)},r.prototype.withSubscribe=function(e){return new r(e)},r}(l),c=function(t){function n(t){var r,i=this;this.subscribe=t,this.toEventStream=R(this.toEventStream,this),this.toProperty=R(this.toProperty,this),this.changes=R(this.changes,this),this.sample=R(this.sample,this),n.__super__.constructor.call(this),r=function(t,r,s){var o,u;return o=f,u=f,new n(function(n){var a,f,l,c,h,d,v,g,y,b,w;return w=!1,y=C,b=C,g=function(){return y(),b(),w=!0},c=!1,d=!1,a=function(){var t;if(c&&d)return t=n(m()),t===e.noMore&&g(),t},l=!1,f=function(t,r,i){return function(s){var f;return s.isEnd()?(t(),a(),e.noMore):s.isError()?(f=n(s),f===e.noMore&&g(),f):(r(new p(s.value)),o.isDefined&&u.isDefined?l&&s.isInitial()?e.more:(l=!0,f=i(n,s,o.value,u.value),f===e.noMore&&g(),f):e.more)}},h=f(function(){return c=!0},function(e){return o=e},r),v=f(function(){return d=!0},function(e){return u=e},s),y=i.subscribe(h),w||(b=t.subscribe(v)),g})},this.combine=function(t,n){var r;return r=O(n),e.combineAsArray(i,t).map(function(e){return r(e[0],e[1])})},this.sampledBy=function(e,t){var n,i;return t==null&&(t=g),t=O(t),n=function(e,n,r,i){return e(n.apply(function(){return t(r(),i())}))},i=r(e,C,n),e instanceof o&&(i=i.changes()),i.takeUntil(e.filter(!1).mapEnd())}}return q(n,t),n.prototype.sample=function(t){return this.sampledBy(e.interval(t,{}))},n.prototype.changes=function(){var e=this;return new o(function(t){return e.subscribe(function(e){if(!e.isInitial())return t(e)})})},n.prototype.withHandler=function(e){return new n((new h(this.subscribe,e)).subscribe)},n.prototype.withSubscribe=function(e){return new n((new h(e)).subscribe)},n.prototype.toProperty=function(){return this},n.prototype.toEventStream=function(){var e=this;return new o(function(t){return e.subscribe(function(e){return e.isInitial()&&(e=e.toNext()),t(e)})})},n.prototype.and=function(e){return this.combine(e,function(e,t){return e&&t})},n.prototype.or=function(e){return this.combine(e,function(e,t){return e||t})},n.prototype.decode=function(t){return this.combine(e.combineTemplate(t),function(e,t){return t[e]})},n.prototype.delay=function(e){return this.delayChanges(function(t){return t.delay(e)})},n.prototype.throttle=function(e){return this.delayChanges(function(t){return t.throttle(e)})},n.prototype.throttle2=function(e){return this.delayChanges(function(t){return t.throttle2(e)})},n.prototype.delayChanges=function(e){return d(this,e(this.changes()))},n}(l),d=function(t,n){var r;return r=function(t){var n;return n=f,t.subscribe(function(t){return t.isInitial()&&(n=new p(t.value())),e.noMore}),n},n.toProperty(r(t))},n=function(){function t(t,n){var r,i,o,u,a,f,l,c=this;t==null&&(t=function(){return C}),a=[],o=!1,this.hasSubscribers=function(){return a.length>0},f=C,u=function(e){return a=B.without(e,a)},l=[],i=function(e){var t,n,r,i;if(l!=null){n=l,l=void 0;for(r=0,i=n.length;r<i;r++)t=n[r],t()}return e.onDone=s.prototype.onDone},r=function(e){return l.push(e)},this.push=function(t){var n,s,o,f,h;l=[],t.onDone=r,o=a;for(f=0,h=o.length;f<h;f++)s=o[f],n=s(t),(n===e.noMore||t.isEnd())&&u(s);return i(t),c.hasSubscribers()?e.more:e.noMore},n==null&&(n=function(e){return this.push(e)}),this.handleEvent=function(e){return e.isEnd()&&(o=!0),n.apply(c,[e])},this.subscribe=function(e){return o?(e(m()),C):(a=a.concat(e),a.length===1&&(f=t(c.handleEvent)),function(){u(e);if(!c.hasSubscribers())return f()})}}return t}(),h=function(t){function n(t,r){var i,s,o,u=this;n.__super__.constructor.call(this,t,r),i=f,o=this.push,t=this.subscribe,s=!1,this.push=function(e){return e.isEnd()&&(s=!0),e.hasValue()&&(i=new p(e.value())),o.apply(u,[e])},this.subscribe=function(n){var r,o,a;return r=!1,a=function(){return u.hasSubscribers()||s},o=i.filter(a).map(function(e){return n(b(e))}),o.getOrElse(e.more)===e.noMore?C:s?(n(m()),C):t.apply(u,[n])}}return q(n,t),n}(n),t=function(t){function r(){var t,s,o,u,a,f,l,c,h,p,d=this;u=void 0,c=[],s=!1,o=function(t){return function(n){return n.isEnd()?(p(t),e.noMore):u(n)}},h=function(){var e,t,n;for(t=0,n=c.length;t<n;t++)e=c[t],e.unsub!=null&&e.unsub();return c=[]},f=function(e){return e.unsub=e.input.subscribe(o(e.input))},p=function(e){var t,n,r,i;for(t=r=0,i=c.length;r<i;t=++r){n=c[t];if(n.input===e){n.unsub!=null&&n.unsub(),c.splice(t,1);return}}},a=function(e){var t,n,r,i,s;u=e,n=[],s=v(c);for(r=0,i=s.length;r<i;r++)t=s[r],f(t);return h},t=new n(a),l=function(e){return t.subscribe(e)},r.__super__.constructor.call(this,l),this.plug=function(e){var t;if(s)return;return t={input:e},c.push(t),u!=null&&f(t),function(){return p(e)}},this.push=function(e){if(u!=null)return u(N(e))},this.error=function(e){if(u!=null)return u(new i(e))},this.end=function(){s=!0,h();if(u!=null)return u(m())}}return q(r,t),r}(o),p=function(){function e(e){this.value=e}return e.prototype.getOrElse=function(){return this.value},e.prototype.get=function(){return this.value},e.prototype.filter=function(t){return t(this.value)?new e(this.value):f},e.prototype.map=function(t){return new e(t(this.value))},e.prototype.forEach=function(e){return e(this.value)},e.prototype.isDefined=!0,e.prototype.toArray=function(){return[this.value]},e}(),f={getOrElse:function(e){return e},filter:function(){return f},map:function(){return f},forEach:function(){},isDefined:!1,toArray:function(){return[]}},e.EventStream=o,e.Property=c,e.Observable=l,e.Bus=t,e.Initial=u,e.Next=a,e.End=r,e.Error=i,C=function(){},S=function(e,t){return t},g=function(e,t){return e},b=function(e){return new u(B.always(e))},N=function(e){return new a(B.always(e))},m=function(){return new r},M=function(e){return e instanceof s?e:N(e)},v=function(e){return e.slice(0)},y=Array.prototype.indexOf?function(e,t){return e.indexOf(t)}:function(e,t){var n,r,i,s;for(n=i=0,s=e.length;i<s;n=++i){r=e[n];if(t===r)return n}return-1},L=function(e,t){var n;n=y(t,e);if(n>=0)return t.splice(n,1)},E=function(e){return typeof e=="function"},T=function(e,t,n){return n===void 0&&(n=[]),function(r){return e[t].apply(e,n.concat([r]))}},k=function(e,t){return function(){var n;return n=1<=arguments.length?F.call(arguments,0):[],e.apply(null,t.concat(n))}},x=function(e,t){return E(e)?t.length?k(e,t):e:w(e)?_(e,t):typeof e=="object"&&t.length?T(e,B.head(t),B.tail(t)):B.always(e)},w=function(e){return typeof e=="string"&&e.length>1&&e.charAt(0)==="."},e.isFieldKey=w,_=function(e,t){var n,r;return r=e.slice(1).split("."),n=B.map(H(t),r),function(t){var r,i;for(r=0,i=n.length;r<i;r++)e=n[r],t=e(t);return t}},H=function(e){return function(t){return function(n){var r;return r=n[t],E(r)?r.apply(n,e):r}}},D=function(e){return e.slice(1)},O=function(e){var t;if(E(e))return e;if(w(e))return t=D(e),function(e,n){return e[t](n)}},P=function(e){return e instanceof p||e===f?e:new p(e)},typeof define!="undefined"&&define!==null&&define.amd!=null&&typeof define=="function"&&define(function(){return e}),B={head:function(e){return e[0]},always:function(e){return function(){return e}},empty:function(e){return e.length===0},tail:function(e){return e.slice(1,e.length)},filter:function(e,t){var n,r,i,s;n=[];for(i=0,s=t.length;i<s;i++)r=t[i],e(r)&&n.push(r);return n},map:function(e,t){var n,r,i,s;s=[];for(r=0,i=t.length;r<i;r++)n=t[r],s.push(e(n));return s},each:function(e,t){var n,r,i;i=[];for(n in e)r=e[n],i.push(t(n,r));return i},toArray:function(e){return e instanceof Array?e:[e]},contains:function(e,t){return y(e,t)!==-1},id:function(e){return e},last:function(e){return e[e.length-1]},all:function(e){var t,n,r;for(n=0,r=e.length;n<r;n++){t=e[n];if(!t)return!1}return!0},without:function(e,t){return B.filter(function(t){return t!==e},t)}},e._=B}).call(this);
{
"name": "baconjs",
"version": "0.1.8",
"version": "0.1.9",
"author": "Juha Paananen",

@@ -5,0 +5,0 @@ "licenses": [

@@ -827,2 +827,6 @@ Bacon.js

Run performance tests:
coffee performance/*
Dependencies

@@ -893,1 +897,2 @@ ============

Use GitHub issues and Pull Requests.

@@ -0,1 +1,7 @@

## 0.1.9
- Performance improvements
- Fix stream ending in case an exception is thrown (#106)
- Rewrite binder stream factory to compose all others (#105)
## 0.1.8

@@ -2,0 +8,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc