Socket
Socket
Sign inDemoInstall

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.7 to 0.1.8

browsertest/browserify

2

component.json
{
"name": "baconjs",
"version": "0.1.7",
"version": "0.1.8",
"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, 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, cloneObject, end, former, indexOf, initial, isEvent, isFieldKey, isFunction, latter, makeFunction, methodCall, next, nop, partiallyApplied, remove, sendWrapped, toCombinator, toEvent, toFieldExtractor, toFieldKey, toOption, toSimpleExtractor, _, _ref,
__slice = [].slice,

@@ -8,5 +8,29 @@ __hasProp = {}.hasOwnProperty,

if ((_ref = this.jQuery || this.Zepto) != null) {
_ref.fn.asEventStream = function(eventName, selector, eventTransformer) {
var element;
if (typeof module !== "undefined" && module !== null) {
module.exports = Bacon = {};
Bacon.Bacon = Bacon;
} else {
this.Bacon = Bacon = {};
}
Bacon.asStream = function(binder, eventTransformer) {
if (eventTransformer == null) {
eventTransformer = _.id;
}
return new EventStream(function(sink) {
var unbind;
return unbind = binder(function() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
if (Bacon.noMore === sink(next(eventTransformer.apply(null, args)))) {
return unbind();
}
});
});
};
Bacon.$ = {
asEventStream: function(eventName, selector, eventTransformer) {
var _ref,
_this = this;
if (eventTransformer == null) {

@@ -16,26 +40,45 @@ eventTransformer = _.id;

if (isFunction(selector)) {
eventTransformer = selector;
selector = null;
_ref = [selector, null], eventTransformer = _ref[0], selector = _ref[1];
}
element = this;
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();
}
return Bacon.asStream(function(handler) {
_this.on(eventName, selector, handler);
return function() {
return _this.off(eventName, selector, handler);
};
unbind = function() {
return element.off(eventName, selector, handler);
};
element.on(eventName, selector, handler);
return unbind;
});
};
}
};
if ((_ref = typeof jQuery !== "undefined" && jQuery !== null ? jQuery : typeof Zepto !== "undefined" && Zepto !== null ? Zepto : null) != null) {
_ref.fn.asEventStream = Bacon.$.asEventStream;
}
Bacon = this.Bacon = {};
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();
}
};
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;
});
};

@@ -70,7 +113,9 @@ Bacon.fromPromise = function(promise) {

poll = function() {
var valueEvent;
index++;
if (index < values.length) {
return toEvent(values[index]);
valueEvent = toEvent(values[index]);
if (index < values.length - 1) {
return valueEvent;
} else {
return end();
return [valueEvent, end()];
}

@@ -111,8 +156,15 @@ };

handler = function() {
var reply, value;
value = poll();
reply = sink(value);
if (reply === Bacon.noMore || value.isEnd()) {
return unbind();
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;
};

@@ -127,31 +179,2 @@ unbind = function() {

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();
}
};
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;
});
};
Bacon.interval = function(delay, value) {

@@ -538,10 +561,24 @@ var poll;

f = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
f = makeFunction(f, args);
return this.withHandler(function(event) {
if (event.filter(f)) {
return this.push(event);
} else {
return Bacon.more;
}
});
if (f instanceof Property) {
return f.sampledBy(this, function(p, s) {
return [p, s];
}).filter(function(_arg) {
var p, s;
p = _arg[0], s = _arg[1];
return p;
}).map(function(_arg) {
var p, s;
p = _arg[0], s = _arg[1];
return s;
});
} else {
f = makeFunction(f, args);
return this.withHandler(function(event) {
if (event.filter(f)) {
return this.push(event);
} else {
return Bacon.more;
}
});
}
};

@@ -612,2 +649,17 @@

Observable.prototype.mapEnd = function() {
var args, f;
f = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
f = makeFunction(f, args);
return this.withHandler(function(event) {
if (event.isEnd()) {
this.push(next(f(event)));
this.push(end());
return Bacon.noMore;
} else {
return this.push(event);
}
});
};
Observable.prototype.doAction = function() {

@@ -904,22 +956,2 @@ var args, f;

EventStream.prototype.filter = function() {
var args, p;
p = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
if (p instanceof Property) {
return p.sampledBy(this, function(p, s) {
return [p, s];
}).filter(function(_arg) {
var p, s;
p = _arg[0], s = _arg[1];
return p;
}).map(function(_arg) {
var p, s;
p = _arg[0], s = _arg[1];
return s;
});
} else {
return EventStream.__super__.filter.apply(this, [p].concat(__slice.call(args)));
}
};
EventStream.prototype.delay = function(delay) {

@@ -937,42 +969,87 @@ return this.flatMap(function(value) {

EventStream.prototype.throttle2 = function(delay) {
return this.bufferWithTime(delay).map(function(values) {
return values[values.length - 1];
});
};
EventStream.prototype.bufferWithTime = function(delay) {
var buffer, flush, storeAndMaybeTrigger, values;
values = [];
storeAndMaybeTrigger = function(value) {
values.push(value);
return values.length === 1;
var schedule,
_this = this;
schedule = function(buffer) {
return buffer.schedule();
};
flush = function() {
var output;
output = values;
values = [];
return output;
return this.buffer(delay, schedule, schedule);
};
EventStream.prototype.bufferWithCount = function(count) {
var flushOnCount;
flushOnCount = function(buffer) {
if (buffer.values.length === count) {
return buffer.flush();
}
};
buffer = function() {
return Bacon.later(delay).map(flush);
};
return this.filter(storeAndMaybeTrigger).flatMap(buffer);
return this.buffer(0, flushOnCount);
};
EventStream.prototype.bufferWithCount = function(count) {
var values;
values = [];
EventStream.prototype.buffer = function(delay, onInput, onFlush) {
var buffer, delayMs, reply;
if (onInput == null) {
onInput = (function() {});
}
if (onFlush == null) {
onFlush = (function() {});
}
buffer = {
scheduled: false,
end: null,
values: [],
flush: function() {
var reply;
this.scheduled = false;
if (this.values.length > 0) {
reply = this.push(next(this.values));
this.values = [];
if (this.end != null) {
return this.push(this.end);
} else if (reply !== Bacon.noMore) {
return onFlush(this);
}
} else {
if (this.end != null) {
return this.push(this.end);
}
}
},
schedule: function() {
var _this = this;
if (!this.scheduled) {
this.scheduled = true;
return delay(function() {
return _this.flush();
});
}
}
};
reply = Bacon.more;
if (!isFunction(delay)) {
delayMs = delay;
delay = function(f) {
return setTimeout(f, delayMs);
};
}
return this.withHandler(function(event) {
var flush,
_this = this;
flush = function() {
_this.push(next(values, event));
return values = [];
};
buffer.push = this.push;
if (event.isError()) {
return this.push(event);
reply = this.push(event);
} else if (event.isEnd()) {
flush();
return this.push(event);
buffer.end = event;
if (!buffer.scheduled) {
buffer.flush();
}
} else {
values.push(event.value());
if (values.length === count) {
return flush();
}
buffer.values.push(event.value());
onInput(buffer);
}
return reply;
});

@@ -1057,17 +1134,2 @@ };

EventStream.prototype.mapEnd = function() {
var args, f;
f = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
f = makeFunction(f, args);
return this.withHandler(function(event) {
if (event.isEnd()) {
this.push(next(f(event)));
this.push(end());
return Bacon.noMore;
} else {
return this.push(event);
}
});
};
EventStream.prototype.withHandler = function(handler) {

@@ -1189,3 +1251,3 @@ var dispatcher;

this.sampledBy = function(sampler, combinator) {
var pushPropertyValue;
var pushPropertyValue, values;
if (combinator == null) {

@@ -1198,3 +1260,7 @@ combinator = former;

};
return combine(sampler, nop, pushPropertyValue).changes().takeUntil(sampler.filter(false).mapEnd());
values = combine(sampler, nop, pushPropertyValue);
if (sampler instanceof EventStream) {
values = values.changes();
}
return values.takeUntil(sampler.filter(false).mapEnd());
};

@@ -1227,2 +1293,3 @@ }

Property.prototype.toProperty = function() {
assertNoArguments(arguments);
return this;

@@ -1262,9 +1329,23 @@ };

Property.prototype.delay = function(delay) {
return addPropertyInitValueToStream(this, this.changes().delay(delay));
return this.delayChanges(function(changes) {
return changes.delay(delay);
});
};
Property.prototype.throttle = function(delay) {
return addPropertyInitValueToStream(this, this.changes().throttle(delay));
return this.delayChanges(function(changes) {
return changes.throttle(delay);
});
};
Property.prototype.throttle2 = function(delay) {
return this.delayChanges(function(changes) {
return changes.throttle2(delay);
});
};
Property.prototype.delayChanges = function(f) {
return addPropertyInitValueToStream(this, f(this.changes()));
};
return Property;

@@ -1695,2 +1776,6 @@

assertNoArguments = function(args) {
return assert("no arguments supported", args.length === 0);
};
assertString = function(x) {

@@ -1844,2 +1929,9 @@ return assert("not a string : " + x, typeof x === "string");

},
toArray: function(xs) {
if (xs instanceof Array) {
return xs;
} else {
return [xs];
}
},
contains: function(xs, x) {

@@ -1846,0 +1938,0 @@ return indexOf(xs, x) !== -1;

@@ -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)}};(I=this.jQuery||this.Zepto)!=null&&(I.fn.asEventStream=function(t,n,r){var i;return r==null&&(r=F.id),x(n)&&(r=n,n=null),i=this,new o(function(s){var o,u;return o=function(){var t,n;t=1<=arguments.length?q.call(arguments,0):[],n=s(k(r.apply(null,t)));if(n===e.noMore)return u()},u=function(){return i.off(t,n,o)},i.on(t,n,o),u})}),e=this.Bacon={},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(){return r++,r<n.length?D(n[r]):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;i=n(),t=r(i);if(t===e.noMore||i.isEnd())return o()},o=function(){return clearInterval(s)},s=setInterval(i,t),o})},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.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=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.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.filter=function(){var e,t;return t=arguments[0],e=2<=arguments.length?q.call(arguments,1):[],t instanceof c?t.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}):r.__super__.filter.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.bufferWithTime=function(t){var n,r,i,s;return s=[],i=function(e){return s.push(e),s.length===1},r=function(){var e;return e=s,s=[],e},n=function(){return e.later(t).map(r)},this.filter(i).flatMap(n)},r.prototype.bufferWithCount=function(e){var t;return t=[],this.withHandler(function(n){var r,i=this;r=function(){return i.push(k(t,n)),t=[]};if(n.isError())return this.push(n);if(n.isEnd())return r(),this.push(n);t.push(n.value());if(t.length===e)return r()})},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.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)})},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;return t==null&&(t=y),t=_(t),n=function(e,n,r,i){return e(n.apply(t(r,i)))},r(e,L,n).changes().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 d(this,this.changes().delay(e))},n.prototype.throttle=function(e){return d(this,this.changes().throttle(e))},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},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,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);
{
"name": "baconjs",
"version": "0.1.7",
"version": "0.1.8",
"author": "Juha Paananen",

@@ -17,15 +17,46 @@ "licenses": [

"grunt-contrib-copy": "~0.3.2",
"benchmark": "1.0.0"
"benchmark": "1.0.0",
"browserify": "1.18.0",
"sinon": "~1.6.0"
},
"testling": {
"browsers": {
"ie": [ 6, 7, 8, 9, 10 ],
"ff": [ 12, 17 ],
"chrome": [ 20, 23 ],
"opera": [ 10, 12 ],
"safari": [ 5.1, 6 ],
"iphone": [ 6 ],
"ipad": [ 6 ]
"ie": [
6,
7,
8,
9,
10
],
"ff": [
12,
13,
14,
15,
16,
17
],
"chrome": [
20,
21,
22,
23
],
"opera": [
10,
11,
12
],
"safari": [
5.1,
6
],
"iphone": [
6
],
"ipad": [
6
]
},
"files": "jasmine-harness.coffee"
"files": "browsertest/jasmine-harness.coffee"
},

@@ -32,0 +63,0 @@ "scripts": {

@@ -113,3 +113,3 @@ Bacon.js

$("span).css("visibility", "visible")
$("span").css("visibility", "visible")

@@ -221,3 +221,3 @@ For an actual tutorial, please check out my [blog posts](http://nullzzz.blogspot.fi/2012/11/baconjs-tutorial-part-i-hacking-with.html)

`stream.filter(property)` filters a stream based on the value of a
`observable.filter(property)` filters values based on the value of a
property. Event will be included in output iff the property holds `true`

@@ -248,3 +248,3 @@ at the time of the event.

var throttled = source.throttle(1)
var throttled = source.throttle(2)

@@ -254,2 +254,14 @@ source: asdf----asdf----

`observable.throttle2(delay)` throttles stream/property by given amount
of milliseconds. Events are emitted with the minimum interval of
`delay`, but this version of throttle does not wait for a quiet period.
The implementation if based on stream.bufferWithTime.
Example:
var throttled = source.throttle2(2)
source: asdf----asdf----
throttled: --s--f----s--f--
`observable.doAction(f)` returns a stream/property where the function f

@@ -371,2 +383,8 @@ is executed for each value, before dispatching to subscribers. This is

`stream.bufferWithTime(f)` works with a given "defer-function" instead
of a delay. Here's a simple example, which is equivalent to
stream.bufferWithTime(10):
stream.bufferWithTime(function(f) { setTimeout(f, 10) })
`stream.bufferWithCount(count)` buffers stream events with given count.

@@ -447,5 +465,10 @@ The buffer is flushed when it contains the given number of elements. So, if

`property.sampledBy(stream, f)` samples the property on stream events.
The result EventStream values will be formed using the given function
`f(propertyValue, streamValue)`. You can use a method name (such as
`property.sampledBy(property)` creates a Property by sampling the
property value at each event from the given property. The result
Property will contain the property value at each event in the source
property.
`property.sampledBy(streamOrProperty, f)` samples the property on stream
events. The result values will be formed using the given function
`f(propertyValue, samplerValue)`. You can use a method name (such as
".concat") instead of a function too.

@@ -805,4 +828,6 @@

npm install -g phantomjs
phantomjs browsertest/lib/mocha-phantomjs.coffee browsertest/phantom.runner.html
npm install
npm install --save-dev browserify@1.18.0
npm install -g testem
testem

@@ -830,12 +855,15 @@ Dependencies

Bacon.js is not browser dependent, because it is not a UI library. Hence there are not actual browser tests and no
"official" list of supported browsers.
TLDR: good.
I have used Bacon.js with Chrome, Firefox, Safari, IE 8+, iPhone, iPad.
Bacon.js is not browser dependent, because it is not a UI library.
I have personally used it Bacon.js with Chrome, Firefox, Safari, IE 6+, iPhone, iPad.
Automatically tested on each commit on modern browsers and IE6+.
The full Bacon.js test suite is run on testling.ci with a wide range of browsers:
[![browser support test report](http://ci.testling.com/raimohanska/bacon.js.png)](http://ci.testling.com/raimohanska/bacon.js)
Don't take the above browser support status too seriously, it's actually much
better. the reds are mostly false positives. Will improve browser
testing soon to get more reliable results.
Results from those tests are quite unreliable, producing random failures, but the bottom line is that there are no outstanding compatibility issues.

@@ -851,3 +879,3 @@ Node.js

Bacon = require("baconjs").bacon()
Bacon = require("baconjs").Bacon
Bacon.sequentially(1000, ["B", "A", "C", "O", "N"]).log()

@@ -871,3 +899,3 @@

==========
Use GitHub issues and Pull Requests.

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

## 0.1.8
- add Property.filter(property)
- reject arguments in Property.toProperty
- add Property.sampledBy(property)
- generalize mapEnd to all Observables
- fix bufferWithTime behaviour: output at steady rate as long as there's anything to output
- add throttle2
## 0.1.7

@@ -2,0 +11,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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