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.0.7 to 0.0.8

examples/sliding_window.html

2

component.json
{
"name": "baconjs",
"version": "0.0.7",
"version": "0.0.8",
"main": "./lib/Bacon.js"
}
(function() {
var Bacon, Bus, Dispatcher, End, Error, Event, EventStream, Initial, Next, None, Observable, Property, PropertyDispatcher, Some, assert, assertArray, assertEvent, assertFunction, assertString, cloneArray, cloneObject, end, former, initial, isEvent, isFieldKey, isFunction, latter, makeFunction, methodCall, next, nop, partiallyApplied, propertyThenStream, 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, assertString, cloneArray, cloneObject, end, former, initial, isEvent, isFieldKey, isFunction, latter, makeFunction, methodCall, next, nop, partiallyApplied, remove, sendWrapped, toCombinator, toEvent, toFieldExtractor, toFieldKey, toOption, toSimpleExtractor, _, _ref,
__slice = Array.prototype.slice,

@@ -223,3 +223,3 @@ __hasProp = Object.prototype.hasOwnProperty,

Bacon.combineTemplate = function(template) {
var applyStreamValue, combinator, compileTemplate, constantValue, current, funcs, setValue, streams;
var applyStreamValue, combinator, compile, compileTemplate, constantValue, current, funcs, mkContext, setValue, streams;
funcs = [];

@@ -243,35 +243,40 @@ streams = [];

};
compileTemplate = function(template) {
var key, popContext, pushContext, value, _results;
_results = [];
for (key in template) {
value = template[key];
if (value instanceof Observable) {
streams.push(value);
_results.push(funcs.push(applyStreamValue(key, streams.length - 1)));
} else if (typeof value === "object") {
pushContext = function(key) {
return function(ctxStack, values) {
var newContext;
newContext = {};
setValue(ctxStack, key, newContext);
return ctxStack.push(newContext);
};
mkContext = function(template) {
if (template instanceof Array) {
return [];
} else {
return {};
}
};
compile = function(key, value) {
var popContext, pushContext;
if (value instanceof Observable) {
streams.push(value);
return funcs.push(applyStreamValue(key, streams.length - 1));
} else if (typeof value === "object") {
pushContext = function(key) {
return function(ctxStack, values) {
var newContext;
newContext = mkContext(value);
setValue(ctxStack, key, newContext);
return ctxStack.push(newContext);
};
popContext = function(ctxStack, values) {
return ctxStack.pop();
};
funcs.push(pushContext(key));
compileTemplate(value);
_results.push(funcs.push(popContext));
} else {
_results.push(funcs.push(constantValue(key, value)));
}
};
popContext = function(ctxStack, values) {
return ctxStack.pop();
};
funcs.push(pushContext(key));
compileTemplate(value);
return funcs.push(popContext);
} else {
return funcs.push(constantValue(key, value));
}
return _results;
};
compileTemplate = function(template) {
return _.each(template, compile);
};
compileTemplate(template);
combinator = function(values) {
var ctxStack, f, rootContext, _i, _len;
rootContext = {};
rootContext = mkContext(template);
ctxStack = [rootContext];

@@ -468,2 +473,3 @@ for (_i = 0, _len = funcs.length; _i < _len; _i++) {

this["switch"] = __bind(this["switch"], this);
this.scan = __bind(this.scan, this);
this.takeUntil = __bind(this.takeUntil, this); this.assign = this.onValue;

@@ -667,7 +673,12 @@ }

Observable.prototype.skipDuplicates = function() {
Observable.prototype.skipDuplicates = function(isEqual) {
if (isEqual == null) {
isEqual = function(a, b) {
return a === b;
};
}
return this.withStateMachine(void 0, function(prev, event) {
if (!event.hasValue()) {
return [prev, [event]];
} else if (prev !== event.value) {
} else if (!isEqual(prev, event.value)) {
return [event.value, [event]];

@@ -700,2 +711,39 @@ } else {

Observable.prototype.scan = function(seed, f) {
var acc, subscribe,
_this = this;
f = toCombinator(f);
acc = toOption(seed);
subscribe = function(sink) {
var initSent, unsub;
initSent = false;
unsub = _this.subscribe(function(event) {
if (event.hasValue()) {
if (initSent && event.isInitial()) {
return Bacon.more;
} else {
initSent = true;
acc = new Some(f(acc.getOrElse(void 0), event.value));
return sink(event.apply(acc.get()));
}
} else {
if (event.isEnd()) initSent = true;
return sink(event);
}
});
if (!initSent) {
acc.forEach(function(value) {
var reply;
reply = sink(initial(value));
if (reply === Bacon.noMore) {
unsub();
return unsub = nop;
}
});
}
return unsub;
};
return new Property(new PropertyDispatcher(subscribe).subscribe);
};
Observable.prototype.flatMap = function(f) {

@@ -785,2 +833,8 @@ var root;

Observable.prototype.slidingWindow = function(n) {
return this.scan([], function(window, value) {
return window.concat([value]).slice(-n);
});
};
return Observable;

@@ -930,27 +984,2 @@

EventStream.prototype.scan = function(seed, f) {
var acc, d, handleEvent, subscribe;
acc = toOption(seed);
f = toCombinator(f);
handleEvent = function(event) {
if (event.hasValue()) {
acc = new Some(f(acc.getOrElse(void 0), event.value));
}
return this.push(event.apply(acc.getOrElse(void 0)));
};
d = new Dispatcher(this.subscribe, handleEvent);
subscribe = function(sink) {
var reply;
reply = acc.map(function(val) {
return sink(initial(val));
}).getOrElse(Bacon.more);
if (reply !== Bacon.noMore) {
return d.subscribe(sink);
} else {
return nop;
}
};
return new Property(subscribe);
};
EventStream.prototype.concat = function(right) {

@@ -1163,8 +1192,14 @@ var left;

Property.prototype.decode = function(cases) {
return this.combine(Bacon.combineTemplate(cases), function(key, values) {
return values[key];
});
};
Property.prototype.delay = function(delay) {
return propertyThenStream(this, this.changes().delay(delay));
return addPropertyInitValueToStream(this, this.changes().delay(delay));
};
Property.prototype.throttle = function(delay) {
return propertyThenStream(this, this.changes().throttle(delay));
return addPropertyInitValueToStream(this, this.changes().throttle(delay));
};

@@ -1176,3 +1211,3 @@

propertyThenStream = function(property, stream) {
addPropertyInitValueToStream = function(property, stream) {
var getInitValue;

@@ -1188,3 +1223,3 @@ getInitValue = function(property) {

};
return stream.toProperty.apply(stream, getInitValue(property).toArray());
return stream.toProperty(getInitValue(property));
};

@@ -1298,3 +1333,4 @@

this.subscribe = function(sink) {
var reply, shouldBounceInitialValue;
var initSent, reply, shouldBounceInitialValue;
initSent = false;
shouldBounceInitialValue = function() {

@@ -1400,2 +1436,6 @@ return _this.hasSubscribers() || ended;

Some.prototype.get = function() {
return this.value;
};
Some.prototype.filter = function(f) {

@@ -1413,2 +1453,6 @@ if (f(this.value)) {

Some.prototype.forEach = function(f) {
return f(this.value);
};
Some.prototype.isDefined = true;

@@ -1434,2 +1478,3 @@

},
forEach: function() {},
isDefined: false,

@@ -1665,2 +1710,11 @@ toArray: function() {

},
each: function(xs, f) {
var key, value, _results;
_results = [];
for (key in xs) {
value = xs[key];
_results.push(f(key, value));
}
return _results;
},
contains: function(xs, x) {

@@ -1667,0 +1721,0 @@ return xs.indexOf(x) >= 0;

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

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

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

@@ -69,6 +69,4 @@ Bacon.js

function always(value) { return function() { return value } }
var plus = $("#plus").asEventStream("click").map(always(1))
var minus = $("#minus").asEventStream("click").map(always(-1))
var plus = $("#plus").asEventStream("click").map(1)
var minus = $("#minus").asEventStream("click").map(-1)
var both = plus.merge(minus)

@@ -113,2 +111,4 @@

$("span).css("visibility", "visible")
For an actual tutorial, please check out my [blog posts](http://nullzzz.blogspot.fi/2012/11/baconjs-tutorial-part-i-hacking-with.html)

@@ -135,6 +135,7 @@ API

`Bacon.sequentially(interval, values)` creates a stream containing given
values (given as array). Delivered with given interval (in milliseconds)
values (given as array). Delivered with given interval in milliseconds.
`Bacon.repeatedly(interval, values)` repeats given elements indefinitely
with given interval (in milliseconds)
with given interval in milliseconds. For example, sequentially(10, [1,2,3])
would lead to 1,2,3,1,2,3... to be repeated indefinitely.

@@ -161,3 +162,6 @@ `Bacon.fromEventTarget(target, event)` creates an EventStream from events

`streamOrProperty.map(f)` maps values using given function, returning a new
Both EventStream and Property share the Observable interface, and hence
share a lot of methods. Common methods are listed below.
`observable.map(f)` maps values using given function, returning a new
EventStream. Instead of a function, you can also provide a constant

@@ -175,3 +179,3 @@ value. Further, you can use a property extractor string like

`streamOrProperty.mapError(f)` maps errors using given function. More
`observable.mapError(f)` maps errors using given function. More
spedifically, feeds the "error" field of the error event to the function

@@ -181,7 +185,7 @@ and produces a "Next" event based on the return value. Function

`streamOrProperty.mapEnd(f)` Adds an extra Next event just before End. The value is created
`observable.mapEnd(f)` Adds an extra Next event just before End. The value is created
by calling the given function when the source stream ends. Instead of a
function, a static value can be used. You can even omit the argument if
`streamOrProperty.filter(f)` filters values using given predicate function.
`observable.filter(f)` filters values using given predicate function.
Instead of a function, you can use a constant value (true/false) or a

@@ -195,18 +199,18 @@ property extractor string (like ".isValuable") instead. Just like with

`streamOrProperty.takeWhile(f)` takes while given predicate function holds true
`observable.takeWhile(f)` takes while given predicate function holds true
`streamOrProperty.take(n)` takes at most n elements from the stream
`observable.take(n)` takes at most n elements from the stream
`streamOrProperty.takeUntil(stream2)` takes elements from source until a Next event
`observable.takeUntil(stream2)` takes elements from source until a Next event
appears in the other stream. If other stream ends without value, it is
ignored
`streamOrProperty.skip(n)` skips the first n elements from the stream
`observable.skip(n)` skips the first n elements from the stream
`streamOrProperty.delay(delay)` delays the stream/property by given amount of milliseconds. Does not delay the initial value of a Property.
`observable.delay(delay)` delays the stream/property by given amount of milliseconds. Does not delay the initial value of a Property.
`streamOrProperty.throttle(delay)` throttles stream/property by given amount of milliseconds. This means that event is only emitted after the given
`observable.throttle(delay)` throttles stream/property by given amount of milliseconds. This means that event is only emitted after the given
"quiet period". Does not affect the initial value of a Property.
`streamOrProperty.doAction(f)` returns a stream/property where the function f
`observable.doAction(f)` returns a stream/property where the function f
is executed for each value, before dispatching to subscribers. This is

@@ -220,6 +224,6 @@ useful for debugging, but also for stuff like calling the

`streamOrProperty.not()` returns a stream/property that inverts boolean
`observable.not()` returns a stream/property that inverts boolean
values
`streamOrProperty.flatMap(f)` for each element in the source stream, spawn a new
`observable.flatMap(f)` for each element in the source stream, spawn a new
stream using the function `f`. Collect events from each of the spawned

@@ -237,3 +241,3 @@ streams into the result stream. This is very similar to selectMany in

`streamOrProperty.flatMapLatest(f)` like flatMap, but instead of including events from
`observable.flatMapLatest(f)` like flatMap, but instead of including events from
all spawned streams, only includes them from the latest spawned stream.

@@ -244,3 +248,36 @@ You can think this as switching from stream to stream. The old name for

`observable.scan(seed, f)` scans stream/property with given seed value and
accumulator function, resulting to a Property. For example, you might
use zero as seed and a "plus" function as the accumulator to create
an "integral" property. Instead of a function, you can also supply a
method name such as ".concat", in which case this method is called on
the accumulator value and the new stream value is used as argument.
Example:
var plus = function (a,b) { return a + b }
Bacon.sequentially(1, [1,2,3]).scan(0, plus)
This would result to following elements in the result stream:
seed value = 0
0 + 1 = 1
1 + 2 = 3
3 + 3 = 6
When applied to a Property as in `r = p.scan(f,seed)`, there's a (hopefully insignificant) catch:
The starting value for `r` depends on whether `p` has an
initial value when scan is applied. If there's no initial value, this works
identically to EventStream.scan: the `seed` will be the initial value of
`r`. However, if `r` already has a current/initial value `x`, the
seed won't be output as is. Instead, the initial value of `r` will be `f(seed, x)`. This makes sense,
because there can only be 1 initial value for a Property at a time.
`observable.slidingWindow(n)` returns a Property that represents a
"sliding window" into the history of the values of the Observable. For
example, if you have a stream `s` with value a sequence 1 - 2 - 3 - 4 - 5, the
respective values in `s.slidingWindow(2)` would be [] - [1] - [1,2] -
[2,3] - [3,4] - [4,5].
EventStream

@@ -270,25 +307,7 @@ -----------

`stream.scan(seed, f)` scans stream with given seed value and
accumulator function, resulting to a Property. For example, you might
use zero as seed and a "plus" function as the accumulator to create
an "integral" property. Instead of a function, you can also supply a
method name such as ".concat", in which case this method is called on
the accumulator value and the new stream value is used as argument.
`stream.skipDuplicates([isEqual])` drops consecutive equal elements. So,
from [1, 2, 2, 1] you'd get [1, 2, 1]. Uses the === operator for equality
checking by default. If the isEqual argument is supplied, checks by calling
isEqual(oldValue, newValue)
Example:
var plus = function (a,b) { return a + b }
Bacon.sequentially(1, [1,2,3]).scan(0, plus)
This would result to following elements in the result stream:
seed value = 0
0 + 1 = 1
1 + 2 = 3
3 + 3 = 6
`stream.skipDuplicates()` drops consecutive equal elements. So,
from [1, 2, 2, 1] you'd get [1, 2, 1]. Uses === operator for equality
checking.
`stream.merge(stream2)` merges two streams into one stream that delivers

@@ -379,5 +398,6 @@ events from both

`property.skipDuplicates()` drops consecutive equal values. So,
from [1, 2, 2, 1] you'd get [1, 2, 1]. Uses === operator for equality
checking.
`property.skipDuplicates([isEqual])` drops consecutive equal elements. So,
from [1, 2, 2, 1] you'd get [1, 2, 1]. Uses the === operator for equality
checking by default. If the isEqual argument is supplied, checks by calling
isEqual(oldValue, newValue)

@@ -392,2 +412,14 @@ `property.changes()` returns an EventStream of property value changes.

`property.decode(mapping)` decodes input using the given mapping. Is a
bit like a switch-case or the decode function in Oracle SQL. For
example, the following would map the value 1 into the the string "mike"
and the value 2 into the value of the `who` property.
property.decode({1 : "mike", 2 : who})
This is actually based on `combineTemplate` so you can compose static
and dynamic data quite freely, as in
property.decode({1 : { type: "mike" }, 2 : { type: "other", whoThen : who }})
Combining multiple streams and properties

@@ -589,6 +621,6 @@ -----------------------------------------

You can take action on errors by using the `streamOrProperty.onError(f)`
You can take action on errors by using the `observable.onError(f)`
callback.
`streamOrProperty.errors()` returns a stream containing Error events only.
`observable.errors()` returns a stream containing Error events only.
Same as filtering with a function that always returns false.

@@ -598,3 +630,3 @@

An Error does not terminate the stream. The method `streamOrProperty.endOnError()`
An Error does not terminate the stream. The method `observable.endOnError()`
returns a stream/property that ends immediately after first error.

@@ -601,0 +633,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