Skip to content

Instantly share code, notes, and snippets.

@CrossEye
Created October 18, 2014 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CrossEye/6d5f583dfa412ae227cf to your computer and use it in GitHub Desktop.
Save CrossEye/6d5f583dfa412ae227cf to your computer and use it in GitHub Desktop.
requirebin sketch
var transform = function(n) {return 3 * n + 2;};
var log = function(n, idx, obj) {
return 'n: ' + n + ', idx: ' + idx + ', obj: ' + obj;
};
var Lazy = require('lazy.js');
console.log("lazy.js")
console.log(Lazy.range(3).map(transform).map(log).toArray().join('\n'));
console.log("----------------------------------------");
var Lz = require('lz');
console.log("lz")
console.log(Lz.range(0, 3).map(transform).map(log).toArray().join("\n"));
console.log("----------------------------------------");
var H = require('highland');
var t = require('transducers.js');
console.log("transducters")
console.log(t.seq([0, 1, 2], t.compose(t.map(transform), t.map(log))));
console.log("----------------------------------------");
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}({lz:[function(require,module,exports){(function(name,definition){"use strict";if(typeof define=="function"){define(definition)}else if(typeof module!="undefined"&&module.exports){module.exports=definition()}else{var Module=definition(),global=this,old=global[name];Module.noConflict=function(){global[name]=old;return Module};global[name]=Module}}).call(this,"lz",function(){"use strict";var UNDEFINED={};var FALSE={};function _n(){var _this=this;if(_this._p)_this._p(_this._i);var item=_this._l[_this._i++];if(_this._i>_this.length)return UNDEFINED;for(var j=0;j<_this._f.length;j+=1){item=_this._f[j](item);if(item===FALSE)return _this._n()}return item}function _p(list,x){return typeof list==="string"?list.concat(x):(list.push(x),list)}function lz(list){var _this=this;if(!(_this instanceof lz)){return new lz(list)}_this._f=[];_this._i=0;_this._l=list;_this.length=list.length}Object.defineProperty(Array.prototype,"lz",{value:function(){return new lz(this)}});var lz_prototype=lz.prototype;lz_prototype._r=function(value){this._i=0;return value};lz_prototype._n=_n;lz_prototype.compact=function(){var _this=this;_this._v=null;_this._f.push(function(x){if(!x)return FALSE;return x});return _this};lz_prototype.concat=function(arr){var _this=this;var length=_this.length;_this.length+=arr.length;if(arr instanceof lz){_this._f.push(function(x){if(_this._i>length){x=arr._n();_this._l=_p(_this._l,x)}return x})}else{_this._f.push(function(x){if(_this._i>length){x=arr[_this._i-length-1];_this._l=_p(_this._l,x)}return x})}return _this};lz_prototype.cycle=function(){return lz.cycle(this._l)};lz_prototype.drop=function(n){var _this=this;_this._v=null;var item;while(n-->0){item=_this._n();if(item===UNDEFINED){_this._v=[];return _this}}_this._l=_this._l.slice(_this._i);_this._i=0;_this.length=_this._l.length;return _this};lz_prototype.dropWhile=function(fn){var _this=this;_this._v=null;var item;while(true){item=_this._n();if(item===UNDEFINED){_this._v=[];return _this}if(fn(item)===false)break}_this._l=_this._l.slice(_this._i-1);_this._i=0;_this.length=_this._l.length;return _this};lz_prototype.filter=function(f){var _this=this;_this._v=null;_this._f.push(function(x){if(f(x)===true)return x;else return FALSE});return _this};lz_prototype.flatten=function(shallow){return lz.flatten(this.$(),shallow)};lz_prototype.init=function(){var _this=this;var results=[];var item;var n=_this.length;while(--n>0){item=_this._n();if(item===UNDEFINED)break;results.push(item)}_this._l=_this._v=results;_this._f=[];_this._i=0;_this.length=_this._l.length;return _this};lz_prototype.map=function(f){var _this=this;_this._v=null;_this._f.push(function(x){return f(x)});return _this};lz_prototype.of=function(b){return new lz(b)};lz_prototype.scanl=function(fn){var _this=this;_this._v=null;var prev;_this._f.push(function(x){return prev=fn(prev,x)||x});return _this};lz_prototype.sort=function(fn){var _this=this;_this._v=_this._l=Array.prototype.sort.call(_this._l,fn);return _this};lz_prototype.tail=function(){var _this=this;var results=[];var item;var n=_this.length;_this._n();while(--n>0){item=_this._n();if(item===UNDEFINED)break;results.push(item)}_this._l=_this._v=results;_this._f=[];_this._i=0;_this.length=_this._l.length;return _this};lz_prototype.take=function(n){var _this=this;var results=[];var item;while(n-->0){item=_this._n();if(item===UNDEFINED)break;results.push(item)}_this._l=_this._v=results;_this._f=[];_this._i=0;_this.length=_this._l.length;return _this};lz_prototype.takeWhile=function(fn){var _this=this;var results=[];var result;var item;while(true){item=_this._n();if(item===UNDEFINED)break;result=fn(item);if(result===true)results.push(item);else break}_this._l=_this._v=results;_this._f=[];_this._i=0;_this.length=_this._l.length;return _this};lz_prototype.empty=function(){return new lz([])};lz_prototype.zipWith=function(fn,list){return lz.zipWith(fn,list,this._l)};lz_prototype.all=function(fn){var _this=this;var item;var i=_this.length;while(i-->0){item=_this._n();if(item===UNDEFINED)break;if(fn(item)===false)return _this._r(false)}return _this._r(true)};lz_prototype.and=function(){var _this=this;var item;var i=_this.length;while(i-->0){item=_this._n();if(item===UNDEFINED)break;if(!item)return _this._r(false)}return _this._r(true)};lz_prototype.any=function(fn){var _this=this;var item;var i=_this.length;while(i-->0){item=_this._n();if(item===UNDEFINED)break;if(fn(item)===true)return _this._r(true)}return _this._r(false)};lz_prototype.at=function(n){var _this=this;n=n<0?_this.length+n:n;if(n<0)return _this._r(null);while(--n>=0){if(_this._n()===UNDEFINED)return _this._r(null)}var item=_this._n();return _this._r(item===UNDEFINED?null:item)};lz_prototype.chain=function(f){var _this=this;if(typeof f!=="function"){throw new TypeError("Chain argument must be a function")}var result=f(_this._v||_this._l);if(result instanceof lz){return result}else{return new lz(result.length?result:[result])}};lz_prototype.foldl=function(fn){var _this=this;var result,next;var i=_this.length;result=_this._n();if(result===UNDEFINED)return _this._r(null);while(i-->0){next=_this._n();if(next===UNDEFINED)break;result=fn(result,next)}return _this._r(result)};lz_prototype.elem=function(x){var _this=this;var item;var i=_this.length;var notANumber=isNaN(x);while(i-->0){item=_this._n();if(item===UNDEFINED)break;if(item===x){return _this._r(x!==0||1/x===1/item)}else if(notANumber&&x!==x&&item!==item){return _this._r(true)}}return _this._r(false)};lz_prototype.head=function(){var _this=this;var item=_this._n();return _this._r(item===UNDEFINED?null:item)};lz_prototype.last=function(){var _this=this;var n=-1;var result;var item;while(++n<_this.length){item=_this._n();if(item===UNDEFINED)break;result=item}return _this._r(result)};lz_prototype.nil=function(){var _this=this;var item;if(_this.length===0)return _this._r(true);var i=_this.length;while(i-->0){item=_this._n();if(item===UNDEFINED)break;if(item!=null)return _this._r(false)}return _this._r(true)};lz_prototype.max=function(fn){return lz.max(this.$(),fn)};lz_prototype.min=function(fn){return lz.min(this.$(),fn)};lz_prototype.or=function(){var _this=this;var item;var i=_this.length;while(i-->0){item=_this._n();if(item===UNDEFINED)break;if(!!item)return _this._r(true)}return _this._r(false)};lz_prototype.$=lz_prototype.toArray=function(){var _this=this;if(_this._v){return _this._v}var results=[];var item;var n=_this.length;while(n>0){item=_this._n();if(item===UNDEFINED)break;results.push(item);n-=1}_this._v=results;_this._f=[];_this._i=0;return results};lz_prototype.toString=function(joinBy){var _this=this;if(typeof joinBy!=="string"){joinBy=""}if(_this._v){return typeof _this._v==="string"?_this._v:_this._v.join(joinBy)}var result="";var item,next;while(true){item=_this._n();if(item===UNDEFINED)break;result+=item;next=_this._n();if(next===UNDEFINED)break;result+=joinBy+next}_this._v=result;_this._f=[];_this._i=0;return result};lz_prototype.unlines=function(){var _this=this;var result="";var item,next;while(true){item=_this._n();if(item===UNDEFINED)break;result+=item;next=_this._n();if(next===UNDEFINED)break;result+="\n"+next}return result};lz_prototype.unwords=function(){var _this=this;var result="";var item,next;while(true){item=_this._n();if(item===UNDEFINED)break;result+=item;next=_this._n();if(next===UNDEFINED)break;result+=" "+next}return result};lz.concatMap=function(fn,coll){var l=coll.length;var i=-1;var results=[];while(++i<l){results.push.apply(results,fn(coll[i]))}var instance=new lz(results);instance._v=results;return instance};lz.cycle=function(list){var z=new lz(list);var length=list.length;z.length=Infinity;z._n=function(){if(this._i===length){this._i=0}return _n.call(this)};return z};lz.flatten=function(arr,shallow){var result=[];if(!arr)return result;var value,index=-1,length=arr.length;while(++index<length){value=arr[index];if(Array.isArray(value))result.push.apply(result,shallow?value:lz.flatten(value));else result.push(value)}return result};lz.foldl=function(fn,arr){if(!arr)return null;var item,value=arr[0],index=0,length=arr.length;if(arr instanceof lz){index=arr.length;value=arr._n();if(value===UNDEFINED)return null;while(index-->0){item=arr._n();if(item===UNDEFINED)break;value=fn(value,item)}}else{while(++index<length){value=fn(value,arr[index])}}return value};lz.iterate=function(fn,n){var z=new lz([]);var result;z.length=Infinity;z._n=function(){result=fn(result)||n;this._l.push(result);return _n.call(this)};return z};lz.lines=function(str){return new lz(str.split("\n"))};lz.max=function(arr,fn){if(!arr)return null;var item,value=-Infinity,index=-1,length=arr.length;if(fn){while(++index<length){item=fn(arr[index]);if(item>value)value=item}}else{while(++index<length){item=arr[index];if(item>value)value=item}}return value};lz.min=function(arr,fn){if(!arr)return null;var item,value=Infinity,index=-1,length=arr.length;if(fn){while(++index<length){item=fn(arr[index]);if(item<value)value=item}}else{while(++index<length){item=arr[index];if(item<value)value=item}}return value};lz.of=function(b){return new lz(b)};lz.range=function(start,end){var z=new lz([]);z.length=end;z._p=function(i){this._l[i]=i+start};return z};lz.repeat=function(n){var z=new lz([]);z.length=Infinity;z._n=function(){this._l.push(n);return _n.call(this)};return z};lz.replicate=function(times,n){var z=new lz([]);z.length=times;z._p=function(i){this._l[i]=n};return z};lz.words=function(str){return new lz(str.split(" "))};lz.empty=function(){return new lz([])};lz.zipWith=function(fn,list1,list2){var z=new lz([]);z.length=list1.length<list2.length?list1.length:list2.length;if(!(list1 instanceof lz)&&!(list2 instanceof lz)){z._n=function(){if(this._i>=this.length)return UNDEFINED;return fn(list1[this._i],list2[this._i++])};return z}else{if(!(list1 instanceof lz))list1=lz(list1);if(!(list2 instanceof lz))list2=lz(list2);z._n=function(){this._l.push(fn(list1._n(),list2._n()));return _n.call(this)};return z}};lz.flip=function(a,b){return b};lz.identity=function(a){return a};lz.not=function(b){return!b};return lz})},{}]},{},[]);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}({1:[function(require,module,exports){function EventEmitter(){this._events=this._events||{};this._maxListeners=this._maxListeners||undefined}module.exports=EventEmitter;EventEmitter.EventEmitter=EventEmitter;EventEmitter.prototype._events=undefined;EventEmitter.prototype._maxListeners=undefined;EventEmitter.defaultMaxListeners=10;EventEmitter.prototype.setMaxListeners=function(n){if(!isNumber(n)||n<0||isNaN(n))throw TypeError("n must be a positive number");this._maxListeners=n;return this};EventEmitter.prototype.emit=function(type){var er,handler,len,args,i,listeners;if(!this._events)this._events={};if(type==="error"){if(!this._events.error||isObject(this._events.error)&&!this._events.error.length){er=arguments[1];if(er instanceof Error){throw er}else{throw TypeError('Uncaught, unspecified "error" event.')}return false}}handler=this._events[type];if(isUndefined(handler))return false;if(isFunction(handler)){switch(arguments.length){case 1:handler.call(this);break;case 2:handler.call(this,arguments[1]);break;case 3:handler.call(this,arguments[1],arguments[2]);break;default:len=arguments.length;args=new Array(len-1);for(i=1;i<len;i++)args[i-1]=arguments[i];handler.apply(this,args)}}else if(isObject(handler)){len=arguments.length;args=new Array(len-1);for(i=1;i<len;i++)args[i-1]=arguments[i];listeners=handler.slice();len=listeners.length;for(i=0;i<len;i++)listeners[i].apply(this,args)}return true};EventEmitter.prototype.addListener=function(type,listener){var m;if(!isFunction(listener))throw TypeError("listener must be a function");if(!this._events)this._events={};if(this._events.newListener)this.emit("newListener",type,isFunction(listener.listener)?listener.listener:listener);if(!this._events[type])this._events[type]=listener;else if(isObject(this._events[type]))this._events[type].push(listener);else this._events[type]=[this._events[type],listener];if(isObject(this._events[type])&&!this._events[type].warned){var m;if(!isUndefined(this._maxListeners)){m=this._maxListeners}else{m=EventEmitter.defaultMaxListeners}if(m&&m>0&&this._events[type].length>m){this._events[type].warned=true;console.error("(node) warning: possible EventEmitter memory "+"leak detected. %d listeners added. "+"Use emitter.setMaxListeners() to increase limit.",this._events[type].length);if(typeof console.trace==="function"){console.trace()}}}return this};EventEmitter.prototype.on=EventEmitter.prototype.addListener;EventEmitter.prototype.once=function(type,listener){if(!isFunction(listener))throw TypeError("listener must be a function");var fired=false;function g(){this.removeListener(type,g);if(!fired){fired=true;listener.apply(this,arguments)}}g.listener=listener;this.on(type,g);return this};EventEmitter.prototype.removeListener=function(type,listener){var list,position,length,i;if(!isFunction(listener))throw TypeError("listener must be a function");if(!this._events||!this._events[type])return this;list=this._events[type];length=list.length;position=-1;if(list===listener||isFunction(list.listener)&&list.listener===listener){delete this._events[type];if(this._events.removeListener)this.emit("removeListener",type,listener)}else if(isObject(list)){for(i=length;i-->0;){if(list[i]===listener||list[i].listener&&list[i].listener===listener){position=i;break}}if(position<0)return this;if(list.length===1){list.length=0;delete this._events[type]}else{list.splice(position,1)}if(this._events.removeListener)this.emit("removeListener",type,listener)}return this};EventEmitter.prototype.removeAllListeners=function(type){var key,listeners;if(!this._events)return this;if(!this._events.removeListener){if(arguments.length===0)this._events={};else if(this._events[type])delete this._events[type];return this}if(arguments.length===0){for(key in this._events){if(key==="removeListener")continue;this.removeAllListeners(key)}this.removeAllListeners("removeListener");this._events={};return this}listeners=this._events[type];if(isFunction(listeners)){this.removeListener(type,listeners)}else{while(listeners.length)this.removeListener(type,listeners[listeners.length-1])}delete this._events[type];return this};EventEmitter.prototype.listeners=function(type){var ret;if(!this._events||!this._events[type])ret=[];else if(isFunction(this._events[type]))ret=[this._events[type]];else ret=this._events[type].slice();return ret};EventEmitter.listenerCount=function(emitter,type){var ret;if(!emitter._events||!emitter._events[type])ret=0;else if(isFunction(emitter._events[type]))ret=1;else ret=emitter._events[type].length;return ret};function isFunction(arg){return typeof arg==="function"}function isNumber(arg){return typeof arg==="number"}function isObject(arg){return typeof arg==="object"&&arg!==null}function isUndefined(arg){return arg===void 0}},{}],2:[function(require,module,exports){if(typeof Object.create==="function"){module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:false,writable:true,configurable:true}})}}else{module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype;ctor.prototype=new TempCtor;ctor.prototype.constructor=ctor}}},{}],3:[function(require,module,exports){var process=module.exports={};process.nextTick=function(){var canSetImmediate=typeof window!=="undefined"&&window.setImmediate;var canPost=typeof window!=="undefined"&&window.postMessage&&window.addEventListener;if(canSetImmediate){return function(f){return window.setImmediate(f)}}if(canPost){var queue=[];window.addEventListener("message",function(ev){var source=ev.source;if((source===window||source===null)&&ev.data==="process-tick"){ev.stopPropagation();if(queue.length>0){var fn=queue.shift();fn()}}},true);return function nextTick(fn){queue.push(fn);window.postMessage("process-tick","*")}}return function nextTick(fn){setTimeout(fn,0)}}();process.title="browser";process.browser=true;process.env={};process.argv=[];function noop(){}process.on=noop;process.addListener=noop;process.once=noop;process.off=noop;process.removeListener=noop;process.removeAllListeners=noop;process.emit=noop;process.binding=function(name){throw new Error("process.binding is not supported")};process.cwd=function(){return"/"};process.chdir=function(dir){throw new Error("process.chdir is not supported")}},{}],4:[function(require,module,exports){module.exports=function isBuffer(arg){return arg&&typeof arg==="object"&&typeof arg.copy==="function"&&typeof arg.fill==="function"&&typeof arg.readUInt8==="function"}},{}],5:[function(require,module,exports){(function(process,global){var formatRegExp=/%[sdj%]/g;exports.format=function(f){if(!isString(f)){var objects=[];for(var i=0;i<arguments.length;i++){objects.push(inspect(arguments[i]))}return objects.join(" ")}var i=1;var args=arguments;var len=args.length;var str=String(f).replace(formatRegExp,function(x){if(x==="%%")return"%";if(i>=len)return x;switch(x){case"%s":return String(args[i++]);case"%d":return Number(args[i++]);case"%j":try{return JSON.stringify(args[i++])}catch(_){return"[Circular]"}default:return x}});for(var x=args[i];i<len;x=args[++i]){if(isNull(x)||!isObject(x)){str+=" "+x}else{str+=" "+inspect(x)}}return str};exports.deprecate=function(fn,msg){if(isUndefined(global.process)){return function(){return exports.deprecate(fn,msg).apply(this,arguments)}}if(process.noDeprecation===true){return fn}var warned=false;function deprecated(){if(!warned){if(process.throwDeprecation){throw new Error(msg)}else if(process.traceDeprecation){console.trace(msg)}else{console.error(msg)}warned=true}return fn.apply(this,arguments)}return deprecated};var debugs={};var debugEnviron;exports.debuglog=function(set){if(isUndefined(debugEnviron))debugEnviron=process.env.NODE_DEBUG||"";set=set.toUpperCase();if(!debugs[set]){if(new RegExp("\\b"+set+"\\b","i").test(debugEnviron)){var pid=process.pid;debugs[set]=function(){var msg=exports.format.apply(exports,arguments);console.error("%s %d: %s",set,pid,msg)}}else{debugs[set]=function(){}}}return debugs[set]};function inspect(obj,opts){var ctx={seen:[],stylize:stylizeNoColor};if(arguments.length>=3)ctx.depth=arguments[2];if(arguments.length>=4)ctx.colors=arguments[3];if(isBoolean(opts)){ctx.showHidden=opts}else if(opts){exports._extend(ctx,opts)}if(isUndefined(ctx.showHidden))ctx.showHidden=false;if(isUndefined(ctx.depth))ctx.depth=2;if(isUndefined(ctx.colors))ctx.colors=false;if(isUndefined(ctx.customInspect))ctx.customInspect=true;if(ctx.colors)ctx.stylize=stylizeWithColor;return formatValue(ctx,obj,ctx.depth)}exports.inspect=inspect;inspect.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]};inspect.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"};function stylizeWithColor(str,styleType){var style=inspect.styles[styleType];if(style){return"["+inspect.colors[style][0]+"m"+str+"["+inspect.colors[style][1]+"m"}else{return str}}function stylizeNoColor(str,styleType){return str}function arrayToHash(array){var hash={};array.forEach(function(val,idx){hash[val]=true});return hash}function formatValue(ctx,value,recurseTimes){if(ctx.customInspect&&value&&isFunction(value.inspect)&&value.inspect!==exports.inspect&&!(value.constructor&&value.constructor.prototype===value)){var ret=value.inspect(recurseTimes,ctx);if(!isString(ret)){ret=formatValue(ctx,ret,recurseTimes)}return ret}var primitive=formatPrimitive(ctx,value);if(primitive){return primitive}var keys=Object.keys(value);var visibleKeys=arrayToHash(keys);if(ctx.showHidden){keys=Object.getOwnPropertyNames(value)}if(isError(value)&&(keys.indexOf("message")>=0||keys.indexOf("description")>=0)){return formatError(value)}if(keys.length===0){if(isFunction(value)){var name=value.name?": "+value.name:"";return ctx.stylize("[Function"+name+"]","special")}if(isRegExp(value)){return ctx.stylize(RegExp.prototype.toString.call(value),"regexp")}if(isDate(value)){return ctx.stylize(Date.prototype.toString.call(value),"date")}if(isError(value)){return formatError(value)}}var base="",array=false,braces=["{","}"];if(isArray(value)){array=true;braces=["[","]"]}if(isFunction(value)){var n=value.name?": "+value.name:"";base=" [Function"+n+"]"}if(isRegExp(value)){base=" "+RegExp.prototype.toString.call(value)}if(isDate(value)){base=" "+Date.prototype.toUTCString.call(value)}if(isError(value)){base=" "+formatError(value)}if(keys.length===0&&(!array||value.length==0)){return braces[0]+base+braces[1]}if(recurseTimes<0){if(isRegExp(value)){return ctx.stylize(RegExp.prototype.toString.call(value),"regexp")}else{return ctx.stylize("[Object]","special")}}ctx.seen.push(value);var output;if(array){output=formatArray(ctx,value,recurseTimes,visibleKeys,keys)}else{output=keys.map(function(key){return formatProperty(ctx,value,recurseTimes,visibleKeys,key,array)})}ctx.seen.pop();return reduceToSingleString(output,base,braces)}function formatPrimitive(ctx,value){if(isUndefined(value))return ctx.stylize("undefined","undefined");if(isString(value)){var simple="'"+JSON.stringify(value).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return ctx.stylize(simple,"string")}if(isNumber(value))return ctx.stylize(""+value,"number");if(isBoolean(value))return ctx.stylize(""+value,"boolean");if(isNull(value))return ctx.stylize("null","null")}function formatError(value){return"["+Error.prototype.toString.call(value)+"]"}function formatArray(ctx,value,recurseTimes,visibleKeys,keys){var output=[];for(var i=0,l=value.length;i<l;++i){if(hasOwnProperty(value,String(i))){output.push(formatProperty(ctx,value,recurseTimes,visibleKeys,String(i),true))}else{output.push("")}}keys.forEach(function(key){if(!key.match(/^\d+$/)){output.push(formatProperty(ctx,value,recurseTimes,visibleKeys,key,true))}});return output}function formatProperty(ctx,value,recurseTimes,visibleKeys,key,array){var name,str,desc;desc=Object.getOwnPropertyDescriptor(value,key)||{value:value[key]};if(desc.get){if(desc.set){str=ctx.stylize("[Getter/Setter]","special")}else{str=ctx.stylize("[Getter]","special")}}else{if(desc.set){str=ctx.stylize("[Setter]","special")}}if(!hasOwnProperty(visibleKeys,key)){name="["+key+"]"}if(!str){if(ctx.seen.indexOf(desc.value)<0){if(isNull(recurseTimes)){str=formatValue(ctx,desc.value,null)}else{str=formatValue(ctx,desc.value,recurseTimes-1)}if(str.indexOf("\n")>-1){if(array){str=str.split("\n").map(function(line){return" "+line}).join("\n").substr(2)}else{str="\n"+str.split("\n").map(function(line){return" "+line}).join("\n")}}}else{str=ctx.stylize("[Circular]","special")}}if(isUndefined(name)){if(array&&key.match(/^\d+$/)){return str}name=JSON.stringify(""+key);if(name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)){name=name.substr(1,name.length-2);name=ctx.stylize(name,"name")}else{name=name.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'");name=ctx.stylize(name,"string")}}return name+": "+str}function reduceToSingleString(output,base,braces){var numLinesEst=0;var length=output.reduce(function(prev,cur){numLinesEst++;if(cur.indexOf("\n")>=0)numLinesEst++;return prev+cur.replace(/\u001b\[\d\d?m/g,"").length+1},0);if(length>60){return braces[0]+(base===""?"":base+"\n ")+" "+output.join(",\n ")+" "+braces[1]}return braces[0]+base+" "+output.join(", ")+" "+braces[1]}function isArray(ar){return Array.isArray(ar)}exports.isArray=isArray;function isBoolean(arg){return typeof arg==="boolean"}exports.isBoolean=isBoolean;function isNull(arg){return arg===null}exports.isNull=isNull;function isNullOrUndefined(arg){return arg==null}exports.isNullOrUndefined=isNullOrUndefined;function isNumber(arg){return typeof arg==="number"}exports.isNumber=isNumber;function isString(arg){return typeof arg==="string"}exports.isString=isString;function isSymbol(arg){return typeof arg==="symbol"}exports.isSymbol=isSymbol;function isUndefined(arg){return arg===void 0}exports.isUndefined=isUndefined;function isRegExp(re){return isObject(re)&&objectToString(re)==="[object RegExp]"}exports.isRegExp=isRegExp;function isObject(arg){return typeof arg==="object"&&arg!==null}exports.isObject=isObject;function isDate(d){return isObject(d)&&objectToString(d)==="[object Date]"}exports.isDate=isDate;function isError(e){return isObject(e)&&(objectToString(e)==="[object Error]"||e instanceof Error)}exports.isError=isError;function isFunction(arg){return typeof arg==="function"}exports.isFunction=isFunction;function isPrimitive(arg){return arg===null||typeof arg==="boolean"||typeof arg==="number"||typeof arg==="string"||typeof arg==="symbol"||typeof arg==="undefined"}exports.isPrimitive=isPrimitive;exports.isBuffer=require("./support/isBuffer");function objectToString(o){return Object.prototype.toString.call(o)}function pad(n){return n<10?"0"+n.toString(10):n.toString(10)}var months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function timestamp(){var d=new Date;var time=[pad(d.getHours()),pad(d.getMinutes()),pad(d.getSeconds())].join(":");return[d.getDate(),months[d.getMonth()],time].join(" ")}exports.log=function(){console.log("%s - %s",timestamp(),exports.format.apply(exports,arguments))};exports.inherits=require("inherits");exports._extend=function(origin,add){if(!add||!isObject(add))return origin;var keys=Object.keys(add);var i=keys.length;while(i--){origin[keys[i]]=add[keys[i]]}return origin};function hasOwnProperty(obj,prop){return Object.prototype.hasOwnProperty.call(obj,prop)}}).call(this,require("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./support/isBuffer":4,_process:3,inherits:2}],highland:[function(require,module,exports){(function(process,global){var inherits=require("util").inherits;var EventEmitter=require("events").EventEmitter;exports=module.exports=function(xs,ee,mappingHint){return new Stream(xs,ee,mappingHint)};var _=exports;var ArrayProto=Array.prototype,ObjProto=Object.prototype;var slice=ArrayProto.slice,toString=ObjProto.toString;_.isFunction=function(x){return typeof x==="function"};_.isObject=function(x){return typeof x==="object"&&x!==null};_.isString=function(x){return typeof x==="string"};_.isArray=Array.isArray||function(x){return toString.call(x)==="[object Array]"};if(typeof setImmediate==="undefined"){if(typeof process==="undefined"||!process.nextTick){_.setImmediate=function(fn){setTimeout(fn,0)}}else{_.setImmediate=process.nextTick}}else if(typeof process==="undefined"||!process.stdout){_.setImmediate=function(fn){setImmediate(fn)}}else{_.setImmediate=setImmediate}var _global=this;if(typeof global!=="undefined"){_global=global}else if(typeof window!=="undefined"){_global=window}if(!_global.nil){_global.nil={}}var nil=_.nil=_global.nil;_.curry=function(fn){var args=slice.call(arguments);return _.ncurry.apply(this,[fn.length].concat(args))};_.ncurry=function(n,fn){var largs=slice.call(arguments,2);if(largs.length>=n){return fn.apply(this,largs.slice(0,n))}return function(){var args=largs.concat(slice.call(arguments));if(args.length<n){return _.ncurry.apply(this,[n,fn].concat(args))}return fn.apply(this,args.slice(0,n))}};_.partial=function(f){var args=slice.call(arguments,1);return function(){return f.apply(this,args.concat(slice.call(arguments)))}};_.flip=_.curry(function(fn,x,y){return fn(y,x)});_.compose=function(){var fns=slice.call(arguments).reverse();return _.seq.apply(null,fns)};_.seq=function(){var fns=slice.call(arguments);return function(){if(!fns.length){return}var r=fns[0].apply(this,arguments);for(var i=1;i<fns.length;i++){r=fns[i].call(this,r)}return r}};function Stream(xs,ee,mappingHint){if(xs&&_.isStream(xs)){return xs}EventEmitter.call(this);var self=this;self.__HighlandStream__=true;self.id=(""+Math.random()).substr(2,6);this.paused=true;this._incoming=[];this._outgoing=[];this._consumers=[];this._observers=[];this._destructors=[];this._send_events=false;this._delegate=null;this.source=null;this.writable=true;self.on("newListener",function(ev){if(ev==="data"){self._send_events=true;_.setImmediate(self.resume.bind(self))}else if(ev==="end"){self._send_events=true}});self.on("removeListener",function(ev){if(ev==="end"||ev==="data"){var end_listeners=self.listeners("end").length;var data_listeners=self.listeners("data").length;if(end_listeners+data_listeners===0){self._send_events=false}}});if(xs===undefined){}else if(_.isArray(xs)){self._incoming=xs.concat([nil])}else if(typeof xs==="function"){this._generator=xs;this._generator_push=function(err,x){self.write(err?new StreamError(err):x)};this._generator_next=function(s){if(s){var _paused=self.paused;if(!_paused){self.pause()}self.write(new StreamRedirect(s));if(!_paused){self.resume()}}else{self._generator_running=false}if(!self.paused){self.resume()}}}else if(_.isObject(xs)){if(_.isFunction(xs.then)){return _(function(push){xs.then(function(value){push(null,value);return push(null,nil)},function(err){push(err);return push(null,nil)})})}else{xs.on("error",function(err){self.write(new StreamError(err))});xs.pipe(self)}}else if(typeof xs==="string"){var mappingHintType=typeof mappingHint;var mapper;if(mappingHintType==="function"){mapper=mappingHint}else if(mappingHintType==="number"){mapper=function(){return slice.call(arguments,0,mappingHint)}}else if(_.isArray(mappingHint)){mapper=function(){var args=arguments;return mappingHint.reduce(function(ctx,hint,idx){ctx[hint]=args[idx];return ctx},{})}}else{mapper=function(x){return x}}ee.on(xs,function(){var ctx=mapper.apply(this,arguments);self.write(ctx)})}else{throw new Error("Unexpected argument type to Stream(): "+typeof xs)}}inherits(Stream,EventEmitter);function exposeMethod(name){var f=Stream.prototype[name];var n=f.length;_[name]=_.ncurry(n+1,function(){var args=Array.prototype.slice.call(arguments);var s=_(args.pop());return f.apply(s,args)})}function StreamError(err){this.__HighlandStreamError__=true;this.error=err}function StreamRedirect(to){this.__HighlandStreamRedirect__=true;this.to=to}_.isStream=function(x){return _.isObject(x)&&x.__HighlandStream__};_._isStreamError=function(x){return _.isObject(x)&&x.__HighlandStreamError__};_._isStreamRedirect=function(x){return _.isObject(x)&&x.__HighlandStreamRedirect__};Stream.prototype._send=function(err,x){if(x===nil){this.ended=true}if(this._consumers.length){for(var i=0,len=this._consumers.length;i<len;i++){var c=this._consumers[i];if(err){c.write(new StreamError(err))}else{c.write(x)}}}if(this._observers.length){for(var j=0,len2=this._observers.length;j<len2;j++){this._observers[j].write(x)}}if(this._send_events){if(x===nil){this.emit("end")}else{this.emit("data",x)}}};Stream.prototype.pause=function(){this.paused=true;if(this.source){this.source._checkBackPressure()}};Stream.prototype._checkBackPressure=function(){if(!this._consumers.length){return this.pause()}for(var i=0,len=this._consumers.length;i<len;i++){if(this._consumers[i].paused){return this.pause()
}}return this.resume()};Stream.prototype._readFromBuffer=function(){var len=this._incoming.length;var i=0;while(i<len&&!this.paused){var x=this._incoming[i];if(_._isStreamError(x)){this._send(x.error)}else if(_._isStreamRedirect(x)){this._redirect(x.to)}else{this._send(null,x)}i++}this._incoming.splice(0,i)};Stream.prototype._sendOutgoing=function(){var len=this._outgoing.length;var i=0;while(i<len&&!this.paused){var x=this._outgoing[i];if(_._isStreamError(x)){Stream.prototype._send.call(this,x.error)}else if(_._isStreamRedirect(x)){this._redirect(x.to)}else{Stream.prototype._send.call(this,null,x)}i++}this._outgoing.splice(0,i)};Stream.prototype.resume=function(){if(this._resume_running){this._repeat_resume=true;return}this._resume_running=true;do{this._repeat_resume=false;this.paused=false;this._sendOutgoing();this._readFromBuffer();if(!this.paused){if(this.source){this.source._checkBackPressure()}else if(this._generator){this._runGenerator()}else{this.emit("drain")}}}while(this._repeat_resume);this._resume_running=false};Stream.prototype.end=function(){this.write(nil)};Stream.prototype.pipe=function(dest){var self=this;var canClose=dest!==process.stdout&&dest!==process.stderr;var s=self.consume(function(err,x,push,next){if(err){self.emit("error",err);return}if(x===nil){if(canClose){dest.end()}}else if(dest.write(x)!==false){next()}});dest.on("drain",onConsumerDrain);this._destructors.push(function(){dest.removeListener("drain",onConsumerDrain)});s.resume();return dest;function onConsumerDrain(){s.resume()}};Stream.prototype.destroy=function(){var self=this;this.end();_(this._consumers).each(function(consumer){self._removeConsumer(consumer)});if(this.source){this.source._removeConsumer(this)}_(this._destructors).each(function(destructor){destructor()})};Stream.prototype._runGenerator=function(){if(this._generator_running){return}this._generator_running=true;this._generator(this._generator_push,this._generator_next)};Stream.prototype._redirect=function(to){to=_(to);while(to._delegate){to=to._delegate}to._consumers=this._consumers.map(function(c){c.source=to;return c});this._consumers=[];to._delegate_source=this._delegate_source||this;to._delegate_source._delegate=to;if(this.paused){to.pause()}else{this.pause();to._checkBackPressure()}};Stream.prototype._addConsumer=function(s){if(this._consumers.length){throw new Error("Stream already being consumed, you must either fork() or observe()")}s.source=this;this._consumers.push(s);this._checkBackPressure()};Stream.prototype._removeConsumer=function(s){var src=this;while(src._delegate){src=src._delegate}src._consumers=src._consumers.filter(function(c){return c!==s});if(s.source===src){s.source=null}src._checkBackPressure()};Stream.prototype.consume=function(f){var self=this;while(self._delegate){self=self._delegate}var s=new Stream;var _send=s._send;var push=function(err,x){if(x===nil){self._removeConsumer(s)}if(s.paused){if(err){s._outgoing.push(new StreamError(err))}else{s._outgoing.push(x)}}else{_send.call(s,err,x)}};var async;var next_called;var next=function(s2){if(s2){var _paused=s.paused;if(!_paused){s.pause()}s.write(new StreamRedirect(s2));if(!_paused){s.resume()}}else if(async){s.resume()}else{next_called=true}};s._send=function(err,x){async=false;next_called=false;f(err,x,push,next);async=true;if(!next_called){s.pause()}};self._addConsumer(s);return s};exposeMethod("consume");Stream.prototype.pull=function(f){var s=this.consume(function(err,x){s.source._removeConsumer(s);f(err,x)});s.id="pull:"+s.id;s.resume()};Stream.prototype.write=function(x){if(this.paused){this._incoming.push(x)}else{if(_._isStreamError(x)){this._send(x.error)}else{this._send(null,x)}}return!this.paused};Stream.prototype.fork=function(){var s=new Stream;s.id="fork:"+s.id;s.source=this;this._consumers.push(s);this._checkBackPressure();return s};Stream.prototype.observe=function(){var s=new Stream;s.id="observe:"+s.id;s.source=this;this._observers.push(s);return s};Stream.prototype.errors=function(f){return this.consume(function(err,x,push,next){if(err){f(err,push);next()}else if(x===nil){push(null,nil)}else{push(null,x);next()}})};exposeMethod("errors");Stream.prototype.stopOnError=function(f){return this.consume(function(err,x,push,next){if(err){f(err,push);push(null,nil)}else if(x===nil){push(null,nil)}else{push(null,x);next()}})};exposeMethod("stopOnError");Stream.prototype.each=function(f){var self=this;return this.consume(function(err,x,push,next){if(err){self.emit("error",err)}else if(x!==nil){f(x);next()}}).resume()};exposeMethod("each");Stream.prototype.apply=function(f){return this.toArray(function(args){f.apply(null,args)})};exposeMethod("apply");Stream.prototype.toArray=function(f){var self=this;var xs=[];var s=this.consume(function(err,x,push,next){if(err){self.emit("error",err)}else if(x===nil){f(xs)}else{xs.push(x);next()}});s.id="toArray:"+s.id;s.resume()};Stream.prototype.map=function(f){if(!_.isFunction(f)){var val=f;f=function(){return val}}return this.consume(function(err,x,push,next){if(err){push(err);next()}else if(x===nil){push(err,x)}else{var fnVal,fnErr;try{fnVal=f(x)}catch(e){fnErr=e}push(fnErr,fnVal);next()}})};exposeMethod("map");Stream.prototype.doto=function(f){return this.map(function(x){f(x);return x})};exposeMethod("doto");Stream.prototype.ratelimit=function(num,ms){if(num<1){throw new Error("Invalid number of operations per ms: "+num)}var sent=0;return this.consume(function(err,x,push,next){if(err){push(err);next()}else if(x===nil){push(null,nil)}else{if(sent<num){sent++;push(null,x);next()}else{setTimeout(function(){sent=1;push(null,x);next()},ms)}}})};exposeMethod("ratelimit");Stream.prototype.flatMap=function(f){return this.map(f).sequence()};exposeMethod("flatMap");Stream.prototype.pluck=function(prop){return this.consume(function(err,x,push,next){if(err){push(err);next()}else if(x===nil){push(err,x)}else if(_.isObject(x)){push(null,x[prop]);next()}else{push(new Error("Expected Object, got "+typeof x));next()}})};exposeMethod("pluck");Stream.prototype.filter=function(f){return this.consume(function(err,x,push,next){if(err){push(err);next()}else if(x===nil){push(err,x)}else{var fnVal,fnErr;try{fnVal=f(x)}catch(e){fnErr=e}if(fnErr){push(fnErr)}else if(fnVal){push(null,x)}next()}})};exposeMethod("filter");Stream.prototype.flatFilter=function(f){return this.flatMap(function(x){return f(x).take(1).otherwise(errorStream()).flatMap(function(bool){return _(bool?[x]:[])})});function errorStream(){return _(function(push){push(new Error("Stream returned by function was empty."));push(null,_.nil)})}};exposeMethod("flatFilter");Stream.prototype.reject=function(f){return this.filter(_.compose(_.not,f))};exposeMethod("reject");Stream.prototype.find=function(f){return this.filter(f).take(1)};exposeMethod("find");Stream.prototype.group=function(f){var lambda=_.isString(f)?_.get(f):f;return this.reduce({},function(m,o){var key=lambda(o);if(!m.hasOwnProperty(key)){m[key]=[]}m[key].push(o);return m}.bind(this))};exposeMethod("group");Stream.prototype.compact=function(){return this.filter(function(x){return x})};exposeMethod("compact");Stream.prototype.where=function(props){return this.filter(function(x){for(var k in props){if(x[k]!==props[k]){return false}}return true})};exposeMethod("where");Stream.prototype.zip=function(ys){ys=_(ys);var xs=this;var returned=0;var z=[];function nextValue(index,max,src,push,next){src.pull(function(err,x){if(err){push(err);nextValue(index,max,src,push,next)}else if(x===_.nil){push(null,nil)}else{returned++;z[index]=x;if(returned===max){push(null,z);next()}}})}return _(function(push,next){returned=0;z=[];nextValue(0,2,xs,push,next);nextValue(1,2,ys,push,next)})};exposeMethod("zip");Stream.prototype.batch=function(n){var batched=[];return this.consume(function(err,x,push,next){if(err){push(err);next()}if(x===nil){if(batched.length>0){push(null,batched)}push(null,nil)}else{batched.push(x);if(batched.length===n){push(null,batched);batched=[]}next()}})};exposeMethod("batch");Stream.prototype.take=function(n){if(n===0){return _([])}var s=this.consume(function(err,x,push,next){if(err){push(err);if(n>0){next()}else{push(null,nil)}}else if(x===nil){push(null,nil)}else{n--;push(null,x);if(n>0){next()}else{push(null,nil)}}});s.id="take:"+s.id;return s};exposeMethod("take");Stream.prototype.head=function(){return this.take(1)};exposeMethod("head");Stream.prototype.last=function(){var nothing={};var prev=nothing;return this.consume(function(err,x,push,next){if(err){push(err);next()}else if(x===nil){if(prev!==nothing){push(null,prev)}push(null,nil)}else{prev=x;next()}})};exposeMethod("last");Stream.prototype.through=function(target){if(_.isFunction(target)){return target(this)}else{var output=_();target.pause();this.pipe(target).pipe(output);return output}};exposeMethod("through");_.pipeline=function(){if(!arguments.length){return _()}var start=arguments[0],rest;if(!_.isStream(start)&&!_.isFunction(start.resume)){start=_();rest=slice.call(arguments)}else{start=_(start);rest=slice.call(arguments,1)}var end=rest.reduce(function(src,dest){return src.through(dest)},start);var wrapper=_(function(push,next){end.pull(function(err,x){if(err){wrapper._send(err);next()}else if(x===nil){wrapper._send(null,nil)}else{wrapper._send(null,x);next()}})});wrapper.write=function(x){start.write(x)};return wrapper};Stream.prototype.sequence=function(){var original=this;var curr=this;return _(function(push,next){curr.pull(function(err,x){if(err){push(err);return next()}else if(_.isArray(x)){if(onOriginalStream()){x.forEach(function(y){push(null,y)})}else{push(null,x)}return next()}else if(_.isStream(x)){if(onOriginalStream()){curr=x;return next()}else{push(null,x);return next()}}else if(x===nil){if(onOriginalStream()){push(null,nil)}else{curr=original;return next()}}else{if(onOriginalStream()){push(new Error("Expected Stream, got "+typeof x));return next()}else{push(null,x);return next()}}})});function onOriginalStream(){return curr===original}};exposeMethod("sequence");Stream.prototype.series=Stream.prototype.sequence;_.series=_.sequence;Stream.prototype.flatten=function(){var curr=this;var stack=[];return _(function(push,next){curr.pull(function(err,x){if(err){push(err);return next()}if(_.isArray(x)){x=_(x)}if(_.isStream(x)){stack.push(curr);curr=x;next()}else if(x===nil){if(stack.length){curr=stack.pop();next()}else{push(null,nil)}}else{push(null,x);next()}})})};exposeMethod("flatten");Stream.prototype.parallel=function(n){var source=this;var running=[];var ended=false;var reading_source=false;return _(function(push,next){if(running.length&&running[0].buffer.length){var buf=running[0].buffer;for(var i=0;i<buf.length;i++){if(buf[i][1]===nil){running.shift();return next()}else{push.apply(null,buf[i])}}}else if(running.length<n&&!ended&&!reading_source){reading_source=true;source.pull(function(err,x){reading_source=false;if(err){push(err)}else if(x===nil){ended=true}else{var run={stream:x,buffer:[]};running.push(run);x.consume(function(err,y,_push,_next){if(running[0]===run){if(y===nil){running.shift();next()}else{push(err,y)}}else{run.buffer.push([err,y])}if(y!==nil){_next()}}).resume()}return next()})}else if(!running.length&&ended){push(null,nil)}else{}})};exposeMethod("parallel");Stream.prototype.otherwise=function(ys){var xs=this;return xs.consume(function(err,x,push,next){if(err){push(err);next()}if(x===nil){next(ys)}else{push(null,x);next(xs)}})};exposeMethod("otherwise");Stream.prototype.append=function(y){return this.consume(function(err,x,push,next){if(x===nil){push(null,y);push(null,_.nil)}else{push(err,x);next()}})};exposeMethod("append");Stream.prototype.reduce=function(z,f){return this.consume(function(err,x,push,next){if(x===nil){push(null,z);push(null,_.nil)}else if(err){push(err);next()}else{try{z=f(z,x)}catch(e){push(e);push(null,_.nil);return}next()}})};exposeMethod("reduce");Stream.prototype.reduce1=function(f){var self=this;return _(function(push,next){self.pull(function(err,x){if(err){push(err);next()}if(x===nil){push(null,nil)}else{next(self.reduce(x,f))}})})};exposeMethod("reduce1");Stream.prototype.collect=function(){var xs=[];return this.consume(function(err,x,push,next){if(err){push(err);next()}else if(x===nil){push(null,xs);push(null,nil)}else{xs.push(x);next()}})};exposeMethod("collect");Stream.prototype.scan=function(z,f){var self=this;return _([z]).concat(self.consume(function(err,x,push,next){if(x===nil){push(null,_.nil)}else if(err){push(err);next()}else{try{z=f(z,x)}catch(e){push(e);push(null,_.nil);return}push(null,z);next()}}))};exposeMethod("scan");Stream.prototype.scan1=function(f){var self=this;return _(function(push,next){self.pull(function(err,x){if(err){push(err);next()}if(x===nil){push(null,nil)}else{next(self.scan(x,f))}})})};exposeMethod("scan1");Stream.prototype.concat=function(ys){ys=_(ys);return this.consume(function(err,x,push,next){if(x===nil){next(ys)}else{push(err,x);next()}})};exposeMethod("concat");Stream.prototype.merge=function(){var self=this;var resuming=false;var go_next=false;var srcs;return _(function(push,next){var safeNext=function(){if(!resuming){next()}else{go_next=true}};if(!srcs){self.errors(push).toArray(function(xs){srcs=xs;srcs.forEach(function(src){src.on("end",function(){srcs=srcs.filter(function(s){return s!==src});safeNext()});src.on("data",function(x){src.pause();push(null,x);safeNext()});src.on("error",function(err){push(err);safeNext()})});next()})}else if(srcs.length===0){push(null,nil)}else{go_next=false;resuming=true;srcs.forEach(function(src){src.resume()});resuming=false;if(go_next){next()}}})};exposeMethod("merge");Stream.prototype.invoke=function(method,args){return this.map(function(x){return x[method].apply(x,args)})};exposeMethod("invoke");Stream.prototype.throttle=function(ms){var s=new Stream;var last=0-ms;var _write=s.write;s.write=function(x){var now=(new Date).getTime();if(_._isStreamError(x)||x===nil){return _write.apply(this,arguments)}else if(now-ms>=last){last=now;return _write.apply(this,arguments)}};this._addConsumer(s);return s};exposeMethod("throttle");Stream.prototype.debounce=function(ms){var s=new Stream;var t=null;var nothing={};var last=nothing;var _write=s.write;s.write=function(x){if(_._isStreamError(x)){return _write.apply(this,arguments)}else if(x===nil){if(t){clearTimeout(t)}if(last!==nothing){_write.call(s,last)}return _write.apply(this,arguments)}else{last=x;if(t){clearTimeout(t)}t=setTimeout(function(){_write.call(s,last)},ms);return!this.paused}};this._addConsumer(s);return s};exposeMethod("debounce");Stream.prototype.latest=function(){var s=new Stream;var _write=s.write;s.pause=function(){this.paused=true};s.write=function(x){if(_._isStreamError(x)){_write.call(this,x)}else if(x===nil){_write.call(this,x)}else{if(this.paused){this._incoming=this._incoming.filter(function(x){return _._isStreamError(x)||x===nil});this._incoming.push(x)}else{_write.call(this,x)}}return true};this._addConsumer(s);s.resume();return s};exposeMethod("latest");_.values=function(obj){return _.keys(obj).map(function(k){return obj[k]})};_.keys=function(obj){var keys=[];for(var k in obj){if(obj.hasOwnProperty(k)){keys.push(k)}}return _(keys)};_.pairs=function(obj){return _.keys(obj).map(function(k){return[k,obj[k]]})};_.extend=_.curry(function(extensions,target){for(var k in extensions){if(extensions.hasOwnProperty(k)){target[k]=extensions[k]}}return target});_.get=_.curry(function(prop,obj){return obj[prop]});_.set=_.curry(function(prop,val,obj){obj[prop]=val;return obj});_.log=function(){console.log.apply(console,arguments)};_.wrapCallback=function(f){return function(){var args=slice.call(arguments);return _(function(push){var cb=function(err,x){if(err){push(err)}else{push(null,x)}push(null,nil)};f.apply(null,args.concat([cb]))})}};_.add=_.curry(function(a,b){return a+b});_.not=function(x){return!x}}).call(this,require("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{_process:3,events:1,util:5}]},{},[]);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}({"transducers.js":[function(require,module,exports){var symbolExists=typeof Symbol!=="undefined";var protocols={iterator:symbolExists?Symbol.iterator:"@@iterator",transformer:symbolExists?Symbol("transformer"):"@@transformer"};function throwProtocolError(name,coll){throw new Error("don't know how to "+name+" collection: "+coll)}function fulfillsProtocol(obj,name){if(name==="iterator"){return obj[protocols.iterator]||obj.next}return obj[protocols[name]]}function getProtocolProperty(obj,name){return obj[protocols[name]]}function iterator(coll){var iter=getProtocolProperty(coll,"iterator");if(iter){return iter.call(coll)}else if(coll.next){return coll}else if(isArray(coll)){return new ArrayIterator(coll)}else if(isObject(coll)){return new ObjectIterator(coll)}}function ArrayIterator(arr){this.arr=arr;this.index=0}ArrayIterator.prototype.next=function(){if(this.index<this.arr.length){return{value:this.arr[this.index++],done:false}}return{done:true}};function ObjectIterator(obj){this.obj=obj;this.keys=Object.keys(obj);this.index=0}ObjectIterator.prototype.next=function(){if(this.index<this.keys.length){var k=this.keys[this.index++];return{value:[k,this.obj[k]],done:false}}return{done:true}};var toString=Object.prototype.toString;var isArray=typeof Array.isArray==="function"?Array.isArray:function(obj){return toString.call(obj)=="[object Array]"};function isFunction(x){return typeof x==="function"}function isObject(x){return x instanceof Object&&Object.getPrototypeOf(x)===Object.getPrototypeOf({})}function isNumber(x){return typeof x==="number"}function Reduced(val){this.val=val}function reduce(coll,xform,init){if(isArray(coll)){var result=init;var index=-1;var len=coll.length;while(++index<len){result=xform.step(result,coll[index]);if(result instanceof Reduced){return result.val}}return xform.result(result)}else if(isObject(coll)||fulfillsProtocol(coll,"iterator")){var result=init;var iter=iterator(coll);var val=iter.next();while(!val.done){result=xform.step(result,val.value);if(result instanceof Reduced){return result.val}val=iter.next()}return xform.result(result)}throwProtocolError("iterate",coll)}function transduce(coll,xform,reducer,init){xform=xform(reducer);if(init===undefined){init=xform.init()}return reduce(coll,xform,init)}function compose(){var funcs=Array.prototype.slice.call(arguments);return function(r){var value=r;for(var i=funcs.length-1;i>=0;i--){value=funcs[i](value)}return value}}function transformer(f){return{init:function(){throw new Error("init value unavailable")},result:function(v){return v},step:f}}function bound(f,ctx,count){count=count!=null?count:1;if(!ctx){return f}else{switch(count){case 1:return function(x){return f.call(ctx,x)};case 2:return function(x,y){return f.call(ctx,x,y)};default:return f.bind(ctx)}}}function arrayMap(arr,f,ctx){var index=-1;var length=arr.length;var result=Array(length);f=bound(f,ctx,2);while(++index<length){result[index]=f(arr[index],index)}return result}function arrayFilter(arr,f,ctx){var len=arr.length;var result=[];f=bound(f,ctx,2);for(var i=0;i<len;i++){if(f(arr[i],i)){result.push(arr[i])}}return result}function Map(f,xform){this.xform=xform;this.f=f}Map.prototype.init=function(){return this.xform.init()};Map.prototype.result=function(v){return this.xform.result(v)};Map.prototype.step=function(res,input){return this.xform.step(res,this.f(input))};function map(coll,f,ctx){if(isFunction(coll)){ctx=f;f=coll;coll=null}f=bound(f,ctx);if(coll){if(isArray(coll)){return arrayMap(coll,f,ctx)}return seq(coll,map(f))}return function(xform){return new Map(f,xform)}}function Filter(f,xform){this.xform=xform;this.f=f}Filter.prototype.init=function(){return this.xform.init()};Filter.prototype.result=function(v){return this.xform.result(v)};Filter.prototype.step=function(res,input){if(this.f(input)){return this.xform.step(res,input)}return res};function filter(coll,f,ctx){if(isFunction(coll)){ctx=f;f=coll;coll=null}f=bound(f,ctx);if(coll){if(isArray(coll)){return arrayFilter(coll,f,ctx)}return seq(coll,filter(f))}return function(xform){return new Filter(f,xform)}}function remove(coll,f,ctx){if(isFunction(coll)){ctx=f;f=coll;coll=null}f=bound(f,ctx);return filter(coll,function(x){return!f(x)})}function keep(coll){return filter(coll,function(x){return x!=null})}function Dedupe(xform){this.xform=xform;this.last=undefined}Dedupe.prototype.init=function(){return this.xform.init()};Dedupe.prototype.result=function(v){return this.xform.result(v)};Dedupe.prototype.step=function(result,input){if(input!==this.last){this.last=input;return this.xform.step(result,input)}return result};function dedupe(coll){if(coll){return seq(coll,dedupe())}return function(xform){return new Dedupe(xform)}}function TakeWhile(f,xform){this.xform=xform;this.f=f}TakeWhile.prototype.init=function(){return this.xform.init()};TakeWhile.prototype.result=function(v){return this.xform.result(v)};TakeWhile.prototype.step=function(result,input){if(this.f(input)){return this.xform.step(result,input)}return new Reduced(result)};function takeWhile(coll,f,ctx){if(isFunction(coll)){ctx=f;f=coll;coll=null}f=bound(f,ctx);if(coll){return seq(coll,takeWhile(f))}return function(xform){return new TakeWhile(f,xform)}}function Take(n,xform){this.n=n;this.i=0;this.xform=xform}Take.prototype.init=function(){return this.xform.init()};Take.prototype.result=function(v){return this.xform.result(v)};Take.prototype.step=function(result,input){if(this.i++<this.n){return this.xform.step(result,input)}return new Reduced(result)};function take(coll,n){if(isNumber(coll)){n=coll;coll=null}if(coll){return seq(coll,take(n))}return function(xform){return new Take(n,xform)}}function Drop(n,xform){this.n=n;this.i=0;this.xform=xform}Drop.prototype.init=function(){return this.xform.init()};Drop.prototype.result=function(v){return this.xform.result(v)};Drop.prototype.step=function(result,input){if(this.i++<this.n){return result}return this.xform.step(result,input)};function drop(coll,n){if(isNumber(coll)){n=coll;coll=null}if(coll){return seq(coll,drop(n))}return function(xform){return new Drop(n,xform)}}function DropWhile(f,xform){this.xform=xform;this.f=f;this.dropping=true}DropWhile.prototype.init=function(){return this.xform.init()};DropWhile.prototype.result=function(v){return this.xform.result(v)};DropWhile.prototype.step=function(result,input){if(this.dropping){if(this.f(input)){return result}else{this.dropping=false}}return this.xform.step(result,input)};function dropWhile(coll,f,ctx){if(isFunction(coll)){ctx=f;f=coll;coll=null}f=bound(f,ctx);if(coll){return seq(coll,dropWhile(f))}return function(xform){return new DropWhile(f,xform)}}function Cat(xform){this.xform=xform}Cat.prototype.init=function(){return this.xform.init()};Cat.prototype.result=function(v){return this.xform.result(v)};Cat.prototype.step=function(result,input){var xform=this.xform;var newxform={init:function(){return xform.init()},result:function(v){return v},step:function(result,input){var val=xform.step(result,input);return val instanceof Reduced?new Reduced(val):val}};return reduce(input,newxform,result)};function cat(xform){return new Cat(xform)}function mapcat(f,ctx){f=bound(f,ctx);return compose(map(f),cat)}function push(arr,x){arr.push(x);return arr}function merge(obj,x){if(isArray(x)&&x.length===2){obj[x[0]]=x[1]}else{var keys=Object.keys(x);var len=keys.length;for(var i=0;i<len;i++){obj[keys[i]]=x[keys[i]]}}return obj}var arrayReducer={init:function(){return[]},result:function(v){return v},step:push};var objReducer={init:function(){return{}},result:function(v){return v},step:merge};function getReducer(coll){if(isArray(coll)){return arrayReducer}else if(isObject(coll)){return objReducer}else if(fulfillsProtocol(coll,"transformer")){return getProtocolProperty(coll,"transformer")}throwProtocolError("getReducer",coll)}function toArray(coll,xform){if(!xform){return reduce(coll,arrayReducer,[])}return transduce(coll,xform,arrayReducer,[])}function toObj(coll,xform){if(!xform){return reduce(coll,objReducer,{})}return transduce(coll,xform,objReducer,{})}function toIter(coll,xform){if(!xform){return iterator(coll)}return new LazyTransformer(xform,coll)}function seq(coll,xform){if(isArray(coll)){return transduce(coll,xform,arrayReducer,[])}else if(isObject(coll)){return transduce(coll,xform,objReducer,{})}else if(fulfillsProtocol(coll,"transformer")){var transformer=getProtocolProperty(coll,"transformer");return transduce(coll,xform,transformer,transformer.init())}else if(fulfillsProtocol(coll,"iterator")){return new LazyTransformer(xform,coll)}throwProtocolError("sequence",coll)}function into(to,xform,from){if(isArray(to)){return transduce(from,xform,arrayReducer,to)}else if(isObject(to)){return transduce(from,xform,objReducer,to)}else if(fulfillsProtocol(to,"transformer")){return transduce(from,xform,getProtocolProperty(to,"transformer"),to)}throwProtocolError("into",to)}var stepper={result:function(v){return v instanceof Reduced?v.val:v},step:function(lt,x){lt.items.push(x);return lt.rest}};function Stepper(xform,iter){this.xform=xform(stepper);this.iter=iter}Stepper.prototype.step=function(lt){var len=lt.items.length;while(lt.items.length===len){var n=this.iter.next();if(n.done||n.value instanceof Reduced){this.xform.result(this);break}this.xform.step(lt,n.value)}};function LazyTransformer(xform,coll){this.iter=iterator(coll);this.items=[];this.stepper=new Stepper(xform,iterator(coll))}LazyTransformer.prototype[protocols.iterator]=function(){return this};LazyTransformer.prototype.next=function(){this.step();if(this.items.length){return{value:this.items.pop(),done:false}}else{return{done:true}}};LazyTransformer.prototype.step=function(){if(!this.items.length){this.stepper.step(this)}};function range(n){var arr=new Array(n);for(var i=0;i<arr.length;i++){arr[i]=i}return arr}module.exports={reduce:reduce,transformer:transformer,Reduced:Reduced,iterator:iterator,push:push,merge:merge,transduce:transduce,seq:seq,toArray:toArray,toObj:toObj,toIter:toIter,into:into,compose:compose,map:map,filter:filter,remove:remove,cat:cat,mapcat:mapcat,keep:keep,dedupe:dedupe,take:take,takeWhile:takeWhile,drop:drop,dropWhile:dropWhile,range:range,protocols:protocols,LazyTransformer:LazyTransformer}},{}]},{},[]);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}({1:[function(require,module,exports){},{}],2:[function(require,module,exports){var base64=require("base64-js");var ieee754=require("ieee754");exports.Buffer=Buffer;exports.SlowBuffer=Buffer;exports.INSPECT_MAX_BYTES=50;Buffer.poolSize=8192;var TYPED_ARRAY_SUPPORT=function(){try{var buf=new ArrayBuffer(0);var arr=new Uint8Array(buf);arr.foo=function(){return 42};return 42===arr.foo()&&typeof arr.subarray==="function"&&new Uint8Array(1).subarray(1,1).byteLength===0}catch(e){return false}}();function Buffer(subject,encoding,noZero){if(!(this instanceof Buffer))return new Buffer(subject,encoding,noZero);var type=typeof subject;var length;if(type==="number")length=subject>0?subject>>>0:0;else if(type==="string"){if(encoding==="base64")subject=base64clean(subject);length=Buffer.byteLength(subject,encoding)}else if(type==="object"&&subject!==null){if(subject.type==="Buffer"&&isArray(subject.data))subject=subject.data;length=+subject.length>0?Math.floor(+subject.length):0}else throw new Error("First argument needs to be a number, array or string.");var buf;if(TYPED_ARRAY_SUPPORT){buf=Buffer._augment(new Uint8Array(length))}else{buf=this;buf.length=length;buf._isBuffer=true}var i;if(TYPED_ARRAY_SUPPORT&&typeof subject.byteLength==="number"){buf._set(subject)}else if(isArrayish(subject)){if(Buffer.isBuffer(subject)){for(i=0;i<length;i++)buf[i]=subject.readUInt8(i)}else{for(i=0;i<length;i++)buf[i]=(subject[i]%256+256)%256}}else if(type==="string"){buf.write(subject,0,encoding)}else if(type==="number"&&!TYPED_ARRAY_SUPPORT&&!noZero){for(i=0;i<length;i++){buf[i]=0}}return buf}Buffer.isEncoding=function(encoding){switch(String(encoding).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return true;default:return false}};Buffer.isBuffer=function(b){return!!(b!=null&&b._isBuffer)};Buffer.byteLength=function(str,encoding){var ret;str=str.toString();switch(encoding||"utf8"){case"hex":ret=str.length/2;break;case"utf8":case"utf-8":ret=utf8ToBytes(str).length;break;case"ascii":case"binary":case"raw":ret=str.length;break;case"base64":ret=base64ToBytes(str).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":ret=str.length*2;break;default:throw new Error("Unknown encoding")}return ret};Buffer.concat=function(list,totalLength){assert(isArray(list),"Usage: Buffer.concat(list[, length])");if(list.length===0){return new Buffer(0)}else if(list.length===1){return list[0]}var i;if(totalLength===undefined){totalLength=0;for(i=0;i<list.length;i++){totalLength+=list[i].length}}var buf=new Buffer(totalLength);var pos=0;for(i=0;i<list.length;i++){var item=list[i];item.copy(buf,pos);pos+=item.length}return buf};Buffer.compare=function(a,b){assert(Buffer.isBuffer(a)&&Buffer.isBuffer(b),"Arguments must be Buffers");var x=a.length;var y=b.length;for(var i=0,len=Math.min(x,y);i<len&&a[i]===b[i];i++){}if(i!==len){x=a[i];y=b[i]}if(x<y){return-1}if(y<x){return 1}return 0};function hexWrite(buf,string,offset,length){offset=Number(offset)||0;var remaining=buf.length-offset;if(!length){length=remaining}else{length=Number(length);if(length>remaining){length=remaining}}var strLen=string.length;assert(strLen%2===0,"Invalid hex string");if(length>strLen/2){length=strLen/2}for(var i=0;i<length;i++){var byte=parseInt(string.substr(i*2,2),16);assert(!isNaN(byte),"Invalid hex string");buf[offset+i]=byte}return i}function utf8Write(buf,string,offset,length){var charsWritten=blitBuffer(utf8ToBytes(string),buf,offset,length);return charsWritten}function asciiWrite(buf,string,offset,length){var charsWritten=blitBuffer(asciiToBytes(string),buf,offset,length);return charsWritten}function binaryWrite(buf,string,offset,length){return asciiWrite(buf,string,offset,length)}function base64Write(buf,string,offset,length){var charsWritten=blitBuffer(base64ToBytes(string),buf,offset,length);return charsWritten}function utf16leWrite(buf,string,offset,length){var charsWritten=blitBuffer(utf16leToBytes(string),buf,offset,length);return charsWritten}Buffer.prototype.write=function(string,offset,length,encoding){if(isFinite(offset)){if(!isFinite(length)){encoding=length;length=undefined}}else{var swap=encoding;encoding=offset;offset=length;length=swap}offset=Number(offset)||0;var remaining=this.length-offset;if(!length){length=remaining}else{length=Number(length);if(length>remaining){length=remaining}}encoding=String(encoding||"utf8").toLowerCase();var ret;switch(encoding){case"hex":ret=hexWrite(this,string,offset,length);break;case"utf8":case"utf-8":ret=utf8Write(this,string,offset,length);break;case"ascii":ret=asciiWrite(this,string,offset,length);break;case"binary":ret=binaryWrite(this,string,offset,length);break;case"base64":ret=base64Write(this,string,offset,length);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":ret=utf16leWrite(this,string,offset,length);
break;default:throw new Error("Unknown encoding")}return ret};Buffer.prototype.toString=function(encoding,start,end){var self=this;encoding=String(encoding||"utf8").toLowerCase();start=Number(start)||0;end=end===undefined?self.length:Number(end);if(end===start)return"";var ret;switch(encoding){case"hex":ret=hexSlice(self,start,end);break;case"utf8":case"utf-8":ret=utf8Slice(self,start,end);break;case"ascii":ret=asciiSlice(self,start,end);break;case"binary":ret=binarySlice(self,start,end);break;case"base64":ret=base64Slice(self,start,end);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":ret=utf16leSlice(self,start,end);break;default:throw new Error("Unknown encoding")}return ret};Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};Buffer.prototype.equals=function(b){assert(Buffer.isBuffer(b),"Argument must be a Buffer");return Buffer.compare(this,b)===0};Buffer.prototype.compare=function(b){assert(Buffer.isBuffer(b),"Argument must be a Buffer");return Buffer.compare(this,b)};Buffer.prototype.copy=function(target,target_start,start,end){var source=this;if(!start)start=0;if(!end&&end!==0)end=this.length;if(!target_start)target_start=0;if(end===start)return;if(target.length===0||source.length===0)return;assert(end>=start,"sourceEnd < sourceStart");assert(target_start>=0&&target_start<target.length,"targetStart out of bounds");assert(start>=0&&start<source.length,"sourceStart out of bounds");assert(end>=0&&end<=source.length,"sourceEnd out of bounds");if(end>this.length)end=this.length;if(target.length-target_start<end-start)end=target.length-target_start+start;var len=end-start;if(len<100||!TYPED_ARRAY_SUPPORT){for(var i=0;i<len;i++){target[i+target_start]=this[i+start]}}else{target._set(this.subarray(start,start+len),target_start)}};function base64Slice(buf,start,end){if(start===0&&end===buf.length){return base64.fromByteArray(buf)}else{return base64.fromByteArray(buf.slice(start,end))}}function utf8Slice(buf,start,end){var res="";var tmp="";end=Math.min(buf.length,end);for(var i=start;i<end;i++){if(buf[i]<=127){res+=decodeUtf8Char(tmp)+String.fromCharCode(buf[i]);tmp=""}else{tmp+="%"+buf[i].toString(16)}}return res+decodeUtf8Char(tmp)}function asciiSlice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;i++){ret+=String.fromCharCode(buf[i])}return ret}function binarySlice(buf,start,end){return asciiSlice(buf,start,end)}function hexSlice(buf,start,end){var len=buf.length;if(!start||start<0)start=0;if(!end||end<0||end>len)end=len;var out="";for(var i=start;i<end;i++){out+=toHex(buf[i])}return out}function utf16leSlice(buf,start,end){var bytes=buf.slice(start,end);var res="";for(var i=0;i<bytes.length;i+=2){res+=String.fromCharCode(bytes[i]+bytes[i+1]*256)}return res}Buffer.prototype.slice=function(start,end){var len=this.length;start=~~start;end=end===undefined?len:~~end;if(start<0){start+=len;if(start<0)start=0}else if(start>len){start=len}if(end<0){end+=len;if(end<0)end=0}else if(end>len){end=len}if(end<start)end=start;if(TYPED_ARRAY_SUPPORT){return Buffer._augment(this.subarray(start,end))}else{var sliceLen=end-start;var newBuf=new Buffer(sliceLen,undefined,true);for(var i=0;i<sliceLen;i++){newBuf[i]=this[i+start]}return newBuf}};Buffer.prototype.get=function(offset){console.log(".get() is deprecated. Access using array indexes instead.");return this.readUInt8(offset)};Buffer.prototype.set=function(v,offset){console.log(".set() is deprecated. Access using array indexes instead.");return this.writeUInt8(v,offset)};Buffer.prototype.readUInt8=function(offset,noAssert){if(!noAssert){assert(offset!==undefined&&offset!==null,"missing offset");assert(offset<this.length,"Trying to read beyond buffer length")}if(offset>=this.length)return;return this[offset]};function readUInt16(buf,offset,littleEndian,noAssert){if(!noAssert){assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset+1<buf.length,"Trying to read beyond buffer length")}var len=buf.length;if(offset>=len)return;var val;if(littleEndian){val=buf[offset];if(offset+1<len)val|=buf[offset+1]<<8}else{val=buf[offset]<<8;if(offset+1<len)val|=buf[offset+1]}return val}Buffer.prototype.readUInt16LE=function(offset,noAssert){return readUInt16(this,offset,true,noAssert)};Buffer.prototype.readUInt16BE=function(offset,noAssert){return readUInt16(this,offset,false,noAssert)};function readUInt32(buf,offset,littleEndian,noAssert){if(!noAssert){assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset+3<buf.length,"Trying to read beyond buffer length")}var len=buf.length;if(offset>=len)return;var val;if(littleEndian){if(offset+2<len)val=buf[offset+2]<<16;if(offset+1<len)val|=buf[offset+1]<<8;val|=buf[offset];if(offset+3<len)val=val+(buf[offset+3]<<24>>>0)}else{if(offset+1<len)val=buf[offset+1]<<16;if(offset+2<len)val|=buf[offset+2]<<8;if(offset+3<len)val|=buf[offset+3];val=val+(buf[offset]<<24>>>0)}return val}Buffer.prototype.readUInt32LE=function(offset,noAssert){return readUInt32(this,offset,true,noAssert)};Buffer.prototype.readUInt32BE=function(offset,noAssert){return readUInt32(this,offset,false,noAssert)};Buffer.prototype.readInt8=function(offset,noAssert){if(!noAssert){assert(offset!==undefined&&offset!==null,"missing offset");assert(offset<this.length,"Trying to read beyond buffer length")}if(offset>=this.length)return;var neg=this[offset]&128;if(neg)return(255-this[offset]+1)*-1;else return this[offset]};function readInt16(buf,offset,littleEndian,noAssert){if(!noAssert){assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset+1<buf.length,"Trying to read beyond buffer length")}var len=buf.length;if(offset>=len)return;var val=readUInt16(buf,offset,littleEndian,true);var neg=val&32768;if(neg)return(65535-val+1)*-1;else return val}Buffer.prototype.readInt16LE=function(offset,noAssert){return readInt16(this,offset,true,noAssert)};Buffer.prototype.readInt16BE=function(offset,noAssert){return readInt16(this,offset,false,noAssert)};function readInt32(buf,offset,littleEndian,noAssert){if(!noAssert){assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset+3<buf.length,"Trying to read beyond buffer length")}var len=buf.length;if(offset>=len)return;var val=readUInt32(buf,offset,littleEndian,true);var neg=val&2147483648;if(neg)return(4294967295-val+1)*-1;else return val}Buffer.prototype.readInt32LE=function(offset,noAssert){return readInt32(this,offset,true,noAssert)};Buffer.prototype.readInt32BE=function(offset,noAssert){return readInt32(this,offset,false,noAssert)};function readFloat(buf,offset,littleEndian,noAssert){if(!noAssert){assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset+3<buf.length,"Trying to read beyond buffer length")}return ieee754.read(buf,offset,littleEndian,23,4)}Buffer.prototype.readFloatLE=function(offset,noAssert){return readFloat(this,offset,true,noAssert)};Buffer.prototype.readFloatBE=function(offset,noAssert){return readFloat(this,offset,false,noAssert)};function readDouble(buf,offset,littleEndian,noAssert){if(!noAssert){assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset+7<buf.length,"Trying to read beyond buffer length")}return ieee754.read(buf,offset,littleEndian,52,8)}Buffer.prototype.readDoubleLE=function(offset,noAssert){return readDouble(this,offset,true,noAssert)};Buffer.prototype.readDoubleBE=function(offset,noAssert){return readDouble(this,offset,false,noAssert)};Buffer.prototype.writeUInt8=function(value,offset,noAssert){if(!noAssert){assert(value!==undefined&&value!==null,"missing value");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset<this.length,"trying to write beyond buffer length");verifuint(value,255)}if(offset>=this.length)return;this[offset]=value;return offset+1};function writeUInt16(buf,value,offset,littleEndian,noAssert){if(!noAssert){assert(value!==undefined&&value!==null,"missing value");assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset+1<buf.length,"trying to write beyond buffer length");verifuint(value,65535)}var len=buf.length;if(offset>=len)return;for(var i=0,j=Math.min(len-offset,2);i<j;i++){buf[offset+i]=(value&255<<8*(littleEndian?i:1-i))>>>(littleEndian?i:1-i)*8}return offset+2}Buffer.prototype.writeUInt16LE=function(value,offset,noAssert){return writeUInt16(this,value,offset,true,noAssert)};Buffer.prototype.writeUInt16BE=function(value,offset,noAssert){return writeUInt16(this,value,offset,false,noAssert)};function writeUInt32(buf,value,offset,littleEndian,noAssert){if(!noAssert){assert(value!==undefined&&value!==null,"missing value");assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset+3<buf.length,"trying to write beyond buffer length");verifuint(value,4294967295)}var len=buf.length;if(offset>=len)return;for(var i=0,j=Math.min(len-offset,4);i<j;i++){buf[offset+i]=value>>>(littleEndian?i:3-i)*8&255}return offset+4}Buffer.prototype.writeUInt32LE=function(value,offset,noAssert){return writeUInt32(this,value,offset,true,noAssert)};Buffer.prototype.writeUInt32BE=function(value,offset,noAssert){return writeUInt32(this,value,offset,false,noAssert)};Buffer.prototype.writeInt8=function(value,offset,noAssert){if(!noAssert){assert(value!==undefined&&value!==null,"missing value");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset<this.length,"Trying to write beyond buffer length");verifsint(value,127,-128)}if(offset>=this.length)return;if(value>=0)this.writeUInt8(value,offset,noAssert);else this.writeUInt8(255+value+1,offset,noAssert);return offset+1};function writeInt16(buf,value,offset,littleEndian,noAssert){if(!noAssert){assert(value!==undefined&&value!==null,"missing value");assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset+1<buf.length,"Trying to write beyond buffer length");verifsint(value,32767,-32768)}var len=buf.length;if(offset>=len)return;if(value>=0)writeUInt16(buf,value,offset,littleEndian,noAssert);else writeUInt16(buf,65535+value+1,offset,littleEndian,noAssert);return offset+2}Buffer.prototype.writeInt16LE=function(value,offset,noAssert){return writeInt16(this,value,offset,true,noAssert)};Buffer.prototype.writeInt16BE=function(value,offset,noAssert){return writeInt16(this,value,offset,false,noAssert)};function writeInt32(buf,value,offset,littleEndian,noAssert){if(!noAssert){assert(value!==undefined&&value!==null,"missing value");assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset+3<buf.length,"Trying to write beyond buffer length");verifsint(value,2147483647,-2147483648)}var len=buf.length;if(offset>=len)return;if(value>=0)writeUInt32(buf,value,offset,littleEndian,noAssert);else writeUInt32(buf,4294967295+value+1,offset,littleEndian,noAssert);return offset+4}Buffer.prototype.writeInt32LE=function(value,offset,noAssert){return writeInt32(this,value,offset,true,noAssert)};Buffer.prototype.writeInt32BE=function(value,offset,noAssert){return writeInt32(this,value,offset,false,noAssert)};function writeFloat(buf,value,offset,littleEndian,noAssert){if(!noAssert){assert(value!==undefined&&value!==null,"missing value");assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset+3<buf.length,"Trying to write beyond buffer length");verifIEEE754(value,3.4028234663852886e38,-3.4028234663852886e38)}var len=buf.length;if(offset>=len)return;ieee754.write(buf,value,offset,littleEndian,23,4);return offset+4}Buffer.prototype.writeFloatLE=function(value,offset,noAssert){return writeFloat(this,value,offset,true,noAssert)};Buffer.prototype.writeFloatBE=function(value,offset,noAssert){return writeFloat(this,value,offset,false,noAssert)};function writeDouble(buf,value,offset,littleEndian,noAssert){if(!noAssert){assert(value!==undefined&&value!==null,"missing value");assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset+7<buf.length,"Trying to write beyond buffer length");verifIEEE754(value,1.7976931348623157e308,-1.7976931348623157e308)}var len=buf.length;if(offset>=len)return;ieee754.write(buf,value,offset,littleEndian,52,8);return offset+8}Buffer.prototype.writeDoubleLE=function(value,offset,noAssert){return writeDouble(this,value,offset,true,noAssert)};Buffer.prototype.writeDoubleBE=function(value,offset,noAssert){return writeDouble(this,value,offset,false,noAssert)};Buffer.prototype.fill=function(value,start,end){if(!value)value=0;if(!start)start=0;if(!end)end=this.length;assert(end>=start,"end < start");if(end===start)return;if(this.length===0)return;assert(start>=0&&start<this.length,"start out of bounds");assert(end>=0&&end<=this.length,"end out of bounds");var i;if(typeof value==="number"){for(i=start;i<end;i++){this[i]=value}}else{var bytes=utf8ToBytes(value.toString());var len=bytes.length;for(i=start;i<end;i++){this[i]=bytes[i%len]}}return this};Buffer.prototype.inspect=function(){var out=[];var len=this.length;for(var i=0;i<len;i++){out[i]=toHex(this[i]);if(i===exports.INSPECT_MAX_BYTES){out[i+1]="...";break}}return"<Buffer "+out.join(" ")+">"};Buffer.prototype.toArrayBuffer=function(){if(typeof Uint8Array!=="undefined"){if(TYPED_ARRAY_SUPPORT){return new Buffer(this).buffer}else{var buf=new Uint8Array(this.length);for(var i=0,len=buf.length;i<len;i+=1){buf[i]=this[i]}return buf.buffer}}else{throw new Error("Buffer.toArrayBuffer not supported in this browser")}};var BP=Buffer.prototype;Buffer._augment=function(arr){arr._isBuffer=true;arr._get=arr.get;arr._set=arr.set;arr.get=BP.get;arr.set=BP.set;arr.write=BP.write;arr.toString=BP.toString;arr.toLocaleString=BP.toString;arr.toJSON=BP.toJSON;arr.equals=BP.equals;arr.compare=BP.compare;arr.copy=BP.copy;arr.slice=BP.slice;arr.readUInt8=BP.readUInt8;arr.readUInt16LE=BP.readUInt16LE;arr.readUInt16BE=BP.readUInt16BE;arr.readUInt32LE=BP.readUInt32LE;arr.readUInt32BE=BP.readUInt32BE;arr.readInt8=BP.readInt8;arr.readInt16LE=BP.readInt16LE;arr.readInt16BE=BP.readInt16BE;arr.readInt32LE=BP.readInt32LE;arr.readInt32BE=BP.readInt32BE;arr.readFloatLE=BP.readFloatLE;arr.readFloatBE=BP.readFloatBE;arr.readDoubleLE=BP.readDoubleLE;arr.readDoubleBE=BP.readDoubleBE;arr.writeUInt8=BP.writeUInt8;arr.writeUInt16LE=BP.writeUInt16LE;arr.writeUInt16BE=BP.writeUInt16BE;arr.writeUInt32LE=BP.writeUInt32LE;arr.writeUInt32BE=BP.writeUInt32BE;arr.writeInt8=BP.writeInt8;arr.writeInt16LE=BP.writeInt16LE;arr.writeInt16BE=BP.writeInt16BE;arr.writeInt32LE=BP.writeInt32LE;arr.writeInt32BE=BP.writeInt32BE;arr.writeFloatLE=BP.writeFloatLE;arr.writeFloatBE=BP.writeFloatBE;arr.writeDoubleLE=BP.writeDoubleLE;arr.writeDoubleBE=BP.writeDoubleBE;arr.fill=BP.fill;arr.inspect=BP.inspect;arr.toArrayBuffer=BP.toArrayBuffer;return arr};var INVALID_BASE64_RE=/[^+\/0-9A-z]/g;function base64clean(str){str=stringtrim(str).replace(INVALID_BASE64_RE,"");while(str.length%4!==0){str=str+"="}return str}function stringtrim(str){if(str.trim)return str.trim();return str.replace(/^\s+|\s+$/g,"")}function isArray(subject){return(Array.isArray||function(subject){return Object.prototype.toString.call(subject)==="[object Array]"})(subject)}function isArrayish(subject){return isArray(subject)||Buffer.isBuffer(subject)||subject&&typeof subject==="object"&&typeof subject.length==="number"}function toHex(n){if(n<16)return"0"+n.toString(16);return n.toString(16)}function utf8ToBytes(str){var byteArray=[];for(var i=0;i<str.length;i++){var b=str.charCodeAt(i);if(b<=127){byteArray.push(b)}else{var start=i;if(b>=55296&&b<=57343)i++;var h=encodeURIComponent(str.slice(start,i+1)).substr(1).split("%");for(var j=0;j<h.length;j++){byteArray.push(parseInt(h[j],16))}}}return byteArray}function asciiToBytes(str){var byteArray=[];for(var i=0;i<str.length;i++){byteArray.push(str.charCodeAt(i)&255)}return byteArray}function utf16leToBytes(str){var c,hi,lo;var byteArray=[];for(var i=0;i<str.length;i++){c=str.charCodeAt(i);hi=c>>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(str)}function blitBuffer(src,dst,offset,length){for(var i=0;i<length;i++){if(i+offset>=dst.length||i>=src.length)break;dst[i+offset]=src[i]}return i}function decodeUtf8Char(str){try{return decodeURIComponent(str)}catch(err){return String.fromCharCode(65533)}}function verifuint(value,max){assert(typeof value==="number","cannot write a non-number as a number");assert(value>=0,"specified a negative value for writing an unsigned value");assert(value<=max,"value is larger than maximum value for type");assert(Math.floor(value)===value,"value has a fractional component")}function verifsint(value,max,min){assert(typeof value==="number","cannot write a non-number as a number");assert(value<=max,"value larger than maximum allowed value");assert(value>=min,"value smaller than minimum allowed value");assert(Math.floor(value)===value,"value has a fractional component")}function verifIEEE754(value,max,min){assert(typeof value==="number","cannot write a non-number as a number");assert(value<=max,"value larger than maximum allowed value");assert(value>=min,"value smaller than minimum allowed value")}function assert(test,message){if(!test)throw new Error(message||"Failed assertion")}},{"base64-js":3,ieee754:4}],3:[function(require,module,exports){var lookup="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(exports){"use strict";var Arr=typeof Uint8Array!=="undefined"?Uint8Array:Array;var PLUS="+".charCodeAt(0);var SLASH="/".charCodeAt(0);var NUMBER="0".charCodeAt(0);var LOWER="a".charCodeAt(0);var UPPER="A".charCodeAt(0);function decode(elt){var code=elt.charCodeAt(0);if(code===PLUS)return 62;if(code===SLASH)return 63;if(code<NUMBER)return-1;if(code<NUMBER+10)return code-NUMBER+26+26;if(code<UPPER+26)return code-UPPER;if(code<LOWER+26)return code-LOWER+26}function b64ToByteArray(b64){var i,j,l,tmp,placeHolders,arr;if(b64.length%4>0){throw new Error("Invalid string. Length must be a multiple of 4")}var len=b64.length;placeHolders="="===b64.charAt(len-2)?2:"="===b64.charAt(len-1)?1:0;arr=new Arr(b64.length*3/4-placeHolders);l=placeHolders>0?b64.length-4:b64.length;var L=0;function push(v){arr[L++]=v}for(i=0,j=0;i<l;i+=4,j+=3){tmp=decode(b64.charAt(i))<<18|decode(b64.charAt(i+1))<<12|decode(b64.charAt(i+2))<<6|decode(b64.charAt(i+3));push((tmp&16711680)>>16);push((tmp&65280)>>8);push(tmp&255)}if(placeHolders===2){tmp=decode(b64.charAt(i))<<2|decode(b64.charAt(i+1))>>4;push(tmp&255)}else if(placeHolders===1){tmp=decode(b64.charAt(i))<<10|decode(b64.charAt(i+1))<<4|decode(b64.charAt(i+2))>>2;push(tmp>>8&255);push(tmp&255)}return arr}function uint8ToBase64(uint8){var i,extraBytes=uint8.length%3,output="",temp,length;function encode(num){return lookup.charAt(num)}function tripletToBase64(num){return encode(num>>18&63)+encode(num>>12&63)+encode(num>>6&63)+encode(num&63)}for(i=0,length=uint8.length-extraBytes;i<length;i+=3){temp=(uint8[i]<<16)+(uint8[i+1]<<8)+uint8[i+2];output+=tripletToBase64(temp)}switch(extraBytes){case 1:temp=uint8[uint8.length-1];output+=encode(temp>>2);output+=encode(temp<<4&63);output+="==";break;case 2:temp=(uint8[uint8.length-2]<<8)+uint8[uint8.length-1];output+=encode(temp>>10);output+=encode(temp>>4&63);output+=encode(temp<<2&63);output+="=";break}return output}exports.toByteArray=b64ToByteArray;exports.fromByteArray=uint8ToBase64})(typeof exports==="undefined"?this.base64js={}:exports)},{}],4:[function(require,module,exports){exports.read=function(buffer,offset,isLE,mLen,nBytes){var e,m,eLen=nBytes*8-mLen-1,eMax=(1<<eLen)-1,eBias=eMax>>1,nBits=-7,i=isLE?nBytes-1:0,d=isLE?-1:1,s=buffer[offset+i];i+=d;e=s&(1<<-nBits)-1;s>>=-nBits;nBits+=eLen;for(;nBits>0;e=e*256+buffer[offset+i],i+=d,nBits-=8);m=e&(1<<-nBits)-1;e>>=-nBits;nBits+=mLen;for(;nBits>0;m=m*256+buffer[offset+i],i+=d,nBits-=8);if(e===0){e=1-eBias}else if(e===eMax){return m?NaN:(s?-1:1)*Infinity}else{m=m+Math.pow(2,mLen);e=e-eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)};exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c,eLen=nBytes*8-mLen-1,eMax=(1<<eLen)-1,eBias=eMax>>1,rt=mLen===23?Math.pow(2,-24)-Math.pow(2,-77):0,i=isLE?0:nBytes-1,d=isLE?1:-1,s=value<0||value===0&&1/value<0?1:0;value=Math.abs(value);if(isNaN(value)||value===Infinity){m=isNaN(value)?1:0;e=eMax}else{e=Math.floor(Math.log(value)/Math.LN2);if(value*(c=Math.pow(2,-e))<1){e--;c*=2}if(e+eBias>=1){value+=rt/c}else{value+=rt*Math.pow(2,1-eBias)}if(value*c>=2){e++;c/=2}if(e+eBias>=eMax){m=0;e=eMax}else if(e+eBias>=1){m=(value*c-1)*Math.pow(2,mLen);e=e+eBias}else{m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen);e=0}}for(;mLen>=8;buffer[offset+i]=m&255,i+=d,m/=256,mLen-=8);e=e<<mLen|m;eLen+=mLen;for(;eLen>0;buffer[offset+i]=e&255,i+=d,e/=256,eLen-=8);buffer[offset+i-d]|=s*128}},{}],5:[function(require,module,exports){function EventEmitter(){this._events=this._events||{};this._maxListeners=this._maxListeners||undefined}module.exports=EventEmitter;EventEmitter.EventEmitter=EventEmitter;EventEmitter.prototype._events=undefined;EventEmitter.prototype._maxListeners=undefined;EventEmitter.defaultMaxListeners=10;EventEmitter.prototype.setMaxListeners=function(n){if(!isNumber(n)||n<0||isNaN(n))throw TypeError("n must be a positive number");this._maxListeners=n;return this};EventEmitter.prototype.emit=function(type){var er,handler,len,args,i,listeners;if(!this._events)this._events={};if(type==="error"){if(!this._events.error||isObject(this._events.error)&&!this._events.error.length){er=arguments[1];if(er instanceof Error){throw er}else{throw TypeError('Uncaught, unspecified "error" event.')}return false}}handler=this._events[type];if(isUndefined(handler))return false;if(isFunction(handler)){switch(arguments.length){case 1:handler.call(this);break;case 2:handler.call(this,arguments[1]);break;case 3:handler.call(this,arguments[1],arguments[2]);break;default:len=arguments.length;args=new Array(len-1);for(i=1;i<len;i++)args[i-1]=arguments[i];handler.apply(this,args)}}else if(isObject(handler)){len=arguments.length;args=new Array(len-1);for(i=1;i<len;i++)args[i-1]=arguments[i];listeners=handler.slice();len=listeners.length;for(i=0;i<len;i++)listeners[i].apply(this,args)}return true};EventEmitter.prototype.addListener=function(type,listener){var m;if(!isFunction(listener))throw TypeError("listener must be a function");if(!this._events)this._events={};if(this._events.newListener)this.emit("newListener",type,isFunction(listener.listener)?listener.listener:listener);if(!this._events[type])this._events[type]=listener;else if(isObject(this._events[type]))this._events[type].push(listener);else this._events[type]=[this._events[type],listener];if(isObject(this._events[type])&&!this._events[type].warned){var m;if(!isUndefined(this._maxListeners)){m=this._maxListeners}else{m=EventEmitter.defaultMaxListeners}if(m&&m>0&&this._events[type].length>m){this._events[type].warned=true;console.error("(node) warning: possible EventEmitter memory "+"leak detected. %d listeners added. "+"Use emitter.setMaxListeners() to increase limit.",this._events[type].length);if(typeof console.trace==="function"){console.trace()}}}return this};EventEmitter.prototype.on=EventEmitter.prototype.addListener;EventEmitter.prototype.once=function(type,listener){if(!isFunction(listener))throw TypeError("listener must be a function");var fired=false;function g(){this.removeListener(type,g);if(!fired){fired=true;listener.apply(this,arguments)}}g.listener=listener;this.on(type,g);return this};EventEmitter.prototype.removeListener=function(type,listener){var list,position,length,i;if(!isFunction(listener))throw TypeError("listener must be a function");if(!this._events||!this._events[type])return this;list=this._events[type];length=list.length;position=-1;if(list===listener||isFunction(list.listener)&&list.listener===listener){delete this._events[type];if(this._events.removeListener)this.emit("removeListener",type,listener)}else if(isObject(list)){for(i=length;i-->0;){if(list[i]===listener||list[i].listener&&list[i].listener===listener){position=i;break}}if(position<0)return this;if(list.length===1){list.length=0;delete this._events[type]}else{list.splice(position,1)}if(this._events.removeListener)this.emit("removeListener",type,listener)}return this};EventEmitter.prototype.removeAllListeners=function(type){var key,listeners;if(!this._events)return this;if(!this._events.removeListener){if(arguments.length===0)this._events={};else if(this._events[type])delete this._events[type];return this}if(arguments.length===0){for(key in this._events){if(key==="removeListener")continue;this.removeAllListeners(key)}this.removeAllListeners("removeListener");this._events={};return this}listeners=this._events[type];if(isFunction(listeners)){this.removeListener(type,listeners)}else{while(listeners.length)this.removeListener(type,listeners[listeners.length-1])}delete this._events[type];return this};EventEmitter.prototype.listeners=function(type){var ret;if(!this._events||!this._events[type])ret=[];else if(isFunction(this._events[type]))ret=[this._events[type]];else ret=this._events[type].slice();return ret};EventEmitter.listenerCount=function(emitter,type){var ret;if(!emitter._events||!emitter._events[type])ret=0;else if(isFunction(emitter._events[type]))ret=1;else ret=emitter._events[type].length;return ret};function isFunction(arg){return typeof arg==="function"}function isNumber(arg){return typeof arg==="number"}function isObject(arg){return typeof arg==="object"&&arg!==null}function isUndefined(arg){return arg===void 0}},{}],6:[function(require,module,exports){var http=module.exports;var EventEmitter=require("events").EventEmitter;var Request=require("./lib/request");var url=require("url");http.request=function(params,cb){if(typeof params==="string"){params=url.parse(params)}if(!params)params={};if(!params.host&&!params.port){params.port=parseInt(window.location.port,10)}if(!params.host&&params.hostname){params.host=params.hostname}if(!params.scheme)params.scheme=window.location.protocol.split(":")[0];if(!params.host){params.host=window.location.hostname||window.location.host}if(/:/.test(params.host)){if(!params.port){params.port=params.host.split(":")[1]}params.host=params.host.split(":")[0]}if(!params.port)params.port=params.scheme=="https"?443:80;var req=new Request(new xhrHttp,params);if(cb)req.on("response",cb);return req};http.get=function(params,cb){params.method="GET";var req=http.request(params,cb);req.end();return req};http.Agent=function(){};http.Agent.defaultMaxSockets=4;var xhrHttp=function(){if(typeof window==="undefined"){throw new Error("no window object present")}else if(window.XMLHttpRequest){return window.XMLHttpRequest}else if(window.ActiveXObject){var axs=["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.3.0","Microsoft.XMLHTTP"];for(var i=0;i<axs.length;i++){try{var ax=new window.ActiveXObject(axs[i]);return function(){if(ax){var ax_=ax;ax=null;return ax_}else{return new window.ActiveXObject(axs[i])}}}catch(e){}}throw new Error("ajax not supported in this browser")}else{throw new Error("ajax not supported in this browser")}}();http.STATUS_CODES={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",300:"Multiple Choices",301:"Moved Permanently",302:"Moved Temporarily",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Time-out",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Request Entity Too Large",414:"Request-URI Too Large",415:"Unsupported Media Type",416:"Requested Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Time-out",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"}},{"./lib/request":7,events:5,url:31}],7:[function(require,module,exports){var Stream=require("stream");var Response=require("./response");var Base64=require("Base64");var inherits=require("inherits");var Request=module.exports=function(xhr,params){var self=this;self.writable=true;self.xhr=xhr;self.body=[];self.uri=(params.scheme||"http")+"://"+params.host+(params.port?":"+params.port:"")+(params.path||"/");if(typeof params.withCredentials==="undefined"){params.withCredentials=true}try{xhr.withCredentials=params.withCredentials}catch(e){}if(params.responseType)try{xhr.responseType=params.responseType}catch(e){}xhr.open(params.method||"GET",self.uri,true);xhr.onerror=function(event){self.emit("error",new Error("Network error"))};self._headers={};if(params.headers){var keys=objectKeys(params.headers);for(var i=0;i<keys.length;i++){var key=keys[i];if(!self.isSafeRequestHeader(key))continue;var value=params.headers[key];self.setHeader(key,value)}}if(params.auth){this.setHeader("Authorization","Basic "+Base64.btoa(params.auth))}var res=new Response;res.on("close",function(){self.emit("close")});res.on("ready",function(){self.emit("response",res)});res.on("error",function(err){self.emit("error",err)});xhr.onreadystatechange=function(){if(xhr.__aborted)return;res.handle(xhr)}};inherits(Request,Stream);Request.prototype.setHeader=function(key,value){this._headers[key.toLowerCase()]=value};Request.prototype.getHeader=function(key){return this._headers[key.toLowerCase()]};Request.prototype.removeHeader=function(key){delete this._headers[key.toLowerCase()]};Request.prototype.write=function(s){this.body.push(s)};Request.prototype.destroy=function(s){this.xhr.__aborted=true;this.xhr.abort();this.emit("close")};Request.prototype.end=function(s){if(s!==undefined)this.body.push(s);var keys=objectKeys(this._headers);for(var i=0;i<keys.length;i++){var key=keys[i];var value=this._headers[key];if(isArray(value)){for(var j=0;j<value.length;j++){this.xhr.setRequestHeader(key,value[j])}}else this.xhr.setRequestHeader(key,value)}if(this.body.length===0){this.xhr.send("")}else if(typeof this.body[0]==="string"){this.xhr.send(this.body.join(""))}else if(isArray(this.body[0])){var body=[];for(var i=0;i<this.body.length;i++){body.push.apply(body,this.body[i])}this.xhr.send(body)}else if(/Array/.test(Object.prototype.toString.call(this.body[0]))){var len=0;for(var i=0;i<this.body.length;i++){len+=this.body[i].length}var body=new this.body[0].constructor(len);var k=0;for(var i=0;i<this.body.length;i++){var b=this.body[i];for(var j=0;j<b.length;j++){body[k++]=b[j]}}this.xhr.send(body)}else{var body="";for(var i=0;i<this.body.length;i++){body+=this.body[i].toString()}this.xhr.send(body)}};Request.unsafeHeaders=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","content-transfer-encoding","date","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","user-agent","via"];
Request.prototype.isSafeRequestHeader=function(headerName){if(!headerName)return false;return indexOf(Request.unsafeHeaders,headerName.toLowerCase())===-1};var objectKeys=Object.keys||function(obj){var keys=[];for(var key in obj)keys.push(key);return keys};var isArray=Array.isArray||function(xs){return Object.prototype.toString.call(xs)==="[object Array]"};var indexOf=function(xs,x){if(xs.indexOf)return xs.indexOf(x);for(var i=0;i<xs.length;i++){if(xs[i]===x)return i}return-1}},{"./response":8,Base64:9,inherits:10,stream:30}],8:[function(require,module,exports){var Stream=require("stream");var util=require("util");var Response=module.exports=function(res){this.offset=0;this.readable=true};util.inherits(Response,Stream);var capable={streaming:true,status2:true};function parseHeaders(res){var lines=res.getAllResponseHeaders().split(/\r?\n/);var headers={};for(var i=0;i<lines.length;i++){var line=lines[i];if(line==="")continue;var m=line.match(/^([^:]+):\s*(.*)/);if(m){var key=m[1].toLowerCase(),value=m[2];if(headers[key]!==undefined){if(isArray(headers[key])){headers[key].push(value)}else{headers[key]=[headers[key],value]}}else{headers[key]=value}}else{headers[line]=true}}return headers}Response.prototype.getResponse=function(xhr){var respType=String(xhr.responseType).toLowerCase();if(respType==="blob")return xhr.responseBlob||xhr.response;if(respType==="arraybuffer")return xhr.response;return xhr.responseText};Response.prototype.getHeader=function(key){return this.headers[key.toLowerCase()]};Response.prototype.handle=function(res){if(res.readyState===2&&capable.status2){try{this.statusCode=res.status;this.headers=parseHeaders(res)}catch(err){capable.status2=false}if(capable.status2){this.emit("ready")}}else if(capable.streaming&&res.readyState===3){try{if(!this.statusCode){this.statusCode=res.status;this.headers=parseHeaders(res);this.emit("ready")}}catch(err){}try{this._emitData(res)}catch(err){capable.streaming=false}}else if(res.readyState===4){if(!this.statusCode){this.statusCode=res.status;this.emit("ready")}this._emitData(res);if(res.error){this.emit("error",this.getResponse(res))}else this.emit("end");this.emit("close")}};Response.prototype._emitData=function(res){var respBody=this.getResponse(res);if(respBody.toString().match(/ArrayBuffer/)){this.emit("data",new Uint8Array(respBody,this.offset));this.offset=respBody.byteLength;return}if(respBody.length>this.offset){this.emit("data",respBody.slice(this.offset));this.offset=respBody.length}};var isArray=Array.isArray||function(xs){return Object.prototype.toString.call(xs)==="[object Array]"}},{stream:30,util:33}],9:[function(require,module,exports){(function(){var object=typeof exports!="undefined"?exports:this;var chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function InvalidCharacterError(message){this.message=message}InvalidCharacterError.prototype=new Error;InvalidCharacterError.prototype.name="InvalidCharacterError";object.btoa||(object.btoa=function(input){for(var block,charCode,idx=0,map=chars,output="";input.charAt(idx|0)||(map="=",idx%1);output+=map.charAt(63&block>>8-idx%1*8)){charCode=input.charCodeAt(idx+=3/4);if(charCode>255){throw new InvalidCharacterError("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.")}block=block<<8|charCode}return output});object.atob||(object.atob=function(input){input=input.replace(/=+$/,"");if(input.length%4==1){throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded.")}for(var bc=0,bs,buffer,idx=0,output="";buffer=input.charAt(idx++);~buffer&&(bs=bc%4?bs*64+buffer:buffer,bc++%4)?output+=String.fromCharCode(255&bs>>(-2*bc&6)):0){buffer=chars.indexOf(buffer)}return output})})()},{}],10:[function(require,module,exports){if(typeof Object.create==="function"){module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:false,writable:true,configurable:true}})}}else{module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype;ctor.prototype=new TempCtor;ctor.prototype.constructor=ctor}}},{}],11:[function(require,module,exports){module.exports=Array.isArray||function(arr){return Object.prototype.toString.call(arr)=="[object Array]"}},{}],12:[function(require,module,exports){exports.endianness=function(){return"LE"};exports.hostname=function(){if(typeof location!=="undefined"){return location.hostname}else return""};exports.loadavg=function(){return[]};exports.uptime=function(){return 0};exports.freemem=function(){return Number.MAX_VALUE};exports.totalmem=function(){return Number.MAX_VALUE};exports.cpus=function(){return[]};exports.type=function(){return"Browser"};exports.release=function(){if(typeof navigator!=="undefined"){return navigator.appVersion}return""};exports.networkInterfaces=exports.getNetworkInterfaces=function(){return{}};exports.arch=function(){return"javascript"};exports.platform=function(){return"browser"};exports.tmpdir=exports.tmpDir=function(){return"/tmp"};exports.EOL="\n"},{}],13:[function(require,module,exports){var process=module.exports={};process.nextTick=function(){var canSetImmediate=typeof window!=="undefined"&&window.setImmediate;var canPost=typeof window!=="undefined"&&window.postMessage&&window.addEventListener;if(canSetImmediate){return function(f){return window.setImmediate(f)}}if(canPost){var queue=[];window.addEventListener("message",function(ev){var source=ev.source;if((source===window||source===null)&&ev.data==="process-tick"){ev.stopPropagation();if(queue.length>0){var fn=queue.shift();fn()}}},true);return function nextTick(fn){queue.push(fn);window.postMessage("process-tick","*")}}return function nextTick(fn){setTimeout(fn,0)}}();process.title="browser";process.browser=true;process.env={};process.argv=[];function noop(){}process.on=noop;process.addListener=noop;process.once=noop;process.off=noop;process.removeListener=noop;process.removeAllListeners=noop;process.emit=noop;process.binding=function(name){throw new Error("process.binding is not supported")};process.cwd=function(){return"/"};process.chdir=function(dir){throw new Error("process.chdir is not supported")}},{}],14:[function(require,module,exports){(function(global){(function(root){var freeExports=typeof exports=="object"&&exports;var freeModule=typeof module=="object"&&module&&module.exports==freeExports&&module;var freeGlobal=typeof global=="object"&&global;if(freeGlobal.global===freeGlobal||freeGlobal.window===freeGlobal){root=freeGlobal}var punycode,maxInt=2147483647,base=36,tMin=1,tMax=26,skew=38,damp=700,initialBias=72,initialN=128,delimiter="-",regexPunycode=/^xn--/,regexNonASCII=/[^ -~]/,regexSeparators=/\x2E|\u3002|\uFF0E|\uFF61/g,errors={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},baseMinusTMin=base-tMin,floor=Math.floor,stringFromCharCode=String.fromCharCode,key;function error(type){throw RangeError(errors[type])}function map(array,fn){var length=array.length;while(length--){array[length]=fn(array[length])}return array}function mapDomain(string,fn){return map(string.split(regexSeparators),fn).join(".")}function ucs2decode(string){var output=[],counter=0,length=string.length,value,extra;while(counter<length){value=string.charCodeAt(counter++);if(value>=55296&&value<=56319&&counter<length){extra=string.charCodeAt(counter++);if((extra&64512)==56320){output.push(((value&1023)<<10)+(extra&1023)+65536)}else{output.push(value);counter--}}else{output.push(value)}}return output}function ucs2encode(array){return map(array,function(value){var output="";if(value>65535){value-=65536;output+=stringFromCharCode(value>>>10&1023|55296);value=56320|value&1023}output+=stringFromCharCode(value);return output}).join("")}function basicToDigit(codePoint){if(codePoint-48<10){return codePoint-22}if(codePoint-65<26){return codePoint-65}if(codePoint-97<26){return codePoint-97}return base}function digitToBasic(digit,flag){return digit+22+75*(digit<26)-((flag!=0)<<5)}function adapt(delta,numPoints,firstTime){var k=0;delta=firstTime?floor(delta/damp):delta>>1;delta+=floor(delta/numPoints);for(;delta>baseMinusTMin*tMax>>1;k+=base){delta=floor(delta/baseMinusTMin)}return floor(k+(baseMinusTMin+1)*delta/(delta+skew))}function decode(input){var output=[],inputLength=input.length,out,i=0,n=initialN,bias=initialBias,basic,j,index,oldi,w,k,digit,t,baseMinusT;basic=input.lastIndexOf(delimiter);if(basic<0){basic=0}for(j=0;j<basic;++j){if(input.charCodeAt(j)>=128){error("not-basic")}output.push(input.charCodeAt(j))}for(index=basic>0?basic+1:0;index<inputLength;){for(oldi=i,w=1,k=base;;k+=base){if(index>=inputLength){error("invalid-input")}digit=basicToDigit(input.charCodeAt(index++));if(digit>=base||digit>floor((maxInt-i)/w)){error("overflow")}i+=digit*w;t=k<=bias?tMin:k>=bias+tMax?tMax:k-bias;if(digit<t){break}baseMinusT=base-t;if(w>floor(maxInt/baseMinusT)){error("overflow")}w*=baseMinusT}out=output.length+1;bias=adapt(i-oldi,out,oldi==0);if(floor(i/out)>maxInt-n){error("overflow")}n+=floor(i/out);i%=out;output.splice(i++,0,n)}return ucs2encode(output)}function encode(input){var n,delta,handledCPCount,basicLength,bias,j,m,q,k,t,currentValue,output=[],inputLength,handledCPCountPlusOne,baseMinusT,qMinusT;input=ucs2decode(input);inputLength=input.length;n=initialN;delta=0;bias=initialBias;for(j=0;j<inputLength;++j){currentValue=input[j];if(currentValue<128){output.push(stringFromCharCode(currentValue))}}handledCPCount=basicLength=output.length;if(basicLength){output.push(delimiter)}while(handledCPCount<inputLength){for(m=maxInt,j=0;j<inputLength;++j){currentValue=input[j];if(currentValue>=n&&currentValue<m){m=currentValue}}handledCPCountPlusOne=handledCPCount+1;if(m-n>floor((maxInt-delta)/handledCPCountPlusOne)){error("overflow")}delta+=(m-n)*handledCPCountPlusOne;n=m;for(j=0;j<inputLength;++j){currentValue=input[j];if(currentValue<n&&++delta>maxInt){error("overflow")}if(currentValue==n){for(q=delta,k=base;;k+=base){t=k<=bias?tMin:k>=bias+tMax?tMax:k-bias;if(q<t){break}qMinusT=q-t;baseMinusT=base-t;output.push(stringFromCharCode(digitToBasic(t+qMinusT%baseMinusT,0)));q=floor(qMinusT/baseMinusT)}output.push(stringFromCharCode(digitToBasic(q,0)));bias=adapt(delta,handledCPCountPlusOne,handledCPCount==basicLength);delta=0;++handledCPCount}}++delta;++n}return output.join("")}function toUnicode(domain){return mapDomain(domain,function(string){return regexPunycode.test(string)?decode(string.slice(4).toLowerCase()):string})}function toASCII(domain){return mapDomain(domain,function(string){return regexNonASCII.test(string)?"xn--"+encode(string):string})}punycode={version:"1.2.4",ucs2:{decode:ucs2decode,encode:ucs2encode},decode:decode,encode:encode,toASCII:toASCII,toUnicode:toUnicode};if(typeof define=="function"&&typeof define.amd=="object"&&define.amd){define("punycode",function(){return punycode})}else if(freeExports&&!freeExports.nodeType){if(freeModule){freeModule.exports=punycode}else{for(key in punycode){punycode.hasOwnProperty(key)&&(freeExports[key]=punycode[key])}}}else{root.punycode=punycode}})(this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],15:[function(require,module,exports){"use strict";function hasOwnProperty(obj,prop){return Object.prototype.hasOwnProperty.call(obj,prop)}module.exports=function(qs,sep,eq,options){sep=sep||"&";eq=eq||"=";var obj={};if(typeof qs!=="string"||qs.length===0){return obj}var regexp=/\+/g;qs=qs.split(sep);var maxKeys=1e3;if(options&&typeof options.maxKeys==="number"){maxKeys=options.maxKeys}var len=qs.length;if(maxKeys>0&&len>maxKeys){len=maxKeys}for(var i=0;i<len;++i){var x=qs[i].replace(regexp,"%20"),idx=x.indexOf(eq),kstr,vstr,k,v;if(idx>=0){kstr=x.substr(0,idx);vstr=x.substr(idx+1)}else{kstr=x;vstr=""}k=decodeURIComponent(kstr);v=decodeURIComponent(vstr);if(!hasOwnProperty(obj,k)){obj[k]=v}else if(isArray(obj[k])){obj[k].push(v)}else{obj[k]=[obj[k],v]}}return obj};var isArray=Array.isArray||function(xs){return Object.prototype.toString.call(xs)==="[object Array]"}},{}],16:[function(require,module,exports){"use strict";var stringifyPrimitive=function(v){switch(typeof v){case"string":return v;case"boolean":return v?"true":"false";case"number":return isFinite(v)?v:"";default:return""}};module.exports=function(obj,sep,eq,name){sep=sep||"&";eq=eq||"=";if(obj===null){obj=undefined}if(typeof obj==="object"){return map(objectKeys(obj),function(k){var ks=encodeURIComponent(stringifyPrimitive(k))+eq;if(isArray(obj[k])){return map(obj[k],function(v){return ks+encodeURIComponent(stringifyPrimitive(v))}).join(sep)}else{return ks+encodeURIComponent(stringifyPrimitive(obj[k]))}}).join(sep)}if(!name)return"";return encodeURIComponent(stringifyPrimitive(name))+eq+encodeURIComponent(stringifyPrimitive(obj))};var isArray=Array.isArray||function(xs){return Object.prototype.toString.call(xs)==="[object Array]"};function map(xs,f){if(xs.map)return xs.map(f);var res=[];for(var i=0;i<xs.length;i++){res.push(f(xs[i],i))}return res}var objectKeys=Object.keys||function(obj){var res=[];for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))res.push(key)}return res}},{}],17:[function(require,module,exports){"use strict";exports.decode=exports.parse=require("./decode");exports.encode=exports.stringify=require("./encode")},{"./decode":15,"./encode":16}],18:[function(require,module,exports){module.exports=require("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":19}],19:[function(require,module,exports){(function(process){module.exports=Duplex;var objectKeys=Object.keys||function(obj){var keys=[];for(var key in obj)keys.push(key);return keys};var util=require("core-util-is");util.inherits=require("inherits");var Readable=require("./_stream_readable");var Writable=require("./_stream_writable");util.inherits(Duplex,Readable);forEach(objectKeys(Writable.prototype),function(method){if(!Duplex.prototype[method])Duplex.prototype[method]=Writable.prototype[method]});function Duplex(options){if(!(this instanceof Duplex))return new Duplex(options);Readable.call(this,options);Writable.call(this,options);if(options&&options.readable===false)this.readable=false;if(options&&options.writable===false)this.writable=false;this.allowHalfOpen=true;if(options&&options.allowHalfOpen===false)this.allowHalfOpen=false;this.once("end",onend)}function onend(){if(this.allowHalfOpen||this._writableState.ended)return;process.nextTick(this.end.bind(this))}function forEach(xs,f){for(var i=0,l=xs.length;i<l;i++){f(xs[i],i)}}}).call(this,require("_process"))},{"./_stream_readable":21,"./_stream_writable":23,_process:13,"core-util-is":24,inherits:10}],20:[function(require,module,exports){module.exports=PassThrough;var Transform=require("./_stream_transform");var util=require("core-util-is");util.inherits=require("inherits");util.inherits(PassThrough,Transform);function PassThrough(options){if(!(this instanceof PassThrough))return new PassThrough(options);Transform.call(this,options)}PassThrough.prototype._transform=function(chunk,encoding,cb){cb(null,chunk)}},{"./_stream_transform":22,"core-util-is":24,inherits:10}],21:[function(require,module,exports){(function(process){module.exports=Readable;var isArray=require("isarray");var Buffer=require("buffer").Buffer;Readable.ReadableState=ReadableState;var EE=require("events").EventEmitter;if(!EE.listenerCount)EE.listenerCount=function(emitter,type){return emitter.listeners(type).length};var Stream=require("stream");var util=require("core-util-is");util.inherits=require("inherits");var StringDecoder;util.inherits(Readable,Stream);function ReadableState(options,stream){options=options||{};var hwm=options.highWaterMark;this.highWaterMark=hwm||hwm===0?hwm:16*1024;this.highWaterMark=~~this.highWaterMark;this.buffer=[];this.length=0;this.pipes=null;this.pipesCount=0;this.flowing=false;this.ended=false;this.endEmitted=false;this.reading=false;this.calledRead=false;this.sync=true;this.needReadable=false;this.emittedReadable=false;this.readableListening=false;this.objectMode=!!options.objectMode;this.defaultEncoding=options.defaultEncoding||"utf8";this.ranOut=false;this.awaitDrain=0;this.readingMore=false;this.decoder=null;this.encoding=null;if(options.encoding){if(!StringDecoder)StringDecoder=require("string_decoder/").StringDecoder;this.decoder=new StringDecoder(options.encoding);this.encoding=options.encoding}}function Readable(options){if(!(this instanceof Readable))return new Readable(options);this._readableState=new ReadableState(options,this);this.readable=true;Stream.call(this)}Readable.prototype.push=function(chunk,encoding){var state=this._readableState;if(typeof chunk==="string"&&!state.objectMode){encoding=encoding||state.defaultEncoding;if(encoding!==state.encoding){chunk=new Buffer(chunk,encoding);encoding=""}}return readableAddChunk(this,state,chunk,encoding,false)};Readable.prototype.unshift=function(chunk){var state=this._readableState;return readableAddChunk(this,state,chunk,"",true)};function readableAddChunk(stream,state,chunk,encoding,addToFront){var er=chunkInvalid(state,chunk);if(er){stream.emit("error",er)}else if(chunk===null||chunk===undefined){state.reading=false;if(!state.ended)onEofChunk(stream,state)}else if(state.objectMode||chunk&&chunk.length>0){if(state.ended&&!addToFront){var e=new Error("stream.push() after EOF");stream.emit("error",e)}else if(state.endEmitted&&addToFront){var e=new Error("stream.unshift() after end event");stream.emit("error",e)}else{if(state.decoder&&!addToFront&&!encoding)chunk=state.decoder.write(chunk);state.length+=state.objectMode?1:chunk.length;if(addToFront){state.buffer.unshift(chunk)}else{state.reading=false;state.buffer.push(chunk)}if(state.needReadable)emitReadable(stream);maybeReadMore(stream,state)}}else if(!addToFront){state.reading=false}return needMoreData(state)}function needMoreData(state){return!state.ended&&(state.needReadable||state.length<state.highWaterMark||state.length===0)}Readable.prototype.setEncoding=function(enc){if(!StringDecoder)StringDecoder=require("string_decoder/").StringDecoder;this._readableState.decoder=new StringDecoder(enc);this._readableState.encoding=enc};var MAX_HWM=8388608;function roundUpToNextPowerOf2(n){if(n>=MAX_HWM){n=MAX_HWM}else{n--;for(var p=1;p<32;p<<=1)n|=n>>p;n++}return n}function howMuchToRead(n,state){if(state.length===0&&state.ended)return 0;if(state.objectMode)return n===0?0:1;if(n===null||isNaN(n)){if(state.flowing&&state.buffer.length)return state.buffer[0].length;else return state.length}if(n<=0)return 0;if(n>state.highWaterMark)state.highWaterMark=roundUpToNextPowerOf2(n);if(n>state.length){if(!state.ended){state.needReadable=true;return 0}else return state.length}return n}Readable.prototype.read=function(n){var state=this._readableState;state.calledRead=true;var nOrig=n;var ret;if(typeof n!=="number"||n>0)state.emittedReadable=false;if(n===0&&state.needReadable&&(state.length>=state.highWaterMark||state.ended)){emitReadable(this);return null}n=howMuchToRead(n,state);if(n===0&&state.ended){ret=null;if(state.length>0&&state.decoder){ret=fromList(n,state);state.length-=ret.length}if(state.length===0)endReadable(this);return ret}var doRead=state.needReadable;if(state.length-n<=state.highWaterMark)doRead=true;if(state.ended||state.reading)doRead=false;if(doRead){state.reading=true;state.sync=true;if(state.length===0)state.needReadable=true;this._read(state.highWaterMark);state.sync=false}if(doRead&&!state.reading)n=howMuchToRead(nOrig,state);if(n>0)ret=fromList(n,state);else ret=null;if(ret===null){state.needReadable=true;n=0}state.length-=n;if(state.length===0&&!state.ended)state.needReadable=true;if(state.ended&&!state.endEmitted&&state.length===0)endReadable(this);return ret};function chunkInvalid(state,chunk){var er=null;if(!Buffer.isBuffer(chunk)&&"string"!==typeof chunk&&chunk!==null&&chunk!==undefined&&!state.objectMode){er=new TypeError("Invalid non-string/buffer chunk")}return er}function onEofChunk(stream,state){if(state.decoder&&!state.ended){var chunk=state.decoder.end();if(chunk&&chunk.length){state.buffer.push(chunk);state.length+=state.objectMode?1:chunk.length}}state.ended=true;if(state.length>0)emitReadable(stream);else endReadable(stream)}function emitReadable(stream){var state=stream._readableState;state.needReadable=false;if(state.emittedReadable)return;state.emittedReadable=true;if(state.sync)process.nextTick(function(){emitReadable_(stream)});else emitReadable_(stream)}function emitReadable_(stream){stream.emit("readable")}function maybeReadMore(stream,state){if(!state.readingMore){state.readingMore=true;process.nextTick(function(){maybeReadMore_(stream,state)})}}function maybeReadMore_(stream,state){var len=state.length;while(!state.reading&&!state.flowing&&!state.ended&&state.length<state.highWaterMark){stream.read(0);if(len===state.length)break;else len=state.length}state.readingMore=false}Readable.prototype._read=function(n){this.emit("error",new Error("not implemented"))};Readable.prototype.pipe=function(dest,pipeOpts){var src=this;var state=this._readableState;switch(state.pipesCount){case 0:state.pipes=dest;break;case 1:state.pipes=[state.pipes,dest];break;default:state.pipes.push(dest);break}state.pipesCount+=1;var doEnd=(!pipeOpts||pipeOpts.end!==false)&&dest!==process.stdout&&dest!==process.stderr;var endFn=doEnd?onend:cleanup;if(state.endEmitted)process.nextTick(endFn);else src.once("end",endFn);dest.on("unpipe",onunpipe);function onunpipe(readable){if(readable!==src)return;cleanup()}function onend(){dest.end()}var ondrain=pipeOnDrain(src);dest.on("drain",ondrain);function cleanup(){dest.removeListener("close",onclose);dest.removeListener("finish",onfinish);dest.removeListener("drain",ondrain);dest.removeListener("error",onerror);dest.removeListener("unpipe",onunpipe);src.removeListener("end",onend);src.removeListener("end",cleanup);if(!dest._writableState||dest._writableState.needDrain)ondrain()}function onerror(er){unpipe();dest.removeListener("error",onerror);if(EE.listenerCount(dest,"error")===0)dest.emit("error",er)}if(!dest._events||!dest._events.error)dest.on("error",onerror);else if(isArray(dest._events.error))dest._events.error.unshift(onerror);else dest._events.error=[onerror,dest._events.error];function onclose(){dest.removeListener("finish",onfinish);unpipe()}dest.once("close",onclose);function onfinish(){dest.removeListener("close",onclose);unpipe()}dest.once("finish",onfinish);function unpipe(){src.unpipe(dest)}dest.emit("pipe",src);if(!state.flowing){this.on("readable",pipeOnReadable);state.flowing=true;process.nextTick(function(){flow(src)})}return dest};function pipeOnDrain(src){return function(){var dest=this;var state=src._readableState;state.awaitDrain--;if(state.awaitDrain===0)flow(src)}}function flow(src){var state=src._readableState;var chunk;state.awaitDrain=0;function write(dest,i,list){var written=dest.write(chunk);if(false===written){state.awaitDrain++}}while(state.pipesCount&&null!==(chunk=src.read())){if(state.pipesCount===1)write(state.pipes,0,null);else forEach(state.pipes,write);src.emit("data",chunk);if(state.awaitDrain>0)return}if(state.pipesCount===0){state.flowing=false;if(EE.listenerCount(src,"data")>0)emitDataEvents(src);return}state.ranOut=true}function pipeOnReadable(){if(this._readableState.ranOut){this._readableState.ranOut=false;flow(this)}}Readable.prototype.unpipe=function(dest){var state=this._readableState;if(state.pipesCount===0)return this;if(state.pipesCount===1){if(dest&&dest!==state.pipes)return this;if(!dest)dest=state.pipes;state.pipes=null;state.pipesCount=0;this.removeListener("readable",pipeOnReadable);state.flowing=false;if(dest)dest.emit("unpipe",this);return this}if(!dest){var dests=state.pipes;var len=state.pipesCount;state.pipes=null;state.pipesCount=0;this.removeListener("readable",pipeOnReadable);state.flowing=false;for(var i=0;i<len;i++)dests[i].emit("unpipe",this);return this}var i=indexOf(state.pipes,dest);if(i===-1)return this;state.pipes.splice(i,1);state.pipesCount-=1;if(state.pipesCount===1)state.pipes=state.pipes[0];dest.emit("unpipe",this);return this};Readable.prototype.on=function(ev,fn){var res=Stream.prototype.on.call(this,ev,fn);if(ev==="data"&&!this._readableState.flowing)emitDataEvents(this);if(ev==="readable"&&this.readable){var state=this._readableState;if(!state.readableListening){state.readableListening=true;state.emittedReadable=false;state.needReadable=true;if(!state.reading){this.read(0)}else if(state.length){emitReadable(this,state)}}}return res};Readable.prototype.addListener=Readable.prototype.on;Readable.prototype.resume=function(){emitDataEvents(this);this.read(0);this.emit("resume")};Readable.prototype.pause=function(){emitDataEvents(this,true);this.emit("pause")};function emitDataEvents(stream,startPaused){var state=stream._readableState;if(state.flowing){throw new Error("Cannot switch to old mode now.")}var paused=startPaused||false;var readable=false;stream.readable=true;stream.pipe=Stream.prototype.pipe;stream.on=stream.addListener=Stream.prototype.on;stream.on("readable",function(){readable=true;var c;while(!paused&&null!==(c=stream.read()))stream.emit("data",c);if(c===null){readable=false;stream._readableState.needReadable=true}});stream.pause=function(){paused=true;this.emit("pause")};stream.resume=function(){paused=false;if(readable)process.nextTick(function(){stream.emit("readable")});else this.read(0);this.emit("resume")};stream.emit("readable")}Readable.prototype.wrap=function(stream){var state=this._readableState;var paused=false;var self=this;stream.on("end",function(){if(state.decoder&&!state.ended){var chunk=state.decoder.end();if(chunk&&chunk.length)self.push(chunk)}self.push(null)});stream.on("data",function(chunk){if(state.decoder)chunk=state.decoder.write(chunk);if(state.objectMode&&(chunk===null||chunk===undefined))return;else if(!state.objectMode&&(!chunk||!chunk.length))return;var ret=self.push(chunk);if(!ret){paused=true;stream.pause()}});for(var i in stream){if(typeof stream[i]==="function"&&typeof this[i]==="undefined"){this[i]=function(method){return function(){return stream[method].apply(stream,arguments)}}(i)}}var events=["error","close","destroy","pause","resume"];forEach(events,function(ev){stream.on(ev,self.emit.bind(self,ev))});self._read=function(n){if(paused){paused=false;stream.resume()}};return self};Readable._fromList=fromList;function fromList(n,state){var list=state.buffer;var length=state.length;var stringMode=!!state.decoder;var objectMode=!!state.objectMode;var ret;if(list.length===0)return null;if(length===0)ret=null;else if(objectMode)ret=list.shift();else if(!n||n>=length){if(stringMode)ret=list.join("");else ret=Buffer.concat(list,length);list.length=0}else{if(n<list[0].length){var buf=list[0];ret=buf.slice(0,n);list[0]=buf.slice(n)}else if(n===list[0].length){ret=list.shift()}else{if(stringMode)ret="";else ret=new Buffer(n);var c=0;for(var i=0,l=list.length;i<l&&c<n;i++){var buf=list[0];var cpy=Math.min(n-c,buf.length);if(stringMode)ret+=buf.slice(0,cpy);else buf.copy(ret,c,0,cpy);if(cpy<buf.length)list[0]=buf.slice(cpy);else list.shift();c+=cpy}}}return ret}function endReadable(stream){var state=stream._readableState;if(state.length>0)throw new Error("endReadable called on non-empty stream");if(!state.endEmitted&&state.calledRead){state.ended=true;process.nextTick(function(){if(!state.endEmitted&&state.length===0){state.endEmitted=true;stream.readable=false;stream.emit("end")}})}}function forEach(xs,f){for(var i=0,l=xs.length;i<l;i++){f(xs[i],i)}}function indexOf(xs,x){for(var i=0,l=xs.length;i<l;i++){if(xs[i]===x)return i}return-1}}).call(this,require("_process"))},{_process:13,buffer:2,"core-util-is":24,events:5,inherits:10,isarray:11,stream:30,"string_decoder/":25}],22:[function(require,module,exports){module.exports=Transform;var Duplex=require("./_stream_duplex");var util=require("core-util-is");util.inherits=require("inherits");util.inherits(Transform,Duplex);function TransformState(options,stream){this.afterTransform=function(er,data){return afterTransform(stream,er,data)};this.needTransform=false;this.transforming=false;this.writecb=null;this.writechunk=null}function afterTransform(stream,er,data){var ts=stream._transformState;ts.transforming=false;var cb=ts.writecb;if(!cb)return stream.emit("error",new Error("no writecb in Transform class"));ts.writechunk=null;ts.writecb=null;if(data!==null&&data!==undefined)stream.push(data);if(cb)cb(er);var rs=stream._readableState;rs.reading=false;if(rs.needReadable||rs.length<rs.highWaterMark){stream._read(rs.highWaterMark)}}function Transform(options){if(!(this instanceof Transform))return new Transform(options);Duplex.call(this,options);var ts=this._transformState=new TransformState(options,this);var stream=this;this._readableState.needReadable=true;this._readableState.sync=false;this.once("finish",function(){if("function"===typeof this._flush)this._flush(function(er){done(stream,er)});else done(stream)})}Transform.prototype.push=function(chunk,encoding){this._transformState.needTransform=false;return Duplex.prototype.push.call(this,chunk,encoding)};Transform.prototype._transform=function(chunk,encoding,cb){throw new Error("not implemented")};Transform.prototype._write=function(chunk,encoding,cb){var ts=this._transformState;ts.writecb=cb;ts.writechunk=chunk;ts.writeencoding=encoding;if(!ts.transforming){var rs=this._readableState;if(ts.needTransform||rs.needReadable||rs.length<rs.highWaterMark)this._read(rs.highWaterMark)}};Transform.prototype._read=function(n){var ts=this._transformState;if(ts.writechunk!==null&&ts.writecb&&!ts.transforming){ts.transforming=true;this._transform(ts.writechunk,ts.writeencoding,ts.afterTransform)}else{ts.needTransform=true}};function done(stream,er){if(er)return stream.emit("error",er);var ws=stream._writableState;var rs=stream._readableState;var ts=stream._transformState;if(ws.length)throw new Error("calling transform done when ws.length != 0");if(ts.transforming)throw new Error("calling transform done when still transforming");return stream.push(null)}},{"./_stream_duplex":19,"core-util-is":24,inherits:10}],23:[function(require,module,exports){(function(process){module.exports=Writable;var Buffer=require("buffer").Buffer;Writable.WritableState=WritableState;var util=require("core-util-is");util.inherits=require("inherits");var Stream=require("stream");util.inherits(Writable,Stream);function WriteReq(chunk,encoding,cb){this.chunk=chunk;this.encoding=encoding;this.callback=cb}function WritableState(options,stream){options=options||{};var hwm=options.highWaterMark;this.highWaterMark=hwm||hwm===0?hwm:16*1024;this.objectMode=!!options.objectMode;this.highWaterMark=~~this.highWaterMark;this.needDrain=false;this.ending=false;this.ended=false;this.finished=false;var noDecode=options.decodeStrings===false;this.decodeStrings=!noDecode;this.defaultEncoding=options.defaultEncoding||"utf8";this.length=0;this.writing=false;this.sync=true;this.bufferProcessing=false;this.onwrite=function(er){onwrite(stream,er)};this.writecb=null;this.writelen=0;this.buffer=[];this.errorEmitted=false}function Writable(options){var Duplex=require("./_stream_duplex");if(!(this instanceof Writable)&&!(this instanceof Duplex))return new Writable(options);this._writableState=new WritableState(options,this);this.writable=true;Stream.call(this)}Writable.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))};function writeAfterEnd(stream,state,cb){var er=new Error("write after end");stream.emit("error",er);process.nextTick(function(){cb(er)})}function validChunk(stream,state,chunk,cb){var valid=true;if(!Buffer.isBuffer(chunk)&&"string"!==typeof chunk&&chunk!==null&&chunk!==undefined&&!state.objectMode){var er=new TypeError("Invalid non-string/buffer chunk");stream.emit("error",er);
process.nextTick(function(){cb(er)});valid=false}return valid}Writable.prototype.write=function(chunk,encoding,cb){var state=this._writableState;var ret=false;if(typeof encoding==="function"){cb=encoding;encoding=null}if(Buffer.isBuffer(chunk))encoding="buffer";else if(!encoding)encoding=state.defaultEncoding;if(typeof cb!=="function")cb=function(){};if(state.ended)writeAfterEnd(this,state,cb);else if(validChunk(this,state,chunk,cb))ret=writeOrBuffer(this,state,chunk,encoding,cb);return ret};function decodeChunk(state,chunk,encoding){if(!state.objectMode&&state.decodeStrings!==false&&typeof chunk==="string"){chunk=new Buffer(chunk,encoding)}return chunk}function writeOrBuffer(stream,state,chunk,encoding,cb){chunk=decodeChunk(state,chunk,encoding);if(Buffer.isBuffer(chunk))encoding="buffer";var len=state.objectMode?1:chunk.length;state.length+=len;var ret=state.length<state.highWaterMark;if(!ret)state.needDrain=true;if(state.writing)state.buffer.push(new WriteReq(chunk,encoding,cb));else doWrite(stream,state,len,chunk,encoding,cb);return ret}function doWrite(stream,state,len,chunk,encoding,cb){state.writelen=len;state.writecb=cb;state.writing=true;state.sync=true;stream._write(chunk,encoding,state.onwrite);state.sync=false}function onwriteError(stream,state,sync,er,cb){if(sync)process.nextTick(function(){cb(er)});else cb(er);stream._writableState.errorEmitted=true;stream.emit("error",er)}function onwriteStateUpdate(state){state.writing=false;state.writecb=null;state.length-=state.writelen;state.writelen=0}function onwrite(stream,er){var state=stream._writableState;var sync=state.sync;var cb=state.writecb;onwriteStateUpdate(state);if(er)onwriteError(stream,state,sync,er,cb);else{var finished=needFinish(stream,state);if(!finished&&!state.bufferProcessing&&state.buffer.length)clearBuffer(stream,state);if(sync){process.nextTick(function(){afterWrite(stream,state,finished,cb)})}else{afterWrite(stream,state,finished,cb)}}}function afterWrite(stream,state,finished,cb){if(!finished)onwriteDrain(stream,state);cb();if(finished)finishMaybe(stream,state)}function onwriteDrain(stream,state){if(state.length===0&&state.needDrain){state.needDrain=false;stream.emit("drain")}}function clearBuffer(stream,state){state.bufferProcessing=true;for(var c=0;c<state.buffer.length;c++){var entry=state.buffer[c];var chunk=entry.chunk;var encoding=entry.encoding;var cb=entry.callback;var len=state.objectMode?1:chunk.length;doWrite(stream,state,len,chunk,encoding,cb);if(state.writing){c++;break}}state.bufferProcessing=false;if(c<state.buffer.length)state.buffer=state.buffer.slice(c);else state.buffer.length=0}Writable.prototype._write=function(chunk,encoding,cb){cb(new Error("not implemented"))};Writable.prototype.end=function(chunk,encoding,cb){var state=this._writableState;if(typeof chunk==="function"){cb=chunk;chunk=null;encoding=null}else if(typeof encoding==="function"){cb=encoding;encoding=null}if(typeof chunk!=="undefined"&&chunk!==null)this.write(chunk,encoding);if(!state.ending&&!state.finished)endWritable(this,state,cb)};function needFinish(stream,state){return state.ending&&state.length===0&&!state.finished&&!state.writing}function finishMaybe(stream,state){var need=needFinish(stream,state);if(need){state.finished=true;stream.emit("finish")}return need}function endWritable(stream,state,cb){state.ending=true;finishMaybe(stream,state);if(cb){if(state.finished)process.nextTick(cb);else stream.once("finish",cb)}state.ended=true}}).call(this,require("_process"))},{"./_stream_duplex":19,_process:13,buffer:2,"core-util-is":24,inherits:10,stream:30}],24:[function(require,module,exports){(function(Buffer){function isArray(ar){return Array.isArray(ar)}exports.isArray=isArray;function isBoolean(arg){return typeof arg==="boolean"}exports.isBoolean=isBoolean;function isNull(arg){return arg===null}exports.isNull=isNull;function isNullOrUndefined(arg){return arg==null}exports.isNullOrUndefined=isNullOrUndefined;function isNumber(arg){return typeof arg==="number"}exports.isNumber=isNumber;function isString(arg){return typeof arg==="string"}exports.isString=isString;function isSymbol(arg){return typeof arg==="symbol"}exports.isSymbol=isSymbol;function isUndefined(arg){return arg===void 0}exports.isUndefined=isUndefined;function isRegExp(re){return isObject(re)&&objectToString(re)==="[object RegExp]"}exports.isRegExp=isRegExp;function isObject(arg){return typeof arg==="object"&&arg!==null}exports.isObject=isObject;function isDate(d){return isObject(d)&&objectToString(d)==="[object Date]"}exports.isDate=isDate;function isError(e){return isObject(e)&&(objectToString(e)==="[object Error]"||e instanceof Error)}exports.isError=isError;function isFunction(arg){return typeof arg==="function"}exports.isFunction=isFunction;function isPrimitive(arg){return arg===null||typeof arg==="boolean"||typeof arg==="number"||typeof arg==="string"||typeof arg==="symbol"||typeof arg==="undefined"}exports.isPrimitive=isPrimitive;function isBuffer(arg){return Buffer.isBuffer(arg)}exports.isBuffer=isBuffer;function objectToString(o){return Object.prototype.toString.call(o)}}).call(this,require("buffer").Buffer)},{buffer:2}],25:[function(require,module,exports){var Buffer=require("buffer").Buffer;var isBufferEncoding=Buffer.isEncoding||function(encoding){switch(encoding&&encoding.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return true;default:return false}};function assertEncoding(encoding){if(encoding&&!isBufferEncoding(encoding)){throw new Error("Unknown encoding: "+encoding)}}var StringDecoder=exports.StringDecoder=function(encoding){this.encoding=(encoding||"utf8").toLowerCase().replace(/[-_]/,"");assertEncoding(encoding);switch(this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2;this.detectIncompleteChar=utf16DetectIncompleteChar;break;case"base64":this.surrogateSize=3;this.detectIncompleteChar=base64DetectIncompleteChar;break;default:this.write=passThroughWrite;return}this.charBuffer=new Buffer(6);this.charReceived=0;this.charLength=0};StringDecoder.prototype.write=function(buffer){var charStr="";var offset=0;while(this.charLength){var i=buffer.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:buffer.length;buffer.copy(this.charBuffer,this.charReceived,offset,i);this.charReceived+=i-offset;offset=i;if(this.charReceived<this.charLength){return""}charStr=this.charBuffer.slice(0,this.charLength).toString(this.encoding);var charCode=charStr.charCodeAt(charStr.length-1);if(charCode>=55296&&charCode<=56319){this.charLength+=this.surrogateSize;charStr="";continue}this.charReceived=this.charLength=0;if(i==buffer.length)return charStr;buffer=buffer.slice(i,buffer.length);break}var lenIncomplete=this.detectIncompleteChar(buffer);var end=buffer.length;if(this.charLength){buffer.copy(this.charBuffer,0,buffer.length-lenIncomplete,end);this.charReceived=lenIncomplete;end-=lenIncomplete}charStr+=buffer.toString(this.encoding,0,end);var end=charStr.length-1;var charCode=charStr.charCodeAt(end);if(charCode>=55296&&charCode<=56319){var size=this.surrogateSize;this.charLength+=size;this.charReceived+=size;this.charBuffer.copy(this.charBuffer,size,0,size);this.charBuffer.write(charStr.charAt(charStr.length-1),this.encoding);return charStr.substring(0,end)}return charStr};StringDecoder.prototype.detectIncompleteChar=function(buffer){var i=buffer.length>=3?3:buffer.length;for(;i>0;i--){var c=buffer[buffer.length-i];if(i==1&&c>>5==6){this.charLength=2;break}if(i<=2&&c>>4==14){this.charLength=3;break}if(i<=3&&c>>3==30){this.charLength=4;break}}return i};StringDecoder.prototype.end=function(buffer){var res="";if(buffer&&buffer.length)res=this.write(buffer);if(this.charReceived){var cr=this.charReceived;var buf=this.charBuffer;var enc=this.encoding;res+=buf.slice(0,cr).toString(enc)}return res};function passThroughWrite(buffer){return buffer.toString(this.encoding)}function utf16DetectIncompleteChar(buffer){var incomplete=this.charReceived=buffer.length%2;this.charLength=incomplete?2:0;return incomplete}function base64DetectIncompleteChar(buffer){var incomplete=this.charReceived=buffer.length%3;this.charLength=incomplete?3:0;return incomplete}},{buffer:2}],26:[function(require,module,exports){module.exports=require("./lib/_stream_passthrough.js")},{"./lib/_stream_passthrough.js":20}],27:[function(require,module,exports){exports=module.exports=require("./lib/_stream_readable.js");exports.Readable=exports;exports.Writable=require("./lib/_stream_writable.js");exports.Duplex=require("./lib/_stream_duplex.js");exports.Transform=require("./lib/_stream_transform.js");exports.PassThrough=require("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":19,"./lib/_stream_passthrough.js":20,"./lib/_stream_readable.js":21,"./lib/_stream_transform.js":22,"./lib/_stream_writable.js":23}],28:[function(require,module,exports){module.exports=require("./lib/_stream_transform.js")},{"./lib/_stream_transform.js":22}],29:[function(require,module,exports){module.exports=require("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":23}],30:[function(require,module,exports){module.exports=Stream;var EE=require("events").EventEmitter;var inherits=require("inherits");inherits(Stream,EE);Stream.Readable=require("readable-stream/readable.js");Stream.Writable=require("readable-stream/writable.js");Stream.Duplex=require("readable-stream/duplex.js");Stream.Transform=require("readable-stream/transform.js");Stream.PassThrough=require("readable-stream/passthrough.js");Stream.Stream=Stream;function Stream(){EE.call(this)}Stream.prototype.pipe=function(dest,options){var source=this;function ondata(chunk){if(dest.writable){if(false===dest.write(chunk)&&source.pause){source.pause()}}}source.on("data",ondata);function ondrain(){if(source.readable&&source.resume){source.resume()}}dest.on("drain",ondrain);if(!dest._isStdio&&(!options||options.end!==false)){source.on("end",onend);source.on("close",onclose)}var didOnEnd=false;function onend(){if(didOnEnd)return;didOnEnd=true;dest.end()}function onclose(){if(didOnEnd)return;didOnEnd=true;if(typeof dest.destroy==="function")dest.destroy()}function onerror(er){cleanup();if(EE.listenerCount(this,"error")===0){throw er}}source.on("error",onerror);dest.on("error",onerror);function cleanup(){source.removeListener("data",ondata);dest.removeListener("drain",ondrain);source.removeListener("end",onend);source.removeListener("close",onclose);source.removeListener("error",onerror);dest.removeListener("error",onerror);source.removeListener("end",cleanup);source.removeListener("close",cleanup);dest.removeListener("close",cleanup)}source.on("end",cleanup);source.on("close",cleanup);dest.on("close",cleanup);dest.emit("pipe",source);return dest}},{events:5,inherits:10,"readable-stream/duplex.js":18,"readable-stream/passthrough.js":26,"readable-stream/readable.js":27,"readable-stream/transform.js":28,"readable-stream/writable.js":29}],31:[function(require,module,exports){var punycode=require("punycode");exports.parse=urlParse;exports.resolve=urlResolve;exports.resolveObject=urlResolveObject;exports.format=urlFormat;exports.Url=Url;function Url(){this.protocol=null;this.slashes=null;this.auth=null;this.host=null;this.port=null;this.hostname=null;this.hash=null;this.search=null;this.query=null;this.pathname=null;this.path=null;this.href=null}var protocolPattern=/^([a-z0-9.+-]+:)/i,portPattern=/:[0-9]*$/,delims=["<",">",'"',"`"," ","\r","\n"," "],unwise=["{","}","|","\\","^","`"].concat(delims),autoEscape=["'"].concat(unwise),nonHostChars=["%","/","?",";","#"].concat(autoEscape),hostEndingChars=["/","?","#"],hostnameMaxLen=255,hostnamePartPattern=/^[a-z0-9A-Z_-]{0,63}$/,hostnamePartStart=/^([a-z0-9A-Z_-]{0,63})(.*)$/,unsafeProtocol={javascript:true,"javascript:":true},hostlessProtocol={javascript:true,"javascript:":true},slashedProtocol={http:true,https:true,ftp:true,gopher:true,file:true,"http:":true,"https:":true,"ftp:":true,"gopher:":true,"file:":true},querystring=require("querystring");function urlParse(url,parseQueryString,slashesDenoteHost){if(url&&isObject(url)&&url instanceof Url)return url;var u=new Url;u.parse(url,parseQueryString,slashesDenoteHost);return u}Url.prototype.parse=function(url,parseQueryString,slashesDenoteHost){if(!isString(url)){throw new TypeError("Parameter 'url' must be a string, not "+typeof url)}var rest=url;rest=rest.trim();var proto=protocolPattern.exec(rest);if(proto){proto=proto[0];var lowerProto=proto.toLowerCase();this.protocol=lowerProto;rest=rest.substr(proto.length)}if(slashesDenoteHost||proto||rest.match(/^\/\/[^@\/]+@[^@\/]+/)){var slashes=rest.substr(0,2)==="//";if(slashes&&!(proto&&hostlessProtocol[proto])){rest=rest.substr(2);this.slashes=true}}if(!hostlessProtocol[proto]&&(slashes||proto&&!slashedProtocol[proto])){var hostEnd=-1;for(var i=0;i<hostEndingChars.length;i++){var hec=rest.indexOf(hostEndingChars[i]);if(hec!==-1&&(hostEnd===-1||hec<hostEnd))hostEnd=hec}var auth,atSign;if(hostEnd===-1){atSign=rest.lastIndexOf("@")}else{atSign=rest.lastIndexOf("@",hostEnd)}if(atSign!==-1){auth=rest.slice(0,atSign);rest=rest.slice(atSign+1);this.auth=decodeURIComponent(auth)}hostEnd=-1;for(var i=0;i<nonHostChars.length;i++){var hec=rest.indexOf(nonHostChars[i]);if(hec!==-1&&(hostEnd===-1||hec<hostEnd))hostEnd=hec}if(hostEnd===-1)hostEnd=rest.length;this.host=rest.slice(0,hostEnd);rest=rest.slice(hostEnd);this.parseHost();this.hostname=this.hostname||"";var ipv6Hostname=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!ipv6Hostname){var hostparts=this.hostname.split(/\./);for(var i=0,l=hostparts.length;i<l;i++){var part=hostparts[i];if(!part)continue;if(!part.match(hostnamePartPattern)){var newpart="";for(var j=0,k=part.length;j<k;j++){if(part.charCodeAt(j)>127){newpart+="x"}else{newpart+=part[j]}}if(!newpart.match(hostnamePartPattern)){var validParts=hostparts.slice(0,i);var notHost=hostparts.slice(i+1);var bit=part.match(hostnamePartStart);if(bit){validParts.push(bit[1]);notHost.unshift(bit[2])}if(notHost.length){rest="/"+notHost.join(".")+rest}this.hostname=validParts.join(".");break}}}}if(this.hostname.length>hostnameMaxLen){this.hostname=""}else{this.hostname=this.hostname.toLowerCase()}if(!ipv6Hostname){var domainArray=this.hostname.split(".");var newOut=[];for(var i=0;i<domainArray.length;++i){var s=domainArray[i];newOut.push(s.match(/[^A-Za-z0-9_-]/)?"xn--"+punycode.encode(s):s)}this.hostname=newOut.join(".")}var p=this.port?":"+this.port:"";var h=this.hostname||"";this.host=h+p;this.href+=this.host;if(ipv6Hostname){this.hostname=this.hostname.substr(1,this.hostname.length-2);if(rest[0]!=="/"){rest="/"+rest}}}if(!unsafeProtocol[lowerProto]){for(var i=0,l=autoEscape.length;i<l;i++){var ae=autoEscape[i];var esc=encodeURIComponent(ae);if(esc===ae){esc=escape(ae)}rest=rest.split(ae).join(esc)}}var hash=rest.indexOf("#");if(hash!==-1){this.hash=rest.substr(hash);rest=rest.slice(0,hash)}var qm=rest.indexOf("?");if(qm!==-1){this.search=rest.substr(qm);this.query=rest.substr(qm+1);if(parseQueryString){this.query=querystring.parse(this.query)}rest=rest.slice(0,qm)}else if(parseQueryString){this.search="";this.query={}}if(rest)this.pathname=rest;if(slashedProtocol[lowerProto]&&this.hostname&&!this.pathname){this.pathname="/"}if(this.pathname||this.search){var p=this.pathname||"";var s=this.search||"";this.path=p+s}this.href=this.format();return this};function urlFormat(obj){if(isString(obj))obj=urlParse(obj);if(!(obj instanceof Url))return Url.prototype.format.call(obj);return obj.format()}Url.prototype.format=function(){var auth=this.auth||"";if(auth){auth=encodeURIComponent(auth);auth=auth.replace(/%3A/i,":");auth+="@"}var protocol=this.protocol||"",pathname=this.pathname||"",hash=this.hash||"",host=false,query="";if(this.host){host=auth+this.host}else if(this.hostname){host=auth+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]");if(this.port){host+=":"+this.port}}if(this.query&&isObject(this.query)&&Object.keys(this.query).length){query=querystring.stringify(this.query)}var search=this.search||query&&"?"+query||"";if(protocol&&protocol.substr(-1)!==":")protocol+=":";if(this.slashes||(!protocol||slashedProtocol[protocol])&&host!==false){host="//"+(host||"");if(pathname&&pathname.charAt(0)!=="/")pathname="/"+pathname}else if(!host){host=""}if(hash&&hash.charAt(0)!=="#")hash="#"+hash;if(search&&search.charAt(0)!=="?")search="?"+search;pathname=pathname.replace(/[?#]/g,function(match){return encodeURIComponent(match)});search=search.replace("#","%23");return protocol+host+pathname+search+hash};function urlResolve(source,relative){return urlParse(source,false,true).resolve(relative)}Url.prototype.resolve=function(relative){return this.resolveObject(urlParse(relative,false,true)).format()};function urlResolveObject(source,relative){if(!source)return relative;return urlParse(source,false,true).resolveObject(relative)}Url.prototype.resolveObject=function(relative){if(isString(relative)){var rel=new Url;rel.parse(relative,false,true);relative=rel}var result=new Url;Object.keys(this).forEach(function(k){result[k]=this[k]},this);result.hash=relative.hash;if(relative.href===""){result.href=result.format();return result}if(relative.slashes&&!relative.protocol){Object.keys(relative).forEach(function(k){if(k!=="protocol")result[k]=relative[k]});if(slashedProtocol[result.protocol]&&result.hostname&&!result.pathname){result.path=result.pathname="/"}result.href=result.format();return result}if(relative.protocol&&relative.protocol!==result.protocol){if(!slashedProtocol[relative.protocol]){Object.keys(relative).forEach(function(k){result[k]=relative[k]});result.href=result.format();return result}result.protocol=relative.protocol;if(!relative.host&&!hostlessProtocol[relative.protocol]){var relPath=(relative.pathname||"").split("/");while(relPath.length&&!(relative.host=relPath.shift()));if(!relative.host)relative.host="";if(!relative.hostname)relative.hostname="";if(relPath[0]!=="")relPath.unshift("");if(relPath.length<2)relPath.unshift("");result.pathname=relPath.join("/")}else{result.pathname=relative.pathname}result.search=relative.search;result.query=relative.query;result.host=relative.host||"";result.auth=relative.auth;result.hostname=relative.hostname||relative.host;result.port=relative.port;if(result.pathname||result.search){var p=result.pathname||"";var s=result.search||"";result.path=p+s}result.slashes=result.slashes||relative.slashes;result.href=result.format();return result}var isSourceAbs=result.pathname&&result.pathname.charAt(0)==="/",isRelAbs=relative.host||relative.pathname&&relative.pathname.charAt(0)==="/",mustEndAbs=isRelAbs||isSourceAbs||result.host&&relative.pathname,removeAllDots=mustEndAbs,srcPath=result.pathname&&result.pathname.split("/")||[],relPath=relative.pathname&&relative.pathname.split("/")||[],psychotic=result.protocol&&!slashedProtocol[result.protocol];if(psychotic){result.hostname="";result.port=null;if(result.host){if(srcPath[0]==="")srcPath[0]=result.host;else srcPath.unshift(result.host)}result.host="";if(relative.protocol){relative.hostname=null;relative.port=null;if(relative.host){if(relPath[0]==="")relPath[0]=relative.host;else relPath.unshift(relative.host)}relative.host=null}mustEndAbs=mustEndAbs&&(relPath[0]===""||srcPath[0]==="")}if(isRelAbs){result.host=relative.host||relative.host===""?relative.host:result.host;result.hostname=relative.hostname||relative.hostname===""?relative.hostname:result.hostname;result.search=relative.search;result.query=relative.query;srcPath=relPath}else if(relPath.length){if(!srcPath)srcPath=[];srcPath.pop();srcPath=srcPath.concat(relPath);result.search=relative.search;result.query=relative.query}else if(!isNullOrUndefined(relative.search)){if(psychotic){result.hostname=result.host=srcPath.shift();var authInHost=result.host&&result.host.indexOf("@")>0?result.host.split("@"):false;if(authInHost){result.auth=authInHost.shift();result.host=result.hostname=authInHost.shift()}}result.search=relative.search;result.query=relative.query;if(!isNull(result.pathname)||!isNull(result.search)){result.path=(result.pathname?result.pathname:"")+(result.search?result.search:"")}result.href=result.format();return result}if(!srcPath.length){result.pathname=null;if(result.search){result.path="/"+result.search}else{result.path=null}result.href=result.format();return result}var last=srcPath.slice(-1)[0];var hasTrailingSlash=(result.host||relative.host)&&(last==="."||last==="..")||last==="";var up=0;for(var i=srcPath.length;i>=0;i--){last=srcPath[i];if(last=="."){srcPath.splice(i,1)}else if(last===".."){srcPath.splice(i,1);up++}else if(up){srcPath.splice(i,1);up--}}if(!mustEndAbs&&!removeAllDots){for(;up--;up){srcPath.unshift("..")}}if(mustEndAbs&&srcPath[0]!==""&&(!srcPath[0]||srcPath[0].charAt(0)!=="/")){srcPath.unshift("")}if(hasTrailingSlash&&srcPath.join("/").substr(-1)!=="/"){srcPath.push("")}var isAbsolute=srcPath[0]===""||srcPath[0]&&srcPath[0].charAt(0)==="/";if(psychotic){result.hostname=result.host=isAbsolute?"":srcPath.length?srcPath.shift():"";var authInHost=result.host&&result.host.indexOf("@")>0?result.host.split("@"):false;if(authInHost){result.auth=authInHost.shift();result.host=result.hostname=authInHost.shift()}}mustEndAbs=mustEndAbs||result.host&&srcPath.length;if(mustEndAbs&&!isAbsolute){srcPath.unshift("")}if(!srcPath.length){result.pathname=null;result.path=null}else{result.pathname=srcPath.join("/")}if(!isNull(result.pathname)||!isNull(result.search)){result.path=(result.pathname?result.pathname:"")+(result.search?result.search:"")}result.auth=relative.auth||result.auth;result.slashes=result.slashes||relative.slashes;result.href=result.format();return result};Url.prototype.parseHost=function(){var host=this.host;var port=portPattern.exec(host);if(port){port=port[0];if(port!==":"){this.port=port.substr(1)}host=host.substr(0,host.length-port.length)}if(host)this.hostname=host};function isString(arg){return typeof arg==="string"}function isObject(arg){return typeof arg==="object"&&arg!==null}function isNull(arg){return arg===null}function isNullOrUndefined(arg){return arg==null}},{punycode:14,querystring:17}],32:[function(require,module,exports){module.exports=function isBuffer(arg){return arg&&typeof arg==="object"&&typeof arg.copy==="function"&&typeof arg.fill==="function"&&typeof arg.readUInt8==="function"}},{}],33:[function(require,module,exports){(function(process,global){var formatRegExp=/%[sdj%]/g;exports.format=function(f){if(!isString(f)){var objects=[];for(var i=0;i<arguments.length;i++){objects.push(inspect(arguments[i]))}return objects.join(" ")}var i=1;var args=arguments;var len=args.length;var str=String(f).replace(formatRegExp,function(x){if(x==="%%")return"%";if(i>=len)return x;switch(x){case"%s":return String(args[i++]);case"%d":return Number(args[i++]);case"%j":try{return JSON.stringify(args[i++])}catch(_){return"[Circular]"}default:return x}});for(var x=args[i];i<len;x=args[++i]){if(isNull(x)||!isObject(x)){str+=" "+x}else{str+=" "+inspect(x)}}return str};exports.deprecate=function(fn,msg){if(isUndefined(global.process)){return function(){return exports.deprecate(fn,msg).apply(this,arguments)}}if(process.noDeprecation===true){return fn}var warned=false;function deprecated(){if(!warned){if(process.throwDeprecation){throw new Error(msg)}else if(process.traceDeprecation){console.trace(msg)}else{console.error(msg)}warned=true}return fn.apply(this,arguments)}return deprecated};var debugs={};var debugEnviron;exports.debuglog=function(set){if(isUndefined(debugEnviron))debugEnviron=process.env.NODE_DEBUG||"";set=set.toUpperCase();if(!debugs[set]){if(new RegExp("\\b"+set+"\\b","i").test(debugEnviron)){var pid=process.pid;debugs[set]=function(){var msg=exports.format.apply(exports,arguments);console.error("%s %d: %s",set,pid,msg)}}else{debugs[set]=function(){}}}return debugs[set]};function inspect(obj,opts){var ctx={seen:[],stylize:stylizeNoColor};if(arguments.length>=3)ctx.depth=arguments[2];if(arguments.length>=4)ctx.colors=arguments[3];if(isBoolean(opts)){ctx.showHidden=opts}else if(opts){exports._extend(ctx,opts)}if(isUndefined(ctx.showHidden))ctx.showHidden=false;if(isUndefined(ctx.depth))ctx.depth=2;if(isUndefined(ctx.colors))ctx.colors=false;if(isUndefined(ctx.customInspect))ctx.customInspect=true;if(ctx.colors)ctx.stylize=stylizeWithColor;return formatValue(ctx,obj,ctx.depth)}exports.inspect=inspect;inspect.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]};inspect.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"};function stylizeWithColor(str,styleType){var style=inspect.styles[styleType];if(style){return"["+inspect.colors[style][0]+"m"+str+"["+inspect.colors[style][1]+"m"}else{return str}}function stylizeNoColor(str,styleType){return str}function arrayToHash(array){var hash={};array.forEach(function(val,idx){hash[val]=true});return hash}function formatValue(ctx,value,recurseTimes){if(ctx.customInspect&&value&&isFunction(value.inspect)&&value.inspect!==exports.inspect&&!(value.constructor&&value.constructor.prototype===value)){var ret=value.inspect(recurseTimes,ctx);if(!isString(ret)){ret=formatValue(ctx,ret,recurseTimes)}return ret}var primitive=formatPrimitive(ctx,value);if(primitive){return primitive}var keys=Object.keys(value);var visibleKeys=arrayToHash(keys);if(ctx.showHidden){keys=Object.getOwnPropertyNames(value)}if(isError(value)&&(keys.indexOf("message")>=0||keys.indexOf("description")>=0)){return formatError(value)}if(keys.length===0){if(isFunction(value)){var name=value.name?": "+value.name:"";return ctx.stylize("[Function"+name+"]","special")}if(isRegExp(value)){return ctx.stylize(RegExp.prototype.toString.call(value),"regexp")}if(isDate(value)){return ctx.stylize(Date.prototype.toString.call(value),"date")}if(isError(value)){return formatError(value)}}var base="",array=false,braces=["{","}"];if(isArray(value)){array=true;braces=["[","]"]}if(isFunction(value)){var n=value.name?": "+value.name:"";base=" [Function"+n+"]"}if(isRegExp(value)){base=" "+RegExp.prototype.toString.call(value)}if(isDate(value)){base=" "+Date.prototype.toUTCString.call(value)}if(isError(value)){base=" "+formatError(value)}if(keys.length===0&&(!array||value.length==0)){return braces[0]+base+braces[1]}if(recurseTimes<0){if(isRegExp(value)){return ctx.stylize(RegExp.prototype.toString.call(value),"regexp")}else{return ctx.stylize("[Object]","special")}}ctx.seen.push(value);var output;if(array){output=formatArray(ctx,value,recurseTimes,visibleKeys,keys)}else{output=keys.map(function(key){return formatProperty(ctx,value,recurseTimes,visibleKeys,key,array)})}ctx.seen.pop();return reduceToSingleString(output,base,braces)}function formatPrimitive(ctx,value){if(isUndefined(value))return ctx.stylize("undefined","undefined");if(isString(value)){var simple="'"+JSON.stringify(value).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return ctx.stylize(simple,"string")}if(isNumber(value))return ctx.stylize(""+value,"number");if(isBoolean(value))return ctx.stylize(""+value,"boolean");if(isNull(value))return ctx.stylize("null","null")}function formatError(value){return"["+Error.prototype.toString.call(value)+"]"}function formatArray(ctx,value,recurseTimes,visibleKeys,keys){var output=[];for(var i=0,l=value.length;i<l;++i){if(hasOwnProperty(value,String(i))){output.push(formatProperty(ctx,value,recurseTimes,visibleKeys,String(i),true))}else{output.push("")}}keys.forEach(function(key){if(!key.match(/^\d+$/)){output.push(formatProperty(ctx,value,recurseTimes,visibleKeys,key,true))}});return output}function formatProperty(ctx,value,recurseTimes,visibleKeys,key,array){var name,str,desc;desc=Object.getOwnPropertyDescriptor(value,key)||{value:value[key]};if(desc.get){if(desc.set){str=ctx.stylize("[Getter/Setter]","special")}else{str=ctx.stylize("[Getter]","special")}}else{if(desc.set){str=ctx.stylize("[Setter]","special")}}if(!hasOwnProperty(visibleKeys,key)){name="["+key+"]"}if(!str){if(ctx.seen.indexOf(desc.value)<0){if(isNull(recurseTimes)){str=formatValue(ctx,desc.value,null)}else{str=formatValue(ctx,desc.value,recurseTimes-1)}if(str.indexOf("\n")>-1){if(array){str=str.split("\n").map(function(line){return" "+line}).join("\n").substr(2)}else{str="\n"+str.split("\n").map(function(line){return" "+line}).join("\n")}}}else{str=ctx.stylize("[Circular]","special")}}if(isUndefined(name)){if(array&&key.match(/^\d+$/)){return str}name=JSON.stringify(""+key);if(name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)){name=name.substr(1,name.length-2);name=ctx.stylize(name,"name")}else{name=name.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'");name=ctx.stylize(name,"string")}}return name+": "+str}function reduceToSingleString(output,base,braces){var numLinesEst=0;var length=output.reduce(function(prev,cur){numLinesEst++;if(cur.indexOf("\n")>=0)numLinesEst++;return prev+cur.replace(/\u001b\[\d\d?m/g,"").length+1},0);if(length>60){return braces[0]+(base===""?"":base+"\n ")+" "+output.join(",\n ")+" "+braces[1]}return braces[0]+base+" "+output.join(", ")+" "+braces[1]}function isArray(ar){return Array.isArray(ar)}exports.isArray=isArray;function isBoolean(arg){return typeof arg==="boolean"}exports.isBoolean=isBoolean;function isNull(arg){return arg===null}exports.isNull=isNull;function isNullOrUndefined(arg){return arg==null}exports.isNullOrUndefined=isNullOrUndefined;function isNumber(arg){return typeof arg==="number"}exports.isNumber=isNumber;function isString(arg){return typeof arg==="string"}exports.isString=isString;function isSymbol(arg){return typeof arg==="symbol"}exports.isSymbol=isSymbol;function isUndefined(arg){return arg===void 0}exports.isUndefined=isUndefined;function isRegExp(re){return isObject(re)&&objectToString(re)==="[object RegExp]"}exports.isRegExp=isRegExp;function isObject(arg){return typeof arg==="object"&&arg!==null}exports.isObject=isObject;function isDate(d){return isObject(d)&&objectToString(d)==="[object Date]"}exports.isDate=isDate;function isError(e){return isObject(e)&&(objectToString(e)==="[object Error]"||e instanceof Error)}exports.isError=isError;function isFunction(arg){return typeof arg==="function"}exports.isFunction=isFunction;function isPrimitive(arg){return arg===null||typeof arg==="boolean"||typeof arg==="number"||typeof arg==="string"||typeof arg==="symbol"||typeof arg==="undefined"}exports.isPrimitive=isPrimitive;exports.isBuffer=require("./support/isBuffer");function objectToString(o){return Object.prototype.toString.call(o)}function pad(n){return n<10?"0"+n.toString(10):n.toString(10)}var months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function timestamp(){var d=new Date;var time=[pad(d.getHours()),pad(d.getMinutes()),pad(d.getSeconds())].join(":");return[d.getDate(),months[d.getMonth()],time].join(" ")}exports.log=function(){console.log("%s - %s",timestamp(),exports.format.apply(exports,arguments))};exports.inherits=require("inherits");exports._extend=function(origin,add){if(!add||!isObject(add))return origin;var keys=Object.keys(add);var i=keys.length;while(i--){origin[keys[i]]=add[keys[i]]}return origin};function hasOwnProperty(obj,prop){return Object.prototype.hasOwnProperty.call(obj,prop)}}).call(this,require("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./support/isBuffer":32,_process:13,inherits:10}],34:[function(require,module,exports){(function(context){function Lazy(source){if(source instanceof Array){return new ArrayWrapper(source)}else if(typeof source==="string"){return new StringWrapper(source)}else if(source instanceof Sequence){return source}if(Lazy.extensions){var extensions=Lazy.extensions,length=extensions.length,result;
while(!result&&length--){result=extensions[length](source)}if(result){return result}}return new ObjectWrapper(source)}Lazy.VERSION="0.3.2";Lazy.noop=function noop(){};Lazy.identity=function identity(x){return x};Lazy.strict=function strict(){function StrictLazy(source){if(source==null){throw"You cannot wrap null or undefined using Lazy."}if(typeof source==="number"||typeof source==="boolean"){throw"You cannot wrap primitive values using Lazy."}return Lazy(source)}Lazy(Lazy).each(function(property,name){StrictLazy[name]=property});return StrictLazy};function Sequence(){}Sequence.define=function define(methodName,overrides){if(!overrides||!overrides.getIterator&&!overrides.each){throw"A custom sequence must implement *at least* getIterator or each!"}return defineSequenceType(Sequence,methodName,overrides)};Sequence.prototype.size=function size(){return this.getIndex().length()};Sequence.prototype.getIterator=function getIterator(){return new Iterator(this)};Sequence.prototype.root=function root(){return this.parent.root()};Sequence.prototype.value=function value(){return this.toArray()};Sequence.prototype.apply=function apply(source){var root=this.root(),previousSource=root.source,result;try{root.source=source;result=this.value()}finally{root.source=previousSource}return result};function Iterator(sequence){this.sequence=sequence;this.index=-1}Iterator.prototype.current=function current(){return this.cachedIndex&&this.cachedIndex.get(this.index)};Iterator.prototype.moveNext=function moveNext(){var cachedIndex=this.cachedIndex;if(!cachedIndex){cachedIndex=this.cachedIndex=this.sequence.getIndex()}if(this.index>=cachedIndex.length()-1){return false}++this.index;return true};Sequence.prototype.toArray=function toArray(){return this.reduce(function(arr,element){arr.push(element);return arr},[])};Sequence.prototype.getIndex=function getIndex(){if(!this.cachedIndex){this.cachedIndex=new ArrayWrapper(this.toArray())}return this.cachedIndex};Sequence.prototype.memoize=function memoize(){return new MemoizedSequence(this)};function MemoizedSequence(parent){this.parent=parent}Sequence.prototype.toObject=function toObject(){return this.reduce(function(object,pair){object[pair[0]]=pair[1];return object},{})};Sequence.prototype.each=function each(fn){var iterator=this.getIterator(),i=-1;while(iterator.moveNext()){if(fn(iterator.current(),++i)===false){return false}}return true};Sequence.prototype.forEach=function forEach(fn){return this.each(fn)};Sequence.prototype.map=function map(mapFn){return new MappedSequence(this,createCallback(mapFn))};Sequence.prototype.collect=function collect(mapFn){return this.map(mapFn)};function MappedSequence(parent,mapFn){this.parent=parent;this.mapFn=mapFn}MappedSequence.prototype=new Sequence;MappedSequence.prototype.getIterator=function getIterator(){return new MappingIterator(this.parent,this.mapFn)};MappedSequence.prototype.each=function each(fn){var mapFn=this.mapFn;return this.parent.each(function(e,i){return fn(mapFn(e,i),i)})};function MappingIterator(sequence,mapFn){this.iterator=sequence.getIterator();this.mapFn=mapFn;this.index=-1}MappingIterator.prototype.current=function current(){return this.mapFn(this.iterator.current(),this.index)};MappingIterator.prototype.moveNext=function moveNext(){if(this.iterator.moveNext()){++this.index;return true}return false};Sequence.prototype.pluck=function pluck(property){return this.map(property)};Sequence.prototype.invoke=function invoke(methodName){return this.map(function(e){return e[methodName]()})};Sequence.prototype.filter=function filter(filterFn){return new FilteredSequence(this,createCallback(filterFn))};Sequence.prototype.select=function select(filterFn){return this.filter(filterFn)};function FilteredSequence(parent,filterFn){this.parent=parent;this.filterFn=filterFn}FilteredSequence.prototype=new Sequence;FilteredSequence.prototype.getIterator=function getIterator(){return new FilteringIterator(this.parent,this.filterFn)};FilteredSequence.prototype.each=function each(fn){var filterFn=this.filterFn;return this.parent.each(function(e,i){if(filterFn(e,i)){return fn(e,i)}})};FilteredSequence.prototype.reverse=function reverse(){return this.parent.reverse().filter(this.filterFn)};function FilteringIterator(sequence,filterFn){this.iterator=sequence.getIterator();this.filterFn=filterFn;this.index=0}FilteringIterator.prototype.current=function current(){return this.value};FilteringIterator.prototype.moveNext=function moveNext(){var iterator=this.iterator,filterFn=this.filterFn,value;while(iterator.moveNext()){value=iterator.current();if(filterFn(value,this.index++)){this.value=value;return true}}this.value=undefined;return false};Sequence.prototype.reject=function reject(rejectFn){rejectFn=createCallback(rejectFn);return this.filter(function(e){return!rejectFn(e)})};Sequence.prototype.ofType=function ofType(type){return this.filter(function(e){return typeof e===type})};Sequence.prototype.where=function where(properties){return this.filter(properties)};Sequence.prototype.reverse=function reverse(){return new ReversedSequence(this)};function ReversedSequence(parent){this.parent=parent}ReversedSequence.prototype=new Sequence;ReversedSequence.prototype.getIterator=function getIterator(){return new ReversedIterator(this.parent)};function ReversedIterator(sequence){this.sequence=sequence}ReversedIterator.prototype.current=function current(){return this.sequence.getIndex().get(this.index)};ReversedIterator.prototype.moveNext=function moveNext(){var indexed=this.sequence.getIndex(),length=indexed.length();if(typeof this.index==="undefined"){this.index=length}return--this.index>=0};Sequence.prototype.concat=function concat(var_args){return new ConcatenatedSequence(this,arraySlice.call(arguments,0))};function ConcatenatedSequence(parent,arrays){this.parent=parent;this.arrays=arrays}ConcatenatedSequence.prototype=new Sequence;ConcatenatedSequence.prototype.each=function each(fn){var done=false,i=0;this.parent.each(function(e){if(fn(e,i++)===false){done=true;return false}});if(!done){Lazy(this.arrays).flatten().each(function(e){if(fn(e,i++)===false){return false}})}};Sequence.prototype.first=function first(count){if(typeof count==="undefined"){return getFirst(this)}return new TakeSequence(this,count)};Sequence.prototype.head=Sequence.prototype.take=function(count){return this.first(count)};function TakeSequence(parent,count){this.parent=parent;this.count=count}TakeSequence.prototype=new Sequence;TakeSequence.prototype.getIterator=function getIterator(){return new TakeIterator(this.parent,this.count)};TakeSequence.prototype.each=function each(fn){var count=this.count,i=0;this.parent.each(function(e){var result;if(i<count){result=fn(e,i)}if(++i>=count){return false}return result})};function TakeIterator(sequence,count){this.iterator=sequence.getIterator();this.count=count}TakeIterator.prototype.current=function current(){return this.iterator.current()};TakeIterator.prototype.moveNext=function moveNext(){return--this.count>=0&&this.iterator.moveNext()};Sequence.prototype.takeWhile=function takeWhile(predicate){return new TakeWhileSequence(this,predicate)};function TakeWhileSequence(parent,predicate){this.parent=parent;this.predicate=predicate}TakeWhileSequence.prototype=new Sequence;TakeWhileSequence.prototype.each=function each(fn){var predicate=this.predicate;this.parent.each(function(e){return predicate(e)&&fn(e)})};Sequence.prototype.initial=function initial(count){if(typeof count==="undefined"){count=1}return this.take(this.getIndex().length()-count)};Sequence.prototype.last=function last(count){if(typeof count==="undefined"){return this.reverse().first()}return this.reverse().take(count).reverse()};Sequence.prototype.findWhere=function findWhere(properties){return this.where(properties).first()};Sequence.prototype.rest=function rest(count){return new DropSequence(this,count)};Sequence.prototype.skip=Sequence.prototype.tail=Sequence.prototype.drop=function drop(count){return this.rest(count)};function DropSequence(parent,count){this.parent=parent;this.count=typeof count==="number"?count:1}DropSequence.prototype=new Sequence;DropSequence.prototype.each=function each(fn){var count=this.count,dropped=0,i=0;this.parent.each(function(e){if(dropped++<count){return}return fn(e,i++)})};Sequence.prototype.dropWhile=function dropWhile(predicate){return new DropWhileSequence(this,predicate)};Sequence.prototype.skipWhile=function skipWhile(predicate){return this.dropWhile(predicate)};function DropWhileSequence(parent,predicate){this.parent=parent;this.predicate=predicate}DropWhileSequence.prototype=new Sequence;DropWhileSequence.prototype.each=function each(fn){var predicate=this.predicate,done=false;this.parent.each(function(e){if(!done){if(predicate(e)){return}done=true}return fn(e)})};Sequence.prototype.sortBy=function sortBy(sortFn){return new SortedSequence(this,sortFn)};function SortedSequence(parent,sortFn){this.parent=parent;this.sortFn=sortFn}SortedSequence.prototype=new Sequence;SortedSequence.prototype.each=function each(fn){var sortFn=createCallback(this.sortFn),sorted=this.parent.toArray(),i=-1;sorted.sort(function(x,y){return compare(x,y,sortFn)});return forEach(sorted,fn)};Sequence.prototype.groupBy=function groupBy(keyFn){return new GroupedSequence(this,keyFn)};function GroupedSequence(parent,keyFn){this.parent=parent;this.keyFn=keyFn}Sequence.prototype.countBy=function countBy(keyFn){return new CountedSequence(this,keyFn)};function CountedSequence(parent,keyFn){this.parent=parent;this.keyFn=keyFn}Sequence.prototype.uniq=function uniq(keyFn){return new UniqueSequence(this,keyFn)};Sequence.prototype.unique=function unique(keyFn){return this.uniq(keyFn)};function UniqueSequence(parent,keyFn){this.parent=parent;this.keyFn=keyFn}UniqueSequence.prototype=new Sequence;UniqueSequence.prototype.each=function each(fn){var cache=new Set,keyFn=this.keyFn,i=0;if(keyFn){keyFn=createCallback(keyFn);return this.parent.each(function(e){if(cache.add(keyFn(e))){return fn(e,i++)}})}else{return this.parent.each(function(e){if(cache.add(e)){return fn(e,i++)}})}};Sequence.prototype.zip=function zip(var_args){if(arguments.length===1){return new SimpleZippedSequence(this,var_args)}else{return new ZippedSequence(this,arraySlice.call(arguments,0))}};function ZippedSequence(parent,arrays){this.parent=parent;this.arrays=arrays}ZippedSequence.prototype=new Sequence;ZippedSequence.prototype.each=function each(fn){var arrays=this.arrays,i=0;this.parent.each(function(e){var group=[e];for(var j=0;j<arrays.length;++j){if(arrays[j].length>i){group.push(arrays[j][i])}}return fn(group,i++)})};Sequence.prototype.shuffle=function shuffle(){return new ShuffledSequence(this)};function ShuffledSequence(parent){this.parent=parent}ShuffledSequence.prototype=new Sequence;ShuffledSequence.prototype.each=function each(fn){var shuffled=this.parent.toArray(),floor=Math.floor,random=Math.random,j=0;for(var i=shuffled.length-1;i>0;--i){swap(shuffled,i,floor(random()*i)+1);if(fn(shuffled[i],j++)===false){return}}fn(shuffled[0],j)};Sequence.prototype.flatten=function flatten(){return new FlattenedSequence(this)};function FlattenedSequence(parent){this.parent=parent}FlattenedSequence.prototype=new Sequence;FlattenedSequence.prototype.each=function each(fn){var index=0;return this.parent.each(function recurseVisitor(e){if(e instanceof Array){return forEach(e,recurseVisitor)}if(e instanceof Sequence){return e.each(recurseVisitor)}return fn(e,index++)})};Sequence.prototype.compact=function compact(){return this.filter(function(e){return!!e})};Sequence.prototype.without=function without(var_args){return new WithoutSequence(this,arraySlice.call(arguments,0))};Sequence.prototype.difference=function difference(var_args){return this.without.apply(this,arguments)};function WithoutSequence(parent,values){this.parent=parent;this.values=values}WithoutSequence.prototype=new Sequence;WithoutSequence.prototype.each=function each(fn){var set=createSet(this.values),i=0;return this.parent.each(function(e){if(!set.contains(e)){return fn(e,i++)}})};Sequence.prototype.union=function union(var_args){return this.concat(var_args).uniq()};Sequence.prototype.intersection=function intersection(var_args){if(arguments.length===1&&arguments[0]instanceof Array){return new SimpleIntersectionSequence(this,var_args)}else{return new IntersectionSequence(this,arraySlice.call(arguments,0))}};function IntersectionSequence(parent,arrays){this.parent=parent;this.arrays=arrays}IntersectionSequence.prototype=new Sequence;IntersectionSequence.prototype.each=function each(fn){var sets=Lazy(this.arrays).map(function(values){return new UniqueMemoizer(Lazy(values).getIterator())});var setIterator=new UniqueMemoizer(sets.getIterator()),i=0;return this.parent.each(function(e){var includedInAll=true;setIterator.each(function(set){if(!set.contains(e)){includedInAll=false;return false}});if(includedInAll){return fn(e,i++)}})};function UniqueMemoizer(iterator){this.iterator=iterator;this.set=new Set;this.memo=[];this.currentValue=undefined}UniqueMemoizer.prototype.current=function current(){return this.currentValue};UniqueMemoizer.prototype.moveNext=function moveNext(){var iterator=this.iterator,set=this.set,memo=this.memo,current;while(iterator.moveNext()){current=iterator.current();if(set.add(current)){memo.push(current);this.currentValue=current;return true}}return false};UniqueMemoizer.prototype.each=function each(fn){var memo=this.memo,length=memo.length,i=-1;while(++i<length){if(fn(memo[i],i)===false){return false}}while(this.moveNext()){if(fn(this.currentValue,i++)===false){break}}};UniqueMemoizer.prototype.contains=function contains(e){if(this.set.contains(e)){return true}while(this.moveNext()){if(this.currentValue===e){return true}}return false};Sequence.prototype.every=function every(predicate){predicate=createCallback(predicate);return this.each(function(e,i){return!!predicate(e,i)})};Sequence.prototype.all=function all(predicate){return this.every(predicate)};Sequence.prototype.some=function some(predicate){predicate=createCallback(predicate,true);var success=false;this.each(function(e){if(predicate(e)){success=true;return false}});return success};Sequence.prototype.any=function any(predicate){return this.some(predicate)};Sequence.prototype.none=function none(predicate){return!this.any(predicate)};Sequence.prototype.isEmpty=function isEmpty(){return!this.any()};Sequence.prototype.indexOf=function indexOf(value){var foundIndex=-1;this.each(function(e,i){if(e===value){foundIndex=i;return false}});return foundIndex};Sequence.prototype.lastIndexOf=function lastIndexOf(value){var index=this.reverse().indexOf(value);if(index!==-1){index=this.getIndex().length()-index-1}return index};Sequence.prototype.sortedIndex=function sortedIndex(value){var indexed=this.getIndex(),lower=0,upper=indexed.length(),i;while(lower<upper){i=lower+upper>>>1;if(compare(indexed.get(i),value)===-1){lower=i+1}else{upper=i}}return lower};Sequence.prototype.contains=function contains(value){return this.indexOf(value)!==-1};Sequence.prototype.reduce=function reduce(aggregator,memo){if(arguments.length<2){return this.tail().reduce(aggregator,this.head())}this.each(function(e,i){memo=aggregator(memo,e,i)});return memo};Sequence.prototype.inject=Sequence.prototype.foldl=function foldl(aggregator,memo){return this.reduce(aggregator,memo)};Sequence.prototype.reduceRight=function reduceRight(aggregator,memo){if(arguments.length<2){return this.initial(1).reduceRight(aggregator,this.last())}var i=this.getIndex().length()-1;return this.reverse().reduce(function(m,e){return aggregator(m,e,i--)},memo)};Sequence.prototype.foldr=function foldr(aggregator,memo){return this.reduceRight(aggregator,memo)};Sequence.prototype.consecutive=function consecutive(count){var queue=new Queue(count);var segments=this.map(function(element){if(queue.add(element).count===count){return queue.toArray()}});return segments.compact()};Sequence.prototype.chunk=function chunk(size){if(size<1){throw"You must specify a positive chunk size."}return new ChunkedSequence(this,size)};function ChunkedSequence(parent,size){this.parent=parent;this.chunkSize=size}ChunkedSequence.prototype=new Sequence;ChunkedSequence.prototype.getIterator=function getIterator(){return new ChunkedIterator(this.parent,this.chunkSize)};function ChunkedIterator(sequence,size){this.iterator=sequence.getIterator();this.size=size}ChunkedIterator.prototype.current=function current(){return this.currentChunk};ChunkedIterator.prototype.moveNext=function moveNext(){var iterator=this.iterator,chunkSize=this.size,chunk=[];while(chunk.length<chunkSize&&iterator.moveNext()){chunk.push(iterator.current())}if(chunk.length===0){return false}this.currentChunk=chunk;return true};Sequence.prototype.tap=function tap(callback){return new TappedSequence(this,callback)};function TappedSequence(parent,callback){this.parent=parent;this.callback=callback}TappedSequence.prototype=new Sequence;TappedSequence.prototype.each=function each(fn){var callback=this.callback;return this.parent.each(function(e,i){callback(e,i);return fn(e,i)})};Sequence.prototype.find=function find(predicate){return this.filter(predicate).first()};Sequence.prototype.detect=function detect(predicate){return this.find(predicate)};Sequence.prototype.min=function min(valueFn){if(typeof valueFn!=="undefined"){return this.minBy(valueFn)}return this.reduce(function(x,y){return y<x?y:x},Infinity)};Sequence.prototype.minBy=function minBy(valueFn){valueFn=createCallback(valueFn);return this.reduce(function(x,y){return valueFn(y)<valueFn(x)?y:x})};Sequence.prototype.max=function max(valueFn){if(typeof valueFn!=="undefined"){return this.maxBy(valueFn)}return this.reduce(function(x,y){return y>x?y:x},-Infinity)};Sequence.prototype.maxBy=function maxBy(valueFn){valueFn=createCallback(valueFn);return this.reduce(function(x,y){return valueFn(y)>valueFn(x)?y:x})};Sequence.prototype.sum=function sum(valueFn){if(typeof valueFn!=="undefined"){return this.sumBy(valueFn)}return this.reduce(function(x,y){return x+y},0)};Sequence.prototype.sumBy=function sumBy(valueFn){valueFn=createCallback(valueFn);return this.reduce(function(x,y){return x+valueFn(y)},0)};Sequence.prototype.join=function join(delimiter){delimiter=typeof delimiter==="string"?delimiter:",";return this.reduce(function(str,e){if(str.length>0){str+=delimiter}return str+e},"")};Sequence.prototype.toString=function toString(delimiter){return this.join(delimiter)};Sequence.prototype.async=function async(interval){return new AsyncSequence(this,interval)};function SimpleIntersectionSequence(parent,array){this.parent=parent;this.array=array;this.each=getEachForIntersection(array)}SimpleIntersectionSequence.prototype=new Sequence;SimpleIntersectionSequence.prototype.eachMemoizerCache=function eachMemoizerCache(fn){var iterator=new UniqueMemoizer(Lazy(this.array).getIterator()),i=0;return this.parent.each(function(e){if(iterator.contains(e)){return fn(e,i++)}})};SimpleIntersectionSequence.prototype.eachArrayCache=function eachArrayCache(fn){var array=this.array,find=arrayContains,i=0;return this.parent.each(function(e){if(find(array,e)){return fn(e,i++)}})};function getEachForIntersection(source){if(source.length<40){return SimpleIntersectionSequence.prototype.eachArrayCache}else{return SimpleIntersectionSequence.prototype.eachMemoizerCache}}function SimpleZippedSequence(parent,array){this.parent=parent;this.array=array}SimpleZippedSequence.prototype=new Sequence;SimpleZippedSequence.prototype.each=function each(fn){var array=this.array;return this.parent.each(function(e,i){return fn([e,array[i]],i)})};function ArrayLikeSequence(){}ArrayLikeSequence.prototype=new Sequence;ArrayLikeSequence.define=function define(methodName,overrides){if(!overrides||typeof overrides.get!=="function"){throw"A custom array-like sequence must implement *at least* get!"}return defineSequenceType(ArrayLikeSequence,methodName,overrides)};ArrayLikeSequence.prototype.get=function get(i){return this.parent.get(i)};ArrayLikeSequence.prototype.length=function length(){return this.parent.length()};ArrayLikeSequence.prototype.getIndex=function getIndex(){return this};ArrayLikeSequence.prototype.getIterator=function getIterator(){return new IndexedIterator(this)};function IndexedIterator(sequence){this.sequence=sequence;this.index=-1}IndexedIterator.prototype.current=function current(){return this.sequence.get(this.index)};IndexedIterator.prototype.moveNext=function moveNext(){if(this.index>=this.sequence.length()-1){return false}++this.index;return true};ArrayLikeSequence.prototype.each=function each(fn){var length=this.length(),i=-1;while(++i<length){if(fn(this.get(i),i)===false){return false}}return true};ArrayLikeSequence.prototype.pop=function pop(){return this.initial()};ArrayLikeSequence.prototype.shift=function shift(){return this.drop()};ArrayLikeSequence.prototype.slice=function slice(begin,end){var length=this.length();if(begin<0){begin=length+begin}var result=this.drop(begin);if(typeof end==="number"){if(end<0){end=length+end}result=result.take(end-begin)}return result};ArrayLikeSequence.prototype.map=function map(mapFn){return new IndexedMappedSequence(this,createCallback(mapFn))};function IndexedMappedSequence(parent,mapFn){this.parent=parent;this.mapFn=mapFn}IndexedMappedSequence.prototype=new ArrayLikeSequence;IndexedMappedSequence.prototype.get=function get(i){if(i<0||i>=this.parent.length()){return undefined}return this.mapFn(this.parent.get(i),i)};ArrayLikeSequence.prototype.filter=function filter(filterFn){return new IndexedFilteredSequence(this,createCallback(filterFn))};function IndexedFilteredSequence(parent,filterFn){this.parent=parent;this.filterFn=filterFn}IndexedFilteredSequence.prototype=new FilteredSequence;IndexedFilteredSequence.prototype.each=function each(fn){var parent=this.parent,filterFn=this.filterFn,length=this.parent.length(),i=-1,e;while(++i<length){e=parent.get(i);if(filterFn(e,i)&&fn(e,i)===false){return false}}return true};ArrayLikeSequence.prototype.reverse=function reverse(){return new IndexedReversedSequence(this)};function IndexedReversedSequence(parent){this.parent=parent}IndexedReversedSequence.prototype=new ArrayLikeSequence;IndexedReversedSequence.prototype.get=function get(i){return this.parent.get(this.length()-i-1)};ArrayLikeSequence.prototype.first=function first(count){if(typeof count==="undefined"){return this.get(0)}return new IndexedTakeSequence(this,count)};function IndexedTakeSequence(parent,count){this.parent=parent;this.count=count}IndexedTakeSequence.prototype=new ArrayLikeSequence;IndexedTakeSequence.prototype.length=function length(){var parentLength=this.parent.length();return this.count<=parentLength?this.count:parentLength};ArrayLikeSequence.prototype.rest=function rest(count){return new IndexedDropSequence(this,count)};function IndexedDropSequence(parent,count){this.parent=parent;this.count=typeof count==="number"?count:1}IndexedDropSequence.prototype=new ArrayLikeSequence;IndexedDropSequence.prototype.get=function get(i){return this.parent.get(this.count+i)};IndexedDropSequence.prototype.length=function length(){var parentLength=this.parent.length();return this.count<=parentLength?parentLength-this.count:0};ArrayLikeSequence.prototype.concat=function concat(var_args){if(arguments.length===1&&arguments[0]instanceof Array){return new IndexedConcatenatedSequence(this,var_args)}else{return Sequence.prototype.concat.apply(this,arguments)}};function IndexedConcatenatedSequence(parent,other){this.parent=parent;this.other=other}IndexedConcatenatedSequence.prototype=new ArrayLikeSequence;IndexedConcatenatedSequence.prototype.get=function get(i){var parentLength=this.parent.length();if(i<parentLength){return this.parent.get(i)}else{return this.other[i-parentLength]}};IndexedConcatenatedSequence.prototype.length=function length(){return this.parent.length()+this.other.length};ArrayLikeSequence.prototype.uniq=function uniq(keyFn){return new IndexedUniqueSequence(this,createCallback(keyFn))};function IndexedUniqueSequence(parent,keyFn){this.parent=parent;this.each=getEachForParent(parent);this.keyFn=keyFn}IndexedUniqueSequence.prototype=new Sequence;IndexedUniqueSequence.prototype.eachArrayCache=function eachArrayCache(fn){var parent=this.parent,keyFn=this.keyFn,length=parent.length(),cache=[],find=arrayContains,key,value,i=-1,j=0;while(++i<length){value=parent.get(i);key=keyFn(value);if(!find(cache,key)){cache.push(key);if(fn(value,j++)===false){return false}}}};IndexedUniqueSequence.prototype.eachSetCache=UniqueSequence.prototype.each;function getEachForParent(parent){if(parent.length()<100){return IndexedUniqueSequence.prototype.eachArrayCache}else{return UniqueSequence.prototype.each}}MemoizedSequence.prototype=new ArrayLikeSequence;MemoizedSequence.prototype.cache=function cache(){return this.cachedResult||(this.cachedResult=this.parent.toArray())};MemoizedSequence.prototype.get=function get(i){return this.cache()[i]};MemoizedSequence.prototype.length=function length(){return this.cache().length};MemoizedSequence.prototype.slice=function slice(begin,end){return this.cache().slice(begin,end)};MemoizedSequence.prototype.toArray=function toArray(){return this.cache().slice(0)};function ArrayWrapper(source){this.source=source}ArrayWrapper.prototype=new ArrayLikeSequence;ArrayWrapper.prototype.root=function root(){return this};ArrayWrapper.prototype.get=function get(i){return this.source[i]};ArrayWrapper.prototype.length=function length(){return this.source.length};ArrayWrapper.prototype.each=function each(fn){return forEach(this.source,fn)};ArrayWrapper.prototype.map=ArrayWrapper.prototype.collect=function collect(mapFn){return new MappedArrayWrapper(this,createCallback(mapFn))};ArrayWrapper.prototype.filter=ArrayWrapper.prototype.select=function select(filterFn){return new FilteredArrayWrapper(this,createCallback(filterFn))};ArrayWrapper.prototype.uniq=ArrayWrapper.prototype.unique=function unique(keyFn){return new UniqueArrayWrapper(this,keyFn)};ArrayWrapper.prototype.concat=function concat(var_args){if(arguments.length===1&&arguments[0]instanceof Array){return new ConcatArrayWrapper(this,var_args)}else{return ArrayLikeSequence.prototype.concat.apply(this,arguments)}};ArrayWrapper.prototype.toArray=function toArray(){return this.source.slice(0)};function MappedArrayWrapper(parent,mapFn){this.parent=parent;this.mapFn=mapFn}MappedArrayWrapper.prototype=new ArrayLikeSequence;MappedArrayWrapper.prototype.get=function get(i){var source=this.parent.source;if(i<0||i>=source.length){return undefined}return this.mapFn(source[i])};MappedArrayWrapper.prototype.length=function length(){return this.parent.source.length};MappedArrayWrapper.prototype.each=function each(fn){var source=this.parent.source,length=source.length,mapFn=this.mapFn,i=-1;while(++i<length){if(fn(mapFn(source[i],i),i)===false){return false}}return true};function FilteredArrayWrapper(parent,filterFn){this.parent=parent;this.filterFn=filterFn}FilteredArrayWrapper.prototype=new FilteredSequence;FilteredArrayWrapper.prototype.each=function each(fn){var source=this.parent.source,filterFn=this.filterFn,length=source.length,i=-1,e;while(++i<length){e=source[i];if(filterFn(e,i)&&fn(e,i)===false){return false}}return true};function UniqueArrayWrapper(parent,keyFn){this.parent=parent;this.each=getEachForSource(parent.source);this.keyFn=keyFn}UniqueArrayWrapper.prototype=new Sequence;UniqueArrayWrapper.prototype.eachNoCache=function eachNoCache(fn){var source=this.parent.source,keyFn=this.keyFn,length=source.length,find=arrayContainsBefore,value,i=-1,k=0;while(++i<length){value=source[i];if(!find(source,value,i,keyFn)&&fn(value,k++)===false){return false}}return true};UniqueArrayWrapper.prototype.eachArrayCache=function eachArrayCache(fn){var source=this.parent.source,keyFn=this.keyFn,length=source.length,cache=[],find=arrayContains,key,value,i=-1,j=0;if(keyFn){keyFn=createCallback(keyFn);while(++i<length){value=source[i];key=keyFn(value);if(!find(cache,key)){cache.push(key);if(fn(value,j++)===false){return false}}}}else{while(++i<length){value=source[i];if(!find(cache,value)){cache.push(value);if(fn(value,j++)===false){return false}}}}return true};UniqueArrayWrapper.prototype.eachSetCache=UniqueSequence.prototype.each;function getEachForSource(source){if(source.length<40){return UniqueArrayWrapper.prototype.eachNoCache}else if(source.length<100){return UniqueArrayWrapper.prototype.eachArrayCache}else{return UniqueArrayWrapper.prototype.eachSetCache}}function ConcatArrayWrapper(parent,other){this.parent=parent;this.other=other}ConcatArrayWrapper.prototype=new ArrayLikeSequence;ConcatArrayWrapper.prototype.get=function get(i){var source=this.parent.source,sourceLength=source.length;if(i<sourceLength){return source[i]}else{return this.other[i-sourceLength]}};ConcatArrayWrapper.prototype.length=function length(){return this.parent.source.length+this.other.length};ConcatArrayWrapper.prototype.each=function each(fn){var source=this.parent.source,sourceLength=source.length,other=this.other,otherLength=other.length,i=0,j=-1;while(++j<sourceLength){if(fn(source[j],i++)===false){return false}}j=-1;while(++j<otherLength){if(fn(other[j],i++)===false){return false}}return true};function ObjectLikeSequence(){}ObjectLikeSequence.prototype=new Sequence;ObjectLikeSequence.define=function define(methodName,overrides){if(!overrides||typeof overrides.each!=="function"){throw"A custom object-like sequence must implement *at least* each!"}return defineSequenceType(ObjectLikeSequence,methodName,overrides)};ObjectLikeSequence.prototype.value=function value(){return this.toObject()};ObjectLikeSequence.prototype.get=function get(key){var pair=this.pairs().find(function(pair){return pair[0]===key});return pair?pair[1]:undefined};ObjectLikeSequence.prototype.keys=function keys(){return this.map(function(v,k){return k})};ObjectLikeSequence.prototype.values=function values(){return this.map(function(v,k){return v})};ObjectLikeSequence.prototype.async=function async(){throw"An ObjectLikeSequence does not support asynchronous iteration."};ObjectLikeSequence.prototype.reverse=function reverse(){return this};ObjectLikeSequence.prototype.assign=function assign(other){return new AssignSequence(this,other)};ObjectLikeSequence.prototype.extend=function extend(other){return this.assign(other)};function AssignSequence(parent,other){this.parent=parent;this.other=other}AssignSequence.prototype=new ObjectLikeSequence;AssignSequence.prototype.get=function get(key){return this.other[key]||this.parent.get(key)};AssignSequence.prototype.each=function each(fn){var merged=new Set,done=false;Lazy(this.other).each(function(value,key){if(fn(value,key)===false){done=true;return false}merged.add(key)});if(!done){return this.parent.each(function(value,key){if(!merged.contains(key)&&fn(value,key)===false){return false}})}};ObjectLikeSequence.prototype.defaults=function defaults(defaults){return new DefaultsSequence(this,defaults)};function DefaultsSequence(parent,defaults){this.parent=parent;this.defaults=defaults}DefaultsSequence.prototype=new ObjectLikeSequence;DefaultsSequence.prototype.get=function get(key){return this.parent.get(key)||this.defaults[key]};DefaultsSequence.prototype.each=function each(fn){var merged=new Set,done=false;this.parent.each(function(value,key){if(fn(value,key)===false){done=true;return false}if(typeof value!=="undefined"){merged.add(key)}});if(!done){Lazy(this.defaults).each(function(value,key){if(!merged.contains(key)&&fn(value,key)===false){return false}})}};ObjectLikeSequence.prototype.invert=function invert(){return new InvertedSequence(this)};function InvertedSequence(parent){this.parent=parent}InvertedSequence.prototype=new ObjectLikeSequence;InvertedSequence.prototype.each=function each(fn){this.parent.each(function(value,key){return fn(key,value)})};ObjectLikeSequence.prototype.merge=function merge(var_args){var mergeFn=arguments.length>1&&typeof arguments[arguments.length-1]==="function"?arrayPop.call(arguments):null;
return new MergedSequence(this,arraySlice.call(arguments,0),mergeFn)};function MergedSequence(parent,others,mergeFn){this.parent=parent;this.others=others;this.mergeFn=mergeFn}MergedSequence.prototype=new ObjectLikeSequence;MergedSequence.prototype.each=function each(fn){var others=this.others,mergeFn=this.mergeFn||mergeObjects,keys={};var iteratedFullSource=this.parent.each(function(value,key){var merged=value;forEach(others,function(other){if(key in other){merged=mergeFn(merged,other[key])}});keys[key]=true;return fn(merged,key)});if(iteratedFullSource===false){return false}var remaining={};forEach(others,function(other){for(var k in other){if(!keys[k]){remaining[k]=mergeFn(remaining[k],other[k])}}});return Lazy(remaining).each(fn)};function mergeObjects(a,b){if(typeof b==="undefined"){return a}if(typeof a!=="object"||a===null||typeof b!=="object"||b===null){return b}var merged={},prop;for(prop in a){merged[prop]=mergeObjects(a[prop],b[prop])}for(prop in b){if(!merged[prop]){merged[prop]=b[prop]}}return merged}ObjectLikeSequence.prototype.functions=function functions(){return this.filter(function(v,k){return typeof v==="function"}).map(function(v,k){return k})};ObjectLikeSequence.prototype.methods=function methods(){return this.functions()};ObjectLikeSequence.prototype.pick=function pick(properties){return new PickSequence(this,properties)};function PickSequence(parent,properties){this.parent=parent;this.properties=properties}PickSequence.prototype=new ObjectLikeSequence;PickSequence.prototype.get=function get(key){return arrayContains(this.properties,key)?this.parent.get(key):undefined};PickSequence.prototype.each=function each(fn){var inArray=arrayContains,properties=this.properties;return this.parent.each(function(value,key){if(inArray(properties,key)){return fn(value,key)}})};ObjectLikeSequence.prototype.omit=function omit(properties){return new OmitSequence(this,properties)};function OmitSequence(parent,properties){this.parent=parent;this.properties=properties}OmitSequence.prototype=new ObjectLikeSequence;OmitSequence.prototype.get=function get(key){return arrayContains(this.properties,key)?undefined:this.parent.get(key)};OmitSequence.prototype.each=function each(fn){var inArray=arrayContains,properties=this.properties;return this.parent.each(function(value,key){if(!inArray(properties,key)){return fn(value,key)}})};ObjectLikeSequence.prototype.pairs=function pairs(){return this.map(function(v,k){return[k,v]})};ObjectLikeSequence.prototype.toArray=function toArray(){return this.pairs().toArray()};ObjectLikeSequence.prototype.toObject=function toObject(){return this.reduce(function(object,value,key){object[key]=value;return object},{})};GroupedSequence.prototype=new ObjectLikeSequence;GroupedSequence.prototype.each=function each(fn){var keyFn=createCallback(this.keyFn),grouped={};this.parent.each(function(e){var key=keyFn(e);if(!grouped[key]){grouped[key]=[e]}else{grouped[key].push(e)}});for(var key in grouped){if(fn(grouped[key],key)===false){return false}}return true};CountedSequence.prototype=new ObjectLikeSequence;CountedSequence.prototype.each=function each(fn){var keyFn=createCallback(this.keyFn),counted={};this.parent.each(function(e){var key=keyFn(e);if(!counted[key]){counted[key]=1}else{counted[key]+=1}});for(var key in counted){if(fn(counted[key],key)===false){return false}}return true};ObjectLikeSequence.prototype.watch=function watch(propertyNames){throw"You can only call #watch on a directly wrapped object."};function ObjectWrapper(source){this.source=source}ObjectWrapper.prototype=new ObjectLikeSequence;ObjectWrapper.prototype.root=function root(){return this};ObjectWrapper.prototype.get=function get(key){return this.source[key]};ObjectWrapper.prototype.each=function each(fn){var source=this.source,key;for(key in source){if(fn(source[key],key)===false){return false}}return true};function StringLikeSequence(){}StringLikeSequence.prototype=new ArrayLikeSequence;StringLikeSequence.define=function define(methodName,overrides){if(!overrides||typeof overrides.get!=="function"){throw"A custom string-like sequence must implement *at least* get!"}return defineSequenceType(StringLikeSequence,methodName,overrides)};StringLikeSequence.prototype.value=function value(){return this.toString()};StringLikeSequence.prototype.getIterator=function getIterator(){return new CharIterator(this)};function CharIterator(source){this.source=Lazy(source);this.index=-1}CharIterator.prototype.current=function current(){return this.source.charAt(this.index)};CharIterator.prototype.moveNext=function moveNext(){return++this.index<this.source.length()};StringLikeSequence.prototype.charAt=function charAt(i){return this.get(i)};StringLikeSequence.prototype.charCodeAt=function charCodeAt(i){var char=this.charAt(i);if(!char){return NaN}return char.charCodeAt(0)};StringLikeSequence.prototype.substring=function substring(start,stop){return new StringSegment(this,start,stop)};function StringSegment(parent,start,stop){this.parent=parent;this.start=Math.max(0,start);this.stop=stop}StringSegment.prototype=new StringLikeSequence;StringSegment.prototype.get=function get(i){return this.parent.get(i+this.start)};StringSegment.prototype.length=function length(){return(typeof this.stop==="number"?this.stop:this.parent.length())-this.start};StringLikeSequence.prototype.first=function first(count){if(typeof count==="undefined"){return this.charAt(0)}return this.substring(0,count)};StringLikeSequence.prototype.last=function last(count){if(typeof count==="undefined"){return this.charAt(this.length()-1)}return this.substring(this.length()-count)};StringLikeSequence.prototype.drop=function drop(count){return this.substring(count)};StringLikeSequence.prototype.indexOf=function indexOf(substring,startIndex){return this.toString().indexOf(substring,startIndex)};StringLikeSequence.prototype.lastIndexOf=function lastIndexOf(substring,startIndex){return this.toString().lastIndexOf(substring,startIndex)};StringLikeSequence.prototype.contains=function contains(substring){return this.indexOf(substring)!==-1};StringLikeSequence.prototype.endsWith=function endsWith(suffix){return this.substring(this.length()-suffix.length).toString()===suffix};StringLikeSequence.prototype.startsWith=function startsWith(prefix){return this.substring(0,prefix.length).toString()===prefix};StringLikeSequence.prototype.toUpperCase=function toUpperCase(){return this.mapString(function(char){return char.toUpperCase()})};StringLikeSequence.prototype.toLowerCase=function toLowerCase(){return this.mapString(function(char){return char.toLowerCase()})};StringLikeSequence.prototype.mapString=function mapString(mapFn){return new MappedStringLikeSequence(this,mapFn)};function MappedStringLikeSequence(parent,mapFn){this.parent=parent;this.mapFn=mapFn}MappedStringLikeSequence.prototype=new StringLikeSequence;MappedStringLikeSequence.prototype.get=IndexedMappedSequence.prototype.get;MappedStringLikeSequence.prototype.length=IndexedMappedSequence.prototype.length;StringLikeSequence.prototype.reverse=function reverse(){return new ReversedStringLikeSequence(this)};function ReversedStringLikeSequence(parent){this.parent=parent}ReversedStringLikeSequence.prototype=new StringLikeSequence;ReversedStringLikeSequence.prototype.get=IndexedReversedSequence.prototype.get;ReversedStringLikeSequence.prototype.length=IndexedReversedSequence.prototype.length;StringLikeSequence.prototype.toString=function toString(){return this.join("")};StringLikeSequence.prototype.match=function match(pattern){return new StringMatchSequence(this.source,pattern)};function StringMatchSequence(source,pattern){this.source=source;this.pattern=pattern}StringMatchSequence.prototype=new Sequence;StringMatchSequence.prototype.getIterator=function getIterator(){return new StringMatchIterator(this.source,this.pattern)};function StringMatchIterator(source,pattern){this.source=source;this.pattern=cloneRegex(pattern)}StringMatchIterator.prototype.current=function current(){return this.match[0]};StringMatchIterator.prototype.moveNext=function moveNext(){return!!(this.match=this.pattern.exec(this.source))};StringLikeSequence.prototype.split=function split(delimiter){return new SplitStringSequence(this.source,delimiter)};function SplitStringSequence(source,pattern){this.source=source;this.pattern=pattern}SplitStringSequence.prototype=new Sequence;SplitStringSequence.prototype.getIterator=function getIterator(){if(this.pattern instanceof RegExp){if(this.pattern.source===""||this.pattern.source==="(?:)"){return new CharIterator(this.source)}else{return new SplitWithRegExpIterator(this.source,this.pattern)}}else if(this.pattern===""){return new CharIterator(this.source)}else{return new SplitWithStringIterator(this.source,this.pattern)}};function SplitWithRegExpIterator(source,pattern){this.source=source;this.pattern=cloneRegex(pattern)}SplitWithRegExpIterator.prototype.current=function current(){return this.source.substring(this.start,this.end)};SplitWithRegExpIterator.prototype.moveNext=function moveNext(){if(!this.pattern){return false}var match=this.pattern.exec(this.source);if(match){this.start=this.nextStart?this.nextStart:0;this.end=match.index;this.nextStart=match.index+match[0].length;return true}else if(this.pattern){this.start=this.nextStart;this.end=undefined;this.nextStart=undefined;this.pattern=undefined;return true}return false};function SplitWithStringIterator(source,delimiter){this.source=source;this.delimiter=delimiter}SplitWithStringIterator.prototype.current=function current(){return this.source.substring(this.leftIndex,this.rightIndex)};SplitWithStringIterator.prototype.moveNext=function moveNext(){if(!this.finished){this.leftIndex=typeof this.leftIndex!=="undefined"?this.rightIndex+this.delimiter.length:0;this.rightIndex=this.source.indexOf(this.delimiter,this.leftIndex)}if(this.rightIndex===-1){this.finished=true;this.rightIndex=undefined;return true}return!this.finished};function StringWrapper(source){this.source=source}StringWrapper.prototype=new StringLikeSequence;StringWrapper.prototype.root=function root(){return this};StringWrapper.prototype.get=function get(i){return this.source.charAt(i)};StringWrapper.prototype.length=function length(){return this.source.length};function GeneratedSequence(generatorFn,length){this.get=generatorFn;this.fixedLength=length}GeneratedSequence.prototype=new Sequence;GeneratedSequence.prototype.length=function length(){return this.fixedLength};GeneratedSequence.prototype.each=function each(fn){var generatorFn=this.get,length=this.fixedLength,i=0;while(typeof length==="undefined"||i<length){if(fn(generatorFn(i++))===false){return false}}return true};GeneratedSequence.prototype.getIterator=function getIterator(){return new GeneratedIterator(this)};function GeneratedIterator(sequence){this.sequence=sequence;this.index=0;this.currentValue=null}GeneratedIterator.prototype.current=function current(){return this.currentValue};GeneratedIterator.prototype.moveNext=function moveNext(){var sequence=this.sequence;if(typeof sequence.fixedLength==="number"&&this.index>=sequence.fixedLength){return false}this.currentValue=sequence.get(this.index++);return true};function AsyncSequence(parent,interval){if(parent instanceof AsyncSequence){throw"Sequence is already asynchronous!"}this.parent=parent;this.interval=interval;this.onNextCallback=getOnNextCallback(interval)}AsyncSequence.prototype=new Sequence;AsyncSequence.prototype.getIterator=function getIterator(){throw"An AsyncSequence does not support synchronous iteration."};AsyncSequence.prototype.each=function each(fn){var iterator=this.parent.getIterator(),onNextCallback=this.onNextCallback,i=0;var handle=new AsyncHandle(this.interval);handle.id=onNextCallback(function iterate(){try{if(iterator.moveNext()&&fn(iterator.current(),i++)!==false){handle.id=onNextCallback(iterate)}else{handle.completeCallback()}}catch(e){handle.errorCallback(e)}});return handle};function AsyncHandle(interval){this.cancelCallback=getCancelCallback(interval)}AsyncHandle.prototype.cancel=function cancel(){var cancelCallback=this.cancelCallback;if(this.id){cancelCallback(this.id);this.id=null}};AsyncHandle.prototype.onError=function onError(callback){this.errorCallback=callback};AsyncHandle.prototype.errorCallback=Lazy.noop;AsyncHandle.prototype.onComplete=function onComplete(callback){this.completeCallback=callback};AsyncHandle.prototype.completeCallback=Lazy.noop;function getOnNextCallback(interval){if(typeof interval==="undefined"){if(typeof setImmediate==="function"){return setImmediate}}interval=interval||0;return function(fn){return setTimeout(fn,interval)}}function getCancelCallback(interval){if(typeof interval==="undefined"){if(typeof clearImmediate==="function"){return clearImmediate}}return clearTimeout}AsyncSequence.prototype.reverse=function reverse(){return this.parent.reverse().async()};AsyncSequence.prototype.reduce=function reduce(aggregator,memo){var handle=this.each(function(e,i){if(typeof memo==="undefined"&&i===0){memo=e}else{memo=aggregator(memo,e,i)}});handle.then=handle.onComplete=function(callback){handle.completeCallback=function(){callback(memo)}};return handle};AsyncSequence.prototype.find=function find(predicate){var found;var handle=this.each(function(e,i){if(predicate(e,i)){found=e;return false}});handle.then=handle.onComplete=function(callback){handle.completeCallback=function(){callback(found)}};return handle};AsyncSequence.prototype.indexOf=function indexOf(value){var foundIndex=-1;var handle=this.each(function(e,i){if(e===value){foundIndex=i;return false}});handle.then=handle.onComplete=function(callback){handle.completeCallback=function(){callback(foundIndex)}};return handle};AsyncSequence.prototype.contains=function contains(value){var found=false;var handle=this.each(function(e){if(e===value){found=true;return false}});handle.then=handle.onComplete=function(callback){handle.completeCallback=function(){callback(found)}};return handle};AsyncSequence.prototype.async=function async(){return this};ObjectWrapper.prototype.watch=function watch(propertyNames){return new WatchedPropertySequence(this.source,propertyNames)};function WatchedPropertySequence(object,propertyNames){this.listeners=[];if(!propertyNames){propertyNames=Lazy(object).keys().toArray()}else if(!(propertyNames instanceof Array)){propertyNames=[propertyNames]}var listeners=this.listeners,index=0;Lazy(propertyNames).each(function(propertyName){var propertyValue=object[propertyName];Object.defineProperty(object,propertyName,{get:function(){return propertyValue},set:function(value){for(var i=listeners.length-1;i>=0;--i){if(listeners[i]({property:propertyName,value:value},index)===false){listeners.splice(i,1)}}propertyValue=value;++index}})})}WatchedPropertySequence.prototype=new AsyncSequence;WatchedPropertySequence.prototype.each=function each(fn){this.listeners.push(fn)};function StreamLikeSequence(){}StreamLikeSequence.prototype=new AsyncSequence;StreamLikeSequence.prototype.split=function split(delimiter){return new SplitStreamSequence(this,delimiter)};function SplitStreamSequence(parent,delimiter){this.parent=parent;this.delimiter=delimiter}SplitStreamSequence.prototype=new Sequence;SplitStreamSequence.prototype.each=function each(fn){var delimiter=this.delimiter,done=false,i=0;return this.parent.each(function(chunk){Lazy(chunk).split(delimiter).each(function(piece){if(fn(piece,i++)===false){done=true;return false}});return!done})};StreamLikeSequence.prototype.lines=function lines(){return this.split("\n")};StreamLikeSequence.prototype.match=function match(pattern){return new MatchedStreamSequence(this,pattern)};function MatchedStreamSequence(parent,pattern){this.parent=parent;this.pattern=cloneRegex(pattern)}MatchedStreamSequence.prototype=new AsyncSequence;MatchedStreamSequence.prototype.each=function each(fn){var pattern=this.pattern,done=false,i=0;return this.parent.each(function(chunk){Lazy(chunk).match(pattern).each(function(match){if(fn(match,i++)===false){done=true;return false}});return!done})};Lazy.createWrapper=function createWrapper(initializer){var ctor=function(){this.listeners=[]};ctor.prototype=new StreamLikeSequence;ctor.prototype.each=function(listener){this.listeners.push(listener)};ctor.prototype.emit=function(data){var listeners=this.listeners;for(var len=listeners.length,i=len-1;i>=0;--i){if(listeners[i](data)===false){listeners.splice(i,1)}}};return function(){var sequence=new ctor;initializer.apply(sequence,arguments);return sequence}};Lazy.generate=function generate(generatorFn,length){return new GeneratedSequence(generatorFn,length)};Lazy.range=function range(){var start=arguments.length>1?arguments[0]:0,stop=arguments.length>1?arguments[1]:arguments[0],step=arguments.length>2?arguments[2]:1;return this.generate(function(i){return start+step*i}).take(Math.floor((stop-start)/step))};Lazy.repeat=function repeat(value,count){return Lazy.generate(function(){return value},count)};Lazy.Sequence=Sequence;Lazy.ArrayLikeSequence=ArrayLikeSequence;Lazy.ObjectLikeSequence=ObjectLikeSequence;Lazy.StringLikeSequence=StringLikeSequence;Lazy.StreamLikeSequence=StreamLikeSequence;Lazy.GeneratedSequence=GeneratedSequence;Lazy.AsyncSequence=AsyncSequence;Lazy.AsyncHandle=AsyncHandle;Lazy.deprecate=function deprecate(message,fn){return function(){console.warn(message);return fn.apply(this,arguments)}};var arrayPop=Array.prototype.pop,arraySlice=Array.prototype.slice;function createCallback(callback,defaultValue){switch(typeof callback){case"function":return callback;case"string":return function(e){return e[callback]};case"object":return function(e){return Lazy(callback).all(function(value,key){return e[key]===value})};case"undefined":return defaultValue?function(){return defaultValue}:Lazy.identity;default:throw"Don't know how to make a callback from a "+typeof callback+"!"}}function createSet(values){var set=new Set;Lazy(values||[]).flatten().each(function(e){set.add(e)});return set}function compare(x,y,fn){if(typeof fn==="function"){return compare(fn(x),fn(y))}if(x===y){return 0}return x>y?1:-1}function forEach(array,fn){var i=-1,len=array.length;while(++i<len){if(fn(array[i],i)===false){return false}}return true}function getFirst(sequence){var result;sequence.each(function(e){result=e;return false});return result}function arrayContains(array,element){var i=-1,length=array.length;if(element!==element){while(++i<length){if(array[i]!==array[i]){return true}}return false}while(++i<length){if(array[i]===element){return true}}return false}function arrayContainsBefore(array,element,index,keyFn){var i=-1;if(keyFn){keyFn=createCallback(keyFn);while(++i<index){if(keyFn(array[i])===keyFn(element)){return true}}}else{while(++i<index){if(array[i]===element){return true}}}return false}function swap(array,i,j){var temp=array[i];array[i]=array[j];array[j]=temp}function cloneRegex(pattern){return eval(""+pattern+(!pattern.global?"g":""))}function Set(){this.table={};this.objects=[]}Set.prototype.add=function add(value){var table=this.table,type=typeof value,firstChar,objects;switch(type){case"number":case"boolean":case"undefined":if(!table[value]){table[value]=true;return true}return false;case"string":switch(value.charAt(0)){case"_":case"f":case"t":case"c":case"u":case"@":case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"N":value="@"+value}if(!table[value]){table[value]=true;return true}return false;default:objects=this.objects;if(!arrayContains(objects,value)){objects.push(value);return true}return false}};Set.prototype.contains=function contains(value){var type=typeof value,firstChar;switch(type){case"number":case"boolean":case"undefined":return!!this.table[value];case"string":switch(value.charAt(0)){case"_":case"f":case"t":case"c":case"u":case"@":case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"N":value="@"+value}return!!this.table[value];default:return arrayContains(this.objects,value)}};function Queue(capacity){this.contents=new Array(capacity);this.start=0;this.count=0}Queue.prototype.add=function add(element){var contents=this.contents,capacity=contents.length,start=this.start;if(this.count===capacity){contents[start]=element;this.start=(start+1)%capacity}else{contents[this.count++]=element}return this};Queue.prototype.toArray=function toArray(){var contents=this.contents,start=this.start,count=this.count;var snapshot=contents.slice(start,start+count);if(snapshot.length<count){snapshot=snapshot.concat(contents.slice(0,count-snapshot.length))}return snapshot};function defineSequenceType(base,name,overrides){var ctor=function ctor(){};ctor.prototype=new base;for(var override in overrides){ctor.prototype[override]=overrides[override]}var factory=function factory(){var sequence=new ctor;sequence.parent=this;if(sequence.init){sequence.init.apply(sequence,arguments)}return sequence};var methodNames=typeof name==="string"?[name]:name;for(var i=0;i<methodNames.length;++i){base.prototype[methodNames[i]]=factory}return ctor}if(typeof module==="object"&&module&&module.exports===context){module.exports=Lazy}else{context.Lazy=Lazy}})(this)},{}],"lazy.js":[function(require,module,exports){var fs=require("fs");var http=require("http");var os=require("os");var Stream=require("stream");var URL=require("url");var util=require("util");var Lazy=require("./lazy.js");function StreamedSequence(stream){this.stream=stream}StreamedSequence.prototype=new Lazy.StreamLikeSequence;StreamedSequence.prototype.openStream=function(callback){this.stream.resume();callback(this.stream)};StreamedSequence.prototype.each=function(fn){var encoding=this.encoding||"utf-8";var handle=new Lazy.AsyncHandle;this.openStream(function(stream){var listener=function(e){try{if(fn(e)===false){stream.removeListener("data",listener)}}catch(e){handle.errorCallback(e)}};if(stream.setEncoding){stream.setEncoding(encoding)}stream.on("data",listener);stream.on("end",function(){handle.completeCallback()})});return handle};StreamedSequence.prototype.lines=function(){return this.split(os.EOL||"\n")};function FileStreamSequence(path,encoding){this.path=path;this.encoding=encoding}FileStreamSequence.prototype=new StreamedSequence;FileStreamSequence.prototype.openStream=function(callback){var stream=fs.createReadStream(this.path,{autoClose:true});callback(stream)};Lazy.readFile=function(path,encoding){return new FileStreamSequence(path,encoding)};function HttpStreamSequence(url,encoding){this.url=url;this.encoding=encoding}HttpStreamSequence.prototype=new StreamedSequence;HttpStreamSequence.prototype.openStream=function(callback){http.get(URL.parse(this.url),callback)};Lazy.makeHttpRequest=function(url){return new HttpStreamSequence(url)};if(typeof Stream.Readable!=="undefined"){Lazy.Sequence.prototype.toStream=function toStream(options){return new LazyStream(this,options)};Lazy.Sequence.prototype.pipe=function pipe(destination){this.toStream().pipe(destination)};function LazyStream(sequence,options){options=Lazy(options||{}).extend({objectMode:true}).toObject();Stream.Readable.call(this,options);this.sequence=sequence;this.started=false}util.inherits(LazyStream,Stream.Readable);LazyStream.prototype._read=function(){var self=this;if(!this.started){var handle=this.sequence.each(function(e,i){return self.push(e,i)});if(handle instanceof Lazy.AsyncHandle){handle.onComplete(function(){self.push(null)})}this.started=true}}}Lazy.extensions||(Lazy.extensions=[]);Lazy.extensions.push(function(source){if(source instanceof Stream){return new StreamedSequence(source)}});module.exports=Lazy},{"./lazy.js":34,fs:1,http:6,os:12,stream:30,url:31,util:33}]},{},[]);var transform=function(n){return 3*n+2};var log=function(n,idx,obj){return"n: "+n+", idx: "+idx+", obj: "+obj};var Lazy=require("lazy.js");console.log("lazy.js");console.log(Lazy.range(3).map(transform).map(log).toArray().join("\n"));console.log("----------------------------------------");var Lz=require("lz");console.log("lz");console.log(Lz.range(0,3).map(transform).map(log).toArray().join("\n"));console.log("----------------------------------------");var H=require("highland");var t=require("transducers.js");console.log("transducters");console.log(t.seq([0,1,2],t.compose(t.map(transform),t.map(log))));console.log("----------------------------------------");
{
"name": "requirebin-sketch",
"version": "1.0.0",
"dependencies": {
"lz": "0.1.1",
"highland": "2.0.0",
"transducers.js": "0.2.2",
"lazy.js": "0.3.2"
}
}
<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