made with requirebin
Last active
August 29, 2015 14:10
-
-
Save theadam/0a95d0c2f9d0518a3d99 to your computer and use it in GitHub Desktop.
requirebin sketch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Bacon = require('baconjs'); | |
| var _ = require('lodash'); | |
| function concat(x, y){ | |
| return x.concat(y) | |
| } | |
| var action = new Bacon.Bus(); | |
| var store = action.scan([], concat); | |
| var view = function(){ | |
| store.onValue(function(v){ | |
| console.log(v); | |
| }) | |
| } | |
| view(); | |
| action.push('adam'); | |
| action.push('is'); | |
| action.push('awesome') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({baconjs:[function(require,module,exports){(function(global){(function(){var Bacon,BufferingSource,Bus,CompositeUnsubscribe,ConsumingSource,Desc,Dispatcher,End,Error,Event,EventStream,Exception,Initial,Next,None,Observable,Property,PropertyDispatcher,Some,Source,UpdateBarrier,addPropertyInitValueToStream,assert,assertArray,assertEventStream,assertFunction,assertNoArguments,assertString,cloneArray,compositeUnsubscribe,containsDuplicateDeps,convertArgsToFunction,describe,end,eventIdCounter,findDeps,flatMap_,former,idCounter,initial,isArray,isFieldKey,isFunction,isObservable,latterF,liftCallback,makeFunction,makeFunctionArgs,makeFunction_,makeObservable,makeSpawner,next,nop,partiallyApplied,recursionDepth,registerObs,spys,toCombinator,toEvent,toFieldExtractor,toFieldKey,toOption,toSimpleExtractor,withDescription,withMethodCallSupport,_,_ref,__slice=[].slice,__hasProp={}.hasOwnProperty,__extends=function(child,parent){for(var key in parent){if(__hasProp.call(parent,key))child[key]=parent[key]}function ctor(){this.constructor=child}ctor.prototype=parent.prototype;child.prototype=new ctor;child.__super__=parent.prototype;return child},__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};Bacon={toString:function(){return"Bacon"}};Bacon.version="0.7.32";Exception=(typeof global!=="undefined"&&global!==null?global:this).Error;Bacon.fromBinder=function(binder,eventTransformer){if(eventTransformer==null){eventTransformer=_.id}return new EventStream(describe(Bacon,"fromBinder",binder,eventTransformer),function(sink){var unbind,unbinder,unbound;unbound=false;unbind=function(){if(typeof unbinder!=="undefined"&&unbinder!==null){if(!unbound){unbinder()}return unbound=true}};unbinder=binder(function(){var args,event,reply,value,_i,_len;args=1<=arguments.length?__slice.call(arguments,0):[];value=eventTransformer.apply(this,args);if(!(isArray(value)&&_.last(value)instanceof Event)){value=[value]}reply=Bacon.more;for(_i=0,_len=value.length;_i<_len;_i++){event=value[_i];reply=sink(event=toEvent(event));if(reply===Bacon.noMore||event.isEnd()){if(unbinder!=null){unbind()}else{Bacon.scheduler.setTimeout(unbind,0)}return reply}}return reply});return unbind})};Bacon.$={};Bacon.$.asEventStream=function(eventName,selector,eventTransformer){var _ref;if(isFunction(selector)){_ref=[selector,void 0],eventTransformer=_ref[0],selector=_ref[1]}return withDescription(this.selector||this,"asEventStream",eventName,Bacon.fromBinder(function(_this){return function(handler){_this.on(eventName,selector,handler);return function(){return _this.off(eventName,selector,handler)}}}(this),eventTransformer))};if((_ref=typeof jQuery!=="undefined"&&jQuery!==null?jQuery:typeof Zepto!=="undefined"&&Zepto!==null?Zepto:void 0)!=null){_ref.fn.asEventStream=Bacon.$.asEventStream}Bacon.fromEventTarget=function(target,eventName,eventTransformer){var sub,unsub,_ref1,_ref2,_ref3,_ref4,_ref5,_ref6;sub=(_ref1=(_ref2=(_ref3=target.addEventListener)!=null?_ref3:target.addListener)!=null?_ref2:target.bind)!=null?_ref1:target.on;unsub=(_ref4=(_ref5=(_ref6=target.removeEventListener)!=null?_ref6:target.removeListener)!=null?_ref5:target.unbind)!=null?_ref4:target.off;return withDescription(Bacon,"fromEventTarget",target,eventName,Bacon.fromBinder(function(handler){sub.call(target,eventName,handler);return function(){return unsub.call(target,eventName,handler)}},eventTransformer))};Bacon.fromPromise=function(promise,abort){return withDescription(Bacon,"fromPromise",promise,Bacon.fromBinder(function(handler){promise.then(handler,function(e){return handler(new Error(e))});return function(){if(abort){return typeof promise.abort==="function"?promise.abort():void 0}}},function(value){return[value,end()]}))};Bacon.noMore=["<no-more>"];Bacon.more=["<more>"];Bacon.later=function(delay,value){return withDescription(Bacon,"later",delay,value,Bacon.fromPoll(delay,function(){return[value,end()]}))};Bacon.sequentially=function(delay,values){var index;index=0;return withDescription(Bacon,"sequentially",delay,values,Bacon.fromPoll(delay,function(){var value;value=values[index++];if(index<values.length){return value}else if(index===values.length){return[value,end()]}else{return end()}}))};Bacon.repeatedly=function(delay,values){var index;index=0;return withDescription(Bacon,"repeatedly",delay,values,Bacon.fromPoll(delay,function(){return values[index++%values.length]}))};Bacon.spy=function(spy){return spys.push(spy)};spys=[];registerObs=function(obs){var spy,_i,_len;if(spys.length){if(!registerObs.running){try{registerObs.running=true;for(_i=0,_len=spys.length;_i<_len;_i++){spy=spys[_i];spy(obs)}}finally{delete registerObs.running}}}return void 0};withMethodCallSupport=function(wrapped){return function(){var args,context,f,methodName;f=arguments[0],args=2<=arguments.length?__slice.call(arguments,1):[];if(typeof f==="object"&&args.length){context=f;methodName=args[0];f=function(){return context[methodName].apply(context,arguments)};args=args.slice(1)}return wrapped.apply(null,[f].concat(__slice.call(args)))}};liftCallback=function(desc,wrapped){return withMethodCallSupport(function(){var args,f,stream;f=arguments[0],args=2<=arguments.length?__slice.call(arguments,1):[];stream=partiallyApplied(wrapped,[function(values,callback){return f.apply(null,__slice.call(values).concat([callback]))}]);return withDescription.apply(null,[Bacon,desc,f].concat(__slice.call(args),[Bacon.combineAsArray(args).flatMap(stream)]))})};Bacon.fromCallback=liftCallback("fromCallback",function(){var args,f;f=arguments[0],args=2<=arguments.length?__slice.call(arguments,1):[];return Bacon.fromBinder(function(handler){makeFunction(f,args)(handler);return nop},function(value){return[value,end()]})});Bacon.fromNodeCallback=liftCallback("fromNodeCallback",function(){var args,f;f=arguments[0],args=2<=arguments.length?__slice.call(arguments,1):[];return Bacon.fromBinder(function(handler){makeFunction(f,args)(handler);return nop},function(error,value){if(error){return[new Error(error),end()]}return[value,end()]})});Bacon.fromPoll=function(delay,poll){return withDescription(Bacon,"fromPoll",delay,poll,Bacon.fromBinder(function(handler){var id;id=Bacon.scheduler.setInterval(handler,delay);return function(){return Bacon.scheduler.clearInterval(id)}},poll))};Bacon.interval=function(delay,value){if(value==null){value={}}return withDescription(Bacon,"interval",delay,value,Bacon.fromPoll(delay,function(){return next(value)}))};Bacon.constant=function(value){return new Property(describe(Bacon,"constant",value),function(sink){sink(initial(value));sink(end());return nop})};Bacon.never=function(){return new EventStream(describe(Bacon,"never"),function(sink){sink(end());return nop})};Bacon.once=function(value){return new EventStream(describe(Bacon,"once",value),function(sink){sink(toEvent(value));sink(end());return nop})};Bacon.fromArray=function(values){var i;assertArray(values);i=0;return new EventStream(describe(Bacon,"fromArray",values),function(sink){var reply,unsubd,value;unsubd=false;reply=Bacon.more;while(reply!==Bacon.noMore&&!unsubd){if(i>=values.length){sink(end());reply=Bacon.noMore}else{value=values[i++];reply=sink(toEvent(value))}}return function(){return unsubd=true}})};Bacon.mergeAll=function(){var streams;streams=1<=arguments.length?__slice.call(arguments,0):[];if(isArray(streams[0])){streams=streams[0]}if(streams.length){return new EventStream(describe.apply(null,[Bacon,"mergeAll"].concat(__slice.call(streams))),function(sink){var ends,sinks,smartSink;ends=0;smartSink=function(obs){return function(unsubBoth){return obs.dispatcher.subscribe(function(event){var reply;if(event.isEnd()){ends++;if(ends===streams.length){return sink(end())}else{return Bacon.more}}else{reply=sink(event);if(reply===Bacon.noMore){unsubBoth()}return reply}})}};sinks=_.map(smartSink,streams);return compositeUnsubscribe.apply(null,sinks)})}else{return Bacon.never()}};Bacon.zipAsArray=function(){var streams;streams=1<=arguments.length?__slice.call(arguments,0):[];if(isArray(streams[0])){streams=streams[0]}return withDescription.apply(null,[Bacon,"zipAsArray"].concat(__slice.call(streams),[Bacon.zipWith(streams,function(){var xs;xs=1<=arguments.length?__slice.call(arguments,0):[];return xs})]))};Bacon.zipWith=function(){var f,streams,_ref1;f=arguments[0],streams=2<=arguments.length?__slice.call(arguments,1):[];if(!isFunction(f)){_ref1=[f,streams[0]],streams=_ref1[0],f=_ref1[1]}streams=_.map(function(s){return s.toEventStream()},streams);return withDescription.apply(null,[Bacon,"zipWith",f].concat(__slice.call(streams),[Bacon.when(streams,f)]))};Bacon.groupSimultaneous=function(){var s,sources,streams;streams=1<=arguments.length?__slice.call(arguments,0):[];if(streams.length===1&&isArray(streams[0])){streams=streams[0]}sources=function(){var _i,_len,_results;_results=[];for(_i=0,_len=streams.length;_i<_len;_i++){s=streams[_i];_results.push(new BufferingSource(s))}return _results}();return withDescription.apply(null,[Bacon,"groupSimultaneous"].concat(__slice.call(streams),[Bacon.when(sources,function(){var xs;xs=1<=arguments.length?__slice.call(arguments,0):[];return xs})]))};Bacon.combineAsArray=function(){var index,s,sources,stream,streams,_i,_len;streams=1<=arguments.length?__slice.call(arguments,0):[];if(streams.length===1&&isArray(streams[0])){streams=streams[0]}for(index=_i=0,_len=streams.length;_i<_len;index=++_i){stream=streams[index];if(!isObservable(stream)){streams[index]=Bacon.constant(stream)}}if(streams.length){sources=function(){var _j,_len1,_results;_results=[];for(_j=0,_len1=streams.length;_j<_len1;_j++){s=streams[_j];_results.push(new Source(s,true))}return _results}();return withDescription.apply(null,[Bacon,"combineAsArray"].concat(__slice.call(streams),[Bacon.when(sources,function(){var xs;xs=1<=arguments.length?__slice.call(arguments,0):[];return xs}).toProperty()]))}else{return Bacon.constant([])}};Bacon.onValues=function(){var f,streams,_i;streams=2<=arguments.length?__slice.call(arguments,0,_i=arguments.length-1):(_i=0,[]),f=arguments[_i++];return Bacon.combineAsArray(streams).onValues(f)};Bacon.combineWith=function(){var f,streams;f=arguments[0],streams=2<=arguments.length?__slice.call(arguments,1):[];return withDescription.apply(null,[Bacon,"combineWith",f].concat(__slice.call(streams),[Bacon.combineAsArray(streams).map(function(values){return f.apply(null,values)})]))};Bacon.combineTemplate=function(template){var applyStreamValue,combinator,compile,compileTemplate,constantValue,current,funcs,mkContext,setValue,streams;funcs=[];streams=[];current=function(ctxStack){return ctxStack[ctxStack.length-1]};setValue=function(ctxStack,key,value){return current(ctxStack)[key]=value};applyStreamValue=function(key,index){return function(ctxStack,values){return setValue(ctxStack,key,values[index])}};constantValue=function(key,value){return function(ctxStack){return setValue(ctxStack,key,value)}};mkContext=function(template){if(isArray(template)){return[]}else{return{}}};compile=function(key,value){var popContext,pushContext;if(isObservable(value)){streams.push(value);return funcs.push(applyStreamValue(key,streams.length-1))}else if(value===Object(value)&&typeof value!=="function"&&!(value instanceof RegExp)&&!(value instanceof Date)){pushContext=function(key){return function(ctxStack){var newContext;newContext=mkContext(value);setValue(ctxStack,key,newContext);return ctxStack.push(newContext)}};popContext=function(ctxStack){return ctxStack.pop()};funcs.push(pushContext(key));compileTemplate(value);return funcs.push(popContext)}else{return funcs.push(constantValue(key,value))}};compileTemplate=function(template){return _.each(template,compile)};compileTemplate(template);combinator=function(values){var ctxStack,f,rootContext,_i,_len;rootContext=mkContext(template);ctxStack=[rootContext];for(_i=0,_len=funcs.length;_i<_len;_i++){f=funcs[_i];f(ctxStack,values)}return rootContext};return withDescription(Bacon,"combineTemplate",template,Bacon.combineAsArray(streams).map(combinator))};Bacon.retry=function(options){var delay,isRetryable,maxRetries,retries,retry,source;if(!isFunction(options.source)){throw new Exception("'source' option has to be a function")}source=options.source;retries=options.retries||0;maxRetries=options.maxRetries||retries;delay=options.delay||function(){return 0};isRetryable=options.isRetryable||function(){return true};retry=function(context){var delayedRetry,nextAttemptOptions;nextAttemptOptions={source:source,retries:retries-1,maxRetries:maxRetries,delay:delay,isRetryable:isRetryable};delayedRetry=function(){return Bacon.retry(nextAttemptOptions)};return Bacon.later(delay(context)).filter(false).concat(Bacon.once().flatMap(delayedRetry))};return withDescription(Bacon,"retry",options,source().flatMapError(function(e){if(isRetryable(e)&&retries>0){return retry({error:e,retriesDone:maxRetries-retries})}else{return Bacon.once(new Error(e))}}))};eventIdCounter=0;Event=function(){function Event(){this.id=++eventIdCounter}Event.prototype.isEvent=function(){return true};Event.prototype.isEnd=function(){return false};Event.prototype.isInitial=function(){return false};Event.prototype.isNext=function(){return false};Event.prototype.isError=function(){return false};Event.prototype.hasValue=function(){return false};Event.prototype.filter=function(){return true};Event.prototype.inspect=function(){return this.toString()};Event.prototype.log=function(){return this.toString()};return Event}();Next=function(_super){__extends(Next,_super);function Next(valueF){Next.__super__.constructor.call(this);if(isFunction(valueF)){this.value=_.cached(valueF)}else{this.value=_.always(valueF)}}Next.prototype.isNext=function(){return true};Next.prototype.hasValue=function(){return true};Next.prototype.fmap=function(f){var value;value=this.value;return this.apply(function(){return f(value())})};Next.prototype.apply=function(value){return new Next(value)};Next.prototype.filter=function(f){return f(this.value())};Next.prototype.toString=function(){return _.toString(this.value())};Next.prototype.log=function(){return this.value()};return Next}(Event);Initial=function(_super){__extends(Initial,_super);function Initial(){return Initial.__super__.constructor.apply(this,arguments)}Initial.prototype.isInitial=function(){return true};Initial.prototype.isNext=function(){return false};Initial.prototype.apply=function(value){return new Initial(value)};Initial.prototype.toNext=function(){return new Next(this.value)};return Initial}(Next);End=function(_super){__extends(End,_super);function End(){return End.__super__.constructor.apply(this,arguments)}End.prototype.isEnd=function(){return true};End.prototype.fmap=function(){return this};End.prototype.apply=function(){return this};End.prototype.toString=function(){return"<end>"};return End}(Event);Error=function(_super){__extends(Error,_super);function Error(error){this.error=error}Error.prototype.isError=function(){return true};Error.prototype.fmap=function(){return this};Error.prototype.apply=function(){return this};Error.prototype.toString=function(){return"<error> "+_.toString(this.error)};return Error}(Event);idCounter=0;Observable=function(){function Observable(desc){this.id=++idCounter;withDescription(desc,this);this.initialDesc=this.desc}Observable.prototype.subscribe=function(sink){return UpdateBarrier.wrappedSubscribe(this,sink)};Observable.prototype.subscribeInternal=function(sink){return this.dispatcher.subscribe(sink)};Observable.prototype.onValue=function(){var f;f=makeFunctionArgs(arguments);return this.subscribe(function(event){if(event.hasValue()){return f(event.value())}})};Observable.prototype.onValues=function(f){return this.onValue(function(args){return f.apply(null,args)})};Observable.prototype.onError=function(){var f;f=makeFunctionArgs(arguments);return this.subscribe(function(event){if(event.isError()){return f(event.error)}})};Observable.prototype.onEnd=function(){var f;f=makeFunctionArgs(arguments);return this.subscribe(function(event){if(event.isEnd()){return f()}})};Observable.prototype.errors=function(){return withDescription(this,"errors",this.filter(function(){return false}))};Observable.prototype.filter=function(){var args,f;f=arguments[0],args=2<=arguments.length?__slice.call(arguments,1):[];return convertArgsToFunction(this,f,args,function(f){return withDescription(this,"filter",f,this.withHandler(function(event){if(event.filter(f)){return this.push(event)}else{return Bacon.more}}))})};Observable.prototype.takeWhile=function(){var args,f;f=arguments[0],args=2<=arguments.length?__slice.call(arguments,1):[];return convertArgsToFunction(this,f,args,function(f){return withDescription(this,"takeWhile",f,this.withHandler(function(event){if(event.filter(f)){return this.push(event)}else{this.push(end());return Bacon.noMore}}))})};Observable.prototype.endOnError=function(){var args,f;f=arguments[0],args=2<=arguments.length?__slice.call(arguments,1):[];if(f==null){f=true}return convertArgsToFunction(this,f,args,function(f){return withDescription(this,"endOnError",this.withHandler(function(event){if(event.isError()&&f(event.error)){this.push(event);return this.push(end())}else{return this.push(event)}}))})};Observable.prototype.take=function(count){if(count<=0){return Bacon.never()}return withDescription(this,"take",count,this.withHandler(function(event){if(!event.hasValue()){return this.push(event)}else{count--;if(count>0){return this.push(event)}else{if(count===0){this.push(event)}this.push(end());return Bacon.noMore}}}))};Observable.prototype.map=function(){var args,p;p=arguments[0],args=2<=arguments.length?__slice.call(arguments,1):[];if(p instanceof Property){return p.sampledBy(this,former)}else{return convertArgsToFunction(this,p,args,function(f){return withDescription(this,"map",f,this.withHandler(function(event){return this.push(event.fmap(f))}))})}};Observable.prototype.mapError=function(){var f;f=makeFunctionArgs(arguments);return withDescription(this,"mapError",f,this.withHandler(function(event){if(event.isError()){return this.push(next(f(event.error)))}else{return this.push(event)}}))};Observable.prototype.mapEnd=function(){var f;f=makeFunctionArgs(arguments);return withDescription(this,"mapEnd",f,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(){var f;f=makeFunctionArgs(arguments);return withDescription(this,"doAction",f,this.withHandler(function(event){if(event.hasValue()){f(event.value())}return this.push(event)}))};Observable.prototype.skip=function(count){return withDescription(this,"skip",count,this.withHandler(function(event){if(!event.hasValue()){return this.push(event)}else if(count>0){count--;return Bacon.more}else{return this.push(event)}}))};Observable.prototype.skipDuplicates=function(isEqual){if(isEqual==null){isEqual=function(a,b){return a===b}}return withDescription(this,"skipDuplicates",this.withStateMachine(None,function(prev,event){if(!event.hasValue()){return[prev,[event]]}else if(event.isInitial()||prev===None||!isEqual(prev.get(),event.value())){return[new Some(event.value()),[event]]}else{return[prev,[]]}}))};Observable.prototype.skipErrors=function(){return withDescription(this,"skipErrors",this.withHandler(function(event){if(event.isError()){return Bacon.more}else{return this.push(event)}}))};Observable.prototype.withStateMachine=function(initState,f){var state;state=initState;return withDescription(this,"withStateMachine",initState,f,this.withHandler(function(event){var fromF,newState,output,outputs,reply,_i,_len;fromF=f(state,event);newState=fromF[0],outputs=fromF[1];state=newState;reply=Bacon.more;for(_i=0,_len=outputs.length;_i<_len;_i++){output=outputs[_i];reply=this.push(output);if(reply===Bacon.noMore){return reply}}return reply}))};Observable.prototype.scan=function(seed,f,options){var acc,f_,resultProperty,subscribe;if(options==null){options={}}f_=toCombinator(f);f=options.lazyF?f_:function(x,y){return f_(x(),y())};acc=toOption(seed).map(function(x){return _.always(x)});subscribe=function(_this){return function(sink){var initSent,reply,sendInit,unsub;initSent=false;unsub=nop;reply=Bacon.more;sendInit=function(){if(!initSent){return acc.forEach(function(valueF){initSent=true;reply=sink(new Initial(valueF));if(reply===Bacon.noMore){unsub();return unsub=nop}})}};unsub=_this.dispatcher.subscribe(function(event){var next,prev;if(event.hasValue()){if(initSent&&event.isInitial()){return Bacon.more}else{if(!event.isInitial()){sendInit()}initSent=true;prev=acc.getOrElse(function(){return void 0});next=_.cached(function(){return f(prev,event.value)});acc=new Some(next);if(options.eager){next()}return sink(event.apply(next))}}else{if(event.isEnd()){reply=sendInit()}if(reply!==Bacon.noMore){return sink(event)}}});UpdateBarrier.whenDoneWith(resultProperty,sendInit);return unsub}}(this);return resultProperty=new Property(describe(this,"scan",seed,f),subscribe)};Observable.prototype.fold=function(seed,f,options){return withDescription(this,"fold",seed,f,this.scan(seed,f,options).sampledBy(this.filter(false).mapEnd().toProperty()))};Observable.prototype.zip=function(other,f){if(f==null){f=Array}return withDescription(this,"zip",other,Bacon.zipWith([this,other],f))};Observable.prototype.diff=function(start,f){f=toCombinator(f);return withDescription(this,"diff",start,f,this.scan([start],function(prevTuple,next){return[next,f(prevTuple[0],next)]}).filter(function(tuple){return tuple.length===2}).map(function(tuple){return tuple[1]}))};Observable.prototype.flatMap=function(){return flatMap_(this,makeSpawner(arguments))};Observable.prototype.flatMapFirst=function(){return flatMap_(this,makeSpawner(arguments),true)};Observable.prototype.flatMapWithConcurrencyLimit=function(){var args,limit;limit=arguments[0],args=2<=arguments.length?__slice.call(arguments,1):[];return withDescription.apply(null,[this,"flatMapWithConcurrencyLimit",limit].concat(__slice.call(args),[flatMap_(this,makeSpawner(args),false,limit)]))};Observable.prototype.flatMapLatest=function(){var f,stream;f=makeSpawner(arguments);stream=this.toEventStream();return withDescription(this,"flatMapLatest",f,stream.flatMap(function(value){return makeObservable(f(value)).takeUntil(stream)}))};Observable.prototype.flatMapError=function(fn){return withDescription(this,"flatMapError",fn,this.mapError(function(err){return new Error(err)}).flatMap(function(x){if(x instanceof Error){return fn(x.error)}else{return Bacon.once(x)}}))};Observable.prototype.flatMapConcat=function(){return withDescription.apply(null,[this,"flatMapConcat"].concat(__slice.call(arguments),[this.flatMapWithConcurrencyLimit.apply(this,[1].concat(__slice.call(arguments)))]))};Observable.prototype.bufferingThrottle=function(minimumInterval){return withDescription(this,"bufferingThrottle",minimumInterval,this.flatMapConcat(function(x){return Bacon.once(x).concat(Bacon.later(minimumInterval).filter(false))}))};Observable.prototype.not=function(){return withDescription(this,"not",this.map(function(x){return!x}))};Observable.prototype.log=function(){var args;args=1<=arguments.length?__slice.call(arguments,0):[];this.subscribe(function(event){return typeof console!=="undefined"&&console!==null?typeof console.log==="function"?console.log.apply(console,__slice.call(args).concat([event.log()])):void 0:void 0});return this};Observable.prototype.slidingWindow=function(n,minValues){if(minValues==null){minValues=0}return withDescription(this,"slidingWindow",n,minValues,this.scan([],function(window,value){return window.concat([value]).slice(-n)}).filter(function(values){return values.length>=minValues}))};Observable.prototype.combine=function(other,f){var combinator;combinator=toCombinator(f);return withDescription(this,"combine",other,f,Bacon.combineAsArray(this,other).map(function(values){return combinator(values[0],values[1])}))};Observable.prototype.decode=function(cases){return withDescription(this,"decode",cases,this.combine(Bacon.combineTemplate(cases),function(key,values){return values[key]}))};Observable.prototype.awaiting=function(other){return withDescription(this,"awaiting",other,Bacon.groupSimultaneous(this,other).map(function(_arg){var myValues,otherValues;myValues=_arg[0],otherValues=_arg[1];return otherValues.length===0}).toProperty(false).skipDuplicates())};Observable.prototype.name=function(name){this._name=name;return this};Observable.prototype.withDescription=function(){return describe.apply(null,arguments).apply(this)};Observable.prototype.toString=function(){if(this._name){return this._name}else{return this.desc.toString()}};Observable.prototype.internalDeps=function(){return this.initialDesc.deps()};return Observable}();Observable.prototype.reduce=Observable.prototype.fold;Observable.prototype.assign=Observable.prototype.onValue;Observable.prototype.inspect=Observable.prototype.toString;flatMap_=function(root,f,firstOnly,limit){var childDeps,result,rootDep;rootDep=[root];childDeps=[];result=new EventStream(describe(root,"flatMap"+(firstOnly?"First":""),f),function(sink){var checkEnd,checkQueue,composite,queue,spawn;composite=new CompositeUnsubscribe;queue=[];spawn=function(event){var child;child=makeObservable(f(event.value()));childDeps.push(child);return composite.add(function(unsubAll,unsubMe){return child.dispatcher.subscribe(function(event){var reply;if(event.isEnd()){_.remove(child,childDeps);checkQueue();checkEnd(unsubMe);return Bacon.noMore}else{if(event instanceof Initial){event=event.toNext()}reply=sink(event);if(reply===Bacon.noMore){unsubAll()}return reply}})})};checkQueue=function(){var event;event=queue.shift();if(event){return spawn(event)}};checkEnd=function(unsub){unsub();if(composite.empty()){return sink(end())}};composite.add(function(__,unsubRoot){return root.dispatcher.subscribe(function(event){if(event.isEnd()){return checkEnd(unsubRoot)}else if(event.isError()){return sink(event)}else if(firstOnly&&composite.count()>1){return Bacon.more}else{if(composite.unsubscribed){return Bacon.noMore}if(limit&&composite.count()>limit){return queue.push(event)}else{return spawn(event)}}})});return composite.unsubscribe});result.internalDeps=function(){if(childDeps.length){return rootDep.concat(childDeps)}else{return rootDep}};return result};EventStream=function(_super){__extends(EventStream,_super);function EventStream(desc,subscribe,handler){if(isFunction(desc)){handler=subscribe;subscribe=desc;desc=[]}EventStream.__super__.constructor.call(this,desc);assertFunction(subscribe);this.dispatcher=new Dispatcher(subscribe,handler);registerObs(this)}EventStream.prototype.delay=function(delay){return withDescription(this,"delay",delay,this.flatMap(function(value){return Bacon.later(delay,value)}))};EventStream.prototype.debounce=function(delay){return withDescription(this,"debounce",delay,this.flatMapLatest(function(value){return Bacon.later(delay,value)}))};EventStream.prototype.debounceImmediate=function(delay){return withDescription(this,"debounceImmediate",delay,this.flatMapFirst(function(value){return Bacon.once(value).concat(Bacon.later(delay).filter(false))}))};EventStream.prototype.throttle=function(delay){return withDescription(this,"throttle",delay,this.bufferWithTime(delay).map(function(values){return values[values.length-1]}))};EventStream.prototype.bufferWithTime=function(delay){return withDescription(this,"bufferWithTime",delay,this.bufferWithTimeOrCount(delay,Number.MAX_VALUE))};EventStream.prototype.bufferWithCount=function(count){return withDescription(this,"bufferWithCount",count,this.bufferWithTimeOrCount(void 0,count))};EventStream.prototype.bufferWithTimeOrCount=function(delay,count){var flushOrSchedule;flushOrSchedule=function(buffer){if(buffer.values.length===count){return buffer.flush()}else if(delay!==void 0){return buffer.schedule()}};return withDescription(this,"bufferWithTimeOrCount",delay,count,this.buffer(delay,flushOrSchedule,flushOrSchedule))};EventStream.prototype.buffer=function(delay,onInput,onFlush){var buffer,delayMs,reply;if(onInput==null){onInput=nop}if(onFlush==null){onFlush=nop}buffer={scheduled:false,end:void 0,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(){if(!this.scheduled){this.scheduled=true;return delay(function(_this){return function(){return _this.flush()}}(this))}}};reply=Bacon.more;if(!isFunction(delay)){delayMs=delay;delay=function(f){return Bacon.scheduler.setTimeout(f,delayMs)}}return withDescription(this,"buffer",this.withHandler(function(event){buffer.push=function(_this){return function(event){return _this.push(event)}}(this);if(event.isError()){reply=this.push(event)}else if(event.isEnd()){buffer.end=event;if(!buffer.scheduled){buffer.flush()}}else{buffer.values.push(event.value());onInput(buffer)}return reply}))};EventStream.prototype.merge=function(right){var left;assertEventStream(right);left=this;return withDescription(left,"merge",right,Bacon.mergeAll(this,right))};EventStream.prototype.toProperty=function(initValue){if(arguments.length===0){initValue=None}return withDescription(this,"toProperty",initValue,this.scan(initValue,latterF,{lazyF:true}))};EventStream.prototype.toEventStream=function(){return this};EventStream.prototype.sampledBy=function(sampler,combinator){return withDescription(this,"sampledBy",sampler,combinator,this.toProperty().sampledBy(sampler,combinator))};EventStream.prototype.concat=function(right){var left;left=this;return new EventStream(describe(left,"concat",right),function(sink){var unsubLeft,unsubRight;unsubRight=nop;unsubLeft=left.dispatcher.subscribe(function(e){if(e.isEnd()){return unsubRight=right.dispatcher.subscribe(sink)}else{return sink(e)}});return function(){unsubLeft();return unsubRight()}})};EventStream.prototype.takeUntil=function(stopper){var endMarker;endMarker={};return withDescription(this,"takeUntil",stopper,Bacon.groupSimultaneous(this.mapEnd(endMarker),stopper.skipErrors()).withHandler(function(event){var data,reply,value,_i,_len,_ref1;if(!event.hasValue()){return this.push(event)}else{_ref1=event.value(),data=_ref1[0],stopper=_ref1[1];if(stopper.length){return this.push(end())}else{reply=Bacon.more;for(_i=0,_len=data.length;_i<_len;_i++){value=data[_i];if(value===endMarker){reply=this.push(end())}else{reply=this.push(next(value))}}return reply}}}))};EventStream.prototype.skipUntil=function(starter){var started;started=starter.take(1).map(true).toProperty(false);return withDescription(this,"skipUntil",starter,this.filter(started))};EventStream.prototype.skipWhile=function(){var args,f,ok;f=arguments[0],args=2<=arguments.length?__slice.call(arguments,1):[];ok=false;return convertArgsToFunction(this,f,args,function(f){return withDescription(this,"skipWhile",f,this.withHandler(function(event){if(ok||!event.hasValue()||!f(event.value())){if(event.hasValue()){ok=true}return this.push(event)}else{return Bacon.more}}))})};EventStream.prototype.holdWhen=function(valve){var putToHold,releaseHold,valve_;valve_=valve.startWith(false);releaseHold=valve_.filter(function(x){return!x});putToHold=valve_.filter(_.id);return withDescription(this,"holdWhen",valve,this.filter(false).merge(valve_.flatMapConcat(function(_this){return function(shouldHold){if(!shouldHold){return _this.takeUntil(putToHold)}else{return _this.scan([],function(xs,x){return xs.concat(x)},{eager:true}).sampledBy(releaseHold).take(1).flatMap(Bacon.fromArray) | |
| }}}(this))))};EventStream.prototype.startWith=function(seed){return withDescription(this,"startWith",seed,Bacon.once(seed).concat(this))};EventStream.prototype.withHandler=function(handler){return new EventStream(describe(this,"withHandler",handler),this.dispatcher.subscribe,handler)};return EventStream}(Observable);Property=function(_super){__extends(Property,_super);function Property(desc,subscribe,handler){if(isFunction(desc)){handler=subscribe;subscribe=desc;desc=[]}Property.__super__.constructor.call(this,desc);assertFunction(subscribe);this.dispatcher=new PropertyDispatcher(this,subscribe,handler);registerObs(this)}Property.prototype.sampledBy=function(sampler,combinator){var lazy,result,samplerSource,stream,thisSource;if(combinator!=null){combinator=toCombinator(combinator)}else{lazy=true;combinator=function(f){return f()}}thisSource=new Source(this,false,lazy);samplerSource=new Source(sampler,true,lazy);stream=Bacon.when([thisSource,samplerSource],combinator);result=sampler instanceof Property?stream.toProperty():stream;return withDescription(this,"sampledBy",sampler,combinator,result)};Property.prototype.sample=function(interval){return withDescription(this,"sample",interval,this.sampledBy(Bacon.interval(interval,{})))};Property.prototype.changes=function(){return new EventStream(describe(this,"changes"),function(_this){return function(sink){return _this.dispatcher.subscribe(function(event){if(!event.isInitial()){return sink(event)}})}}(this))};Property.prototype.withHandler=function(handler){return new Property(describe(this,"withHandler",handler),this.dispatcher.subscribe,handler)};Property.prototype.toProperty=function(){assertNoArguments(arguments);return this};Property.prototype.toEventStream=function(){return new EventStream(describe(this,"toEventStream"),function(_this){return function(sink){return _this.dispatcher.subscribe(function(event){if(event.isInitial()){event=event.toNext()}return sink(event)})}}(this))};Property.prototype.and=function(other){return withDescription(this,"and",other,this.combine(other,function(x,y){return x&&y}))};Property.prototype.or=function(other){return withDescription(this,"or",other,this.combine(other,function(x,y){return x||y}))};Property.prototype.delay=function(delay){return this.delayChanges("delay",delay,function(changes){return changes.delay(delay)})};Property.prototype.debounce=function(delay){return this.delayChanges("debounce",delay,function(changes){return changes.debounce(delay)})};Property.prototype.throttle=function(delay){return this.delayChanges("throttle",delay,function(changes){return changes.throttle(delay)})};Property.prototype.delayChanges=function(){var desc,f,_i;desc=2<=arguments.length?__slice.call(arguments,0,_i=arguments.length-1):(_i=0,[]),f=arguments[_i++];return withDescription.apply(null,[this].concat(__slice.call(desc),[addPropertyInitValueToStream(this,f(this.changes()))]))};Property.prototype.takeUntil=function(stopper){var changes;changes=this.changes().takeUntil(stopper);return withDescription(this,"takeUntil",stopper,addPropertyInitValueToStream(this,changes))};Property.prototype.startWith=function(value){return withDescription(this,"startWith",value,this.scan(value,function(prev,next){return next}))};Property.prototype.bufferingThrottle=function(){var _ref1;return(_ref1=Property.__super__.bufferingThrottle.apply(this,arguments)).bufferingThrottle.apply(_ref1,arguments).toProperty()};return Property}(Observable);convertArgsToFunction=function(obs,f,args,method){var sampled;if(f instanceof Property){sampled=f.sampledBy(obs,function(p,s){return[p,s]});return method.call(sampled,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 method.call(obs,f)}};addPropertyInitValueToStream=function(property,stream){var justInitValue;justInitValue=new EventStream(describe(property,"justInitValue"),function(sink){var unsub,value;value=void 0;unsub=property.dispatcher.subscribe(function(event){if(!event.isEnd()){value=event}return Bacon.noMore});UpdateBarrier.whenDoneWith(justInitValue,function(){if(value!=null){sink(value)}return sink(end())});return unsub});return justInitValue.concat(stream).toProperty()};Dispatcher=function(){function Dispatcher(_subscribe,_handleEvent){this._subscribe=_subscribe;this._handleEvent=_handleEvent;this.subscribe=__bind(this.subscribe,this);this.handleEvent=__bind(this.handleEvent,this);this.subscriptions=[];this.queue=[];this.pushing=false;this.ended=false;this.prevError=void 0;this.unsubSrc=void 0}Dispatcher.prototype.hasSubscribers=function(){return this.subscriptions.length>0};Dispatcher.prototype.removeSub=function(subscription){return this.subscriptions=_.without(subscription,this.subscriptions)};Dispatcher.prototype.push=function(event){if(event.isEnd()){this.ended=true}return UpdateBarrier.inTransaction(event,this,this.pushIt,[event])};Dispatcher.prototype.pushIt=function(event){var reply,sub,success,tmp,_i,_len;if(!this.pushing){if(event===this.prevError){return}if(event.isError()){this.prevError=event}success=false;try{this.pushing=true;tmp=this.subscriptions;for(_i=0,_len=tmp.length;_i<_len;_i++){sub=tmp[_i];reply=sub.sink(event);if(reply===Bacon.noMore||event.isEnd()){this.removeSub(sub)}}success=true}finally{this.pushing=false;if(!success){this.queue=[]}}success=true;while(this.queue.length){event=this.queue.shift();this.push(event)}if(this.hasSubscribers()){return Bacon.more}else{this.unsubscribeFromSource();return Bacon.noMore}}else{this.queue.push(event);return Bacon.more}};Dispatcher.prototype.handleEvent=function(event){if(this._handleEvent){return this._handleEvent(event)}else{return this.push(event)}};Dispatcher.prototype.unsubscribeFromSource=function(){if(this.unsubSrc){this.unsubSrc()}return this.unsubSrc=void 0};Dispatcher.prototype.subscribe=function(sink){var subscription;if(this.ended){sink(end());return nop}else{assertFunction(sink);subscription={sink:sink};this.subscriptions.push(subscription);if(this.subscriptions.length===1){this.unsubSrc=this._subscribe(this.handleEvent);assertFunction(this.unsubSrc)}return function(_this){return function(){_this.removeSub(subscription);if(!_this.hasSubscribers()){return _this.unsubscribeFromSource()}}}(this)}};return Dispatcher}();PropertyDispatcher=function(_super){__extends(PropertyDispatcher,_super);function PropertyDispatcher(property,subscribe,handleEvent){this.property=property;this.subscribe=__bind(this.subscribe,this);PropertyDispatcher.__super__.constructor.call(this,subscribe,handleEvent);this.current=None;this.currentValueRootId=void 0;this.propertyEnded=false}PropertyDispatcher.prototype.push=function(event){if(event.isEnd()){this.propertyEnded=true}if(event.hasValue()){this.current=new Some(event);this.currentValueRootId=UpdateBarrier.currentEventId()}return PropertyDispatcher.__super__.push.call(this,event)};PropertyDispatcher.prototype.maybeSubSource=function(sink,reply){if(reply===Bacon.noMore){return nop}else if(this.propertyEnded){sink(end());return nop}else{return Dispatcher.prototype.subscribe.call(this,sink)}};PropertyDispatcher.prototype.subscribe=function(sink){var dispatchingId,initSent,reply,valId;initSent=false;reply=Bacon.more;if(this.current.isDefined&&(this.hasSubscribers()||this.propertyEnded)){dispatchingId=UpdateBarrier.currentEventId();valId=this.currentValueRootId;if(!this.propertyEnded&&valId&&dispatchingId&&dispatchingId!==valId){UpdateBarrier.whenDoneWith(this.property,function(_this){return function(){if(_this.currentValueRootId===valId){return sink(initial(_this.current.get().value()))}}}(this));return this.maybeSubSource(sink,reply)}else{UpdateBarrier.inTransaction(void 0,this,function(){return reply=function(){try{return sink(initial(this.current.get().value()))}catch(_error){return Bacon.more}}.call(this)},[]);return this.maybeSubSource(sink,reply)}}else{return this.maybeSubSource(sink,reply)}};return PropertyDispatcher}(Dispatcher);Bus=function(_super){__extends(Bus,_super);function Bus(){this.guardedSink=__bind(this.guardedSink,this);this.subscribeAll=__bind(this.subscribeAll,this);this.unsubAll=__bind(this.unsubAll,this);this.sink=void 0;this.subscriptions=[];this.ended=false;Bus.__super__.constructor.call(this,describe(Bacon,"Bus"),this.subscribeAll)}Bus.prototype.unsubAll=function(){var sub,_i,_len,_ref1;_ref1=this.subscriptions;for(_i=0,_len=_ref1.length;_i<_len;_i++){sub=_ref1[_i];if(typeof sub.unsub==="function"){sub.unsub()}}return void 0};Bus.prototype.subscribeAll=function(newSink){var subscription,_i,_len,_ref1;this.sink=newSink;_ref1=cloneArray(this.subscriptions);for(_i=0,_len=_ref1.length;_i<_len;_i++){subscription=_ref1[_i];this.subscribeInput(subscription)}return this.unsubAll};Bus.prototype.guardedSink=function(input){return function(_this){return function(event){if(event.isEnd()){_this.unsubscribeInput(input);return Bacon.noMore}else{return _this.sink(event)}}}(this)};Bus.prototype.subscribeInput=function(subscription){return subscription.unsub=subscription.input.dispatcher.subscribe(this.guardedSink(subscription.input))};Bus.prototype.unsubscribeInput=function(input){var i,sub,_i,_len,_ref1;_ref1=this.subscriptions;for(i=_i=0,_len=_ref1.length;_i<_len;i=++_i){sub=_ref1[i];if(sub.input===input){if(typeof sub.unsub==="function"){sub.unsub()}this.subscriptions.splice(i,1);return}}};Bus.prototype.plug=function(input){var sub;if(this.ended){return}sub={input:input};this.subscriptions.push(sub);if(this.sink!=null){this.subscribeInput(sub)}return function(_this){return function(){return _this.unsubscribeInput(input)}}(this)};Bus.prototype.end=function(){this.ended=true;this.unsubAll();return typeof this.sink==="function"?this.sink(end()):void 0};Bus.prototype.push=function(value){return typeof this.sink==="function"?this.sink(next(value)):void 0};Bus.prototype.error=function(error){return typeof this.sink==="function"?this.sink(new Error(error)):void 0};return Bus}(EventStream);Source=function(){function Source(obs,sync,lazy){this.obs=obs;this.sync=sync;this.lazy=lazy!=null?lazy:false;this.queue=[]}Source.prototype.subscribe=function(sink){return this.obs.dispatcher.subscribe(sink)};Source.prototype.toString=function(){return this.obs.toString()};Source.prototype.markEnded=function(){return this.ended=true};Source.prototype.consume=function(){if(this.lazy){return _.always(this.queue[0])}else{return this.queue[0]}};Source.prototype.push=function(x){return this.queue=[x]};Source.prototype.mayHave=function(){return true};Source.prototype.hasAtLeast=function(){return this.queue.length};Source.prototype.flatten=true;return Source}();ConsumingSource=function(_super){__extends(ConsumingSource,_super);function ConsumingSource(){return ConsumingSource.__super__.constructor.apply(this,arguments)}ConsumingSource.prototype.consume=function(){return this.queue.shift()};ConsumingSource.prototype.push=function(x){return this.queue.push(x)};ConsumingSource.prototype.mayHave=function(c){return!this.ended||this.queue.length>=c};ConsumingSource.prototype.hasAtLeast=function(c){return this.queue.length>=c};ConsumingSource.prototype.flatten=false;return ConsumingSource}(Source);BufferingSource=function(_super){__extends(BufferingSource,_super);function BufferingSource(obs){BufferingSource.__super__.constructor.call(this,obs,true)}BufferingSource.prototype.consume=function(){var values;values=this.queue;this.queue=[];return function(){return values}};BufferingSource.prototype.push=function(x){return this.queue.push(x())};BufferingSource.prototype.hasAtLeast=function(){return true};return BufferingSource}(Source);Source.isTrigger=function(s){if(s instanceof Source){return s.sync}else{return s instanceof EventStream}};Source.fromObservable=function(s){if(s instanceof Source){return s}else if(s instanceof Property){return new Source(s,false)}else{return new ConsumingSource(s,true)}};describe=function(){var args,context,method;context=arguments[0],method=arguments[1],args=3<=arguments.length?__slice.call(arguments,2):[];if((context||method)instanceof Desc){return context||method}else{return new Desc(context,method,args)}};findDeps=function(x){if(isArray(x)){return _.flatMap(findDeps,x)}else if(isObservable(x)){return[x]}else if(x instanceof Source){return[x.obs]}else{return[]}};Desc=function(){function Desc(context,method,args){this.context=context;this.method=method;this.args=args;this.cached=void 0}Desc.prototype.deps=function(){return this.cached||(this.cached=findDeps([this.context].concat(this.args)))};Desc.prototype.apply=function(obs){obs.desc=this;return obs};Desc.prototype.toString=function(){return _.toString(this.context)+"."+_.toString(this.method)+"("+_.map(_.toString,this.args)+")"};return Desc}();withDescription=function(){var desc,obs,_i;desc=2<=arguments.length?__slice.call(arguments,0,_i=arguments.length-1):(_i=0,[]),obs=arguments[_i++];return describe.apply(null,desc).apply(obs)};Bacon.when=function(){var f,i,index,ix,len,needsBarrier,pat,patSources,pats,patterns,resultStream,s,sources,triggerFound,usage,_i,_j,_len,_len1,_ref1;if(arguments.length===0){return Bacon.never()}len=arguments.length;usage="when: expecting arguments in the form (Observable+,function)+";assert(usage,len%2===0);sources=[];pats=[];i=0;patterns=[];while(i<len){patterns[i]=arguments[i];patterns[i+1]=arguments[i+1];patSources=_.toArray(arguments[i]);f=arguments[i+1];pat={f:isFunction(f)?f:function(){return f},ixs:[]};triggerFound=false;for(_i=0,_len=patSources.length;_i<_len;_i++){s=patSources[_i];index=_.indexOf(sources,s);if(!triggerFound){triggerFound=Source.isTrigger(s)}if(index<0){sources.push(s);index=sources.length-1}_ref1=pat.ixs;for(_j=0,_len1=_ref1.length;_j<_len1;_j++){ix=_ref1[_j];if(ix.index===index){ix.count++}}pat.ixs.push({index:index,count:1})}assert("At least one EventStream required",triggerFound||!patSources.length);if(patSources.length>0){pats.push(pat)}i=i+2}if(!sources.length){return Bacon.never()}sources=_.map(Source.fromObservable,sources);needsBarrier=_.any(sources,function(s){return s.flatten})&&containsDuplicateDeps(_.map(function(s){return s.obs},sources));return resultStream=new EventStream(describe.apply(null,[Bacon,"when"].concat(__slice.call(patterns))),function(sink){var cannotMatch,cannotSync,ends,match,nonFlattened,part,triggers;triggers=[];ends=false;match=function(p){var _k,_len2,_ref2;_ref2=p.ixs;for(_k=0,_len2=_ref2.length;_k<_len2;_k++){i=_ref2[_k];if(!sources[i.index].hasAtLeast(i.count)){return false}}return true};cannotSync=function(source){return!source.sync||source.ended};cannotMatch=function(p){var _k,_len2,_ref2;_ref2=p.ixs;for(_k=0,_len2=_ref2.length;_k<_len2;_k++){i=_ref2[_k];if(!sources[i.index].mayHave(i.count)){return true}}};nonFlattened=function(trigger){return!trigger.source.flatten};part=function(source){return function(unsubAll){var flush,flushLater,flushWhileTriggers;flushLater=function(){return UpdateBarrier.whenDoneWith(resultStream,flush)};flushWhileTriggers=function(){var functions,p,reply,trigger,_k,_len2;if(triggers.length>0){reply=Bacon.more;trigger=triggers.pop();for(_k=0,_len2=pats.length;_k<_len2;_k++){p=pats[_k];if(match(p)){functions=function(){var _l,_len3,_ref2,_results;_ref2=p.ixs;_results=[];for(_l=0,_len3=_ref2.length;_l<_len3;_l++){i=_ref2[_l];_results.push(sources[i.index].consume())}return _results}();reply=sink(trigger.e.apply(function(){var fun,values;values=function(){var _l,_len3,_results;_results=[];for(_l=0,_len3=functions.length;_l<_len3;_l++){fun=functions[_l];_results.push(fun())}return _results}();return p.f.apply(p,values)}));if(triggers.length){triggers=_.filter(nonFlattened,triggers)}if(reply===Bacon.noMore){return reply}else{return flushWhileTriggers()}}}}else{return Bacon.more}};flush=function(){var reply;reply=flushWhileTriggers();if(ends){ends=false;if(_.all(sources,cannotSync)||_.all(pats,cannotMatch)){reply=Bacon.noMore;sink(end())}}if(reply===Bacon.noMore){unsubAll()}return reply};return source.subscribe(function(e){var reply;if(e.isEnd()){ends=true;source.markEnded();flushLater()}else if(e.isError()){reply=sink(e)}else{source.push(e.value);if(source.sync){triggers.push({source:source,e:e});if(needsBarrier||UpdateBarrier.hasWaiters()){flushLater()}else{flush()}}}if(reply===Bacon.noMore){unsubAll()}return reply||Bacon.more})}};return compositeUnsubscribe.apply(null,function(){var _k,_len2,_results;_results=[];for(_k=0,_len2=sources.length;_k<_len2;_k++){s=sources[_k];_results.push(part(s))}return _results}())})};containsDuplicateDeps=function(observables,state){var checkObservable;if(state==null){state=[]}checkObservable=function(obs){var deps;if(_.contains(state,obs)){return true}else{deps=obs.internalDeps();if(deps.length){state.push(obs);return _.any(deps,checkObservable)}else{state.push(obs);return false}}};return _.any(observables,checkObservable)};Bacon.update=function(){var i,initial,lateBindFirst,patterns;initial=arguments[0],patterns=2<=arguments.length?__slice.call(arguments,1):[];lateBindFirst=function(f){return function(){var args;args=1<=arguments.length?__slice.call(arguments,0):[];return function(i){return f.apply(null,[i].concat(args))}}};i=patterns.length-1;while(i>0){if(!(patterns[i]instanceof Function)){patterns[i]=function(x){return function(){return x}}(patterns[i])}patterns[i]=lateBindFirst(patterns[i]);i=i-2}return withDescription.apply(null,[Bacon,"update",initial].concat(__slice.call(patterns),[Bacon.when.apply(Bacon,patterns).scan(initial,function(x,f){return f(x)})]))};compositeUnsubscribe=function(){var ss;ss=1<=arguments.length?__slice.call(arguments,0):[];return new CompositeUnsubscribe(ss).unsubscribe};CompositeUnsubscribe=function(){function CompositeUnsubscribe(ss){var s,_i,_len;if(ss==null){ss=[]}this.unsubscribe=__bind(this.unsubscribe,this);this.unsubscribed=false;this.subscriptions=[];this.starting=[];for(_i=0,_len=ss.length;_i<_len;_i++){s=ss[_i];this.add(s)}}CompositeUnsubscribe.prototype.add=function(subscription){var ended,unsub,unsubMe;if(this.unsubscribed){return}ended=false;unsub=nop;this.starting.push(subscription);unsubMe=function(_this){return function(){if(_this.unsubscribed){return}ended=true;_this.remove(unsub);return _.remove(subscription,_this.starting)}}(this);unsub=subscription(this.unsubscribe,unsubMe);if(!(this.unsubscribed||ended)){this.subscriptions.push(unsub)}_.remove(subscription,this.starting);return unsub};CompositeUnsubscribe.prototype.remove=function(unsub){if(this.unsubscribed){return}if(_.remove(unsub,this.subscriptions)!==void 0){return unsub()}};CompositeUnsubscribe.prototype.unsubscribe=function(){var s,_i,_len,_ref1;if(this.unsubscribed){return}this.unsubscribed=true;_ref1=this.subscriptions;for(_i=0,_len=_ref1.length;_i<_len;_i++){s=_ref1[_i];s()}this.subscriptions=[];return this.starting=[]};CompositeUnsubscribe.prototype.count=function(){if(this.unsubscribed){return 0}return this.subscriptions.length+this.starting.length};CompositeUnsubscribe.prototype.empty=function(){return this.count()===0};return CompositeUnsubscribe}();Bacon.CompositeUnsubscribe=CompositeUnsubscribe;Some=function(){function Some(value){this.value=value}Some.prototype.getOrElse=function(){return this.value};Some.prototype.get=function(){return this.value};Some.prototype.filter=function(f){if(f(this.value)){return new Some(this.value)}else{return None}};Some.prototype.map=function(f){return new Some(f(this.value))};Some.prototype.forEach=function(f){return f(this.value)};Some.prototype.isDefined=true;Some.prototype.toArray=function(){return[this.value]};Some.prototype.inspect=function(){return"Some("+this.value+")"};Some.prototype.toString=function(){return this.inspect()};return Some}();None={getOrElse:function(value){return value},filter:function(){return None},map:function(){return None},forEach:function(){},isDefined:false,toArray:function(){return[]},inspect:function(){return"None"},toString:function(){return this.inspect()}};UpdateBarrier=function(){var afterTransaction,afters,currentEventId,flush,flushDepsOf,flushWaiters,hasWaiters,inTransaction,rootEvent,waiterObs,waiters,whenDoneWith,wrappedSubscribe;rootEvent=void 0;waiterObs=[];waiters={};afters=[];afterTransaction=function(f){if(rootEvent){return afters.push(f)}else{return f()}};whenDoneWith=function(obs,f){var obsWaiters;if(rootEvent){obsWaiters=waiters[obs.id];if(obsWaiters==null){obsWaiters=waiters[obs.id]=[f];return waiterObs.push(obs)}else{return obsWaiters.push(f)}}else{return f()}};flush=function(){while(waiterObs.length>0){flushWaiters(0)}return void 0};flushWaiters=function(index){var f,obs,obsId,obsWaiters,_i,_len;obs=waiterObs[index];obsId=obs.id;obsWaiters=waiters[obsId];waiterObs.splice(index,1);delete waiters[obsId];flushDepsOf(obs);for(_i=0,_len=obsWaiters.length;_i<_len;_i++){f=obsWaiters[_i];f()}return void 0};flushDepsOf=function(obs){var dep,deps,index,_i,_len;deps=obs.internalDeps();for(_i=0,_len=deps.length;_i<_len;_i++){dep=deps[_i];flushDepsOf(dep);if(waiters[dep.id]){index=_.indexOf(waiterObs,dep);flushWaiters(index)}}return void 0};inTransaction=function(event,context,f,args){var result,theseAfters,_i,_len;if(rootEvent){return f.apply(context,args)}else{rootEvent=event;result=f.apply(context,args);flush();rootEvent=void 0;while(afters.length){theseAfters=afters;afters=[];for(_i=0,_len=theseAfters.length;_i<_len;_i++){f=theseAfters[_i];f()}}return result}};currentEventId=function(){if(rootEvent){return rootEvent.id}else{return void 0}};wrappedSubscribe=function(obs,sink){var doUnsub,unsub,unsubd;unsubd=false;doUnsub=function(){};unsub=function(){unsubd=true;return doUnsub()};doUnsub=obs.dispatcher.subscribe(function(event){return afterTransaction(function(){var reply;if(!unsubd){reply=sink(event);if(reply===Bacon.noMore){return unsub()}}})});return unsub};hasWaiters=function(){return waiterObs.length>0};return{whenDoneWith:whenDoneWith,hasWaiters:hasWaiters,inTransaction:inTransaction,currentEventId:currentEventId,wrappedSubscribe:wrappedSubscribe}}();Bacon.EventStream=EventStream;Bacon.Property=Property;Bacon.Observable=Observable;Bacon.Bus=Bus;Bacon.Initial=Initial;Bacon.Next=Next;Bacon.End=End;Bacon.Error=Error;nop=function(){};latterF=function(_,x){return x()};former=function(x,_){return x};initial=function(value){return new Initial(_.always(value))};next=function(value){return new Next(_.always(value))};end=function(){return new End};toEvent=function(x){if(x instanceof Event){return x}else{return next(x)}};cloneArray=function(xs){return xs.slice(0)};assert=function(message,condition){if(!condition){throw new Exception(message)}};assertEventStream=function(event){if(!(event instanceof EventStream)){throw new Exception("not an EventStream : "+event)}};assertFunction=function(f){return assert("not a function : "+f,isFunction(f))};isFunction=function(f){return typeof f==="function"};isArray=function(xs){return xs instanceof Array};isObservable=function(x){return x instanceof Observable};assertArray=function(xs){if(!isArray(xs)){throw new Exception("not an array : "+xs)}};assertNoArguments=function(args){return assert("no arguments supported",args.length===0)};assertString=function(x){if(typeof x!=="string"){throw new Exception("not a string : "+x)}};partiallyApplied=function(f,applied){return function(){var args;args=1<=arguments.length?__slice.call(arguments,0):[];return f.apply(null,applied.concat(args))}};makeSpawner=function(args){if(args.length===1&&isObservable(args[0])){return _.always(args[0])}else{return makeFunctionArgs(args)}};makeFunctionArgs=function(args){args=Array.prototype.slice.call(args);return makeFunction_.apply(null,args)};makeFunction_=withMethodCallSupport(function(){var args,f;f=arguments[0],args=2<=arguments.length?__slice.call(arguments,1):[];if(isFunction(f)){if(args.length){return partiallyApplied(f,args)}else{return f}}else if(isFieldKey(f)){return toFieldExtractor(f,args)}else{return _.always(f)}});makeFunction=function(f,args){return makeFunction_.apply(null,[f].concat(__slice.call(args)))};makeObservable=function(x){if(isObservable(x)){return x}else{return Bacon.once(x)}};isFieldKey=function(f){return typeof f==="string"&&f.length>1&&f.charAt(0)==="."};Bacon.isFieldKey=isFieldKey;toFieldExtractor=function(f,args){var partFuncs,parts;parts=f.slice(1).split(".");partFuncs=_.map(toSimpleExtractor(args),parts);return function(value){var _i,_len;for(_i=0,_len=partFuncs.length;_i<_len;_i++){f=partFuncs[_i];value=f(value)}return value}};toSimpleExtractor=function(args){return function(key){return function(value){var fieldValue;if(value==null){return void 0}else{fieldValue=value[key];if(isFunction(fieldValue)){return fieldValue.apply(value,args)}else{return fieldValue}}}}};toFieldKey=function(f){return f.slice(1)};toCombinator=function(f){var key;if(isFunction(f)){return f}else if(isFieldKey(f)){key=toFieldKey(f);return function(left,right){return left[key](right)}}else{return assert("not a function or a field key: "+f,false)}};toOption=function(v){if(v instanceof Some||v===None){return v}else{return new Some(v)}};_={indexOf:Array.prototype.indexOf?function(xs,x){return xs.indexOf(x)}:function(xs,x){var i,y,_i,_len;for(i=_i=0,_len=xs.length;_i<_len;i=++_i){y=xs[i];if(x===y){return i}}return-1},indexWhere:function(xs,f){var i,y,_i,_len;for(i=_i=0,_len=xs.length;_i<_len;i=++_i){y=xs[i];if(f(y)){return i}}return-1},head:function(xs){return xs[0]},always:function(x){return function(){return x}},negate:function(f){return function(x){return!f(x)}},empty:function(xs){return xs.length===0},tail:function(xs){return xs.slice(1,xs.length)},filter:function(f,xs){var filtered,x,_i,_len;filtered=[];for(_i=0,_len=xs.length;_i<_len;_i++){x=xs[_i];if(f(x)){filtered.push(x)}}return filtered},map:function(f,xs){var x,_i,_len,_results;_results=[];for(_i=0,_len=xs.length;_i<_len;_i++){x=xs[_i];_results.push(f(x))}return _results},each:function(xs,f){var key,value;for(key in xs){value=xs[key];f(key,value)}return void 0},toArray:function(xs){if(isArray(xs)){return xs}else{return[xs]}},contains:function(xs,x){return _.indexOf(xs,x)!==-1},id:function(x){return x},last:function(xs){return xs[xs.length-1]},all:function(xs,f){var x,_i,_len;if(f==null){f=_.id}for(_i=0,_len=xs.length;_i<_len;_i++){x=xs[_i];if(!f(x)){return false}}return true},any:function(xs,f){var x,_i,_len;if(f==null){f=_.id}for(_i=0,_len=xs.length;_i<_len;_i++){x=xs[_i];if(f(x)){return true}}return false},without:function(x,xs){return _.filter(function(y){return y!==x},xs)},remove:function(x,xs){var i;i=_.indexOf(xs,x);if(i>=0){return xs.splice(i,1)}},fold:function(xs,seed,f){var x,_i,_len;for(_i=0,_len=xs.length;_i<_len;_i++){x=xs[_i];seed=f(seed,x)}return seed},flatMap:function(f,xs){return _.fold(xs,[],function(ys,x){return ys.concat(f(x))})},cached:function(f){var value;value=None;return function(){if(value===None){value=f();f=void 0}return value}},toString:function(obj){var ex,internals,key,value;try{recursionDepth++;if(obj==null){return"undefined"}else if(isFunction(obj)){return"function"}else if(isArray(obj)){if(recursionDepth>5){return"[..]"}return"["+_.map(_.toString,obj).toString()+"]"}else if((obj!=null?obj.toString:void 0)!=null&&obj.toString!==Object.prototype.toString){return obj.toString()}else if(typeof obj==="object"){if(recursionDepth>5){return"{..}"}internals=function(){var _results;_results=[];for(key in obj){if(!__hasProp.call(obj,key))continue;value=function(){try{return obj[key]}catch(_error){ex=_error;return ex}}();_results.push(_.toString(key)+":"+_.toString(value))}return _results}();return"{"+internals+"}"}else{return obj}}finally{recursionDepth--}}};recursionDepth=0;Bacon._=_;Bacon.scheduler={setTimeout:function(f,d){return setTimeout(f,d)},setInterval:function(f,i){return setInterval(f,i)},clearInterval:function(id){return clearInterval(id)},now:function(){return(new Date).getTime()}};if(typeof define!=="undefined"&&define!==null&&define.amd!=null){define([],function(){return Bacon});this.Bacon=Bacon}else if(typeof module!=="undefined"&&module!==null&&module.exports!=null){module.exports=Bacon;Bacon.Bacon=Bacon}else{this.Bacon=Bacon}}).call(this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}]},{},[]);require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({lodash:[function(require,module,exports){(function(global){(function(){var undefined;var arrayPool=[],objectPool=[];var idCounter=0;var keyPrefix=+new Date+"";var largeArraySize=75;var maxPoolSize=40;var whitespace=" \f "+"\n\r\u2028\u2029"+" ";var reEmptyStringLeading=/\b__p \+= '';/g,reEmptyStringMiddle=/\b(__p \+=) '' \+/g,reEmptyStringTrailing=/(__e\(.*?\)|\b__t\)) \+\n'';/g;var reEsTemplate=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;var reFlags=/\w*$/;var reFuncName=/^\s*function[ \n\r\t]+\w/;var reInterpolate=/<%=([\s\S]+?)%>/g;var reLeadingSpacesAndZeros=RegExp("^["+whitespace+"]*0+(?=.$)");var reNoMatch=/($^)/;var reThis=/\bthis\b/;var reUnescapedString=/['\n\r\t\u2028\u2029\\]/g;var contextProps=["Array","Boolean","Date","Function","Math","Number","Object","RegExp","String","_","attachEvent","clearTimeout","isFinite","isNaN","parseInt","setTimeout"];var templateCounter=0;var argsClass="[object Arguments]",arrayClass="[object Array]",boolClass="[object Boolean]",dateClass="[object Date]",funcClass="[object Function]",numberClass="[object Number]",objectClass="[object Object]",regexpClass="[object RegExp]",stringClass="[object String]";var cloneableClasses={};cloneableClasses[funcClass]=false;cloneableClasses[argsClass]=cloneableClasses[arrayClass]=cloneableClasses[boolClass]=cloneableClasses[dateClass]=cloneableClasses[numberClass]=cloneableClasses[objectClass]=cloneableClasses[regexpClass]=cloneableClasses[stringClass]=true;var debounceOptions={leading:false,maxWait:0,trailing:false};var descriptor={configurable:false,enumerable:false,value:null,writable:false};var objectTypes={"boolean":false,"function":true,object:true,number:false,string:false,undefined:false};var stringEscapes={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};var root=objectTypes[typeof window]&&window||this;var freeExports=objectTypes[typeof exports]&&exports&&!exports.nodeType&&exports;var freeModule=objectTypes[typeof module]&&module&&!module.nodeType&&module;var moduleExports=freeModule&&freeModule.exports===freeExports&&freeExports;var freeGlobal=objectTypes[typeof global]&&global;if(freeGlobal&&(freeGlobal.global===freeGlobal||freeGlobal.window===freeGlobal)){root=freeGlobal}function baseIndexOf(array,value,fromIndex){var index=(fromIndex||0)-1,length=array?array.length:0;while(++index<length){if(array[index]===value){return index}}return-1}function cacheIndexOf(cache,value){var type=typeof value;cache=cache.cache;if(type=="boolean"||value==null){return cache[value]?0:-1}if(type!="number"&&type!="string"){type="object"}var key=type=="number"?value:keyPrefix+value;cache=(cache=cache[type])&&cache[key];return type=="object"?cache&&baseIndexOf(cache,value)>-1?0:-1:cache?0:-1}function cachePush(value){var cache=this.cache,type=typeof value;if(type=="boolean"||value==null){cache[value]=true}else{if(type!="number"&&type!="string"){type="object"}var key=type=="number"?value:keyPrefix+value,typeCache=cache[type]||(cache[type]={});if(type=="object"){(typeCache[key]||(typeCache[key]=[])).push(value)}else{typeCache[key]=true}}}function charAtCallback(value){return value.charCodeAt(0)}function compareAscending(a,b){var ac=a.criteria,bc=b.criteria,index=-1,length=ac.length;while(++index<length){var value=ac[index],other=bc[index];if(value!==other){if(value>other||typeof value=="undefined"){return 1 | |
| }if(value<other||typeof other=="undefined"){return-1}}}return a.index-b.index}function createCache(array){var index=-1,length=array.length,first=array[0],mid=array[length/2|0],last=array[length-1];if(first&&typeof first=="object"&&mid&&typeof mid=="object"&&last&&typeof last=="object"){return false}var cache=getObject();cache["false"]=cache["null"]=cache["true"]=cache["undefined"]=false;var result=getObject();result.array=array;result.cache=cache;result.push=cachePush;while(++index<length){result.push(array[index])}return result}function escapeStringChar(match){return"\\"+stringEscapes[match]}function getArray(){return arrayPool.pop()||[]}function getObject(){return objectPool.pop()||{array:null,cache:null,criteria:null,"false":false,index:0,"null":false,number:null,object:null,push:null,string:null,"true":false,undefined:false,value:null}}function releaseArray(array){array.length=0;if(arrayPool.length<maxPoolSize){arrayPool.push(array)}}function releaseObject(object){var cache=object.cache;if(cache){releaseObject(cache)}object.array=object.cache=object.criteria=object.object=object.number=object.string=object.value=null;if(objectPool.length<maxPoolSize){objectPool.push(object)}}function slice(array,start,end){start||(start=0);if(typeof end=="undefined"){end=array?array.length:0}var index=-1,length=end-start||0,result=Array(length<0?0:length);while(++index<length){result[index]=array[start+index]}return result}function runInContext(context){context=context?_.defaults(root.Object(),context,_.pick(root,contextProps)):root;var Array=context.Array,Boolean=context.Boolean,Date=context.Date,Function=context.Function,Math=context.Math,Number=context.Number,Object=context.Object,RegExp=context.RegExp,String=context.String,TypeError=context.TypeError;var arrayRef=[];var objectProto=Object.prototype;var oldDash=context._;var toString=objectProto.toString;var reNative=RegExp("^"+String(toString).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$");var ceil=Math.ceil,clearTimeout=context.clearTimeout,floor=Math.floor,fnToString=Function.prototype.toString,getPrototypeOf=isNative(getPrototypeOf=Object.getPrototypeOf)&&getPrototypeOf,hasOwnProperty=objectProto.hasOwnProperty,push=arrayRef.push,setTimeout=context.setTimeout,splice=arrayRef.splice,unshift=arrayRef.unshift;var defineProperty=function(){try{var o={},func=isNative(func=Object.defineProperty)&&func,result=func(o,o,o)&&func}catch(e){}return result}();var nativeCreate=isNative(nativeCreate=Object.create)&&nativeCreate,nativeIsArray=isNative(nativeIsArray=Array.isArray)&&nativeIsArray,nativeIsFinite=context.isFinite,nativeIsNaN=context.isNaN,nativeKeys=isNative(nativeKeys=Object.keys)&&nativeKeys,nativeMax=Math.max,nativeMin=Math.min,nativeParseInt=context.parseInt,nativeRandom=Math.random;var ctorByClass={};ctorByClass[arrayClass]=Array;ctorByClass[boolClass]=Boolean;ctorByClass[dateClass]=Date;ctorByClass[funcClass]=Function;ctorByClass[objectClass]=Object;ctorByClass[numberClass]=Number;ctorByClass[regexpClass]=RegExp;ctorByClass[stringClass]=String;function lodash(value){return value&&typeof value=="object"&&!isArray(value)&&hasOwnProperty.call(value,"__wrapped__")?value:new lodashWrapper(value)}function lodashWrapper(value,chainAll){this.__chain__=!!chainAll;this.__wrapped__=value}lodashWrapper.prototype=lodash.prototype;var support=lodash.support={};support.funcDecomp=!isNative(context.WinRTError)&&reThis.test(runInContext);support.funcNames=typeof Function.name=="string";lodash.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:reInterpolate,variable:"",imports:{_:lodash}};function baseBind(bindData){var func=bindData[0],partialArgs=bindData[2],thisArg=bindData[4];function bound(){if(partialArgs){var args=slice(partialArgs);push.apply(args,arguments)}if(this instanceof bound){var thisBinding=baseCreate(func.prototype),result=func.apply(thisBinding,args||arguments);return isObject(result)?result:thisBinding}return func.apply(thisArg,args||arguments)}setBindData(bound,bindData);return bound}function baseClone(value,isDeep,callback,stackA,stackB){if(callback){var result=callback(value);if(typeof result!="undefined"){return result}}var isObj=isObject(value);if(isObj){var className=toString.call(value);if(!cloneableClasses[className]){return value}var ctor=ctorByClass[className];switch(className){case boolClass:case dateClass:return new ctor(+value);case numberClass:case stringClass:return new ctor(value);case regexpClass:result=ctor(value.source,reFlags.exec(value));result.lastIndex=value.lastIndex;return result}}else{return value}var isArr=isArray(value);if(isDeep){var initedStack=!stackA;stackA||(stackA=getArray());stackB||(stackB=getArray());var length=stackA.length;while(length--){if(stackA[length]==value){return stackB[length]}}result=isArr?ctor(value.length):{}}else{result=isArr?slice(value):assign({},value)}if(isArr){if(hasOwnProperty.call(value,"index")){result.index=value.index}if(hasOwnProperty.call(value,"input")){result.input=value.input}}if(!isDeep){return result}stackA.push(value);stackB.push(result);(isArr?forEach:forOwn)(value,function(objValue,key){result[key]=baseClone(objValue,isDeep,callback,stackA,stackB)});if(initedStack){releaseArray(stackA);releaseArray(stackB)}return result}function baseCreate(prototype,properties){return isObject(prototype)?nativeCreate(prototype):{}}if(!nativeCreate){baseCreate=function(){function Object(){}return function(prototype){if(isObject(prototype)){Object.prototype=prototype;var result=new Object;Object.prototype=null}return result||context.Object()}}()}function baseCreateCallback(func,thisArg,argCount){if(typeof func!="function"){return identity}if(typeof thisArg=="undefined"||!("prototype"in func)){return func}var bindData=func.__bindData__;if(typeof bindData=="undefined"){if(support.funcNames){bindData=!func.name}bindData=bindData||!support.funcDecomp;if(!bindData){var source=fnToString.call(func);if(!support.funcNames){bindData=!reFuncName.test(source)}if(!bindData){bindData=reThis.test(source);setBindData(func,bindData)}}}if(bindData===false||bindData!==true&&bindData[1]&1){return func}switch(argCount){case 1:return function(value){return func.call(thisArg,value)};case 2:return function(a,b){return func.call(thisArg,a,b)};case 3:return function(value,index,collection){return func.call(thisArg,value,index,collection)};case 4:return function(accumulator,value,index,collection){return func.call(thisArg,accumulator,value,index,collection)}}return bind(func,thisArg)}function baseCreateWrapper(bindData){var func=bindData[0],bitmask=bindData[1],partialArgs=bindData[2],partialRightArgs=bindData[3],thisArg=bindData[4],arity=bindData[5];var isBind=bitmask&1,isBindKey=bitmask&2,isCurry=bitmask&4,isCurryBound=bitmask&8,key=func;function bound(){var thisBinding=isBind?thisArg:this;if(partialArgs){var args=slice(partialArgs);push.apply(args,arguments)}if(partialRightArgs||isCurry){args||(args=slice(arguments));if(partialRightArgs){push.apply(args,partialRightArgs)}if(isCurry&&args.length<arity){bitmask|=16&~32;return baseCreateWrapper([func,isCurryBound?bitmask:bitmask&~3,args,null,thisArg,arity])}}args||(args=arguments);if(isBindKey){func=thisBinding[key]}if(this instanceof bound){thisBinding=baseCreate(func.prototype);var result=func.apply(thisBinding,args);return isObject(result)?result:thisBinding}return func.apply(thisBinding,args)}setBindData(bound,bindData);return bound}function baseDifference(array,values){var index=-1,indexOf=getIndexOf(),length=array?array.length:0,isLarge=length>=largeArraySize&&indexOf===baseIndexOf,result=[];if(isLarge){var cache=createCache(values);if(cache){indexOf=cacheIndexOf;values=cache}else{isLarge=false}}while(++index<length){var value=array[index];if(indexOf(values,value)<0){result.push(value)}}if(isLarge){releaseObject(values)}return result}function baseFlatten(array,isShallow,isStrict,fromIndex){var index=(fromIndex||0)-1,length=array?array.length:0,result=[];while(++index<length){var value=array[index];if(value&&typeof value=="object"&&typeof value.length=="number"&&(isArray(value)||isArguments(value))){if(!isShallow){value=baseFlatten(value,isShallow,isStrict)}var valIndex=-1,valLength=value.length,resIndex=result.length;result.length+=valLength;while(++valIndex<valLength){result[resIndex++]=value[valIndex]}}else if(!isStrict){result.push(value)}}return result}function baseIsEqual(a,b,callback,isWhere,stackA,stackB){if(callback){var result=callback(a,b);if(typeof result!="undefined"){return!!result}}if(a===b){return a!==0||1/a==1/b}var type=typeof a,otherType=typeof b;if(a===a&&!(a&&objectTypes[type])&&!(b&&objectTypes[otherType])){return false}if(a==null||b==null){return a===b}var className=toString.call(a),otherClass=toString.call(b);if(className==argsClass){className=objectClass}if(otherClass==argsClass){otherClass=objectClass}if(className!=otherClass){return false}switch(className){case boolClass:case dateClass:return+a==+b;case numberClass:return a!=+a?b!=+b:a==0?1/a==1/b:a==+b;case regexpClass:case stringClass:return a==String(b)}var isArr=className==arrayClass;if(!isArr){var aWrapped=hasOwnProperty.call(a,"__wrapped__"),bWrapped=hasOwnProperty.call(b,"__wrapped__");if(aWrapped||bWrapped){return baseIsEqual(aWrapped?a.__wrapped__:a,bWrapped?b.__wrapped__:b,callback,isWhere,stackA,stackB)}if(className!=objectClass){return false}var ctorA=a.constructor,ctorB=b.constructor;if(ctorA!=ctorB&&!(isFunction(ctorA)&&ctorA instanceof ctorA&&isFunction(ctorB)&&ctorB instanceof ctorB)&&("constructor"in a&&"constructor"in b)){return false}}var initedStack=!stackA;stackA||(stackA=getArray());stackB||(stackB=getArray());var length=stackA.length;while(length--){if(stackA[length]==a){return stackB[length]==b}}var size=0;result=true;stackA.push(a);stackB.push(b);if(isArr){length=a.length;size=b.length;result=size==length;if(result||isWhere){while(size--){var index=length,value=b[size];if(isWhere){while(index--){if(result=baseIsEqual(a[index],value,callback,isWhere,stackA,stackB)){break}}}else if(!(result=baseIsEqual(a[size],value,callback,isWhere,stackA,stackB))){break}}}}else{forIn(b,function(value,key,b){if(hasOwnProperty.call(b,key)){size++;return result=hasOwnProperty.call(a,key)&&baseIsEqual(a[key],value,callback,isWhere,stackA,stackB)}});if(result&&!isWhere){forIn(a,function(value,key,a){if(hasOwnProperty.call(a,key)){return result=--size>-1}})}}stackA.pop();stackB.pop();if(initedStack){releaseArray(stackA);releaseArray(stackB)}return result}function baseMerge(object,source,callback,stackA,stackB){(isArray(source)?forEach:forOwn)(source,function(source,key){var found,isArr,result=source,value=object[key];if(source&&((isArr=isArray(source))||isPlainObject(source))){var stackLength=stackA.length;while(stackLength--){if(found=stackA[stackLength]==source){value=stackB[stackLength];break}}if(!found){var isShallow;if(callback){result=callback(value,source);if(isShallow=typeof result!="undefined"){value=result}}if(!isShallow){value=isArr?isArray(value)?value:[]:isPlainObject(value)?value:{}}stackA.push(source);stackB.push(value);if(!isShallow){baseMerge(value,source,callback,stackA,stackB)}}}else{if(callback){result=callback(value,source);if(typeof result=="undefined"){result=source}}if(typeof result!="undefined"){value=result}}object[key]=value})}function baseRandom(min,max){return min+floor(nativeRandom()*(max-min+1))}function baseUniq(array,isSorted,callback){var index=-1,indexOf=getIndexOf(),length=array?array.length:0,result=[];var isLarge=!isSorted&&length>=largeArraySize&&indexOf===baseIndexOf,seen=callback||isLarge?getArray():result;if(isLarge){var cache=createCache(seen);indexOf=cacheIndexOf;seen=cache}while(++index<length){var value=array[index],computed=callback?callback(value,index,array):value;if(isSorted?!index||seen[seen.length-1]!==computed:indexOf(seen,computed)<0){if(callback||isLarge){seen.push(computed)}result.push(value)}}if(isLarge){releaseArray(seen.array);releaseObject(seen)}else if(callback){releaseArray(seen)}return result}function createAggregator(setter){return function(collection,callback,thisArg){var result={};callback=lodash.createCallback(callback,thisArg,3);var index=-1,length=collection?collection.length:0;if(typeof length=="number"){while(++index<length){var value=collection[index];setter(result,value,callback(value,index,collection),collection)}}else{forOwn(collection,function(value,key,collection){setter(result,value,callback(value,key,collection),collection)})}return result}}function createWrapper(func,bitmask,partialArgs,partialRightArgs,thisArg,arity){var isBind=bitmask&1,isBindKey=bitmask&2,isCurry=bitmask&4,isCurryBound=bitmask&8,isPartial=bitmask&16,isPartialRight=bitmask&32;if(!isBindKey&&!isFunction(func)){throw new TypeError}if(isPartial&&!partialArgs.length){bitmask&=~16;isPartial=partialArgs=false}if(isPartialRight&&!partialRightArgs.length){bitmask&=~32;isPartialRight=partialRightArgs=false}var bindData=func&&func.__bindData__;if(bindData&&bindData!==true){bindData=slice(bindData);if(bindData[2]){bindData[2]=slice(bindData[2])}if(bindData[3]){bindData[3]=slice(bindData[3])}if(isBind&&!(bindData[1]&1)){bindData[4]=thisArg}if(!isBind&&bindData[1]&1){bitmask|=8}if(isCurry&&!(bindData[1]&4)){bindData[5]=arity}if(isPartial){push.apply(bindData[2]||(bindData[2]=[]),partialArgs)}if(isPartialRight){unshift.apply(bindData[3]||(bindData[3]=[]),partialRightArgs)}bindData[1]|=bitmask;return createWrapper.apply(null,bindData)}var creater=bitmask==1||bitmask===17?baseBind:baseCreateWrapper;return creater([func,bitmask,partialArgs,partialRightArgs,thisArg,arity])}function escapeHtmlChar(match){return htmlEscapes[match]}function getIndexOf(){var result=(result=lodash.indexOf)===indexOf?baseIndexOf:result;return result}function isNative(value){return typeof value=="function"&&reNative.test(value)}var setBindData=!defineProperty?noop:function(func,value){descriptor.value=value;defineProperty(func,"__bindData__",descriptor)};function shimIsPlainObject(value){var ctor,result;if(!(value&&toString.call(value)==objectClass)||(ctor=value.constructor,isFunction(ctor)&&!(ctor instanceof ctor))){return false}forIn(value,function(value,key){result=key});return typeof result=="undefined"||hasOwnProperty.call(value,result)}function unescapeHtmlChar(match){return htmlUnescapes[match]}function isArguments(value){return value&&typeof value=="object"&&typeof value.length=="number"&&toString.call(value)==argsClass||false}var isArray=nativeIsArray||function(value){return value&&typeof value=="object"&&typeof value.length=="number"&&toString.call(value)==arrayClass||false};var shimKeys=function(object){var index,iterable=object,result=[];if(!iterable)return result;if(!objectTypes[typeof object])return result;for(index in iterable){if(hasOwnProperty.call(iterable,index)){result.push(index)}}return result};var keys=!nativeKeys?shimKeys:function(object){if(!isObject(object)){return[]}return nativeKeys(object)};var htmlEscapes={"&":"&","<":"<",">":">",'"':""","'":"'"};var htmlUnescapes=invert(htmlEscapes);var reEscapedHtml=RegExp("("+keys(htmlUnescapes).join("|")+")","g"),reUnescapedHtml=RegExp("["+keys(htmlEscapes).join("")+"]","g");var assign=function(object,source,guard){var index,iterable=object,result=iterable;if(!iterable)return result;var args=arguments,argsIndex=0,argsLength=typeof guard=="number"?2:args.length;if(argsLength>3&&typeof args[argsLength-2]=="function"){var callback=baseCreateCallback(args[--argsLength-1],args[argsLength--],2)}else if(argsLength>2&&typeof args[argsLength-1]=="function"){callback=args[--argsLength]}while(++argsIndex<argsLength){iterable=args[argsIndex];if(iterable&&objectTypes[typeof iterable]){var ownIndex=-1,ownProps=objectTypes[typeof iterable]&&keys(iterable),length=ownProps?ownProps.length:0;while(++ownIndex<length){index=ownProps[ownIndex];result[index]=callback?callback(result[index],iterable[index]):iterable[index]}}}return result};function clone(value,isDeep,callback,thisArg){if(typeof isDeep!="boolean"&&isDeep!=null){thisArg=callback;callback=isDeep;isDeep=false}return baseClone(value,isDeep,typeof callback=="function"&&baseCreateCallback(callback,thisArg,1))}function cloneDeep(value,callback,thisArg){return baseClone(value,true,typeof callback=="function"&&baseCreateCallback(callback,thisArg,1))}function create(prototype,properties){var result=baseCreate(prototype);return properties?assign(result,properties):result}var defaults=function(object,source,guard){var index,iterable=object,result=iterable;if(!iterable)return result;var args=arguments,argsIndex=0,argsLength=typeof guard=="number"?2:args.length;while(++argsIndex<argsLength){iterable=args[argsIndex];if(iterable&&objectTypes[typeof iterable]){var ownIndex=-1,ownProps=objectTypes[typeof iterable]&&keys(iterable),length=ownProps?ownProps.length:0;while(++ownIndex<length){index=ownProps[ownIndex];if(typeof result[index]=="undefined")result[index]=iterable[index]}}}return result};function findKey(object,callback,thisArg){var result;callback=lodash.createCallback(callback,thisArg,3);forOwn(object,function(value,key,object){if(callback(value,key,object)){result=key;return false}});return result}function findLastKey(object,callback,thisArg){var result;callback=lodash.createCallback(callback,thisArg,3);forOwnRight(object,function(value,key,object){if(callback(value,key,object)){result=key;return false}});return result}var forIn=function(collection,callback,thisArg){var index,iterable=collection,result=iterable;if(!iterable)return result;if(!objectTypes[typeof iterable])return result;callback=callback&&typeof thisArg=="undefined"?callback:baseCreateCallback(callback,thisArg,3);for(index in iterable){if(callback(iterable[index],index,collection)===false)return result}return result};function forInRight(object,callback,thisArg){var pairs=[];forIn(object,function(value,key){pairs.push(key,value)});var length=pairs.length;callback=baseCreateCallback(callback,thisArg,3);while(length--){if(callback(pairs[length--],pairs[length],object)===false){break}}return object}var forOwn=function(collection,callback,thisArg){var index,iterable=collection,result=iterable;if(!iterable)return result;if(!objectTypes[typeof iterable])return result;callback=callback&&typeof thisArg=="undefined"?callback:baseCreateCallback(callback,thisArg,3);var ownIndex=-1,ownProps=objectTypes[typeof iterable]&&keys(iterable),length=ownProps?ownProps.length:0;while(++ownIndex<length){index=ownProps[ownIndex];if(callback(iterable[index],index,collection)===false)return result}return result};function forOwnRight(object,callback,thisArg){var props=keys(object),length=props.length;callback=baseCreateCallback(callback,thisArg,3);while(length--){var key=props[length];if(callback(object[key],key,object)===false){break}}return object}function functions(object){var result=[];forIn(object,function(value,key){if(isFunction(value)){result.push(key)}});return result.sort()}function has(object,key){return object?hasOwnProperty.call(object,key):false}function invert(object){var index=-1,props=keys(object),length=props.length,result={};while(++index<length){var key=props[index];result[object[key]]=key}return result}function isBoolean(value){return value===true||value===false||value&&typeof value=="object"&&toString.call(value)==boolClass||false}function isDate(value){return value&&typeof value=="object"&&toString.call(value)==dateClass||false}function isElement(value){return value&&value.nodeType===1||false}function isEmpty(value){var result=true;if(!value){return result}var className=toString.call(value),length=value.length;if(className==arrayClass||className==stringClass||className==argsClass||className==objectClass&&typeof length=="number"&&isFunction(value.splice)){return!length}forOwn(value,function(){return result=false});return result}function isEqual(a,b,callback,thisArg){return baseIsEqual(a,b,typeof callback=="function"&&baseCreateCallback(callback,thisArg,2))}function isFinite(value){return nativeIsFinite(value)&&!nativeIsNaN(parseFloat(value))}function isFunction(value){return typeof value=="function"}function isObject(value){return!!(value&&objectTypes[typeof value])}function isNaN(value){return isNumber(value)&&value!=+value}function isNull(value){return value===null}function isNumber(value){return typeof value=="number"||value&&typeof value=="object"&&toString.call(value)==numberClass||false}var isPlainObject=!getPrototypeOf?shimIsPlainObject:function(value){if(!(value&&toString.call(value)==objectClass)){return false}var valueOf=value.valueOf,objProto=isNative(valueOf)&&(objProto=getPrototypeOf(valueOf))&&getPrototypeOf(objProto);return objProto?value==objProto||getPrototypeOf(value)==objProto:shimIsPlainObject(value)};function isRegExp(value){return value&&typeof value=="object"&&toString.call(value)==regexpClass||false}function isString(value){return typeof value=="string"||value&&typeof value=="object"&&toString.call(value)==stringClass||false}function isUndefined(value){return typeof value=="undefined"}function mapValues(object,callback,thisArg){var result={};callback=lodash.createCallback(callback,thisArg,3);forOwn(object,function(value,key,object){result[key]=callback(value,key,object)});return result}function merge(object){var args=arguments,length=2;if(!isObject(object)){return object}if(typeof args[2]!="number"){length=args.length}if(length>3&&typeof args[length-2]=="function"){var callback=baseCreateCallback(args[--length-1],args[length--],2)}else if(length>2&&typeof args[length-1]=="function"){callback=args[--length]}var sources=slice(arguments,1,length),index=-1,stackA=getArray(),stackB=getArray();while(++index<length){baseMerge(object,sources[index],callback,stackA,stackB)}releaseArray(stackA);releaseArray(stackB);return object}function omit(object,callback,thisArg){var result={};if(typeof callback!="function"){var props=[];forIn(object,function(value,key){props.push(key)});props=baseDifference(props,baseFlatten(arguments,true,false,1));var index=-1,length=props.length;while(++index<length){var key=props[index];result[key]=object[key]}}else{callback=lodash.createCallback(callback,thisArg,3);forIn(object,function(value,key,object){if(!callback(value,key,object)){result[key]=value}})}return result}function pairs(object){var index=-1,props=keys(object),length=props.length,result=Array(length);while(++index<length){var key=props[index];result[index]=[key,object[key]]}return result}function pick(object,callback,thisArg){var result={};if(typeof callback!="function"){var index=-1,props=baseFlatten(arguments,true,false,1),length=isObject(object)?props.length:0;while(++index<length){var key=props[index];if(key in object){result[key]=object[key]}}}else{callback=lodash.createCallback(callback,thisArg,3);forIn(object,function(value,key,object){if(callback(value,key,object)){result[key]=value}})}return result}function transform(object,callback,accumulator,thisArg){var isArr=isArray(object);if(accumulator==null){if(isArr){accumulator=[]}else{var ctor=object&&object.constructor,proto=ctor&&ctor.prototype;accumulator=baseCreate(proto)}}if(callback){callback=lodash.createCallback(callback,thisArg,4);(isArr?forEach:forOwn)(object,function(value,index,object){return callback(accumulator,value,index,object)})}return accumulator}function values(object){var index=-1,props=keys(object),length=props.length,result=Array(length);while(++index<length){result[index]=object[props[index]]}return result}function at(collection){var args=arguments,index=-1,props=baseFlatten(args,true,false,1),length=args[2]&&args[2][args[1]]===collection?1:props.length,result=Array(length);while(++index<length){result[index]=collection[props[index]]}return result}function contains(collection,target,fromIndex){var index=-1,indexOf=getIndexOf(),length=collection?collection.length:0,result=false;fromIndex=(fromIndex<0?nativeMax(0,length+fromIndex):fromIndex)||0;if(isArray(collection)){result=indexOf(collection,target,fromIndex)>-1}else if(typeof length=="number"){result=(isString(collection)?collection.indexOf(target,fromIndex):indexOf(collection,target,fromIndex))>-1}else{forOwn(collection,function(value){if(++index>=fromIndex){return!(result=value===target)}})}return result}var countBy=createAggregator(function(result,value,key){hasOwnProperty.call(result,key)?result[key]++:result[key]=1});function every(collection,callback,thisArg){var result=true;callback=lodash.createCallback(callback,thisArg,3);var index=-1,length=collection?collection.length:0;if(typeof length=="number"){while(++index<length){if(!(result=!!callback(collection[index],index,collection))){break}}}else{forOwn(collection,function(value,index,collection){return result=!!callback(value,index,collection)})}return result}function filter(collection,callback,thisArg){var result=[];callback=lodash.createCallback(callback,thisArg,3);var index=-1,length=collection?collection.length:0;if(typeof length=="number"){while(++index<length){var value=collection[index];if(callback(value,index,collection)){result.push(value)}}}else{forOwn(collection,function(value,index,collection){if(callback(value,index,collection)){result.push(value)}})}return result}function find(collection,callback,thisArg){callback=lodash.createCallback(callback,thisArg,3);var index=-1,length=collection?collection.length:0;if(typeof length=="number"){while(++index<length){var value=collection[index];if(callback(value,index,collection)){return value}}}else{var result;forOwn(collection,function(value,index,collection){if(callback(value,index,collection)){result=value;return false}});return result}}function findLast(collection,callback,thisArg){var result;callback=lodash.createCallback(callback,thisArg,3);forEachRight(collection,function(value,index,collection){if(callback(value,index,collection)){result=value;return false}});return result}function forEach(collection,callback,thisArg){var index=-1,length=collection?collection.length:0;callback=callback&&typeof thisArg=="undefined"?callback:baseCreateCallback(callback,thisArg,3);if(typeof length=="number"){while(++index<length){if(callback(collection[index],index,collection)===false){break}}}else{forOwn(collection,callback)}return collection}function forEachRight(collection,callback,thisArg){var length=collection?collection.length:0;callback=callback&&typeof thisArg=="undefined"?callback:baseCreateCallback(callback,thisArg,3);if(typeof length=="number"){while(length--){if(callback(collection[length],length,collection)===false){break}}}else{var props=keys(collection);length=props.length;forOwn(collection,function(value,key,collection){key=props?props[--length]:--length;return callback(collection[key],key,collection)})}return collection}var groupBy=createAggregator(function(result,value,key){(hasOwnProperty.call(result,key)?result[key]:result[key]=[]).push(value)});var indexBy=createAggregator(function(result,value,key){result[key]=value});function invoke(collection,methodName){var args=slice(arguments,2),index=-1,isFunc=typeof methodName=="function",length=collection?collection.length:0,result=Array(typeof length=="number"?length:0);forEach(collection,function(value){result[++index]=(isFunc?methodName:value[methodName]).apply(value,args)});return result}function map(collection,callback,thisArg){var index=-1,length=collection?collection.length:0;callback=lodash.createCallback(callback,thisArg,3);if(typeof length=="number"){var result=Array(length);while(++index<length){result[index]=callback(collection[index],index,collection)}}else{result=[];forOwn(collection,function(value,key,collection){result[++index]=callback(value,key,collection)})}return result}function max(collection,callback,thisArg){var computed=-Infinity,result=computed;if(typeof callback!="function"&&thisArg&&thisArg[callback]===collection){callback=null}if(callback==null&&isArray(collection)){var index=-1,length=collection.length;while(++index<length){var value=collection[index];if(value>result){result=value}}}else{callback=callback==null&&isString(collection)?charAtCallback:lodash.createCallback(callback,thisArg,3);forEach(collection,function(value,index,collection){var current=callback(value,index,collection);if(current>computed){computed=current;result=value}})}return result}function min(collection,callback,thisArg){var computed=Infinity,result=computed;if(typeof callback!="function"&&thisArg&&thisArg[callback]===collection){callback=null}if(callback==null&&isArray(collection)){var index=-1,length=collection.length;while(++index<length){var value=collection[index];if(value<result){result=value}}}else{callback=callback==null&&isString(collection)?charAtCallback:lodash.createCallback(callback,thisArg,3);forEach(collection,function(value,index,collection){var current=callback(value,index,collection);if(current<computed){computed=current;result=value}})}return result}var pluck=map;function reduce(collection,callback,accumulator,thisArg){if(!collection)return accumulator;var noaccum=arguments.length<3;callback=lodash.createCallback(callback,thisArg,4);var index=-1,length=collection.length;if(typeof length=="number"){if(noaccum){accumulator=collection[++index]}while(++index<length){accumulator=callback(accumulator,collection[index],index,collection)}}else{forOwn(collection,function(value,index,collection){accumulator=noaccum?(noaccum=false,value):callback(accumulator,value,index,collection)})}return accumulator}function reduceRight(collection,callback,accumulator,thisArg){var noaccum=arguments.length<3;callback=lodash.createCallback(callback,thisArg,4);forEachRight(collection,function(value,index,collection){accumulator=noaccum?(noaccum=false,value):callback(accumulator,value,index,collection)});return accumulator}function reject(collection,callback,thisArg){callback=lodash.createCallback(callback,thisArg,3);return filter(collection,function(value,index,collection){return!callback(value,index,collection)})}function sample(collection,n,guard){if(collection&&typeof collection.length!="number"){collection=values(collection)}if(n==null||guard){return collection?collection[baseRandom(0,collection.length-1)]:undefined}var result=shuffle(collection);result.length=nativeMin(nativeMax(0,n),result.length);return result}function shuffle(collection){var index=-1,length=collection?collection.length:0,result=Array(typeof length=="number"?length:0);forEach(collection,function(value){var rand=baseRandom(0,++index);result[index]=result[rand];result[rand]=value});return result}function size(collection){var length=collection?collection.length:0;return typeof length=="number"?length:keys(collection).length}function some(collection,callback,thisArg){var result;callback=lodash.createCallback(callback,thisArg,3);var index=-1,length=collection?collection.length:0;if(typeof length=="number"){while(++index<length){if(result=callback(collection[index],index,collection)){break}}}else{forOwn(collection,function(value,index,collection){return!(result=callback(value,index,collection))})}return!!result}function sortBy(collection,callback,thisArg){var index=-1,isArr=isArray(callback),length=collection?collection.length:0,result=Array(typeof length=="number"?length:0);if(!isArr){callback=lodash.createCallback(callback,thisArg,3)}forEach(collection,function(value,key,collection){var object=result[++index]=getObject();if(isArr){object.criteria=map(callback,function(key){return value[key]})}else{(object.criteria=getArray())[0]=callback(value,key,collection)}object.index=index;object.value=value});length=result.length;result.sort(compareAscending);while(length--){var object=result[length];result[length]=object.value;if(!isArr){releaseArray(object.criteria)}releaseObject(object)}return result}function toArray(collection){if(collection&&typeof collection.length=="number"){return slice(collection)}return values(collection)}var where=filter;function compact(array){var index=-1,length=array?array.length:0,result=[];while(++index<length){var value=array[index];if(value){result.push(value) | |
| }}return result}function difference(array){return baseDifference(array,baseFlatten(arguments,true,true,1))}function findIndex(array,callback,thisArg){var index=-1,length=array?array.length:0;callback=lodash.createCallback(callback,thisArg,3);while(++index<length){if(callback(array[index],index,array)){return index}}return-1}function findLastIndex(array,callback,thisArg){var length=array?array.length:0;callback=lodash.createCallback(callback,thisArg,3);while(length--){if(callback(array[length],length,array)){return length}}return-1}function first(array,callback,thisArg){var n=0,length=array?array.length:0;if(typeof callback!="number"&&callback!=null){var index=-1;callback=lodash.createCallback(callback,thisArg,3);while(++index<length&&callback(array[index],index,array)){n++}}else{n=callback;if(n==null||thisArg){return array?array[0]:undefined}}return slice(array,0,nativeMin(nativeMax(0,n),length))}function flatten(array,isShallow,callback,thisArg){if(typeof isShallow!="boolean"&&isShallow!=null){thisArg=callback;callback=typeof isShallow!="function"&&thisArg&&thisArg[isShallow]===array?null:isShallow;isShallow=false}if(callback!=null){array=map(array,callback,thisArg)}return baseFlatten(array,isShallow)}function indexOf(array,value,fromIndex){if(typeof fromIndex=="number"){var length=array?array.length:0;fromIndex=fromIndex<0?nativeMax(0,length+fromIndex):fromIndex||0}else if(fromIndex){var index=sortedIndex(array,value);return array[index]===value?index:-1}return baseIndexOf(array,value,fromIndex)}function initial(array,callback,thisArg){var n=0,length=array?array.length:0;if(typeof callback!="number"&&callback!=null){var index=length;callback=lodash.createCallback(callback,thisArg,3);while(index--&&callback(array[index],index,array)){n++}}else{n=callback==null||thisArg?1:callback||n}return slice(array,0,nativeMin(nativeMax(0,length-n),length))}function intersection(){var args=[],argsIndex=-1,argsLength=arguments.length,caches=getArray(),indexOf=getIndexOf(),trustIndexOf=indexOf===baseIndexOf,seen=getArray();while(++argsIndex<argsLength){var value=arguments[argsIndex];if(isArray(value)||isArguments(value)){args.push(value);caches.push(trustIndexOf&&value.length>=largeArraySize&&createCache(argsIndex?args[argsIndex]:seen))}}var array=args[0],index=-1,length=array?array.length:0,result=[];outer:while(++index<length){var cache=caches[0];value=array[index];if((cache?cacheIndexOf(cache,value):indexOf(seen,value))<0){argsIndex=argsLength;(cache||seen).push(value);while(--argsIndex){cache=caches[argsIndex];if((cache?cacheIndexOf(cache,value):indexOf(args[argsIndex],value))<0){continue outer}}result.push(value)}}while(argsLength--){cache=caches[argsLength];if(cache){releaseObject(cache)}}releaseArray(caches);releaseArray(seen);return result}function last(array,callback,thisArg){var n=0,length=array?array.length:0;if(typeof callback!="number"&&callback!=null){var index=length;callback=lodash.createCallback(callback,thisArg,3);while(index--&&callback(array[index],index,array)){n++}}else{n=callback;if(n==null||thisArg){return array?array[length-1]:undefined}}return slice(array,nativeMax(0,length-n))}function lastIndexOf(array,value,fromIndex){var index=array?array.length:0;if(typeof fromIndex=="number"){index=(fromIndex<0?nativeMax(0,index+fromIndex):nativeMin(fromIndex,index-1))+1}while(index--){if(array[index]===value){return index}}return-1}function pull(array){var args=arguments,argsIndex=0,argsLength=args.length,length=array?array.length:0;while(++argsIndex<argsLength){var index=-1,value=args[argsIndex];while(++index<length){if(array[index]===value){splice.call(array,index--,1);length--}}}return array}function range(start,end,step){start=+start||0;step=typeof step=="number"?step:+step||1;if(end==null){end=start;start=0}var index=-1,length=nativeMax(0,ceil((end-start)/(step||1))),result=Array(length);while(++index<length){result[index]=start;start+=step}return result}function remove(array,callback,thisArg){var index=-1,length=array?array.length:0,result=[];callback=lodash.createCallback(callback,thisArg,3);while(++index<length){var value=array[index];if(callback(value,index,array)){result.push(value);splice.call(array,index--,1);length--}}return result}function rest(array,callback,thisArg){if(typeof callback!="number"&&callback!=null){var n=0,index=-1,length=array?array.length:0;callback=lodash.createCallback(callback,thisArg,3);while(++index<length&&callback(array[index],index,array)){n++}}else{n=callback==null||thisArg?1:nativeMax(0,callback)}return slice(array,n)}function sortedIndex(array,value,callback,thisArg){var low=0,high=array?array.length:low;callback=callback?lodash.createCallback(callback,thisArg,1):identity;value=callback(value);while(low<high){var mid=low+high>>>1;callback(array[mid])<value?low=mid+1:high=mid}return low}function union(){return baseUniq(baseFlatten(arguments,true,true))}function uniq(array,isSorted,callback,thisArg){if(typeof isSorted!="boolean"&&isSorted!=null){thisArg=callback;callback=typeof isSorted!="function"&&thisArg&&thisArg[isSorted]===array?null:isSorted;isSorted=false}if(callback!=null){callback=lodash.createCallback(callback,thisArg,3)}return baseUniq(array,isSorted,callback)}function without(array){return baseDifference(array,slice(arguments,1))}function xor(){var index=-1,length=arguments.length;while(++index<length){var array=arguments[index];if(isArray(array)||isArguments(array)){var result=result?baseUniq(baseDifference(result,array).concat(baseDifference(array,result))):array}}return result||[]}function zip(){var array=arguments.length>1?arguments:arguments[0],index=-1,length=array?max(pluck(array,"length")):0,result=Array(length<0?0:length);while(++index<length){result[index]=pluck(array,index)}return result}function zipObject(keys,values){var index=-1,length=keys?keys.length:0,result={};if(!values&&length&&!isArray(keys[0])){values=[]}while(++index<length){var key=keys[index];if(values){result[key]=values[index]}else if(key){result[key[0]]=key[1]}}return result}function after(n,func){if(!isFunction(func)){throw new TypeError}return function(){if(--n<1){return func.apply(this,arguments)}}}function bind(func,thisArg){return arguments.length>2?createWrapper(func,17,slice(arguments,2),null,thisArg):createWrapper(func,1,null,null,thisArg)}function bindAll(object){var funcs=arguments.length>1?baseFlatten(arguments,true,false,1):functions(object),index=-1,length=funcs.length;while(++index<length){var key=funcs[index];object[key]=createWrapper(object[key],1,null,null,object)}return object}function bindKey(object,key){return arguments.length>2?createWrapper(key,19,slice(arguments,2),null,object):createWrapper(key,3,null,null,object)}function compose(){var funcs=arguments,length=funcs.length;while(length--){if(!isFunction(funcs[length])){throw new TypeError}}return function(){var args=arguments,length=funcs.length;while(length--){args=[funcs[length].apply(this,args)]}return args[0]}}function curry(func,arity){arity=typeof arity=="number"?arity:+arity||func.length;return createWrapper(func,4,null,null,null,arity)}function debounce(func,wait,options){var args,maxTimeoutId,result,stamp,thisArg,timeoutId,trailingCall,lastCalled=0,maxWait=false,trailing=true;if(!isFunction(func)){throw new TypeError}wait=nativeMax(0,wait)||0;if(options===true){var leading=true;trailing=false}else if(isObject(options)){leading=options.leading;maxWait="maxWait"in options&&(nativeMax(wait,options.maxWait)||0);trailing="trailing"in options?options.trailing:trailing}var delayed=function(){var remaining=wait-(now()-stamp);if(remaining<=0){if(maxTimeoutId){clearTimeout(maxTimeoutId)}var isCalled=trailingCall;maxTimeoutId=timeoutId=trailingCall=undefined;if(isCalled){lastCalled=now();result=func.apply(thisArg,args);if(!timeoutId&&!maxTimeoutId){args=thisArg=null}}}else{timeoutId=setTimeout(delayed,remaining)}};var maxDelayed=function(){if(timeoutId){clearTimeout(timeoutId)}maxTimeoutId=timeoutId=trailingCall=undefined;if(trailing||maxWait!==wait){lastCalled=now();result=func.apply(thisArg,args);if(!timeoutId&&!maxTimeoutId){args=thisArg=null}}};return function(){args=arguments;stamp=now();thisArg=this;trailingCall=trailing&&(timeoutId||!leading);if(maxWait===false){var leadingCall=leading&&!timeoutId}else{if(!maxTimeoutId&&!leading){lastCalled=stamp}var remaining=maxWait-(stamp-lastCalled),isCalled=remaining<=0;if(isCalled){if(maxTimeoutId){maxTimeoutId=clearTimeout(maxTimeoutId)}lastCalled=stamp;result=func.apply(thisArg,args)}else if(!maxTimeoutId){maxTimeoutId=setTimeout(maxDelayed,remaining)}}if(isCalled&&timeoutId){timeoutId=clearTimeout(timeoutId)}else if(!timeoutId&&wait!==maxWait){timeoutId=setTimeout(delayed,wait)}if(leadingCall){isCalled=true;result=func.apply(thisArg,args)}if(isCalled&&!timeoutId&&!maxTimeoutId){args=thisArg=null}return result}}function defer(func){if(!isFunction(func)){throw new TypeError}var args=slice(arguments,1);return setTimeout(function(){func.apply(undefined,args)},1)}function delay(func,wait){if(!isFunction(func)){throw new TypeError}var args=slice(arguments,2);return setTimeout(function(){func.apply(undefined,args)},wait)}function memoize(func,resolver){if(!isFunction(func)){throw new TypeError}var memoized=function(){var cache=memoized.cache,key=resolver?resolver.apply(this,arguments):keyPrefix+arguments[0];return hasOwnProperty.call(cache,key)?cache[key]:cache[key]=func.apply(this,arguments)};memoized.cache={};return memoized}function once(func){var ran,result;if(!isFunction(func)){throw new TypeError}return function(){if(ran){return result}ran=true;result=func.apply(this,arguments);func=null;return result}}function partial(func){return createWrapper(func,16,slice(arguments,1))}function partialRight(func){return createWrapper(func,32,null,slice(arguments,1))}function throttle(func,wait,options){var leading=true,trailing=true;if(!isFunction(func)){throw new TypeError}if(options===false){leading=false}else if(isObject(options)){leading="leading"in options?options.leading:leading;trailing="trailing"in options?options.trailing:trailing}debounceOptions.leading=leading;debounceOptions.maxWait=wait;debounceOptions.trailing=trailing;return debounce(func,wait,debounceOptions)}function wrap(value,wrapper){return createWrapper(wrapper,16,[value])}function constant(value){return function(){return value}}function createCallback(func,thisArg,argCount){var type=typeof func;if(func==null||type=="function"){return baseCreateCallback(func,thisArg,argCount)}if(type!="object"){return property(func)}var props=keys(func),key=props[0],a=func[key];if(props.length==1&&a===a&&!isObject(a)){return function(object){var b=object[key];return a===b&&(a!==0||1/a==1/b)}}return function(object){var length=props.length,result=false;while(length--){if(!(result=baseIsEqual(object[props[length]],func[props[length]],null,true))){break}}return result}}function escape(string){return string==null?"":String(string).replace(reUnescapedHtml,escapeHtmlChar)}function identity(value){return value}function mixin(object,source,options){var chain=true,methodNames=source&&functions(source);if(!source||!options&&!methodNames.length){if(options==null){options=source}ctor=lodashWrapper;source=object;object=lodash;methodNames=functions(source)}if(options===false){chain=false}else if(isObject(options)&&"chain"in options){chain=options.chain}var ctor=object,isFunc=isFunction(ctor);forEach(methodNames,function(methodName){var func=object[methodName]=source[methodName];if(isFunc){ctor.prototype[methodName]=function(){var chainAll=this.__chain__,value=this.__wrapped__,args=[value];push.apply(args,arguments);var result=func.apply(object,args);if(chain||chainAll){if(value===result&&isObject(result)){return this}result=new ctor(result);result.__chain__=chainAll}return result}}})}function noConflict(){context._=oldDash;return this}function noop(){}var now=isNative(now=Date.now)&&now||function(){return(new Date).getTime()};var parseInt=nativeParseInt(whitespace+"08")==8?nativeParseInt:function(value,radix){return nativeParseInt(isString(value)?value.replace(reLeadingSpacesAndZeros,""):value,radix||0)};function property(key){return function(object){return object[key]}}function random(min,max,floating){var noMin=min==null,noMax=max==null;if(floating==null){if(typeof min=="boolean"&&noMax){floating=min;min=1}else if(!noMax&&typeof max=="boolean"){floating=max;noMax=true}}if(noMin&&noMax){max=1}min=+min||0;if(noMax){max=min;min=0}else{max=+max||0}if(floating||min%1||max%1){var rand=nativeRandom();return nativeMin(min+rand*(max-min+parseFloat("1e-"+((rand+"").length-1))),max)}return baseRandom(min,max)}function result(object,key){if(object){var value=object[key];return isFunction(value)?object[key]():value}}function template(text,data,options){var settings=lodash.templateSettings;text=String(text||"");options=defaults({},options,settings);var imports=defaults({},options.imports,settings.imports),importsKeys=keys(imports),importsValues=values(imports);var isEvaluating,index=0,interpolate=options.interpolate||reNoMatch,source="__p += '";var reDelimiters=RegExp((options.escape||reNoMatch).source+"|"+interpolate.source+"|"+(interpolate===reInterpolate?reEsTemplate:reNoMatch).source+"|"+(options.evaluate||reNoMatch).source+"|$","g");text.replace(reDelimiters,function(match,escapeValue,interpolateValue,esTemplateValue,evaluateValue,offset){interpolateValue||(interpolateValue=esTemplateValue);source+=text.slice(index,offset).replace(reUnescapedString,escapeStringChar);if(escapeValue){source+="' +\n__e("+escapeValue+") +\n'"}if(evaluateValue){isEvaluating=true;source+="';\n"+evaluateValue+";\n__p += '"}if(interpolateValue){source+="' +\n((__t = ("+interpolateValue+")) == null ? '' : __t) +\n'"}index=offset+match.length;return match});source+="';\n";var variable=options.variable,hasVariable=variable;if(!hasVariable){variable="obj";source="with ("+variable+") {\n"+source+"\n}\n"}source=(isEvaluating?source.replace(reEmptyStringLeading,""):source).replace(reEmptyStringMiddle,"$1").replace(reEmptyStringTrailing,"$1;");source="function("+variable+") {\n"+(hasVariable?"":variable+" || ("+variable+" = {});\n")+"var __t, __p = '', __e = _.escape"+(isEvaluating?", __j = Array.prototype.join;\n"+"function print() { __p += __j.call(arguments, '') }\n":";\n")+source+"return __p\n}";var sourceURL="\n/*\n//# sourceURL="+(options.sourceURL||"/lodash/template/source["+templateCounter++ +"]")+"\n*/";try{var result=Function(importsKeys,"return "+source+sourceURL).apply(undefined,importsValues)}catch(e){e.source=source;throw e}if(data){return result(data)}result.source=source;return result}function times(n,callback,thisArg){n=(n=+n)>-1?n:0;var index=-1,result=Array(n);callback=baseCreateCallback(callback,thisArg,1);while(++index<n){result[index]=callback(index)}return result}function unescape(string){return string==null?"":String(string).replace(reEscapedHtml,unescapeHtmlChar)}function uniqueId(prefix){var id=++idCounter;return String(prefix==null?"":prefix)+id}function chain(value){value=new lodashWrapper(value);value.__chain__=true;return value}function tap(value,interceptor){interceptor(value);return value}function wrapperChain(){this.__chain__=true;return this}function wrapperToString(){return String(this.__wrapped__)}function wrapperValueOf(){return this.__wrapped__}lodash.after=after;lodash.assign=assign;lodash.at=at;lodash.bind=bind;lodash.bindAll=bindAll;lodash.bindKey=bindKey;lodash.chain=chain;lodash.compact=compact;lodash.compose=compose;lodash.constant=constant;lodash.countBy=countBy;lodash.create=create;lodash.createCallback=createCallback;lodash.curry=curry;lodash.debounce=debounce;lodash.defaults=defaults;lodash.defer=defer;lodash.delay=delay;lodash.difference=difference;lodash.filter=filter;lodash.flatten=flatten;lodash.forEach=forEach;lodash.forEachRight=forEachRight;lodash.forIn=forIn;lodash.forInRight=forInRight;lodash.forOwn=forOwn;lodash.forOwnRight=forOwnRight;lodash.functions=functions;lodash.groupBy=groupBy;lodash.indexBy=indexBy;lodash.initial=initial;lodash.intersection=intersection;lodash.invert=invert;lodash.invoke=invoke;lodash.keys=keys;lodash.map=map;lodash.mapValues=mapValues;lodash.max=max;lodash.memoize=memoize;lodash.merge=merge;lodash.min=min;lodash.omit=omit;lodash.once=once;lodash.pairs=pairs;lodash.partial=partial;lodash.partialRight=partialRight;lodash.pick=pick;lodash.pluck=pluck;lodash.property=property;lodash.pull=pull;lodash.range=range;lodash.reject=reject;lodash.remove=remove;lodash.rest=rest;lodash.shuffle=shuffle;lodash.sortBy=sortBy;lodash.tap=tap;lodash.throttle=throttle;lodash.times=times;lodash.toArray=toArray;lodash.transform=transform;lodash.union=union;lodash.uniq=uniq;lodash.values=values;lodash.where=where;lodash.without=without;lodash.wrap=wrap;lodash.xor=xor;lodash.zip=zip;lodash.zipObject=zipObject;lodash.collect=map;lodash.drop=rest;lodash.each=forEach;lodash.eachRight=forEachRight;lodash.extend=assign;lodash.methods=functions;lodash.object=zipObject;lodash.select=filter;lodash.tail=rest;lodash.unique=uniq;lodash.unzip=zip;mixin(lodash);lodash.clone=clone;lodash.cloneDeep=cloneDeep;lodash.contains=contains;lodash.escape=escape;lodash.every=every;lodash.find=find;lodash.findIndex=findIndex;lodash.findKey=findKey;lodash.findLast=findLast;lodash.findLastIndex=findLastIndex;lodash.findLastKey=findLastKey;lodash.has=has;lodash.identity=identity;lodash.indexOf=indexOf;lodash.isArguments=isArguments;lodash.isArray=isArray;lodash.isBoolean=isBoolean;lodash.isDate=isDate;lodash.isElement=isElement;lodash.isEmpty=isEmpty;lodash.isEqual=isEqual;lodash.isFinite=isFinite;lodash.isFunction=isFunction;lodash.isNaN=isNaN;lodash.isNull=isNull;lodash.isNumber=isNumber;lodash.isObject=isObject;lodash.isPlainObject=isPlainObject;lodash.isRegExp=isRegExp;lodash.isString=isString;lodash.isUndefined=isUndefined;lodash.lastIndexOf=lastIndexOf;lodash.mixin=mixin;lodash.noConflict=noConflict;lodash.noop=noop;lodash.now=now;lodash.parseInt=parseInt;lodash.random=random;lodash.reduce=reduce;lodash.reduceRight=reduceRight;lodash.result=result;lodash.runInContext=runInContext;lodash.size=size;lodash.some=some;lodash.sortedIndex=sortedIndex;lodash.template=template;lodash.unescape=unescape;lodash.uniqueId=uniqueId;lodash.all=every;lodash.any=some;lodash.detect=find;lodash.findWhere=find;lodash.foldl=reduce;lodash.foldr=reduceRight;lodash.include=contains;lodash.inject=reduce;mixin(function(){var source={};forOwn(lodash,function(func,methodName){if(!lodash.prototype[methodName]){source[methodName]=func}});return source}(),false);lodash.first=first;lodash.last=last;lodash.sample=sample;lodash.take=first;lodash.head=first;forOwn(lodash,function(func,methodName){var callbackable=methodName!=="sample";if(!lodash.prototype[methodName]){lodash.prototype[methodName]=function(n,guard){var chainAll=this.__chain__,result=func(this.__wrapped__,n,guard);return!chainAll&&(n==null||guard&&!(callbackable&&typeof n=="function"))?result:new lodashWrapper(result,chainAll)}}});lodash.VERSION="2.4.1";lodash.prototype.chain=wrapperChain;lodash.prototype.toString=wrapperToString;lodash.prototype.value=wrapperValueOf;lodash.prototype.valueOf=wrapperValueOf;forEach(["join","pop","shift"],function(methodName){var func=arrayRef[methodName];lodash.prototype[methodName]=function(){var chainAll=this.__chain__,result=func.apply(this.__wrapped__,arguments);return chainAll?new lodashWrapper(result,chainAll):result}});forEach(["push","reverse","sort","unshift"],function(methodName){var func=arrayRef[methodName];lodash.prototype[methodName]=function(){func.apply(this.__wrapped__,arguments);return this}});forEach(["concat","slice","splice"],function(methodName){var func=arrayRef[methodName];lodash.prototype[methodName]=function(){return new lodashWrapper(func.apply(this.__wrapped__,arguments),this.__chain__)}});return lodash}var _=runInContext();if(typeof define=="function"&&typeof define.amd=="object"&&define.amd){root._=_;define(function(){return _})}else if(freeExports&&freeModule){if(moduleExports){(freeModule.exports=_)._=_}else{freeExports._=_}}else{root._=_}}).call(this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}]},{},[]);var Bacon=require("baconjs");var _=require("lodash");function concat(x,y){return x.concat(y)}var action=new Bacon.Bus;var store=action.scan([],concat);var view=function(){store.onValue(function(v){console.log(v)})};view();action.push("adam");action.push("is");action.push("awesome"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "requirebin-sketch", | |
| "version": "1.0.0", | |
| "dependencies": { | |
| "baconjs": "0.7.32", | |
| "lodash": "2.4.1" | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <style type='text/css'>html, body { margin: 0; padding: 0; border: 0; } | |
| body, html { height: 100%; width: 100%; }</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment