Skip to content

Instantly share code, notes, and snippets.

@davidchase
Created November 10, 2015 19:06
Show Gist options
  • Save davidchase/ab3e4dd45bb0e3640193 to your computer and use it in GitHub Desktop.
Save davidchase/ab3e4dd45bb0e3640193 to your computer and use it in GitHub Desktop.
requirebin sketch
var through = require('through2').obj;
var from = require('from2');
var most = require('most');
var count = 0;
var gen = function gen(size, next) {
if (count++ < 20) {
return next(null, {val: count});
}
};
from({objectMode: true}, gen)
/*.pipe(through(function(chunk, enc, cb){
var keepReading = this.push(chunk);
if(keepReading) this.read();
cb();
})) */
/*.pipe(through(function(chunk, enc, cb){
console.log(chunk);
cb();
})) */
var fromReadableStream = function fromStream(stream) {
var finishEventName = 'end';
return most.create(function (add, end, error) {
function dataHandler (data) {
add(data);
}
function errorHandler (err) {
error(err);
}
function endHandler () {
console.log('called');
end();
}
stream.addListener('data', dataHandler);
stream.addListener('error', errorHandler);
stream.addListener(finishEventName, endHandler);
return function () {
stream.removeListener('data', dataHandler);
stream.removeListener('error', errorHandler);
stream.removeListener(finishEventName, endHandler);
};
})
}
var source = fromReadableStream(from({objectMode: true}, gen));
source.observe(function(x){
console.log(x);
});
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");var isArray=require("is-array");exports.Buffer=Buffer;exports.SlowBuffer=SlowBuffer;exports.INSPECT_MAX_BYTES=50;Buffer.poolSize=8192;var kMaxLength=1073741823;var rootParent={};Buffer.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"){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 TypeError("must start with number, buffer, array or string");if(length>kMaxLength)throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+kMaxLength.toString(16)+" bytes");var buf;if(Buffer.TYPED_ARRAY_SUPPORT){buf=Buffer._augment(new Uint8Array(length))}else{buf=this;buf.length=length;buf._isBuffer=true}var i;if(Buffer.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"&&!Buffer.TYPED_ARRAY_SUPPORT&&!noZero){for(i=0;i<length;i++){buf[i]=0}}if(length>0&&length<=Buffer.poolSize)buf.parent=rootParent;return buf}function SlowBuffer(subject,encoding,noZero){if(!(this instanceof SlowBuffer))return new SlowBuffer(subject,encoding,noZero);var buf=new Buffer(subject,encoding,noZero);delete buf.parent;return buf}Buffer.isBuffer=function(b){return!!(b!=null&&b._isBuffer)};Buffer.compare=function(a,b){if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b))throw new TypeError("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};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.concat=function(list,totalLength){if(!isArray(list))throw new TypeError("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.byteLength=function(str,encoding){var ret;str=str+"";switch(encoding||"utf8"){case"ascii":case"binary":case"raw":ret=str.length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":ret=str.length*2;break;case"hex":ret=str.length>>>1;break;case"utf8":case"utf-8":ret=utf8ToBytes(str).length;break;case"base64":ret=base64ToBytes(str).length;break;default:ret=str.length}return ret};Buffer.prototype.length=undefined;Buffer.prototype.parent=undefined;Buffer.prototype.toString=function(encoding,start,end){var loweredCase=false;start=start>>>0;end=end===undefined||end===Infinity?this.length:end>>>0;if(!encoding)encoding="utf8";if(start<0)start=0;if(end>this.length)end=this.length;if(end<=start)return"";while(true){switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"binary":return binarySlice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase();loweredCase=true}}};Buffer.prototype.equals=function(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");return Buffer.compare(this,b)===0};Buffer.prototype.inspect=function(){var str="";var max=exports.INSPECT_MAX_BYTES;if(this.length>0){str=this.toString("hex",0,max).match(/.{2}/g).join(" ");if(this.length>max)str+=" ... "}return"<Buffer "+str+">"};Buffer.prototype.compare=function(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");return Buffer.compare(this,b)};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)};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;if(strLen%2!==0)throw new Error("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);if(isNaN(byte))throw new Error("Invalid hex string");buf[offset+i]=byte}return i}function utf8Write(buf,string,offset,length){var charsWritten=blitBuffer(utf8ToBytes(string,buf.length-offset),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.length-offset),buf,offset,length,2);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;if(length<0||offset<0||offset>this.length)throw new RangeError("attempt to write outside buffer bounds");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 TypeError("Unknown encoding: "+encoding)}return ret};Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};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]&127)}return ret}function binarySlice(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 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;var newBuf;if(Buffer.TYPED_ARRAY_SUPPORT){newBuf=Buffer._augment(this.subarray(start,end))}else{var sliceLen=end-start;newBuf=new Buffer(sliceLen,undefined,true);for(var i=0;i<sliceLen;i++){newBuf[i]=this[i+start]}}if(newBuf.length)newBuf.parent=this.parent||this;return newBuf};function checkOffset(offset,ext,length){if(offset%1!==0||offset<0)throw new RangeError("offset is not uint");if(offset+ext>length)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i<byteLength&&(mul*=256))val+=this[offset+i]*mul;return val};Buffer.prototype.readUIntBE=function(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset+--byteLength];var mul=1;while(byteLength>0&&(mul*=256))val+=this[offset+--byteLength]*mul;return val};Buffer.prototype.readUInt8=function(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);return this[offset]};Buffer.prototype.readUInt16LE=function(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]|this[offset+1]<<8};Buffer.prototype.readUInt16BE=function(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]<<8|this[offset+1]};Buffer.prototype.readUInt32LE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+this[offset+3]*16777216};Buffer.prototype.readUInt32BE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]*16777216+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])};Buffer.prototype.readIntLE=function(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i<byteLength&&(mul*=256))val+=this[offset+i]*mul;mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readIntBE=function(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var i=byteLength;var mul=1;var val=this[offset+--i];while(i>0&&(mul*=256))val+=this[offset+--i]*mul;mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readInt8=function(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);if(!(this[offset]&128))return this[offset];return(255-this[offset]+1)*-1};Buffer.prototype.readInt16LE=function(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt16BE=function(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt32LE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24};Buffer.prototype.readInt32BE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]};Buffer.prototype.readFloatLE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,true,23,4)};Buffer.prototype.readFloatBE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,false,23,4)};Buffer.prototype.readDoubleLE=function(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,true,52,8)};Buffer.prototype.readDoubleBE=function(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,false,52,8)};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError("buffer must be a Buffer instance");if(value>max||value<min)throw new RangeError("value is out of bounds");if(offset+ext>buf.length)throw new RangeError("index out of range")}Buffer.prototype.writeUIntLE=function(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength),0);var mul=1;var i=0;this[offset]=value&255;while(++i<byteLength&&(mul*=256))this[offset+i]=value/mul>>>0&255;return offset+byteLength};Buffer.prototype.writeUIntBE=function(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength),0);var i=byteLength-1;var mul=1;this[offset+i]=value&255;while(--i>=0&&(mul*=256))this[offset+i]=value/mul>>>0&255;return offset+byteLength};Buffer.prototype.writeUInt8=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,255,0);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);this[offset]=value;return offset+1};function objectWriteUInt16(buf,value,offset,littleEndian){if(value<0)value=65535+value+1;for(var i=0,j=Math.min(buf.length-offset,2);i<j;i++){buf[offset+i]=(value&255<<8*(littleEndian?i:1-i))>>>(littleEndian?i:1-i)*8}}Buffer.prototype.writeUInt16LE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value;this[offset+1]=value>>>8}else objectWriteUInt16(this,value,offset,true);return offset+2};Buffer.prototype.writeUInt16BE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value}else objectWriteUInt16(this,value,offset,false);return offset+2};function objectWriteUInt32(buf,value,offset,littleEndian){if(value<0)value=4294967295+value+1;for(var i=0,j=Math.min(buf.length-offset,4);i<j;i++){buf[offset+i]=value>>>(littleEndian?i:3-i)*8&255}}Buffer.prototype.writeUInt32LE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset+3]=value>>>24;this[offset+2]=value>>>16;this[offset+1]=value>>>8;this[offset]=value}else objectWriteUInt32(this,value,offset,true);return offset+4};Buffer.prototype.writeUInt32BE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value}else objectWriteUInt32(this,value,offset,false);return offset+4};Buffer.prototype.writeIntLE=function(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength-1)-1,-Math.pow(2,8*byteLength-1))}var i=0;var mul=1;var sub=value<0?1:0;this[offset]=value&255;while(++i<byteLength&&(mul*=256))this[offset+i]=(value/mul>>0)-sub&255;return offset+byteLength};Buffer.prototype.writeIntBE=function(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength-1)-1,-Math.pow(2,8*byteLength-1))}var i=byteLength-1;var mul=1;var sub=value<0?1:0;this[offset+i]=value&255;while(--i>=0&&(mul*=256))this[offset+i]=(value/mul>>0)-sub&255;return offset+byteLength};Buffer.prototype.writeInt8=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,127,-128);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);if(value<0)value=255+value+1;this[offset]=value;return offset+1};Buffer.prototype.writeInt16LE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value;this[offset+1]=value>>>8}else objectWriteUInt16(this,value,offset,true);return offset+2};Buffer.prototype.writeInt16BE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value}else objectWriteUInt16(this,value,offset,false);return offset+2};Buffer.prototype.writeInt32LE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value;this[offset+1]=value>>>8;this[offset+2]=value>>>16;this[offset+3]=value>>>24}else objectWriteUInt32(this,value,offset,true);return offset+4};Buffer.prototype.writeInt32BE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(value<0)value=4294967295+value+1;if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value}else objectWriteUInt32(this,value,offset,false);return offset+4};function checkIEEE754(buf,value,offset,ext,max,min){if(value>max||value<min)throw new RangeError("value is out of bounds");if(offset+ext>buf.length)throw new RangeError("index out of range");if(offset<0)throw new RangeError("index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){if(!noAssert)checkIEEE754(buf,value,offset,4,3.4028234663852886e38,-3.4028234663852886e38);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)checkIEEE754(buf,value,offset,8,1.7976931348623157e308,-1.7976931348623157e308);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.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.length)target_start=target.length;if(!target_start)target_start=0;if(end>0&&end<start)end=start;if(end===start)return 0;if(target.length===0||source.length===0)return 0;if(target_start<0)throw new RangeError("targetStart out of bounds");if(start<0||start>=source.length)throw new RangeError("sourceStart out of bounds");if(end<0)throw new RangeError("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<1e3||!Buffer.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)}return len};Buffer.prototype.fill=function(value,start,end){if(!value)value=0;if(!start)start=0;if(!end)end=this.length;if(end<start)throw new RangeError("end < start");if(end===start)return;if(this.length===0)return;if(start<0||start>=this.length)throw new RangeError("start out of bounds");if(end<0||end>this.length)throw new RangeError("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.toArrayBuffer=function(){if(typeof Uint8Array!=="undefined"){if(Buffer.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 TypeError("Buffer.toArrayBuffer not supported in this browser")}};var BP=Buffer.prototype;Buffer._augment=function(arr){arr.constructor=Buffer;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.readUIntLE=BP.readUIntLE;arr.readUIntBE=BP.readUIntBE;arr.readUInt8=BP.readUInt8;arr.readUInt16LE=BP.readUInt16LE;arr.readUInt16BE=BP.readUInt16BE;arr.readUInt32LE=BP.readUInt32LE;arr.readUInt32BE=BP.readUInt32BE;arr.readIntLE=BP.readIntLE;arr.readIntBE=BP.readIntBE;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.writeUIntLE=BP.writeUIntLE;arr.writeUIntBE=BP.writeUIntBE;arr.writeUInt16LE=BP.writeUInt16LE;arr.writeUInt16BE=BP.writeUInt16BE;arr.writeUInt32LE=BP.writeUInt32LE;arr.writeUInt32BE=BP.writeUInt32BE;arr.writeIntLE=BP.writeIntLE;arr.writeIntBE=BP.writeIntBE;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,"");if(str.length<2)return"";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 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(string,units){var codePoint,length=string.length;var leadSurrogate=null;units=units||Infinity;var bytes=[];var i=0;for(;i<length;i++){codePoint=string.charCodeAt(i);if(codePoint>55295&&codePoint<57344){if(leadSurrogate){if(codePoint<56320){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=codePoint;continue}else{codePoint=leadSurrogate-55296<<10|codePoint-56320|65536;leadSurrogate=null}}else{if(codePoint>56319){if((units-=3)>-1)bytes.push(239,191,189);continue}else if(i+1===length){if((units-=3)>-1)bytes.push(239,191,189);continue}else{leadSurrogate=codePoint;continue}}}else if(leadSurrogate){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=null}if(codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,codePoint&63|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,codePoint&63|128)}else if(codePoint<2097152){if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,codePoint&63|128)}else{throw new Error("Invalid code point")}}return bytes}function asciiToBytes(str){var byteArray=[];for(var i=0;i<str.length;i++){byteArray.push(str.charCodeAt(i)&255)}return byteArray}function utf16leToBytes(str,units){var c,hi,lo;var byteArray=[];for(var i=0;i<str.length;i++){if((units-=2)<0)break;c=str.charCodeAt(i);hi=c>>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(base64clean(str))}function blitBuffer(src,dst,offset,length,unitSize){if(unitSize)length-=length%unitSize;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)}}},{"base64-js":3,ieee754:4,"is-array":5}],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);var PLUS_URL_SAFE="-".charCodeAt(0);var SLASH_URL_SAFE="_".charCodeAt(0);function decode(elt){var code=elt.charCodeAt(0);if(code===PLUS||code===PLUS_URL_SAFE)return 62;if(code===SLASH||code===SLASH_URL_SAFE)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){var isArray=Array.isArray;var str=Object.prototype.toString;module.exports=isArray||function(val){return!!val&&"[object Array]"==str.call(val)}},{}],6:[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}throw TypeError('Uncaught, unspecified "error" event.')}}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}},{}],7:[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}}},{}],8:[function(require,module,exports){var process=module.exports={};process.nextTick=function(){var canSetImmediate=typeof window!=="undefined"&&window.setImmediate;var canMutationObserver=typeof window!=="undefined"&&window.MutationObserver;var canPost=typeof window!=="undefined"&&window.postMessage&&window.addEventListener;if(canSetImmediate){return function(f){return window.setImmediate(f)}}var queue=[];if(canMutationObserver){var hiddenDiv=document.createElement("div");var observer=new MutationObserver(function(){var queueList=queue.slice();queue.length=0;queueList.forEach(function(fn){fn()})});observer.observe(hiddenDiv,{attributes:true});return function nextTick(fn){if(!queue.length){hiddenDiv.setAttribute("yes","no")}queue.push(fn)}}if(canPost){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")}},{}],9:[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"}},{}],10:[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":9,_process:8,inherits:7}],11:[function(require,module,exports){"use strict";var objectKeys=Object.keys||function(obj){var keys=[];for(var key in obj)keys.push(key);return keys};module.exports=Duplex;var processNextTick=require("process-nextick-args");var util=require("core-util-is");util.inherits=require("inherits");var Readable=require("./_stream_readable");var Writable=require("./_stream_writable");util.inherits(Duplex,Readable);var keys=objectKeys(Writable.prototype);for(var v=0;v<keys.length;v++){var method=keys[v];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;processNextTick(onEndNT,this)}function onEndNT(self){self.end()}function forEach(xs,f){for(var i=0,l=xs.length;i<l;i++){f(xs[i],i)}}},{"./_stream_readable":12,"./_stream_writable":14,"core-util-is":15,inherits:16,"process-nextick-args":18}],12:[function(require,module,exports){(function(process){"use strict";module.exports=Readable;var processNextTick=require("process-nextick-args");var isArray=require("isarray");var Buffer=require("buffer").Buffer;Readable.ReadableState=ReadableState;var EE=require("events");var EElistenerCount=function(emitter,type){return emitter.listeners(type).length};var Stream;(function(){try{Stream=require("st"+"ream")}catch(_){}finally{if(!Stream)Stream=require("events").EventEmitter}})();var Buffer=require("buffer").Buffer;var util=require("core-util-is");util.inherits=require("inherits");var debugUtil=require("util");var debug;if(debugUtil&&debugUtil.debuglog){debug=debugUtil.debuglog("stream")}else{debug=function(){}}var StringDecoder;util.inherits(Readable,Stream);function ReadableState(options,stream){var Duplex=require("./_stream_duplex");options=options||{};this.objectMode=!!options.objectMode;if(stream instanceof Duplex)this.objectMode=this.objectMode||!!options.readableObjectMode;var hwm=options.highWaterMark;var defaultHwm=this.objectMode?16:16*1024;this.highWaterMark=hwm||hwm===0?hwm:defaultHwm;this.highWaterMark=~~this.highWaterMark;this.buffer=[];this.length=0;this.pipes=null;this.pipesCount=0;this.flowing=null;this.ended=false;this.endEmitted=false;this.reading=false;this.sync=true;this.needReadable=false;this.emittedReadable=false;this.readableListening=false;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){var Duplex=require("./_stream_duplex");if(!(this instanceof Readable))return new Readable(options);this._readableState=new ReadableState(options,this);this.readable=true;if(options&&typeof options.read==="function")this._read=options.read;Stream.call(this)}Readable.prototype.push=function(chunk,encoding){var state=this._readableState;if(!state.objectMode&&typeof chunk==="string"){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)};Readable.prototype.isPaused=function(){return this._readableState.flowing===false};function readableAddChunk(stream,state,chunk,encoding,addToFront){var er=chunkInvalid(state,chunk);if(er){stream.emit("error",er)}else if(chunk===null){state.reading=false;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);if(!addToFront)state.reading=false;if(state.flowing&&state.length===0&&!state.sync){stream.emit("data",chunk);stream.read(0)}else{state.length+=state.objectMode?1:chunk.length;if(addToFront)state.buffer.unshift(chunk);else 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;return this};var MAX_HWM=8388608;function computeNewHighWaterMark(n){if(n>=MAX_HWM){n=MAX_HWM}else{n--;n|=n>>>1;n|=n>>>2;n|=n>>>4;n|=n>>>8;n|=n>>>16;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=computeNewHighWaterMark(n);if(n>state.length){if(!state.ended){state.needReadable=true;return 0}else{return state.length}}return n}Readable.prototype.read=function(n){debug("read",n);var state=this._readableState;var nOrig=n;if(typeof n!=="number"||n>0)state.emittedReadable=false;if(n===0&&state.needReadable&&(state.length>=state.highWaterMark||state.ended)){debug("read: emitReadable",state.length,state.ended);if(state.length===0&&state.ended)endReadable(this);else emitReadable(this);return null}n=howMuchToRead(n,state);if(n===0&&state.ended){if(state.length===0)endReadable(this);return null}var doRead=state.needReadable;debug("need readable",doRead);if(state.length===0||state.length-n<state.highWaterMark){doRead=true;debug("length less than watermark",doRead)}if(state.ended||state.reading){doRead=false;debug("reading or ended",doRead)}if(doRead){debug("do read");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);var ret;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(nOrig!==n&&state.ended&&state.length===0)endReadable(this);if(ret!==null)this.emit("data",ret);return ret};function chunkInvalid(state,chunk){var er=null;if(!Buffer.isBuffer(chunk)&&typeof chunk!=="string"&&chunk!==null&&chunk!==undefined&&!state.objectMode){er=new TypeError("Invalid non-string/buffer chunk")}return er}function onEofChunk(stream,state){if(state.ended)return;if(state.decoder){var chunk=state.decoder.end();if(chunk&&chunk.length){state.buffer.push(chunk);state.length+=state.objectMode?1:chunk.length}}state.ended=true;emitReadable(stream)}function emitReadable(stream){var state=stream._readableState;state.needReadable=false;if(!state.emittedReadable){debug("emitReadable",state.flowing);state.emittedReadable=true;if(state.sync)processNextTick(emitReadable_,stream);else emitReadable_(stream)}}function emitReadable_(stream){debug("emit readable");stream.emit("readable");flow(stream)}function maybeReadMore(stream,state){if(!state.readingMore){state.readingMore=true;processNextTick(maybeReadMore_,stream,state)}}function maybeReadMore_(stream,state){var len=state.length;while(!state.reading&&!state.flowing&&!state.ended&&state.length<state.highWaterMark){debug("maybeReadMore read 0");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;debug("pipe count=%d opts=%j",state.pipesCount,pipeOpts);var doEnd=(!pipeOpts||pipeOpts.end!==false)&&dest!==process.stdout&&dest!==process.stderr;var endFn=doEnd?onend:cleanup;if(state.endEmitted)processNextTick(endFn);else src.once("end",endFn);dest.on("unpipe",onunpipe);function onunpipe(readable){debug("onunpipe");if(readable===src){cleanup()}}function onend(){debug("onend");dest.end()}var ondrain=pipeOnDrain(src);dest.on("drain",ondrain);var cleanedUp=false;function cleanup(){debug("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);src.removeListener("data",ondata);cleanedUp=true;if(state.awaitDrain&&(!dest._writableState||dest._writableState.needDrain))ondrain()}src.on("data",ondata);function ondata(chunk){debug("ondata");var ret=dest.write(chunk);if(false===ret){if(state.pipesCount===1&&state.pipes[0]===dest&&src.listenerCount("data")===1&&!cleanedUp){debug("false write response, pause",src._readableState.awaitDrain);src._readableState.awaitDrain++}src.pause()}}function onerror(er){debug("onerror",er);unpipe();dest.removeListener("error",onerror);if(EElistenerCount(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(){debug("onfinish");dest.removeListener("close",onclose);unpipe()}dest.once("finish",onfinish);function unpipe(){debug("unpipe");src.unpipe(dest)}dest.emit("pipe",src);if(!state.flowing){debug("pipe resume");src.resume()}return dest};function pipeOnDrain(src){return function(){var state=src._readableState;debug("pipeOnDrain",state.awaitDrain);if(state.awaitDrain)state.awaitDrain--;if(state.awaitDrain===0&&EElistenerCount(src,"data")){state.flowing=true;flow(src)}}}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;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;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"&&false!==this._readableState.flowing){this.resume()}if(ev==="readable"&&this.readable){var state=this._readableState;if(!state.readableListening){state.readableListening=true;state.emittedReadable=false;state.needReadable=true;if(!state.reading){processNextTick(nReadingNextTick,this)}else if(state.length){emitReadable(this,state)}}}return res};Readable.prototype.addListener=Readable.prototype.on;function nReadingNextTick(self){debug("readable nexttick read 0");self.read(0)}Readable.prototype.resume=function(){var state=this._readableState;if(!state.flowing){debug("resume");state.flowing=true;resume(this,state)}return this};function resume(stream,state){if(!state.resumeScheduled){state.resumeScheduled=true;processNextTick(resume_,stream,state)}}function resume_(stream,state){if(!state.reading){debug("resume read 0");stream.read(0)}state.resumeScheduled=false;stream.emit("resume");flow(stream);if(state.flowing&&!state.reading)stream.read(0)}Readable.prototype.pause=function(){debug("call pause flowing=%j",this._readableState.flowing);if(false!==this._readableState.flowing){debug("pause");this._readableState.flowing=false;this.emit("pause")}return this};function flow(stream){var state=stream._readableState;debug("flow",state.flowing);if(state.flowing){do{var chunk=stream.read()}while(null!==chunk&&state.flowing)}}Readable.prototype.wrap=function(stream){var state=this._readableState;var paused=false;var self=this;stream.on("end",function(){debug("wrapped end");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){debug("wrapped data");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(this[i]===undefined&&typeof stream[i]==="function"){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){debug("wrapped _read",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 if(list.length===1)ret=list[0];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.ended=true;processNextTick(endReadableNT,state,stream)}}function endReadableNT(state,stream){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"))},{"./_stream_duplex":11,_process:8,buffer:2,"core-util-is":15,events:6,inherits:16,isarray:17,"process-nextick-args":18,"string_decoder/":19,util:1}],13:[function(require,module,exports){"use strict";module.exports=Transform;var Duplex=require("./_stream_duplex");var util=require("core-util-is");util.inherits=require("inherits");util.inherits(Transform,Duplex);function TransformState(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);this._transformState=new TransformState(this);var stream=this;this._readableState.needReadable=true;this._readableState.sync=false;if(options){if(typeof options.transform==="function")this._transform=options.transform;if(typeof options.flush==="function")this._flush=options.flush}this.once("prefinish",function(){if(typeof this._flush==="function")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 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":11,"core-util-is":15,inherits:16}],14:[function(require,module,exports){"use strict";module.exports=Writable;var processNextTick=require("process-nextick-args");var Buffer=require("buffer").Buffer;Writable.WritableState=WritableState;var util=require("core-util-is");util.inherits=require("inherits");var internalUtil={deprecate:require("util-deprecate")};var Stream;(function(){try{Stream=require("st"+"ream")}catch(_){}finally{if(!Stream)Stream=require("events").EventEmitter}})();var Buffer=require("buffer").Buffer;util.inherits(Writable,Stream);function nop(){}function WriteReq(chunk,encoding,cb){this.chunk=chunk;this.encoding=encoding;this.callback=cb;this.next=null}function WritableState(options,stream){var Duplex=require("./_stream_duplex");options=options||{};this.objectMode=!!options.objectMode;if(stream instanceof Duplex)this.objectMode=this.objectMode||!!options.writableObjectMode;var hwm=options.highWaterMark;var defaultHwm=this.objectMode?16:16*1024;this.highWaterMark=hwm||hwm===0?hwm:defaultHwm;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.corked=0;this.sync=true;this.bufferProcessing=false;this.onwrite=function(er){onwrite(stream,er)};this.writecb=null;this.writelen=0;this.bufferedRequest=null;this.lastBufferedRequest=null;this.pendingcb=0;this.prefinished=false;this.errorEmitted=false}WritableState.prototype.getBuffer=function writableStateGetBuffer(){
var current=this.bufferedRequest;var out=[];while(current){out.push(current);current=current.next}return out};(function(){try{Object.defineProperty(WritableState.prototype,"buffer",{get:internalUtil.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer "+"instead.")})}catch(_){}})();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;if(options){if(typeof options.write==="function")this._write=options.write;if(typeof options.writev==="function")this._writev=options.writev}Stream.call(this)}Writable.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))};function writeAfterEnd(stream,cb){var er=new Error("write after end");stream.emit("error",er);processNextTick(cb,er)}function validChunk(stream,state,chunk,cb){var valid=true;if(!Buffer.isBuffer(chunk)&&typeof chunk!=="string"&&chunk!==null&&chunk!==undefined&&!state.objectMode){var er=new TypeError("Invalid non-string/buffer chunk");stream.emit("error",er);processNextTick(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=nop;if(state.ended)writeAfterEnd(this,cb);else if(validChunk(this,state,chunk,cb)){state.pendingcb++;ret=writeOrBuffer(this,state,chunk,encoding,cb)}return ret};Writable.prototype.cork=function(){var state=this._writableState;state.corked++};Writable.prototype.uncork=function(){var state=this._writableState;if(state.corked){state.corked--;if(!state.writing&&!state.corked&&!state.finished&&!state.bufferProcessing&&state.bufferedRequest)clearBuffer(this,state)}};Writable.prototype.setDefaultEncoding=function setDefaultEncoding(encoding){if(typeof encoding==="string")encoding=encoding.toLowerCase();if(!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((encoding+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+encoding);this._writableState.defaultEncoding=encoding};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.corked){var last=state.lastBufferedRequest;state.lastBufferedRequest=new WriteReq(chunk,encoding,cb);if(last){last.next=state.lastBufferedRequest}else{state.bufferedRequest=state.lastBufferedRequest}}else{doWrite(stream,state,false,len,chunk,encoding,cb)}return ret}function doWrite(stream,state,writev,len,chunk,encoding,cb){state.writelen=len;state.writecb=cb;state.writing=true;state.sync=true;if(writev)stream._writev(chunk,state.onwrite);else stream._write(chunk,encoding,state.onwrite);state.sync=false}function onwriteError(stream,state,sync,er,cb){--state.pendingcb;if(sync)processNextTick(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(state);if(!finished&&!state.corked&&!state.bufferProcessing&&state.bufferedRequest){clearBuffer(stream,state)}if(sync){processNextTick(afterWrite,stream,state,finished,cb)}else{afterWrite(stream,state,finished,cb)}}}function afterWrite(stream,state,finished,cb){if(!finished)onwriteDrain(stream,state);state.pendingcb--;cb();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;var entry=state.bufferedRequest;if(stream._writev&&entry&&entry.next){var buffer=[];var cbs=[];while(entry){cbs.push(entry.callback);buffer.push(entry);entry=entry.next}state.pendingcb++;state.lastBufferedRequest=null;doWrite(stream,state,true,state.length,buffer,"",function(err){for(var i=0;i<cbs.length;i++){state.pendingcb--;cbs[i](err)}})}else{while(entry){var chunk=entry.chunk;var encoding=entry.encoding;var cb=entry.callback;var len=state.objectMode?1:chunk.length;doWrite(stream,state,false,len,chunk,encoding,cb);entry=entry.next;if(state.writing){break}}if(entry===null)state.lastBufferedRequest=null}state.bufferedRequest=entry;state.bufferProcessing=false}Writable.prototype._write=function(chunk,encoding,cb){cb(new Error("not implemented"))};Writable.prototype._writev=null;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(chunk!==null&&chunk!==undefined)this.write(chunk,encoding);if(state.corked){state.corked=1;this.uncork()}if(!state.ending&&!state.finished)endWritable(this,state,cb)};function needFinish(state){return state.ending&&state.length===0&&state.bufferedRequest===null&&!state.finished&&!state.writing}function prefinish(stream,state){if(!state.prefinished){state.prefinished=true;stream.emit("prefinish")}}function finishMaybe(stream,state){var need=needFinish(state);if(need){if(state.pendingcb===0){prefinish(stream,state);state.finished=true;stream.emit("finish")}else{prefinish(stream,state)}}return need}function endWritable(stream,state,cb){state.ending=true;finishMaybe(stream,state);if(cb){if(state.finished)processNextTick(cb);else stream.once("finish",cb)}state.ended=true}},{"./_stream_duplex":11,buffer:2,"core-util-is":15,events:6,inherits:16,"process-nextick-args":18,"util-deprecate":20}],15:[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}],16:[function(require,module,exports){arguments[4][7][0].apply(exports,arguments)},{dup:7}],17:[function(require,module,exports){module.exports=Array.isArray||function(arr){return Object.prototype.toString.call(arr)=="[object Array]"}},{}],18:[function(require,module,exports){(function(process){"use strict";module.exports=nextTick;function nextTick(fn){var args=new Array(arguments.length-1);var i=0;while(i<args.length){args[i++]=arguments[i]}process.nextTick(function afterTick(){fn.apply(null,args)})}}).call(this,require("_process"))},{_process:8}],19:[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="";while(this.charLength){var available=buffer.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:buffer.length;buffer.copy(this.charBuffer,this.charReceived,0,available);this.charReceived+=available;if(this.charReceived<this.charLength){return""}buffer=buffer.slice(available,buffer.length);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(buffer.length===0){return charStr}break}this.detectIncompleteChar(buffer);var end=buffer.length;if(this.charLength){buffer.copy(this.charBuffer,0,buffer.length-this.charReceived,end);end-=this.charReceived}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);buffer.copy(this.charBuffer,0,0,size);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}}this.charReceived=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){this.charReceived=buffer.length%2;this.charLength=this.charReceived?2:0}function base64DetectIncompleteChar(buffer){this.charReceived=buffer.length%3;this.charLength=this.charReceived?3:0}},{buffer:2}],20:[function(require,module,exports){(function(global){module.exports=deprecate;function deprecate(fn,msg){if(config("noDeprecation")){return fn}var warned=false;function deprecated(){if(!warned){if(config("throwDeprecation")){throw new Error(msg)}else if(config("traceDeprecation")){console.trace(msg)}else{console.warn(msg)}warned=true}return fn.apply(this,arguments)}return deprecated}function config(name){try{if(!global.localStorage)return false}catch(_){return false}var val=global.localStorage[name];if(null==val)return false;return String(val).toLowerCase()==="true"}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],21:[function(require,module,exports){module.exports=require("./lib/_stream_transform.js")},{"./lib/_stream_transform.js":13}],22:[function(require,module,exports){module.exports=extend;var hasOwnProperty=Object.prototype.hasOwnProperty;function extend(){var target={};for(var i=0;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target}},{}],through2:[function(require,module,exports){(function(process){var Transform=require("readable-stream/transform"),inherits=require("util").inherits,xtend=require("xtend");function DestroyableTransform(opts){Transform.call(this,opts);this._destroyed=false}inherits(DestroyableTransform,Transform);DestroyableTransform.prototype.destroy=function(err){if(this._destroyed)return;this._destroyed=true;var self=this;process.nextTick(function(){if(err)self.emit("error",err);self.emit("close")})};function noop(chunk,enc,callback){callback(null,chunk)}function through2(construct){return function(options,transform,flush){if(typeof options=="function"){flush=transform;transform=options;options={}}if(typeof transform!="function")transform=noop;if(typeof flush!="function")flush=null;return construct(options,transform,flush)}}module.exports=through2(function(options,transform,flush){var t2=new DestroyableTransform(options);t2._transform=transform;if(flush)t2._flush=flush;return t2});module.exports.ctor=through2(function(options,transform,flush){function Through2(override){if(!(this instanceof Through2))return new Through2(override);this.options=xtend(options,override);DestroyableTransform.call(this,this.options)}inherits(Through2,DestroyableTransform);Through2.prototype._transform=transform;if(flush)Through2.prototype._flush=flush;return Through2});module.exports.obj=through2(function(options,transform,flush){var t2=new DestroyableTransform(xtend({objectMode:true,highWaterMark:16},options));t2._transform=transform;if(flush)t2._flush=flush;return t2})}).call(this,require("_process"))},{_process:8,"readable-stream/transform":21,util:10,xtend:22}]},{},[]);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");var isArray=require("is-array");exports.Buffer=Buffer;exports.SlowBuffer=SlowBuffer;exports.INSPECT_MAX_BYTES=50;Buffer.poolSize=8192;var kMaxLength=1073741823;var rootParent={};Buffer.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"){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 TypeError("must start with number, buffer, array or string");if(length>kMaxLength)throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+kMaxLength.toString(16)+" bytes");var buf;if(Buffer.TYPED_ARRAY_SUPPORT){buf=Buffer._augment(new Uint8Array(length))}else{buf=this;buf.length=length;buf._isBuffer=true}var i;if(Buffer.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"&&!Buffer.TYPED_ARRAY_SUPPORT&&!noZero){for(i=0;i<length;i++){buf[i]=0}}if(length>0&&length<=Buffer.poolSize)buf.parent=rootParent;return buf}function SlowBuffer(subject,encoding,noZero){if(!(this instanceof SlowBuffer))return new SlowBuffer(subject,encoding,noZero);var buf=new Buffer(subject,encoding,noZero);delete buf.parent;return buf}Buffer.isBuffer=function(b){return!!(b!=null&&b._isBuffer)};Buffer.compare=function(a,b){if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b))throw new TypeError("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};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.concat=function(list,totalLength){if(!isArray(list))throw new TypeError("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.byteLength=function(str,encoding){var ret;str=str+"";switch(encoding||"utf8"){case"ascii":case"binary":case"raw":ret=str.length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":ret=str.length*2;break;case"hex":ret=str.length>>>1;break;case"utf8":case"utf-8":ret=utf8ToBytes(str).length;break;case"base64":ret=base64ToBytes(str).length;break;default:ret=str.length}return ret};Buffer.prototype.length=undefined;Buffer.prototype.parent=undefined;Buffer.prototype.toString=function(encoding,start,end){var loweredCase=false;start=start>>>0;end=end===undefined||end===Infinity?this.length:end>>>0;if(!encoding)encoding="utf8";if(start<0)start=0;if(end>this.length)end=this.length;if(end<=start)return"";while(true){switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"binary":return binarySlice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase();loweredCase=true}}};Buffer.prototype.equals=function(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");return Buffer.compare(this,b)===0};Buffer.prototype.inspect=function(){var str="";var max=exports.INSPECT_MAX_BYTES;if(this.length>0){str=this.toString("hex",0,max).match(/.{2}/g).join(" ");if(this.length>max)str+=" ... "}return"<Buffer "+str+">"};Buffer.prototype.compare=function(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");return Buffer.compare(this,b)};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)};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;if(strLen%2!==0)throw new Error("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);if(isNaN(byte))throw new Error("Invalid hex string");buf[offset+i]=byte}return i}function utf8Write(buf,string,offset,length){var charsWritten=blitBuffer(utf8ToBytes(string,buf.length-offset),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.length-offset),buf,offset,length,2);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;if(length<0||offset<0||offset>this.length)throw new RangeError("attempt to write outside buffer bounds");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 TypeError("Unknown encoding: "+encoding)}return ret};Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};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]&127)}return ret}function binarySlice(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 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;var newBuf;if(Buffer.TYPED_ARRAY_SUPPORT){newBuf=Buffer._augment(this.subarray(start,end))}else{var sliceLen=end-start;newBuf=new Buffer(sliceLen,undefined,true);for(var i=0;i<sliceLen;i++){newBuf[i]=this[i+start]}}if(newBuf.length)newBuf.parent=this.parent||this;return newBuf};function checkOffset(offset,ext,length){if(offset%1!==0||offset<0)throw new RangeError("offset is not uint");if(offset+ext>length)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i<byteLength&&(mul*=256))val+=this[offset+i]*mul;return val};Buffer.prototype.readUIntBE=function(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset+--byteLength];var mul=1;while(byteLength>0&&(mul*=256))val+=this[offset+--byteLength]*mul;return val};Buffer.prototype.readUInt8=function(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);return this[offset]};Buffer.prototype.readUInt16LE=function(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]|this[offset+1]<<8};Buffer.prototype.readUInt16BE=function(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]<<8|this[offset+1]};Buffer.prototype.readUInt32LE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+this[offset+3]*16777216};Buffer.prototype.readUInt32BE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]*16777216+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])};Buffer.prototype.readIntLE=function(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i<byteLength&&(mul*=256))val+=this[offset+i]*mul;mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readIntBE=function(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var i=byteLength;var mul=1;var val=this[offset+--i];while(i>0&&(mul*=256))val+=this[offset+--i]*mul;mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readInt8=function(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);if(!(this[offset]&128))return this[offset];return(255-this[offset]+1)*-1};Buffer.prototype.readInt16LE=function(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt16BE=function(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt32LE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24};Buffer.prototype.readInt32BE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]};Buffer.prototype.readFloatLE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,true,23,4)};Buffer.prototype.readFloatBE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,false,23,4)};Buffer.prototype.readDoubleLE=function(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,true,52,8)};Buffer.prototype.readDoubleBE=function(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,false,52,8)};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError("buffer must be a Buffer instance");if(value>max||value<min)throw new RangeError("value is out of bounds");if(offset+ext>buf.length)throw new RangeError("index out of range")}Buffer.prototype.writeUIntLE=function(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength),0);var mul=1;var i=0;this[offset]=value&255;while(++i<byteLength&&(mul*=256))this[offset+i]=value/mul>>>0&255;return offset+byteLength};Buffer.prototype.writeUIntBE=function(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength),0);var i=byteLength-1;var mul=1;this[offset+i]=value&255;while(--i>=0&&(mul*=256))this[offset+i]=value/mul>>>0&255;return offset+byteLength};Buffer.prototype.writeUInt8=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,255,0);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);this[offset]=value;return offset+1};function objectWriteUInt16(buf,value,offset,littleEndian){if(value<0)value=65535+value+1;for(var i=0,j=Math.min(buf.length-offset,2);i<j;i++){buf[offset+i]=(value&255<<8*(littleEndian?i:1-i))>>>(littleEndian?i:1-i)*8}}Buffer.prototype.writeUInt16LE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value;this[offset+1]=value>>>8}else objectWriteUInt16(this,value,offset,true);return offset+2};Buffer.prototype.writeUInt16BE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value}else objectWriteUInt16(this,value,offset,false);return offset+2};function objectWriteUInt32(buf,value,offset,littleEndian){if(value<0)value=4294967295+value+1;for(var i=0,j=Math.min(buf.length-offset,4);i<j;i++){buf[offset+i]=value>>>(littleEndian?i:3-i)*8&255}}Buffer.prototype.writeUInt32LE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset+3]=value>>>24;this[offset+2]=value>>>16;this[offset+1]=value>>>8;this[offset]=value}else objectWriteUInt32(this,value,offset,true);return offset+4};Buffer.prototype.writeUInt32BE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value}else objectWriteUInt32(this,value,offset,false);return offset+4};Buffer.prototype.writeIntLE=function(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength-1)-1,-Math.pow(2,8*byteLength-1))}var i=0;var mul=1;var sub=value<0?1:0;this[offset]=value&255;while(++i<byteLength&&(mul*=256))this[offset+i]=(value/mul>>0)-sub&255;return offset+byteLength};Buffer.prototype.writeIntBE=function(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength-1)-1,-Math.pow(2,8*byteLength-1))}var i=byteLength-1;var mul=1;var sub=value<0?1:0;this[offset+i]=value&255;while(--i>=0&&(mul*=256))this[offset+i]=(value/mul>>0)-sub&255;return offset+byteLength};Buffer.prototype.writeInt8=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,127,-128);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);if(value<0)value=255+value+1;this[offset]=value;return offset+1};Buffer.prototype.writeInt16LE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value;this[offset+1]=value>>>8}else objectWriteUInt16(this,value,offset,true);return offset+2};Buffer.prototype.writeInt16BE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value}else objectWriteUInt16(this,value,offset,false);return offset+2};Buffer.prototype.writeInt32LE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value;this[offset+1]=value>>>8;this[offset+2]=value>>>16;this[offset+3]=value>>>24}else objectWriteUInt32(this,value,offset,true);return offset+4};Buffer.prototype.writeInt32BE=function(value,offset,noAssert){
value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(value<0)value=4294967295+value+1;if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value}else objectWriteUInt32(this,value,offset,false);return offset+4};function checkIEEE754(buf,value,offset,ext,max,min){if(value>max||value<min)throw new RangeError("value is out of bounds");if(offset+ext>buf.length)throw new RangeError("index out of range");if(offset<0)throw new RangeError("index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){if(!noAssert)checkIEEE754(buf,value,offset,4,3.4028234663852886e38,-3.4028234663852886e38);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)checkIEEE754(buf,value,offset,8,1.7976931348623157e308,-1.7976931348623157e308);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.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.length)target_start=target.length;if(!target_start)target_start=0;if(end>0&&end<start)end=start;if(end===start)return 0;if(target.length===0||source.length===0)return 0;if(target_start<0)throw new RangeError("targetStart out of bounds");if(start<0||start>=source.length)throw new RangeError("sourceStart out of bounds");if(end<0)throw new RangeError("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<1e3||!Buffer.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)}return len};Buffer.prototype.fill=function(value,start,end){if(!value)value=0;if(!start)start=0;if(!end)end=this.length;if(end<start)throw new RangeError("end < start");if(end===start)return;if(this.length===0)return;if(start<0||start>=this.length)throw new RangeError("start out of bounds");if(end<0||end>this.length)throw new RangeError("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.toArrayBuffer=function(){if(typeof Uint8Array!=="undefined"){if(Buffer.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 TypeError("Buffer.toArrayBuffer not supported in this browser")}};var BP=Buffer.prototype;Buffer._augment=function(arr){arr.constructor=Buffer;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.readUIntLE=BP.readUIntLE;arr.readUIntBE=BP.readUIntBE;arr.readUInt8=BP.readUInt8;arr.readUInt16LE=BP.readUInt16LE;arr.readUInt16BE=BP.readUInt16BE;arr.readUInt32LE=BP.readUInt32LE;arr.readUInt32BE=BP.readUInt32BE;arr.readIntLE=BP.readIntLE;arr.readIntBE=BP.readIntBE;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.writeUIntLE=BP.writeUIntLE;arr.writeUIntBE=BP.writeUIntBE;arr.writeUInt16LE=BP.writeUInt16LE;arr.writeUInt16BE=BP.writeUInt16BE;arr.writeUInt32LE=BP.writeUInt32LE;arr.writeUInt32BE=BP.writeUInt32BE;arr.writeIntLE=BP.writeIntLE;arr.writeIntBE=BP.writeIntBE;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,"");if(str.length<2)return"";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 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(string,units){var codePoint,length=string.length;var leadSurrogate=null;units=units||Infinity;var bytes=[];var i=0;for(;i<length;i++){codePoint=string.charCodeAt(i);if(codePoint>55295&&codePoint<57344){if(leadSurrogate){if(codePoint<56320){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=codePoint;continue}else{codePoint=leadSurrogate-55296<<10|codePoint-56320|65536;leadSurrogate=null}}else{if(codePoint>56319){if((units-=3)>-1)bytes.push(239,191,189);continue}else if(i+1===length){if((units-=3)>-1)bytes.push(239,191,189);continue}else{leadSurrogate=codePoint;continue}}}else if(leadSurrogate){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=null}if(codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,codePoint&63|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,codePoint&63|128)}else if(codePoint<2097152){if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,codePoint&63|128)}else{throw new Error("Invalid code point")}}return bytes}function asciiToBytes(str){var byteArray=[];for(var i=0;i<str.length;i++){byteArray.push(str.charCodeAt(i)&255)}return byteArray}function utf16leToBytes(str,units){var c,hi,lo;var byteArray=[];for(var i=0;i<str.length;i++){if((units-=2)<0)break;c=str.charCodeAt(i);hi=c>>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(base64clean(str))}function blitBuffer(src,dst,offset,length,unitSize){if(unitSize)length-=length%unitSize;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)}}},{"base64-js":3,ieee754:4,"is-array":5}],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);var PLUS_URL_SAFE="-".charCodeAt(0);var SLASH_URL_SAFE="_".charCodeAt(0);function decode(elt){var code=elt.charCodeAt(0);if(code===PLUS||code===PLUS_URL_SAFE)return 62;if(code===SLASH||code===SLASH_URL_SAFE)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){var isArray=Array.isArray;var str=Object.prototype.toString;module.exports=isArray||function(val){return!!val&&"[object Array]"==str.call(val)}},{}],6:[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}throw TypeError('Uncaught, unspecified "error" event.')}}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}},{}],7:[function(require,module,exports){var process=module.exports={};process.nextTick=function(){var canSetImmediate=typeof window!=="undefined"&&window.setImmediate;var canMutationObserver=typeof window!=="undefined"&&window.MutationObserver;var canPost=typeof window!=="undefined"&&window.postMessage&&window.addEventListener;if(canSetImmediate){return function(f){return window.setImmediate(f)}}var queue=[];if(canMutationObserver){var hiddenDiv=document.createElement("div");var observer=new MutationObserver(function(){var queueList=queue.slice();queue.length=0;queueList.forEach(function(fn){fn()})});observer.observe(hiddenDiv,{attributes:true});return function nextTick(fn){if(!queue.length){hiddenDiv.setAttribute("yes","no")}queue.push(fn)}}if(canPost){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")}},{}],8:[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}}},{}],9:[function(require,module,exports){"use strict";var objectKeys=Object.keys||function(obj){var keys=[];for(var key in obj)keys.push(key);return keys};module.exports=Duplex;var processNextTick=require("process-nextick-args");var util=require("core-util-is");util.inherits=require("inherits");var Readable=require("./_stream_readable");var Writable=require("./_stream_writable");util.inherits(Duplex,Readable);var keys=objectKeys(Writable.prototype);for(var v=0;v<keys.length;v++){var method=keys[v];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;processNextTick(onEndNT,this)}function onEndNT(self){self.end()}function forEach(xs,f){for(var i=0,l=xs.length;i<l;i++){f(xs[i],i)}}},{"./_stream_readable":11,"./_stream_writable":13,"core-util-is":14,inherits:8,"process-nextick-args":16}],10:[function(require,module,exports){"use strict";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":12,"core-util-is":14,inherits:8}],11:[function(require,module,exports){(function(process){"use strict";module.exports=Readable;var processNextTick=require("process-nextick-args");var isArray=require("isarray");var Buffer=require("buffer").Buffer;Readable.ReadableState=ReadableState;var EE=require("events");var EElistenerCount=function(emitter,type){return emitter.listeners(type).length};var Stream;(function(){try{Stream=require("st"+"ream")}catch(_){}finally{if(!Stream)Stream=require("events").EventEmitter}})();var Buffer=require("buffer").Buffer;var util=require("core-util-is");util.inherits=require("inherits");var debugUtil=require("util");var debug;if(debugUtil&&debugUtil.debuglog){debug=debugUtil.debuglog("stream")}else{debug=function(){}}var StringDecoder;util.inherits(Readable,Stream);function ReadableState(options,stream){var Duplex=require("./_stream_duplex");options=options||{};this.objectMode=!!options.objectMode;if(stream instanceof Duplex)this.objectMode=this.objectMode||!!options.readableObjectMode;var hwm=options.highWaterMark;var defaultHwm=this.objectMode?16:16*1024;this.highWaterMark=hwm||hwm===0?hwm:defaultHwm;this.highWaterMark=~~this.highWaterMark;this.buffer=[];this.length=0;this.pipes=null;this.pipesCount=0;this.flowing=null;this.ended=false;this.endEmitted=false;this.reading=false;this.sync=true;this.needReadable=false;this.emittedReadable=false;this.readableListening=false;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){var Duplex=require("./_stream_duplex");if(!(this instanceof Readable))return new Readable(options);this._readableState=new ReadableState(options,this);this.readable=true;if(options&&typeof options.read==="function")this._read=options.read;Stream.call(this)}Readable.prototype.push=function(chunk,encoding){var state=this._readableState;if(!state.objectMode&&typeof chunk==="string"){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)};Readable.prototype.isPaused=function(){return this._readableState.flowing===false};function readableAddChunk(stream,state,chunk,encoding,addToFront){var er=chunkInvalid(state,chunk);if(er){stream.emit("error",er)}else if(chunk===null){state.reading=false;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);if(!addToFront)state.reading=false;if(state.flowing&&state.length===0&&!state.sync){stream.emit("data",chunk);stream.read(0)}else{state.length+=state.objectMode?1:chunk.length;if(addToFront)state.buffer.unshift(chunk);else 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;return this};var MAX_HWM=8388608;function computeNewHighWaterMark(n){if(n>=MAX_HWM){n=MAX_HWM}else{n--;n|=n>>>1;n|=n>>>2;n|=n>>>4;n|=n>>>8;n|=n>>>16;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=computeNewHighWaterMark(n);if(n>state.length){if(!state.ended){state.needReadable=true;return 0}else{return state.length}}return n}Readable.prototype.read=function(n){debug("read",n);var state=this._readableState;var nOrig=n;if(typeof n!=="number"||n>0)state.emittedReadable=false;if(n===0&&state.needReadable&&(state.length>=state.highWaterMark||state.ended)){debug("read: emitReadable",state.length,state.ended);if(state.length===0&&state.ended)endReadable(this);else emitReadable(this);return null}n=howMuchToRead(n,state);if(n===0&&state.ended){if(state.length===0)endReadable(this);return null}var doRead=state.needReadable;debug("need readable",doRead);if(state.length===0||state.length-n<state.highWaterMark){doRead=true;debug("length less than watermark",doRead)}if(state.ended||state.reading){doRead=false;debug("reading or ended",doRead)}if(doRead){debug("do read");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);var ret;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(nOrig!==n&&state.ended&&state.length===0)endReadable(this);if(ret!==null)this.emit("data",ret);return ret};function chunkInvalid(state,chunk){var er=null;if(!Buffer.isBuffer(chunk)&&typeof chunk!=="string"&&chunk!==null&&chunk!==undefined&&!state.objectMode){er=new TypeError("Invalid non-string/buffer chunk")}return er}function onEofChunk(stream,state){if(state.ended)return;if(state.decoder){var chunk=state.decoder.end();if(chunk&&chunk.length){state.buffer.push(chunk);state.length+=state.objectMode?1:chunk.length}}state.ended=true;emitReadable(stream)}function emitReadable(stream){var state=stream._readableState;state.needReadable=false;if(!state.emittedReadable){debug("emitReadable",state.flowing);state.emittedReadable=true;if(state.sync)processNextTick(emitReadable_,stream);else emitReadable_(stream)}}function emitReadable_(stream){debug("emit readable");stream.emit("readable");flow(stream)}function maybeReadMore(stream,state){if(!state.readingMore){state.readingMore=true;processNextTick(maybeReadMore_,stream,state)}}function maybeReadMore_(stream,state){var len=state.length;while(!state.reading&&!state.flowing&&!state.ended&&state.length<state.highWaterMark){debug("maybeReadMore read 0");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;debug("pipe count=%d opts=%j",state.pipesCount,pipeOpts);var doEnd=(!pipeOpts||pipeOpts.end!==false)&&dest!==process.stdout&&dest!==process.stderr;var endFn=doEnd?onend:cleanup;if(state.endEmitted)processNextTick(endFn);else src.once("end",endFn);dest.on("unpipe",onunpipe);function onunpipe(readable){debug("onunpipe");if(readable===src){cleanup()}}function onend(){debug("onend");dest.end()}var ondrain=pipeOnDrain(src);dest.on("drain",ondrain);function cleanup(){debug("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);src.removeListener("data",ondata);if(state.awaitDrain&&(!dest._writableState||dest._writableState.needDrain))ondrain()}src.on("data",ondata);function ondata(chunk){debug("ondata");var ret=dest.write(chunk);if(false===ret){debug("false write response, pause",src._readableState.awaitDrain);src._readableState.awaitDrain++;src.pause()}}function onerror(er){debug("onerror",er);unpipe();dest.removeListener("error",onerror);if(EElistenerCount(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(){debug("onfinish");dest.removeListener("close",onclose);unpipe()}dest.once("finish",onfinish);function unpipe(){debug("unpipe");src.unpipe(dest)}dest.emit("pipe",src);if(!state.flowing){debug("pipe resume");src.resume()}return dest};function pipeOnDrain(src){return function(){var state=src._readableState;debug("pipeOnDrain",state.awaitDrain);if(state.awaitDrain)state.awaitDrain--;if(state.awaitDrain===0&&EElistenerCount(src,"data")){state.flowing=true;flow(src)}}}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;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;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"&&false!==this._readableState.flowing){this.resume()}if(ev==="readable"&&this.readable){var state=this._readableState;if(!state.readableListening){state.readableListening=true;state.emittedReadable=false;state.needReadable=true;if(!state.reading){processNextTick(nReadingNextTick,this)}else if(state.length){emitReadable(this,state)}}}return res};Readable.prototype.addListener=Readable.prototype.on;function nReadingNextTick(self){debug("readable nexttick read 0");self.read(0)}Readable.prototype.resume=function(){var state=this._readableState;if(!state.flowing){debug("resume");state.flowing=true;resume(this,state)}return this};function resume(stream,state){if(!state.resumeScheduled){state.resumeScheduled=true;processNextTick(resume_,stream,state)}}function resume_(stream,state){if(!state.reading){debug("resume read 0");stream.read(0)}state.resumeScheduled=false;stream.emit("resume");flow(stream);if(state.flowing&&!state.reading)stream.read(0)}Readable.prototype.pause=function(){debug("call pause flowing=%j",this._readableState.flowing);if(false!==this._readableState.flowing){debug("pause");this._readableState.flowing=false;this.emit("pause")}return this};function flow(stream){var state=stream._readableState;debug("flow",state.flowing);if(state.flowing){do{var chunk=stream.read()}while(null!==chunk&&state.flowing)}}Readable.prototype.wrap=function(stream){var state=this._readableState;var paused=false;var self=this;stream.on("end",function(){debug("wrapped end");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){debug("wrapped data");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(this[i]===undefined&&typeof stream[i]==="function"){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){debug("wrapped _read",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.ended=true;processNextTick(endReadableNT,state,stream)}}function endReadableNT(state,stream){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"))},{"./_stream_duplex":9,_process:7,buffer:2,"core-util-is":14,events:6,inherits:8,isarray:15,"process-nextick-args":16,"string_decoder/":17,util:1}],12:[function(require,module,exports){"use strict";module.exports=Transform;var Duplex=require("./_stream_duplex");var util=require("core-util-is");util.inherits=require("inherits");util.inherits(Transform,Duplex);function TransformState(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);this._transformState=new TransformState(this);var stream=this;this._readableState.needReadable=true;this._readableState.sync=false;if(options){if(typeof options.transform==="function")this._transform=options.transform;if(typeof options.flush==="function")this._flush=options.flush}this.once("prefinish",function(){if(typeof this._flush==="function")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 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":9,"core-util-is":14,inherits:8}],13:[function(require,module,exports){"use strict";module.exports=Writable;var processNextTick=require("process-nextick-args");var Buffer=require("buffer").Buffer;Writable.WritableState=WritableState;var util=require("core-util-is");util.inherits=require("inherits");var internalUtil={deprecate:require("util-deprecate")};var Stream;(function(){try{Stream=require("st"+"ream")}catch(_){}finally{if(!Stream)Stream=require("events").EventEmitter}})();var Buffer=require("buffer").Buffer;util.inherits(Writable,Stream);function nop(){}function WriteReq(chunk,encoding,cb){this.chunk=chunk;this.encoding=encoding;this.callback=cb;this.next=null}function WritableState(options,stream){var Duplex=require("./_stream_duplex");options=options||{};this.objectMode=!!options.objectMode;if(stream instanceof Duplex)this.objectMode=this.objectMode||!!options.writableObjectMode;var hwm=options.highWaterMark;var defaultHwm=this.objectMode?16:16*1024;this.highWaterMark=hwm||hwm===0?hwm:defaultHwm;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.corked=0;this.sync=true;this.bufferProcessing=false;this.onwrite=function(er){onwrite(stream,er)};this.writecb=null;this.writelen=0;this.bufferedRequest=null;this.lastBufferedRequest=null;this.pendingcb=0;this.prefinished=false;this.errorEmitted=false}WritableState.prototype.getBuffer=function writableStateGetBuffer(){var current=this.bufferedRequest;var out=[];while(current){out.push(current);current=current.next}return out};(function(){try{Object.defineProperty(WritableState.prototype,"buffer",{get:internalUtil.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer "+"instead.")})}catch(_){}})();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;if(options){if(typeof options.write==="function")this._write=options.write;if(typeof options.writev==="function")this._writev=options.writev}Stream.call(this)}Writable.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))};function writeAfterEnd(stream,cb){var er=new Error("write after end");stream.emit("error",er);processNextTick(cb,er)}function validChunk(stream,state,chunk,cb){var valid=true;if(!Buffer.isBuffer(chunk)&&typeof chunk!=="string"&&chunk!==null&&chunk!==undefined&&!state.objectMode){var er=new TypeError("Invalid non-string/buffer chunk");stream.emit("error",er);processNextTick(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=nop;if(state.ended)writeAfterEnd(this,cb);else if(validChunk(this,state,chunk,cb)){state.pendingcb++;ret=writeOrBuffer(this,state,chunk,encoding,cb)}return ret};Writable.prototype.cork=function(){var state=this._writableState;state.corked++};Writable.prototype.uncork=function(){var state=this._writableState;if(state.corked){state.corked--;if(!state.writing&&!state.corked&&!state.finished&&!state.bufferProcessing&&state.bufferedRequest)clearBuffer(this,state)}};Writable.prototype.setDefaultEncoding=function setDefaultEncoding(encoding){if(typeof encoding==="string")encoding=encoding.toLowerCase();if(!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((encoding+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+encoding);this._writableState.defaultEncoding=encoding};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.corked){var last=state.lastBufferedRequest;state.lastBufferedRequest=new WriteReq(chunk,encoding,cb);if(last){last.next=state.lastBufferedRequest}else{state.bufferedRequest=state.lastBufferedRequest}}else{doWrite(stream,state,false,len,chunk,encoding,cb)}return ret}function doWrite(stream,state,writev,len,chunk,encoding,cb){state.writelen=len;state.writecb=cb;state.writing=true;state.sync=true;if(writev)stream._writev(chunk,state.onwrite);else stream._write(chunk,encoding,state.onwrite);state.sync=false}function onwriteError(stream,state,sync,er,cb){--state.pendingcb;if(sync)processNextTick(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(state);if(!finished&&!state.corked&&!state.bufferProcessing&&state.bufferedRequest){clearBuffer(stream,state)}if(sync){processNextTick(afterWrite,stream,state,finished,cb)}else{afterWrite(stream,state,finished,cb)}}}function afterWrite(stream,state,finished,cb){if(!finished)onwriteDrain(stream,state);state.pendingcb--;cb();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;var entry=state.bufferedRequest;if(stream._writev&&entry&&entry.next){var buffer=[];var cbs=[];while(entry){cbs.push(entry.callback);buffer.push(entry);entry=entry.next}state.pendingcb++;state.lastBufferedRequest=null;doWrite(stream,state,true,state.length,buffer,"",function(err){for(var i=0;i<cbs.length;i++){state.pendingcb--;cbs[i](err)}})}else{while(entry){var chunk=entry.chunk;var encoding=entry.encoding;var cb=entry.callback;var len=state.objectMode?1:chunk.length;doWrite(stream,state,false,len,chunk,encoding,cb);entry=entry.next;if(state.writing){break}}if(entry===null)state.lastBufferedRequest=null}state.bufferedRequest=entry;state.bufferProcessing=false}Writable.prototype._write=function(chunk,encoding,cb){cb(new Error("not implemented"))};Writable.prototype._writev=null;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(chunk!==null&&chunk!==undefined)this.write(chunk,encoding);if(state.corked){state.corked=1;this.uncork()}if(!state.ending&&!state.finished)endWritable(this,state,cb)};function needFinish(state){return state.ending&&state.length===0&&state.bufferedRequest===null&&!state.finished&&!state.writing}function prefinish(stream,state){if(!state.prefinished){state.prefinished=true;stream.emit("prefinish")}}function finishMaybe(stream,state){var need=needFinish(state);if(need){if(state.pendingcb===0){prefinish(stream,state);state.finished=true;stream.emit("finish")}else{prefinish(stream,state)}}return need}function endWritable(stream,state,cb){state.ending=true;finishMaybe(stream,state);if(cb){if(state.finished)processNextTick(cb);else stream.once("finish",cb)}state.ended=true}},{"./_stream_duplex":9,buffer:2,"core-util-is":14,events:6,inherits:8,"process-nextick-args":16,"util-deprecate":18}],14:[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}],15:[function(require,module,exports){module.exports=Array.isArray||function(arr){return Object.prototype.toString.call(arr)=="[object Array]"}},{}],16:[function(require,module,exports){(function(process){"use strict";module.exports=nextTick;function nextTick(fn){var args=new Array(arguments.length-1);var i=0;while(i<args.length){args[i++]=arguments[i]}process.nextTick(function afterTick(){fn.apply(null,args)})}}).call(this,require("_process"))},{_process:7}],17:[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="";while(this.charLength){var available=buffer.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:buffer.length;buffer.copy(this.charBuffer,this.charReceived,0,available);this.charReceived+=available;if(this.charReceived<this.charLength){return""}buffer=buffer.slice(available,buffer.length);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(buffer.length===0){return charStr}break}this.detectIncompleteChar(buffer);var end=buffer.length;if(this.charLength){buffer.copy(this.charBuffer,0,buffer.length-this.charReceived,end);end-=this.charReceived}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);buffer.copy(this.charBuffer,0,0,size);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}}this.charReceived=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){this.charReceived=buffer.length%2;this.charLength=this.charReceived?2:0}function base64DetectIncompleteChar(buffer){this.charReceived=buffer.length%3;this.charLength=this.charReceived?3:0}},{buffer:2}],18:[function(require,module,exports){(function(global){module.exports=deprecate;function deprecate(fn,msg){if(config("noDeprecation")){return fn}var warned=false;function deprecated(){if(!warned){if(config("throwDeprecation")){throw new Error(msg)}else if(config("traceDeprecation")){console.trace(msg)}else{console.warn(msg)}warned=true}return fn.apply(this,arguments)}return deprecated}function config(name){try{if(!global.localStorage)return false}catch(_){return false}var val=global.localStorage[name];if(null==val)return false;return String(val).toLowerCase()==="true"}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],19:[function(require,module,exports){var Stream=function(){try{return require("st"+"ream")}catch(_){}}();exports=module.exports=require("./lib/_stream_readable.js");exports.Stream=Stream||exports;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":9,"./lib/_stream_passthrough.js":10,"./lib/_stream_readable.js":11,"./lib/_stream_transform.js":12,"./lib/_stream_writable.js":13}],from2:[function(require,module,exports){(function(process){var Readable=require("readable-stream").Readable;var inherits=require("inherits");module.exports=from2;from2.ctor=ctor;from2.obj=obj;var Proto=ctor();function toFunction(list){list=list.slice();return function(_,cb){var err=null;var item=list.length?list.shift():null;if(item instanceof Error){err=item;item=null}cb(err,item)}}function from2(opts,read){if(typeof opts!=="object"||Array.isArray(opts)){read=opts;opts={}}var rs=new Proto(opts);rs._from=Array.isArray(read)?toFunction(read):read;return rs}function ctor(opts,read){if(typeof opts==="function"){read=opts;opts={}}opts=defaults(opts);inherits(Class,Readable);function Class(override){if(!(this instanceof Class))return new Class(override);this._reading=false;this.destroyed=false;Readable.call(this,override||opts)}Class.prototype._from=read;Class.prototype._read=function(size){var self=this;if(this._reading||this.destroyed)return;this._reading=true;this._from(size,check);function check(err,data){if(self.destroyed)return;if(err)return self.destroy(err);if(data===null)return self.push(null);self._reading=false;if(self.push(data))self._read()}};Class.prototype.destroy=function(err){if(this.destroyed)return;this.destroyed=true;var self=this;process.nextTick(function(){if(err)self.emit("error",err);self.emit("close")})};return Class}function obj(opts,read){if(typeof opts==="function"||Array.isArray(opts)){read=opts;opts={}}opts=defaults(opts);opts.objectMode=true;opts.highWaterMark=16;return from2(opts,read)}function defaults(opts){opts=opts||{};return opts}}).call(this,require("_process"))},{_process:7,inherits:8,"readable-stream":19}]},{},[]);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){var process=module.exports={};process.nextTick=function(){var canSetImmediate=typeof window!=="undefined"&&window.setImmediate;var canMutationObserver=typeof window!=="undefined"&&window.MutationObserver;var canPost=typeof window!=="undefined"&&window.postMessage&&window.addEventListener;if(canSetImmediate){return function(f){return window.setImmediate(f)}}var queue=[];if(canMutationObserver){var hiddenDiv=document.createElement("div");var observer=new MutationObserver(function(){var queueList=queue.slice();queue.length=0;queueList.forEach(function(fn){fn()})});observer.observe(hiddenDiv,{attributes:true});return function nextTick(fn){if(!queue.length){hiddenDiv.setAttribute("yes","no")}queue.push(fn)}}if(canPost){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")}},{}],2:[function(require,module,exports){var Promise=require("./Promise");module.exports=LinkedList;function LinkedList(){this.head=null;this.length=0}LinkedList.prototype.add=function(x){if(this.head!==null){this.head.prev=x;x.next=this.head}this.head=x;++this.length};LinkedList.prototype.remove=function(x){--this.length;if(x===this.head){this.head=this.head.next}if(x.next!==null){x.next.prev=x.prev;x.next=null}if(x.prev!==null){x.prev.next=x.next;x.prev=null}};LinkedList.prototype.isEmpty=function(){return this.length===0};LinkedList.prototype.dispose=function(){if(this.isEmpty()){return Promise.resolve()}var promises=[];var x=this.head;this.head=null;this.length=0;while(x!==null){promises.push(x.dispose());x=x.next}return Promise.all(promises)}},{"./Promise":3}],3:[function(require,module,exports){var unhandledRejection=require("when/lib/decorators/unhandledRejection");module.exports=unhandledRejection(require("when/lib/Promise"))},{"when/lib/Promise":64,"when/lib/decorators/unhandledRejection":66}],4:[function(require,module,exports){module.exports=Queue;function Queue(capPow2){this._capacity=capPow2||32;this._length=0;this._head=0}Queue.prototype.push=function(x){var len=this._length;this._checkCapacity(len+1);var i=this._head+len&this._capacity-1;this[i]=x;this._length=len+1};Queue.prototype.shift=function(){var head=this._head;var x=this[head];this[head]=void 0;this._head=head+1&this._capacity-1;this._length--;return x};Queue.prototype.isEmpty=function(){return this._length===0};Queue.prototype.length=function(){return this._length};Queue.prototype._checkCapacity=function(size){if(this._capacity<size){this._ensureCapacity(this._capacity<<1)}};Queue.prototype._ensureCapacity=function(capacity){var oldCapacity=this._capacity;this._capacity=capacity;var last=this._head+this._length;if(last>oldCapacity){copy(this,0,this,oldCapacity,last&oldCapacity-1)}};function copy(src,srcIndex,dst,dstIndex,len){for(var j=0;j<len;++j){dst[j+dstIndex]=src[j+srcIndex];src[j+srcIndex]=void 0}}},{}],5:[function(require,module,exports){module.exports=Stream;function Stream(source){this.source=source}},{}],6:[function(require,module,exports){exports.noop=noop;exports.identity=identity;exports.compose=compose;exports.cons=cons;exports.append=append;exports.drop=drop;exports.tail=tail;exports.copy=copy;exports.map=map;exports.reduce=reduce;exports.replace=replace;exports.remove=remove;exports.removeAll=removeAll;exports.findIndex=findIndex;function noop(){}function identity(x){return x}function compose(f,g){return function(x){return f(g(x))}}function cons(x,array){var l=array.length;var a=new Array(l+1);a[0]=x;for(var i=0;i<l;++i){a[i+1]=array[i]}return a}function append(x,a){var l=a.length;var b=new Array(l+1);for(var i=0;i<l;++i){b[i]=a[i]}b[l]=x;return b}function drop(n,array){var l=array.length;if(n>=l){return[]}l-=n;var a=new Array(l);for(var i=0;i<l;++i){a[i]=array[n+i]}return a}function tail(array){return drop(1,array)}function copy(array){var l=array.length;var a=new Array(l);for(var i=0;i<l;++i){a[i]=array[i]}return a}function map(f,array){var l=array.length;var a=new Array(l);for(var i=0;i<l;++i){a[i]=f(array[i])}return a}function reduce(f,z,array){var r=z;for(var i=0,l=array.length;i<l;++i){r=f(r,array[i],i)}return r}function replace(x,i,array){var l=array.length;var a=new Array(l);for(var j=0;j<l;++j){a[j]=i===j?x:array[j]}return a}function remove(index,array){var l=array.length;if(index>=array){return array}if(l===1){return[]}l-=1;var b=new Array(l);var i;for(i=0;i<index;++i){b[i]=array[i]}for(i=index;i<l;++i){b[i]=array[i+1]}return b}function removeAll(f,a){var l=a.length;var b=new Array(l);for(var x,i=0,j=0;i<l;++i){x=a[i];if(!f(x)){b[j]=x;++j}}b.length=j;return b}function findIndex(x,a){for(var i=0,l=a.length;i<l;++i){if(x===a[i]){return i}}return-1}},{}],7:[function(require,module,exports){var Stream=require("../Stream");var Pipe=require("../sink/Pipe");var runSource=require("../runSource");var noop=require("../base").noop;exports.scan=scan;exports.reduce=reduce;function scan(f,initial,stream){return new Stream(new Scan(f,initial,stream.source))}function Scan(f,z,source){this.f=f;this.value=z;this.source=source}Scan.prototype.run=function(sink,scheduler){return this.source.run(new ScanSink(this.f,this.value,sink),scheduler)};function ScanSink(f,z,sink){this.f=f;this.value=z;this.sink=sink;this.init=true}ScanSink.prototype.event=function(t,x){if(this.init){this.init=false;this.sink.event(t,this.value)}var f=this.f;this.value=f(this.value,x);this.sink.event(t,this.value)};ScanSink.prototype.error=Pipe.prototype.error;ScanSink.prototype.end=function(t){this.sink.end(t,this.value)};function reduce(f,initial,stream){return runSource.withDefaultScheduler(noop,new Accumulate(f,initial,stream.source))}function Accumulate(f,z,source){this.f=f;this.value=z;this.source=source}Accumulate.prototype.run=function(sink,scheduler){return this.source.run(new AccumulateSink(this.f,this.value,sink),scheduler)};function AccumulateSink(f,z,sink){this.f=f;this.value=z;this.sink=sink}AccumulateSink.prototype.event=function(t,x){var f=this.f;this.value=f(this.value,x);this.sink.event(t,this.value)};AccumulateSink.prototype.error=Pipe.prototype.error;AccumulateSink.prototype.end=function(t){this.sink.end(t,this.value)}},{"../Stream":5,"../base":6,"../runSource":44,"../sink/Pipe":51}],8:[function(require,module,exports){var combine=require("./combine").combine;exports.ap=ap;function ap(fs,xs){return combine(apply,fs,xs)}function apply(f,x){return f(x)}},{"./combine":10}],9:[function(require,module,exports){var Stream=require("../Stream");var streamOf=require("../source/core").of;var fromArray=require("../source/fromArray").fromArray;var concatMap=require("./concatMap").concatMap;var Sink=require("../sink/Pipe");var Promise=require("../Promise");var identity=require("../base").identity;exports.concat=concat;exports.cycle=cycle;exports.cons=cons;function cons(x,stream){return concat(streamOf(x),stream)}function concat(left,right){return concatMap(identity,fromArray([left,right]))}function cycle(stream){return new Stream(new Cycle(stream.source))}function Cycle(source){this.source=source}Cycle.prototype.run=function(sink,scheduler){return new CycleSink(this.source,sink,scheduler)};function CycleSink(source,sink,scheduler){this.active=true;this.sink=sink;this.scheduler=scheduler;this.source=source;this.disposable=source.run(this,scheduler)}CycleSink.prototype.error=Sink.prototype.error;CycleSink.prototype.event=function(t,x){if(!this.active){return}this.sink.event(t,x)};CycleSink.prototype.end=function(t){if(!this.active){return}var self=this;Promise.resolve(this.disposable.dispose()).catch(function(e){self.error(t,e)});this.disposable=this.source.run(this,this.scheduler)};CycleSink.prototype.dispose=function(){this.active=false;return this.disposable.dispose()}},{"../Promise":3,"../Stream":5,"../base":6,"../sink/Pipe":51,"../source/core":54,"../source/fromArray":57,"./concatMap":11}],10:[function(require,module,exports){var Stream=require("../Stream");var transform=require("./transform");var core=require("../source/core");var Pipe=require("../sink/Pipe");var IndexSink=require("../sink/IndexSink");var CompoundDisposable=require("../disposable/CompoundDisposable");var base=require("../base");var invoke=require("../invoke");var hasValue=IndexSink.hasValue;var getValue=IndexSink.getValue;var map=base.map;var tail=base.tail;exports.combineArray=combineArray;exports.combine=combine;function combine(f){return new Stream(new Combine(f,map(getSource,tail(arguments))))}function combineArray(f,streams){return streams.length===0?core.empty():streams.length===1?transform.map(f,streams[0]):new Stream(new Combine(f,map(getSource,streams)))}function getSource(stream){return stream.source}function Combine(f,sources){this.f=f;this.sources=sources}Combine.prototype.run=function(sink,scheduler){var l=this.sources.length;var disposables=new Array(l);var sinks=new Array(l);var combineSink=new CombineSink(this.f,sinks,sink);for(var indexSink,i=0;i<l;++i){indexSink=sinks[i]=new IndexSink(i,combineSink);disposables[i]=this.sources[i].run(indexSink,scheduler)}return new CompoundDisposable(disposables)};function CombineSink(f,sinks,sink){this.f=f;this.sinks=sinks;this.sink=sink;this.ready=false;this.activeCount=sinks.length}CombineSink.prototype.event=function(t){if(!this.ready){this.ready=this.sinks.every(hasValue)}if(this.ready){this.sink.event(t,invoke(this.f,map(getValue,this.sinks)))}};CombineSink.prototype.end=function(t,indexedValue){if(--this.activeCount===0){this.sink.end(t,indexedValue.value)}};CombineSink.prototype.error=Pipe.prototype.error},{"../Stream":5,"../base":6,"../disposable/CompoundDisposable":35,"../invoke":42,"../sink/IndexSink":49,"../sink/Pipe":51,"../source/core":54,"./transform":31}],11:[function(require,module,exports){var mergeConcurrently=require("./mergeConcurrently").mergeConcurrently;var map=require("./transform").map;exports.concatMap=concatMap;function concatMap(f,stream){return mergeConcurrently(1,map(f,stream))}},{"./mergeConcurrently":21,"./transform":31}],12:[function(require,module,exports){var Stream=require("../Stream");var Sink=require("../sink/Pipe");var CompoundDisposable=require("../disposable/CompoundDisposable");var PropagateTask=require("../scheduler/PropagateTask");exports.delay=delay;function delay(delayTime,stream){return delayTime<=0?stream:new Stream(new Delay(delayTime,stream.source))}function Delay(dt,source){this.dt=dt;this.source=source}Delay.prototype.run=function(sink,scheduler){var delaySink=new DelaySink(this.dt,sink,scheduler);return new CompoundDisposable([delaySink,this.source.run(delaySink,scheduler)])};function DelaySink(dt,sink,scheduler){this.dt=dt;this.sink=sink;this.scheduler=scheduler}DelaySink.prototype.dispose=function(){var self=this;this.scheduler.cancelAll(function(task){return task.sink===self.sink})};DelaySink.prototype.event=function(t,x){this.scheduler.delay(this.dt,PropagateTask.event(x,this.sink))};DelaySink.prototype.end=function(t,x){this.scheduler.delay(this.dt,PropagateTask.end(x,this.sink))};DelaySink.prototype.error=Sink.prototype.error},{"../Stream":5,"../disposable/CompoundDisposable":35,"../scheduler/PropagateTask":45,"../sink/Pipe":51}],13:[function(require,module,exports){var Stream=require("../Stream");var ValueSource=require("../source/ValueSource");exports.flatMapError=flatMapError;exports.throwError=throwError;function flatMapError(f,stream){return new Stream(new FlatMapError(f,stream.source))}function throwError(e){return new Stream(new ValueSource(error,e))}function error(t,e,sink){sink.error(t,e)}function FlatMapError(f,source){
this.f=f;this.source=source}FlatMapError.prototype.run=function(sink,scheduler){return new FlatMapErrorSink(this.f,this.source,sink,scheduler)};function FlatMapErrorSink(f,source,sink,scheduler){this.f=f;this.sink=sink;this.scheduler=scheduler;this.active=true;this.disposable=source.run(this,scheduler)}FlatMapErrorSink.prototype.error=function(t,e){if(!this.active){return}this.disposable.dispose();var f=this.f;var stream=f(e);this.disposable=stream.source.run(this.sink,this.scheduler)};FlatMapErrorSink.prototype.event=function(t,x){if(!this.active){return}this.sink.event(t,x)};FlatMapErrorSink.prototype.end=function(t,x){if(!this.active){return}this.sink.end(t,x)};FlatMapErrorSink.prototype.dispose=function(){this.active=false;return this.disposable.dispose()}},{"../Stream":5,"../source/ValueSource":53}],14:[function(require,module,exports){var Stream=require("../Stream");var Sink=require("../sink/Pipe");var Filter=require("../fusion/Filter");exports.filter=filter;exports.skipRepeats=skipRepeats;exports.skipRepeatsWith=skipRepeatsWith;function filter(p,stream){return new Stream(Filter.create(p,stream.source))}function skipRepeats(stream){return skipRepeatsWith(same,stream)}function skipRepeatsWith(equals,stream){return new Stream(new SkipRepeats(equals,stream.source))}function SkipRepeats(equals,source){this.equals=equals;this.source=source}SkipRepeats.prototype.run=function(sink,scheduler){return this.source.run(new SkipRepeatsSink(this.equals,sink),scheduler)};function SkipRepeatsSink(equals,sink){this.equals=equals;this.sink=sink;this.value=void 0;this.init=true}SkipRepeatsSink.prototype.end=Sink.prototype.end;SkipRepeatsSink.prototype.error=Sink.prototype.error;SkipRepeatsSink.prototype.event=function(t,x){if(this.init){this.init=false;this.value=x;this.sink.event(t,x)}else if(!this.equals(this.value,x)){this.value=x;this.sink.event(t,x)}};function same(a,b){return a===b}},{"../Stream":5,"../fusion/Filter":39,"../sink/Pipe":51}],15:[function(require,module,exports){var mergeConcurrently=require("./mergeConcurrently").mergeConcurrently;var map=require("./transform").map;exports.flatMap=flatMap;exports.join=join;function flatMap(f,stream){return join(map(f,stream))}function join(stream){return mergeConcurrently(Infinity,stream)}},{"./mergeConcurrently":21,"./transform":31}],16:[function(require,module,exports){var Stream=require("../Stream");var Sink=require("../sink/Pipe");var AwaitingDisposable=require("../disposable/AwaitingDisposable");var CompoundDisposable=require("../disposable/CompoundDisposable");exports.flatMapEnd=flatMapEnd;function flatMapEnd(f,stream){return new Stream(new FlatMapEnd(f,stream.source))}function FlatMapEnd(f,source){this.f=f;this.source=source}FlatMapEnd.prototype.run=function(sink,scheduler){return new FlatMapEndSink(this.f,this.source,sink,scheduler)};function FlatMapEndSink(f,source,sink,scheduler){this.f=f;this.sink=sink;this.scheduler=scheduler;this.active=true;this.disposable=new AwaitingDisposable(source.run(this,scheduler))}FlatMapEndSink.prototype.error=Sink.prototype.error;FlatMapEndSink.prototype.event=function(t,x){if(!this.active){return}this.sink.event(t,x)};FlatMapEndSink.prototype.end=function(t,x){if(!this.active){return}this.dispose();var f=this.f;var stream=f(x);var disposable=stream.source.run(this.sink,this.scheduler);this.disposable=new CompoundDisposable([this.disposable,disposable])};FlatMapEndSink.prototype.dispose=function(){this.active=false;return this.disposable.dispose()}},{"../Stream":5,"../disposable/AwaitingDisposable":34,"../disposable/CompoundDisposable":35,"../sink/Pipe":51}],17:[function(require,module,exports){var combine=require("./combine").combineArray;var paramsRx=/\(([^)]*)/;var liftedSuffix="_most$Stream$lifted";exports.lift=lift;function lift(f){var m=paramsRx.exec(f.toString());var body="return function "+f.name+liftedSuffix+" ("+m[1]+") {\n"+" return combine(f, arguments);\n"+"};";return new Function("combine","f",body)(combine,f)}},{"./combine":10}],18:[function(require,module,exports){var Stream=require("../Stream");var Sink=require("../sink/Pipe");var CompoundDisposable=require("../disposable/CompoundDisposable");var PropagateTask=require("../scheduler/PropagateTask");exports.throttle=throttle;exports.debounce=debounce;function throttle(period,stream){return new Stream(new Throttle(period,stream.source))}function Throttle(period,source){this.dt=period;this.source=source}Throttle.prototype.run=function(sink,scheduler){return this.source.run(new ThrottleSink(this.dt,sink),scheduler)};function ThrottleSink(dt,sink){this.time=0;this.dt=dt;this.sink=sink}ThrottleSink.prototype.event=function(t,x){if(t>=this.time){this.time=t+this.dt;this.sink.event(t,x)}};ThrottleSink.prototype.end=function(t,e){return Sink.prototype.end.call(this,t,e)};ThrottleSink.prototype.error=Sink.prototype.error;function debounce(period,stream){return new Stream(new Debounce(period,stream.source))}function Debounce(dt,source){this.dt=dt;this.source=source}Debounce.prototype.run=function(sink,scheduler){return new DebounceSink(this.dt,this.source,sink,scheduler)};function DebounceSink(dt,source,sink,scheduler){this.dt=dt;this.sink=sink;this.scheduler=scheduler;this.value=void 0;this.timer=null;var sourceDisposable=source.run(this,scheduler);this.disposable=new CompoundDisposable([this,sourceDisposable])}DebounceSink.prototype.event=function(t,x){this._clearTimer();this.value=x;this.timer=this.scheduler.delay(this.dt,PropagateTask.event(x,this.sink))};DebounceSink.prototype.end=function(t,x){if(this._clearTimer()){this.sink.event(t,this.value);this.value=void 0}this.sink.end(t,x)};DebounceSink.prototype.error=function(t,x){this._clearTimer();this.sink.error(t,x)};DebounceSink.prototype.dispose=function(){this._clearTimer()};DebounceSink.prototype._clearTimer=function(){if(this.timer===null){return false}this.timer.cancel();this.timer=null;return true}},{"../Stream":5,"../disposable/CompoundDisposable":35,"../scheduler/PropagateTask":45,"../sink/Pipe":51}],19:[function(require,module,exports){var Stream=require("../Stream");var Pipe=require("../sink/Pipe");exports.loop=loop;function loop(stepper,seed,stream){return new Stream(new Loop(stepper,seed,stream.source))}function Loop(stepper,seed,source){this.step=stepper;this.seed=seed;this.source=source}Loop.prototype.run=function(sink,scheduler){return this.source.run(new LoopSink(this.step,this.seed,sink),scheduler)};function LoopSink(stepper,seed,sink){this.step=stepper;this.seed=seed;this.sink=sink}LoopSink.prototype.error=Pipe.prototype.error;LoopSink.prototype.event=function(t,x){var result=this.step(this.seed,x);this.seed=result.seed;this.sink.event(t,result.value)};LoopSink.prototype.end=function(t){this.sink.end(t,this.seed)}},{"../Stream":5,"../sink/Pipe":51}],20:[function(require,module,exports){var empty=require("../Stream").empty;var fromArray=require("../source/fromArray").fromArray;var mergeConcurrently=require("./mergeConcurrently").mergeConcurrently;var copy=require("../base").copy;exports.merge=merge;exports.mergeArray=mergeArray;function merge(){return mergeArray(copy(arguments))}function mergeArray(streams){var l=streams.length;return l===0?empty():l===1?streams[0]:mergeConcurrently(l,fromArray(streams))}},{"../Stream":5,"../base":6,"../source/fromArray":57,"./mergeConcurrently":21}],21:[function(require,module,exports){var Stream=require("../Stream");var AwaitingDisposable=require("../disposable/AwaitingDisposable");var LinkedList=require("../LinkedList");var Promise=require("../Promise");exports.mergeConcurrently=mergeConcurrently;function mergeConcurrently(concurrency,stream){return new Stream(new MergeConcurrently(concurrency,stream.source))}function MergeConcurrently(concurrency,source){this.concurrency=concurrency;this.source=source}MergeConcurrently.prototype.run=function(sink,scheduler){return new Outer(this.concurrency,this.source,sink,scheduler)};function Outer(concurrency,source,sink,scheduler){this.concurrency=concurrency;this.sink=sink;this.scheduler=scheduler;this.pending=[];this.current=new LinkedList;this.disposable=new AwaitingDisposable(source.run(this,scheduler));this.active=true}Outer.prototype.event=function(t,x){this._addInner(t,x)};Outer.prototype._addInner=function(t,stream){if(this.current.length<this.concurrency){this._startInner(t,stream)}else{this.pending.push(stream)}};Outer.prototype._startInner=function(t,stream){var innerSink=new Inner(t,this,this.sink);this.current.add(innerSink);innerSink.disposable=stream.source.run(innerSink,this.scheduler)};Outer.prototype.end=function(t,x){this.active=false;this.disposable.dispose();this._checkEnd(t,x)};Outer.prototype.error=function(t,e){this.active=false;this.sink.error(t,e)};Outer.prototype.dispose=function(){this.active=false;this.pending.length=0;return Promise.all([this.disposable.dispose(),this.current.dispose()])};Outer.prototype._endInner=function(t,x,inner){this.current.remove(inner);var self=this;Promise.resolve(inner.dispose()).catch(function(e){self.error(t,e)});if(this.pending.length===0){this._checkEnd(t,x)}else{this._startInner(t,this.pending.shift())}};Outer.prototype._checkEnd=function(t,x){if(!this.active&&this.current.isEmpty()){this.sink.end(t,x)}};function Inner(time,outer,sink){this.prev=this.next=null;this.time=time;this.outer=outer;this.sink=sink;this.disposable=void 0}Inner.prototype.event=function(t,x){this.sink.event(Math.max(t,this.time),x)};Inner.prototype.end=function(t,x){this.outer._endInner(Math.max(t,this.time),x,this)};Inner.prototype.error=function(t,e){this.outer.error(Math.max(t,this.time),e)};Inner.prototype.dispose=function(){return this.disposable.dispose()}},{"../LinkedList":2,"../Promise":3,"../Stream":5,"../disposable/AwaitingDisposable":34}],22:[function(require,module,exports){var Stream=require("../Stream");var MulticastSource=require("../source/MulticastSource");exports.multicast=multicast;function multicast(stream){var source=stream.source;return source instanceof MulticastSource?stream:new Stream(new MulticastSource(source))}},{"../Stream":5,"../source/MulticastSource":52}],23:[function(require,module,exports){var runSource=require("../runSource");var noop=require("../base").noop;exports.observe=observe;exports.drain=drain;function observe(f,stream){return runSource.withDefaultScheduler(f,stream.source)}function drain(stream){return runSource.withDefaultScheduler(noop,stream.source)}},{"../base":6,"../runSource":44}],24:[function(require,module,exports){var Stream=require("../Stream");var resolve=require("../Promise").resolve;var fatal=require("../fatalError");exports.fromPromise=fromPromise;exports.await=await;function fromPromise(p){return new Stream(new PromiseSource(p))}function PromiseSource(p){this.promise=p}PromiseSource.prototype.run=function(sink,scheduler){return new PromiseProducer(this.promise,sink,scheduler)};function PromiseProducer(p,sink,scheduler){this.sink=sink;this.scheduler=scheduler;this.active=true;var self=this;resolve(p).then(function(x){self._emit(self.scheduler.now(),x)}).catch(function(e){self._error(self.scheduler.now(),e)})}PromiseProducer.prototype._emit=function(t,x){if(!this.active){return}this.sink.event(t,x);this.sink.end(t,void 0)};PromiseProducer.prototype._error=function(t,e){if(!this.active){return}this.sink.error(t,e)};PromiseProducer.prototype.dispose=function(){this.active=false};function await(stream){return new Stream(new Await(stream.source))}function Await(source){this.source=source}Await.prototype.run=function(sink,scheduler){return this.source.run(new AwaitSink(sink,scheduler),scheduler)};function AwaitSink(sink,scheduler){this.sink=sink;this.scheduler=scheduler;this.queue=void 0}AwaitSink.prototype.event=function(t,promise){var self=this;this.queue=resolve(this.queue).then(function(){return self._event(t,promise)}).catch(function(e){return self._error(t,e)})};AwaitSink.prototype.end=function(t,x){var self=this;this.queue=resolve(this.queue).then(function(){return self._end(t,x)}).catch(function(e){return self._error(t,e)})};AwaitSink.prototype.error=function(t,e){var self=this;this.queue=resolve(this.queue).then(function(){return self._error(t,e)}).catch(fatal)};AwaitSink.prototype._error=function(t,e){try{this.sink.error(Math.max(t,this.scheduler.now()),e)}catch(e){fatal(e);throw e}};AwaitSink.prototype._event=function(t,promise){var self=this;return promise.then(function(x){self.sink.event(Math.max(t,self.scheduler.now()),x)})};AwaitSink.prototype._end=function(t,x){var self=this;return resolve(x).then(function(x){self.sink.end(Math.max(t,self.scheduler.now()),x)})}},{"../Promise":3,"../Stream":5,"../fatalError":38}],25:[function(require,module,exports){var Stream=require("../Stream");var Pipe=require("../sink/Pipe");var CompoundDisposable=require("../disposable/CompoundDisposable");var base=require("../base");var invoke=require("../invoke");exports.sample=sample;exports.sampleWith=sampleWith;exports.sampleArray=sampleArray;function sample(f,sampler){return sampleArray(f,sampler,base.drop(2,arguments))}function sampleWith(sampler,stream){return new Stream(new Sampler(base.identity,sampler.source,[stream.source]))}function sampleArray(f,sampler,streams){return new Stream(new Sampler(f,sampler.source,base.map(getSource,streams)))}function getSource(stream){return stream.source}function Sampler(f,sampler,sources){this.f=f;this.sampler=sampler;this.sources=sources}Sampler.prototype.run=function(sink,scheduler){var l=this.sources.length;var disposables=new Array(l+1);var sinks=new Array(l);var sampleSink=new SampleSink(this.f,sinks,sink);for(var hold,i=0;i<l;++i){hold=sinks[i]=new Hold(sampleSink);disposables[i]=this.sources[i].run(hold,scheduler)}disposables[i]=this.sampler.run(sampleSink,scheduler);return new CompoundDisposable(disposables)};function Hold(sink){this.sink=sink;this.hasValue=false}Hold.prototype.event=function(t,x){this.value=x;this.hasValue=true;this.sink._notify(this)};Hold.prototype.end=base.noop;Hold.prototype.error=Pipe.prototype.error;function SampleSink(f,sinks,sink){this.f=f;this.sinks=sinks;this.sink=sink;this.active=false}SampleSink.prototype._notify=function(){if(!this.active){this.active=this.sinks.every(hasValue)}};SampleSink.prototype.event=function(t){if(this.active){this.sink.event(t,invoke(this.f,base.map(getValue,this.sinks)))}};SampleSink.prototype.end=Pipe.prototype.end;SampleSink.prototype.error=Pipe.prototype.error;function hasValue(hold){return hold.hasValue}function getValue(hold){return hold.value}},{"../Stream":5,"../base":6,"../disposable/CompoundDisposable":35,"../invoke":42,"../sink/Pipe":51}],26:[function(require,module,exports){var Stream=require("../Stream");var Sink=require("../sink/Pipe");var core=require("../source/core");var AwaitingDisposable=require("../disposable/AwaitingDisposable");exports.take=take;exports.skip=skip;exports.slice=slice;exports.takeWhile=takeWhile;exports.skipWhile=skipWhile;function take(n,stream){return slice(0,n,stream)}function skip(n,stream){return slice(n,Infinity,stream)}function slice(start,end,stream){return end<=start?core.empty():new Stream(new Slice(start,end,stream.source))}function Slice(min,max,source){this.skip=min;this.take=max-min;this.source=source}Slice.prototype.run=function(sink,scheduler){return new SliceSink(this.skip,this.take,this.source,sink,scheduler)};function SliceSink(skip,take,source,sink,scheduler){this.skip=skip;this.take=take;this.sink=sink;this.disposable=new AwaitingDisposable(source.run(this,scheduler))}SliceSink.prototype.end=Sink.prototype.end;SliceSink.prototype.error=Sink.prototype.error;SliceSink.prototype.event=function(t,x){if(this.skip>0){this.skip-=1;return}if(this.take===0){return}this.take-=1;this.sink.event(t,x);if(this.take===0){this.dispose();this.sink.end(t,x)}};SliceSink.prototype.dispose=function(){return this.disposable.dispose()};function takeWhile(p,stream){return new Stream(new TakeWhile(p,stream.source))}function TakeWhile(p,source){this.p=p;this.source=source}TakeWhile.prototype.run=function(sink,scheduler){return new TakeWhileSink(this.p,this.source,sink,scheduler)};function TakeWhileSink(p,source,sink,scheduler){this.p=p;this.sink=sink;this.active=true;this.disposable=new AwaitingDisposable(source.run(this,scheduler))}TakeWhileSink.prototype.end=Sink.prototype.end;TakeWhileSink.prototype.error=Sink.prototype.error;TakeWhileSink.prototype.event=function(t,x){if(!this.active){return}var p=this.p;this.active=p(x);if(this.active){this.sink.event(t,x)}else{this.dispose();this.sink.end(t,x)}};TakeWhileSink.prototype.dispose=function(){return this.disposable.dispose()};function skipWhile(p,stream){return new Stream(new SkipWhile(p,stream.source))}function SkipWhile(p,source){this.p=p;this.source=source}SkipWhile.prototype.run=function(sink,scheduler){return this.source.run(new SkipWhileSink(this.p,sink),scheduler)};function SkipWhileSink(p,sink){this.p=p;this.sink=sink;this.skipping=true}SkipWhileSink.prototype.end=Sink.prototype.end;SkipWhileSink.prototype.error=Sink.prototype.error;SkipWhileSink.prototype.event=function(t,x){if(this.skipping){var p=this.p;this.skipping=p(x);if(this.skipping){return}}this.sink.event(t,x)}},{"../Stream":5,"../disposable/AwaitingDisposable":34,"../sink/Pipe":51,"../source/core":54}],27:[function(require,module,exports){var Stream=require("../Stream");var MulticastSource=require("../source/MulticastSource");var until=require("./timeslice").takeUntil;var mergeConcurrently=require("./mergeConcurrently").mergeConcurrently;var map=require("./transform").map;exports.switch=switchLatest;function switchLatest(stream){var upstream=new Stream(new MulticastSource(stream.source));return mergeConcurrently(1,map(untilNext,upstream));function untilNext(s){return until(upstream,s)}}},{"../Stream":5,"../source/MulticastSource":52,"./mergeConcurrently":21,"./timeslice":28,"./transform":31}],28:[function(require,module,exports){var Stream=require("../Stream");var Pipe=require("../sink/Pipe");var CompoundDisposable=require("../disposable/CompoundDisposable");var never=require("../source/core").never;var join=require("../combinator/flatMap").join;var take=require("../combinator/slice").take;var noop=require("../base").noop;exports.during=during;exports.takeUntil=takeUntil;exports.skipUntil=skipUntil;function takeUntil(signal,stream){return new Stream(new Until(signal.source,stream.source))}function skipUntil(signal,stream){return between(signal,never(),stream)}function during(timeWindow,stream){return between(timeWindow,join(timeWindow),stream)}function between(start,end,stream){return new Stream(new During(take(1,start).source,take(1,end).source,stream.source))}function Until(maxSignal,source){this.maxSignal=maxSignal;this.source=source}Until.prototype.run=function(sink,scheduler){var min=new MinBound(sink);var max=new UpperBound(this.maxSignal,sink,scheduler);var disposable=this.source.run(new TimeWindowSink(min,max,sink),scheduler);return new CompoundDisposable([min,max,disposable])};function MinBound(sink){this.value=-Infinity;this.sink=sink}MinBound.prototype.error=Pipe.prototype.error;MinBound.prototype.event=noop;MinBound.prototype.end=noop;MinBound.prototype.dispose=noop;function During(minSignal,maxSignal,source){this.minSignal=minSignal;this.maxSignal=maxSignal;this.source=source}During.prototype.run=function(sink,scheduler){var min=new LowerBound(this.minSignal,sink,scheduler);var max=new UpperBound(this.maxSignal,sink,scheduler);var disposable=this.source.run(new TimeWindowSink(min,max,sink),scheduler);return new CompoundDisposable([min,max,disposable])};function TimeWindowSink(min,max,sink){this.min=min;this.max=max;this.sink=sink}TimeWindowSink.prototype.event=function(t,x){if(t>=this.min.value&&t<this.max.value){this.sink.event(t,x)}};TimeWindowSink.prototype.error=Pipe.prototype.error;TimeWindowSink.prototype.end=Pipe.prototype.end;function LowerBound(signal,sink,scheduler){this.value=Infinity;this.sink=sink;this.disposable=signal.run(this,scheduler)}LowerBound.prototype.event=function(t){if(t<this.value){this.value=t}};LowerBound.prototype.end=noop;LowerBound.prototype.error=Pipe.prototype.error;LowerBound.prototype.dispose=function(){return this.disposable.dispose()};function UpperBound(signal,sink,scheduler){this.value=Infinity;this.sink=sink;this.disposable=signal.run(this,scheduler)}UpperBound.prototype.event=function(t,x){if(t<this.value){this.value=t;this.sink.end(t,x)}};UpperBound.prototype.end=noop;UpperBound.prototype.error=Pipe.prototype.error;UpperBound.prototype.dispose=function(){return this.disposable.dispose()}},{"../Stream":5,"../base":6,"../combinator/flatMap":15,"../combinator/slice":26,"../disposable/CompoundDisposable":35,"../sink/Pipe":51,"../source/core":54}],29:[function(require,module,exports){var Stream=require("../Stream");var Sink=require("../sink/Pipe");exports.timestamp=timestamp;function timestamp(stream){return new Stream(new Timestamp(stream.source))}function Timestamp(source){this.source=source}Timestamp.prototype.run=function(sink,scheduler){return this.source.run(new TimestampSink(sink),scheduler)};function TimestampSink(sink){this.sink=sink}TimestampSink.prototype.end=Sink.prototype.end;TimestampSink.prototype.error=Sink.prototype.error;TimestampSink.prototype.event=function(t,x){this.sink.event(t,{time:t,value:x})}},{"../Stream":5,"../sink/Pipe":51}],30:[function(require,module,exports){var Stream=require("../Stream");exports.transduce=transduce;function transduce(transducer,stream){return new Stream(new Transduce(transducer,stream.source))}function Transduce(transducer,source){this.transducer=transducer;this.source=source}Transduce.prototype.run=function(sink,scheduler){var xf=this.transducer(new Transformer(sink));return this.source.run(new TransduceSink(getTxHandler(xf),sink),scheduler)};function TransduceSink(adapter,sink){this.xf=adapter;this.sink=sink}TransduceSink.prototype.event=function(t,x){var next=this.xf.step(t,x);return this.xf.isReduced(next)?this.sink.end(t,this.xf.getResult(next)):next};TransduceSink.prototype.end=function(t,x){return this.xf.result(x)};TransduceSink.prototype.error=function(t,e){return this.sink.error(t,e)};function Transformer(sink){this.time=-Infinity;this.sink=sink}Transformer.prototype["@@transducer/init"]=Transformer.prototype.init=function(){};Transformer.prototype["@@transducer/step"]=Transformer.prototype.step=function(t,x){if(!isNaN(t)){this.time=Math.max(t,this.time)}return this.sink.event(this.time,x)};Transformer.prototype["@@transducer/result"]=Transformer.prototype.result=function(x){return this.sink.end(this.time,x)};function getTxHandler(tx){return typeof tx["@@transducer/step"]==="function"?new TxAdapter(tx):new LegacyTxAdapter(tx)}function TxAdapter(tx){this.tx=tx}TxAdapter.prototype.step=function(t,x){return this.tx["@@transducer/step"](t,x)};TxAdapter.prototype.result=function(x){return this.tx["@@transducer/result"](x)};TxAdapter.prototype.isReduced=function(x){return x!=null&&x["@@transducer/reduced"]};TxAdapter.prototype.getResult=function(x){return x["@@transducer/value"]};function LegacyTxAdapter(tx){this.tx=tx}LegacyTxAdapter.prototype.step=function(t,x){return this.tx.step(t,x)};LegacyTxAdapter.prototype.result=function(x){return this.tx.result(x)};LegacyTxAdapter.prototype.isReduced=function(x){return x!=null&&x.__transducers_reduced__};LegacyTxAdapter.prototype.getResult=function(x){return x.value}},{"../Stream":5}],31:[function(require,module,exports){var Stream=require("../Stream");var Map=require("../fusion/Map");exports.map=map;exports.constant=constant;exports.tap=tap;function map(f,stream){return new Stream(Map.create(f,stream.source))}function constant(x,stream){return map(function(){return x},stream)}function tap(f,stream){return map(function(x){f(x);return x},stream)}},{"../Stream":5,"../fusion/Map":41}],32:[function(require,module,exports){var Stream=require("../Stream");var transform=require("./transform");var core=require("../source/core");var Sink=require("../sink/Pipe");var IndexSink=require("../sink/IndexSink");var CompoundDisposable=require("../disposable/CompoundDisposable");var base=require("../base");var invoke=require("../invoke");var Queue=require("../Queue");var map=base.map;var tail=base.tail;exports.zip=zip;exports.zipArray=zipArray;function zip(f){return zipArray(f,tail(arguments))}function zipArray(f,streams){return streams.length===0?core.empty():streams.length===1?transform.map(f,streams[0]):new Stream(new Zip(f,map(getSource,streams)))}function getSource(stream){return stream.source}function Zip(f,sources){this.f=f;this.sources=sources}Zip.prototype.run=function(sink,scheduler){var l=this.sources.length;var disposables=new Array(l);var sinks=new Array(l);var buffers=new Array(l);var zipSink=new ZipSink(this.f,buffers,sinks,sink);for(var indexSink,i=0;i<l;++i){buffers[i]=new Queue;indexSink=sinks[i]=new IndexSink(i,zipSink);disposables[i]=this.sources[i].run(indexSink,scheduler)}return new CompoundDisposable(disposables)};function ZipSink(f,buffers,sinks,sink){this.f=f;this.sinks=sinks;this.sink=sink;this.buffers=buffers}ZipSink.prototype.event=function(t,indexedValue){var buffers=this.buffers;var buffer=buffers[indexedValue.index];buffer.push(indexedValue.value);if(buffer.length()===1){if(!ready(this.buffers)){return}emitZipped(this.f,t,buffers,this.sink);if(ended(this.buffers,this.sinks)){this.sink.end(t,void 0)}}};ZipSink.prototype.end=function(t,indexedValue){var buffer=this.buffers[indexedValue.index];if(buffer.isEmpty()){this.sink.end(t,indexedValue.value)}};ZipSink.prototype.error=Sink.prototype.error;function emitZipped(f,t,buffers,sink){sink.event(t,invoke(f,map(head,buffers)))}function head(buffer){return buffer.shift()}function ended(buffers,sinks){for(var i=0,l=buffers.length;i<l;++i){if(buffers[i].isEmpty()&&!sinks[i].active){return true}}return false}function ready(buffers){for(var i=0,l=buffers.length;i<l;++i){if(buffers[i].isEmpty()){return false}}return true}},{"../Queue":4,"../Stream":5,"../base":6,"../disposable/CompoundDisposable":35,"../invoke":42,"../sink/IndexSink":49,"../sink/Pipe":51,"../source/core":54,"./transform":31}],33:[function(require,module,exports){var Promise=require("./Promise");module.exports=defer;function defer(task){return Promise.resolve(task).then(runTask)}function runTask(task){try{return task.run()}catch(e){return task.error(e)}}},{"./Promise":3}],34:[function(require,module,exports){module.exports=AwaitingDisposable;function AwaitingDisposable(disposable){this.disposed=false;this.disposable=disposable;this.value=void 0}AwaitingDisposable.prototype.dispose=function(){if(!this.disposed){this.disposed=true;this.value=this.disposable.dispose()}return this.value}},{}],35:[function(require,module,exports){var all=require("../Promise").all;var map=require("../base").map;module.exports=CompoundDisposable;function CompoundDisposable(disposables){this.disposed=false;this.disposables=disposables}CompoundDisposable.prototype.dispose=function(){if(this.disposed){return}this.disposed=true;return all(map(dispose,this.disposables))};function dispose(disposable){return disposable.dispose()}},{"../Promise":3,"../base":6}],36:[function(require,module,exports){module.exports=Disposable;function Disposable(f,data){this.disposed=false;this._dispose=f;this._data=data}Disposable.prototype.dispose=function(){if(this.disposed){return}this.disposed=true;return this._dispose(this._data)}},{}],37:[function(require,module,exports){var noop=require("../base").noop;module.exports=EmptyDisposable;function EmptyDisposable(){}EmptyDisposable.prototype.dispose=noop},{"../base":6}],38:[function(require,module,exports){module.exports=fatalError;function fatalError(e){setTimeout(function(){throw e},0)}},{}],39:[function(require,module,exports){var Pipe=require("../sink/Pipe");module.exports=Filter;function Filter(p,source){this.p=p;this.source=source}Filter.create=function createFilter(p,source){if(source instanceof Filter){return new Filter(and(source.p,p),source.source)}return new Filter(p,source)};Filter.prototype.run=function(sink,scheduler){return this.source.run(new FilterSink(this.p,sink),scheduler)};function FilterSink(p,sink){this.p=p;this.sink=sink}FilterSink.prototype.end=Pipe.prototype.end;FilterSink.prototype.error=Pipe.prototype.error;FilterSink.prototype.event=function(t,x){var p=this.p;p(x)&&this.sink.event(t,x)};function and(p,q){return function(x){return p(x)&&q(x)}}},{"../sink/Pipe":51}],40:[function(require,module,exports){var Pipe=require("../sink/Pipe");module.exports=FilterMap;function FilterMap(p,f,source){this.p=p;this.f=f;this.source=source}FilterMap.prototype.run=function(sink,scheduler){return this.source.run(new FilterMapSink(this.p,this.f,sink),scheduler)};function FilterMapSink(p,f,sink){this.p=p;this.f=f;this.sink=sink}FilterMapSink.prototype.event=function(t,x){var f=this.f;var p=this.p;p(x)&&this.sink.event(t,f(x))};FilterMapSink.prototype.end=Pipe.prototype.end;FilterMapSink.prototype.error=Pipe.prototype.error},{"../sink/Pipe":51}],41:[function(require,module,exports){var Pipe=require("../sink/Pipe");var Filter=require("./Filter");var FilterMap=require("./FilterMap");var base=require("../base");module.exports=Map;function Map(f,source){this.f=f;this.source=source}Map.create=function createMap(f,source){if(source instanceof Map){return new Map(base.compose(f,source.f),source.source)}if(source instanceof Filter){return new FilterMap(source.p,f,source.source)}if(source instanceof FilterMap){return new FilterMap(source.p,base.compose(f,source.f),source.source)}return new Map(f,source)};Map.prototype.run=function(sink,scheduler){return this.source.run(new MapSink(this.f,sink),scheduler)};function MapSink(f,sink){this.f=f;this.sink=sink}MapSink.prototype.end=Pipe.prototype.end;MapSink.prototype.error=Pipe.prototype.error;MapSink.prototype.event=function(t,x){var f=this.f;this.sink.event(t,f(x))}},{"../base":6,"../sink/Pipe":51,"./Filter":39,"./FilterMap":40}],42:[function(require,module,exports){module.exports=invoke;function invoke(f,args){switch(args.length){case 0:return f();case 1:return f(args[0]);case 2:return f(args[0],args[1]);case 3:return f(args[0],args[1],args[2]);case 4:return f(args[0],args[1],args[2],args[3]);case 5:return f(args[0],args[1],args[2],args[3],args[4]);default:return f.apply(void 0,args)}}},{}],43:[function(require,module,exports){exports.isIterable=isIterable;exports.getIterator=getIterator;exports.makeIterable=makeIterable;var iteratorSymbol;if(typeof Set==="function"&&typeof(new Set)["@@iterator"]==="function"){iteratorSymbol="@@iterator"}else{iteratorSymbol=typeof Symbol==="function"&&Symbol.iterator||"_es6shim_iterator_"}function isIterable(o){return typeof o[iteratorSymbol]==="function"}function getIterator(o){return o[iteratorSymbol]()}function makeIterable(f,o){o[iteratorSymbol]=f;return o}},{}],44:[function(require,module,exports){var Promise=require("./Promise");var Observer=require("./sink/Observer");var defaultScheduler=require("./scheduler/defaultScheduler");exports.withDefaultScheduler=withDefaultScheduler;exports.withScheduler=withScheduler;function withDefaultScheduler(f,source){return withScheduler(f,source,defaultScheduler)}function withScheduler(f,source,scheduler){return new Promise(function(resolve,reject){var disposable;var observer=new Observer(f,function(x){disposeThen(resolve,reject,disposable,x)},function(e){disposeThen(reject,reject,disposable,e)});disposable=source.run(observer,scheduler)})}function disposeThen(resolve,reject,disposable,x){Promise.resolve(disposable.dispose()).then(function(){resolve(x)},reject)}},{"./Promise":3,"./scheduler/defaultScheduler":47,"./sink/Observer":50}],45:[function(require,module,exports){var fatal=require("../fatalError");module.exports=PropagateTask;function PropagateTask(run,value,sink){this._run=run;this.value=value;this.sink=sink;this.active=true}PropagateTask.event=function(value,sink){return new PropagateTask(emit,value,sink)};PropagateTask.end=function(value,sink){return new PropagateTask(end,value,sink);
};PropagateTask.error=function(value,sink){return new PropagateTask(error,value,sink)};PropagateTask.prototype.dispose=function(){this.active=false};PropagateTask.prototype.run=function(t){if(!this.active){return}this._run(t,this.value,this.sink)};PropagateTask.prototype.error=function(t,e){if(!this.active){return fatal(e)}this.sink.error(t,e)};function error(t,e,sink){sink.error(t,e)}function emit(t,x,sink){sink.event(t,x)}function end(t,x,sink){sink.end(t,x)}},{"../fatalError":38}],46:[function(require,module,exports){var base=require("./../base");var findIndex=base.findIndex;module.exports=Scheduler;function ScheduledTask(delay,period,task,scheduler){this.time=delay;this.period=period;this.task=task;this.scheduler=scheduler;this.active=true}ScheduledTask.prototype.run=function(){return this.task.run(this.time)};ScheduledTask.prototype.error=function(e){return this.task.error(this.time,e)};ScheduledTask.prototype.cancel=function(){this.scheduler.cancel(this);return this.task.dispose()};function runTask(task){try{return task.run()}catch(e){return task.error(e)}}function Scheduler(setTimer,clearTimer,now){this.now=now;this._setTimer=setTimer;this._clearTimer=clearTimer;this._timer=null;this._nextArrival=0;this._tasks=[];var self=this;this._runReadyTasksBound=function(){self._runReadyTasks(self.now())}}Scheduler.prototype.asap=function(task){return this.schedule(0,-1,task)};Scheduler.prototype.delay=function(delay,task){return this.schedule(delay,-1,task)};Scheduler.prototype.periodic=function(period,task){return this.schedule(0,period,task)};Scheduler.prototype.schedule=function(delay,period,task){var now=this.now();var st=new ScheduledTask(now+Math.max(0,delay),period,task,this);insertByTime(st,this._tasks);this._scheduleNextRun(now);return st};Scheduler.prototype.cancel=function(task){task.active=false;var i=findIndex(task,this._tasks);if(i>=0){this._tasks.splice(i,1);this._reschedule()}};Scheduler.prototype.cancelAll=function(f){this._tasks=base.removeAll(f,this._tasks);this._reschedule()};Scheduler.prototype._reschedule=function(){if(this._tasks.length===0){this._unschedule()}else{this._scheduleNextRun(this.now())}};Scheduler.prototype._unschedule=function(){this._clearTimer(this._timer);this._timer=null};Scheduler.prototype._runReadyTasks=function(now){this._timer=null;this._runTasks(this._collectReadyTasks(now));this._scheduleNextRun(this.now())};Scheduler.prototype._collectReadyTasks=function(now){var tasks=this._tasks;var l=tasks.length;var toRun=[];var task,i;for(i=0;i<l;++i){task=tasks[i];if(task.time>now){break}if(task.active){toRun.push(task)}}this._tasks=base.drop(i,tasks);return toRun};Scheduler.prototype._runTasks=function(tasks){var l=tasks.length;var task;for(var i=0;i<l;++i){task=tasks[i];runTask(task);if(task.period>=0&&task.active){task.time=task.time+task.period;insertByTime(task,this._tasks)}}};Scheduler.prototype._scheduleNextRun=function(now){if(this._tasks.length===0){return}var nextArrival=this._tasks[0].time;if(this._timer===null){this._scheduleNextArrival(nextArrival,now)}else if(nextArrival<this._nextArrival){this._unschedule();this._scheduleNextArrival(nextArrival,now)}};Scheduler.prototype._scheduleNextArrival=function(nextArrival,now){this._nextArrival=nextArrival;var delay=Math.max(0,nextArrival-now);this._timer=this._setTimer(this._runReadyTasksBound,delay)};function insertByTime(task,tasks){tasks.splice(findInsertion(task,tasks),0,task)}function findInsertion(task,tasks){var i=binarySearch(task,tasks);var l=tasks.length;var t=task.time;while(i<l&&t===tasks[i].time){++i}return i}function binarySearch(x,sortedArray){var lo=0;var hi=sortedArray.length;var mid,y;while(lo<hi){mid=Math.floor((lo+hi)/2);y=sortedArray[mid];if(x.time===y.time){return mid}else if(x.time<y.time){hi=mid}else{lo=mid+1}}return hi}},{"./../base":6}],47:[function(require,module,exports){(function(process){var Scheduler=require("./Scheduler");var defer=require("../defer");var defaultSetTimer,defaultClearTimer;function Task(f){this.f=f;this.active=true}Task.prototype.run=function(){if(!this.active){return}var f=this.f;return f()};Task.prototype.error=function(e){throw e};Task.prototype.cancel=function(){this.active=false};function runAsTask(f){var task=new Task(f);defer(task);return task}if(typeof process==="object"&&typeof process.nextTick==="function"){defaultSetTimer=function(f,ms){return ms<=0?runAsTask(f):setTimeout(f,ms)};defaultClearTimer=function(t){return t instanceof Task?t.cancel():clearTimeout(t)}}else{defaultSetTimer=function(f,ms){return setTimeout(f,ms)};defaultClearTimer=function(t){return clearTimeout(t)}}module.exports=new Scheduler(defaultSetTimer,defaultClearTimer,Date.now)}).call(this,require("_process"))},{"../defer":33,"./Scheduler":46,_process:1}],48:[function(require,module,exports){var defer=require("../defer");module.exports=DeferredSink;function DeferredSink(sink){this.sink=sink;this.events=[];this.length=0;this.active=true}DeferredSink.prototype.event=function(t,x){if(!this.active){return}if(this.length===0){defer(new PropagateAllTask(this))}this.events[this.length++]={time:t,value:x}};DeferredSink.prototype.error=function(t,e){this.active=false;defer(new ErrorTask(t,e,this.sink))};DeferredSink.prototype.end=function(t,x){this.active=false;defer(new EndTask(t,x,this.sink))};function PropagateAllTask(deferred){this.deferred=deferred}PropagateAllTask.prototype.run=function(){var p=this.deferred;var events=p.events;var sink=p.sink;var event;for(var i=0,l=p.length;i<l;++i){event=events[i];sink.event(event.time,event.value);events[i]=void 0}p.length=0};PropagateAllTask.prototype.error=function(e){this.deferred.error(0,e)};function EndTask(t,x,sink){this.time=t;this.value=x;this.sink=sink}EndTask.prototype.run=function(){this.sink.end(this.time,this.value)};EndTask.prototype.error=function(e){this.sink.error(this.time,e)};function ErrorTask(t,e,sink){this.time=t;this.value=e;this.sink=sink}ErrorTask.prototype.run=function(){this.sink.error(this.time,this.value)};ErrorTask.prototype.error=function(e){throw e}},{"../defer":33}],49:[function(require,module,exports){var Sink=require("./Pipe");module.exports=IndexSink;IndexSink.hasValue=hasValue;IndexSink.getValue=getValue;function hasValue(indexSink){return indexSink.hasValue}function getValue(indexSink){return indexSink.value}function IndexSink(i,sink){this.index=i;this.sink=sink;this.active=true;this.hasValue=false;this.value=void 0}IndexSink.prototype.event=function(t,x){if(!this.active){return}this.value=x;this.hasValue=true;this.sink.event(t,this)};IndexSink.prototype.end=function(t,x){if(!this.active){return}this.active=false;this.sink.end(t,{index:this.index,value:x})};IndexSink.prototype.error=Sink.prototype.error},{"./Pipe":51}],50:[function(require,module,exports){module.exports=Observer;function Observer(event,end,error){this._event=event;this._end=end;this._error=error;this.active=true}Observer.prototype.event=function(t,x){if(!this.active){return}this._event(x)};Observer.prototype.end=function(t,x){if(!this.active){return}this.active=false;this._end(x)};Observer.prototype.error=function(t,e){this.active=false;this._error(e)}},{}],51:[function(require,module,exports){module.exports=Pipe;function Pipe(sink){this.sink=sink}Pipe.prototype.event=function(t,x){return this.sink.event(t,x)};Pipe.prototype.end=function(t,x){return this.sink.end(t,x)};Pipe.prototype.error=function(t,e){return this.sink.error(t,e)}},{}],52:[function(require,module,exports){var base=require("../base");var resolve=require("../Promise").resolve;module.exports=MulticastSource;function MulticastSource(source){this.source=source;this.sink=new MulticastSink;this._disposable=void 0}MulticastSource.prototype.run=function(sink,scheduler){var n=this.sink.add(sink);if(n===1){this._disposable=this.source.run(this.sink,scheduler)}return new MulticastDisposable(this,sink)};MulticastSource.prototype._dispose=function(){return resolve(this._disposable).then(dispose)};function dispose(disposable){if(disposable===void 0){return}return disposable.dispose()}function MulticastDisposable(source,sink){this.source=source;this.sink=sink}MulticastDisposable.prototype.dispose=function(){var s=this.source;var remaining=s.sink.remove(this.sink);return remaining===0&&s._dispose()};function MulticastSink(){this.sinks=[]}MulticastSink.prototype.add=function(sink){this.sinks=base.append(sink,this.sinks);return this.sinks.length};MulticastSink.prototype.remove=function(sink){this.sinks=base.remove(base.findIndex(sink,this.sinks),this.sinks);return this.sinks.length};MulticastSink.prototype.event=function(t,x){var s=this.sinks;if(s.length===1){s[0].event(t,x);return}for(var i=0;i<s.length;++i){s[i].event(t,x)}};MulticastSink.prototype.end=function(t,x){var s=this.sinks;if(s.length===1){s[0].end(t,x);return}for(var i=0;i<s.length;++i){s[i].end(t,x)}};MulticastSink.prototype.error=function(t,e){var s=this.sinks;if(s.length===1){s[0].error(t,e);return}for(var i=0;i<s.length;++i){s[i].error(t,e)}}},{"../Promise":3,"../base":6}],53:[function(require,module,exports){var PropagateTask=require("../scheduler/PropagateTask");module.exports=ValueSource;function ValueSource(emit,x){this.emit=emit;this.value=x}ValueSource.prototype.run=function(sink,scheduler){return new ValueProducer(this.emit,this.value,sink,scheduler)};function ValueProducer(emit,x,sink,scheduler){this.task=new PropagateTask(emit,x,sink);scheduler.asap(this.task)}ValueProducer.prototype.dispose=function(){return this.task.dispose()}},{"../scheduler/PropagateTask":45}],54:[function(require,module,exports){var Stream=require("../Stream");var ValueSource=require("../source/ValueSource");var Disposable=require("../disposable/Disposable");var EmptyDisposable=require("../disposable/EmptyDisposable");var PropagateTask=require("../scheduler/PropagateTask");exports.of=streamOf;exports.empty=empty;exports.never=never;function streamOf(x){return new Stream(new ValueSource(emit,x))}function emit(t,x,sink){sink.event(0,x);sink.end(0,void 0)}function empty(){return EMPTY}function EmptySource(){}EmptySource.prototype.run=function(sink,scheduler){var task=PropagateTask.end(void 0,sink);scheduler.asap(task);return new Disposable(dispose,task)};function dispose(task){return task.dispose()}var EMPTY=new Stream(new EmptySource);function never(){return NEVER}function NeverSource(){}NeverSource.prototype.run=function(){return new EmptyDisposable};var NEVER=new Stream(new NeverSource)},{"../Stream":5,"../disposable/Disposable":36,"../disposable/EmptyDisposable":37,"../scheduler/PropagateTask":45,"../source/ValueSource":53}],55:[function(require,module,exports){var Stream=require("../Stream");var MulticastSource=require("./MulticastSource");var DeferredSink=require("../sink/DeferredSink");exports.create=create;function create(run){return new Stream(new MulticastSource(new SubscriberSource(run)))}function SubscriberSource(subscribe){this._subscribe=subscribe}SubscriberSource.prototype.run=function(sink,scheduler){return new Subscription(new DeferredSink(sink),scheduler,this._subscribe)};function Subscription(sink,scheduler,subscribe){this.sink=sink;this.scheduler=scheduler;this.active=true;var s=this;try{this._unsubscribe=subscribe(add,end,error)}catch(e){error(e)}function add(x){s._add(x)}function end(x){s._end(x)}function error(e){s._error(e)}}Subscription.prototype._add=function(x){if(!this.active){return}tryEvent(this.scheduler.now(),x,this.sink)};Subscription.prototype._end=function(x){if(!this.active){return}this.active=false;tryEnd(this.scheduler.now(),x,this.sink)};Subscription.prototype._error=function(x){this.active=false;this.sink.error(this.scheduler.now(),x)};Subscription.prototype.dispose=function(){this.active=false;if(typeof this._unsubscribe==="function"){return this._unsubscribe()}};function tryEvent(t,x,sink){try{sink.event(t,x)}catch(e){sink.error(t,e)}}function tryEnd(t,x,sink){try{sink.end(t,x)}catch(e){sink.error(t,e)}}},{"../Stream":5,"../sink/DeferredSink":48,"./MulticastSource":52}],56:[function(require,module,exports){var fromArray=require("./fromArray").fromArray;var isIterable=require("../iterable").isIterable;var fromIterable=require("./fromIterable").fromIterable;exports.from=from;function from(a){if(Array.isArray(a)){return fromArray(a)}if(isIterable(a)){return fromIterable(a)}throw new TypeError("not iterable: "+a)}},{"../iterable":43,"./fromArray":57,"./fromIterable":59}],57:[function(require,module,exports){var Stream=require("../Stream");var PropagateTask=require("../scheduler/PropagateTask");exports.fromArray=fromArray;function fromArray(a){return new Stream(new ArraySource(a))}function ArraySource(a){this.array=a}ArraySource.prototype.run=function(sink,scheduler){return new ArrayProducer(this.array,sink,scheduler)};function ArrayProducer(array,sink,scheduler){this.scheduler=scheduler;this.task=new PropagateTask(runProducer,array,sink);scheduler.asap(this.task)}ArrayProducer.prototype.dispose=function(){return this.task.dispose()};function runProducer(t,array,sink){return produce(this,array,sink,0)}function produce(task,array,sink,k){for(var i=k,l=array.length;i<l&&task.active;++i){sink.event(0,array[i])}return end();function end(){return task.active&&sink.end(0)}}},{"../Stream":5,"../scheduler/PropagateTask":45}],58:[function(require,module,exports){var Stream=require("../Stream");var MulticastSource=require("./MulticastSource");var DeferredSink=require("../sink/DeferredSink");exports.fromEvent=fromEvent;function fromEvent(event,source){var s;if(typeof source.addEventListener==="function"&&typeof source.removeEventListener==="function"){s=new MulticastSource(new EventTargetSource(event,source))}else if(typeof source.addListener==="function"&&typeof source.removeListener==="function"){s=new EventEmitterSource(event,source)}else{throw new Error("source must support addEventListener/removeEventListener or addListener/removeListener")}return new Stream(s)}function EventTargetSource(event,source){this.event=event;this.source=source}EventTargetSource.prototype.run=function(sink,scheduler){return new EventAdapter(initEventTarget,this.event,this.source,sink,scheduler)};function initEventTarget(addEvent,event,source){source.addEventListener(event,addEvent,false);return function(event,target){target.removeEventListener(event,addEvent,false)}}function EventEmitterSource(event,source){this.event=event;this.source=source}EventEmitterSource.prototype.run=function(sink,scheduler){return new EventAdapter(initEventEmitter,this.event,this.source,new DeferredSink(sink),scheduler)};function initEventEmitter(addEvent,event,source){function addEventVariadic(a){var l=arguments.length;if(l>1){var arr=new Array(l);for(var i=0;i<l;++i){arr[i]=arguments[i]}addEvent(arr)}else{addEvent(a)}}source.addListener(event,addEventVariadic);return function(event,target){target.removeListener(event,addEventVariadic)}}function EventAdapter(init,event,source,sink,scheduler){this.event=event;this.source=source;function addEvent(ev){tryEvent(scheduler.now(),ev,sink)}this._dispose=init(addEvent,event,source)}EventAdapter.prototype.dispose=function(){return this._dispose(this.event,this.source)};function tryEvent(t,x,sink){try{sink.event(t,x)}catch(e){sink.error(t,e)}}},{"../Stream":5,"../sink/DeferredSink":48,"./MulticastSource":52}],59:[function(require,module,exports){var Stream=require("../Stream");var getIterator=require("../iterable").getIterator;var PropagateTask=require("../scheduler/PropagateTask");exports.fromIterable=fromIterable;function fromIterable(iterable){return new Stream(new IterableSource(iterable))}function IterableSource(iterable){this.iterable=iterable}IterableSource.prototype.run=function(sink,scheduler){return new IteratorProducer(getIterator(this.iterable),sink,scheduler)};function IteratorProducer(iterator,sink,scheduler){this.scheduler=scheduler;this.iterator=iterator;this.task=new PropagateTask(runProducer,this,sink);scheduler.asap(this.task)}IteratorProducer.prototype.dispose=function(){return this.task.dispose()};function runProducer(t,producer,sink){var x=producer.iterator.next();if(x.done){sink.end(t,x.value)}else{sink.event(t,x.value)}producer.scheduler.asap(producer.task)}},{"../Stream":5,"../iterable":43,"../scheduler/PropagateTask":45}],60:[function(require,module,exports){var Stream=require("../Stream");var Promise=require("../Promise");var base=require("../base");exports.generate=generate;function generate(f){return new Stream(new GenerateSource(f,base.tail(arguments)))}function GenerateSource(f,args){this.f=f;this.args=args}GenerateSource.prototype.run=function(sink,scheduler){return new Generate(this.f.apply(void 0,this.args),sink,scheduler)};function Generate(iterator,sink,scheduler){this.iterator=iterator;this.sink=sink;this.scheduler=scheduler;this.active=true;var self=this;function err(e){self.sink.error(self.scheduler.now(),e)}Promise.resolve(this).then(next).catch(err)}function next(generate,x){return generate.active?handle(generate,generate.iterator.next(x)):x}function handle(generate,result){if(result.done){return generate.sink.end(generate.scheduler.now(),result.value)}return Promise.resolve(result.value).then(function(x){return emit(generate,x)},function(e){return error(generate,e)})}function emit(generate,x){generate.sink.event(generate.scheduler.now(),x);return next(generate,x)}function error(generate,e){return handle(generate,generate.iterator.throw(e))}Generate.prototype.dispose=function(){this.active=false}},{"../Promise":3,"../Stream":5,"../base":6}],61:[function(require,module,exports){var Stream=require("../Stream");var Promise=require("../Promise");exports.iterate=iterate;function iterate(f,x){return new Stream(new IterateSource(f,x))}function IterateSource(f,x){this.f=f;this.value=x}IterateSource.prototype.run=function(sink,scheduler){return new Iterate(this.f,this.value,sink,scheduler)};function Iterate(f,initial,sink,scheduler){this.f=f;this.sink=sink;this.scheduler=scheduler;this.active=true;var x=initial;var self=this;function err(e){self.sink.error(self.scheduler.now(),e)}function start(iterate){return stepIterate(iterate,x)}Promise.resolve(this).then(start).catch(err)}Iterate.prototype.dispose=function(){this.active=false};function stepIterate(iterate,x){iterate.sink.event(iterate.scheduler.now(),x);if(!iterate.active){return x}var f=iterate.f;return Promise.resolve(f(x)).then(function(y){return continueIterate(iterate,y)})}function continueIterate(iterate,x){return!iterate.active?iterate.value:stepIterate(iterate,x)}},{"../Promise":3,"../Stream":5}],62:[function(require,module,exports){var Stream=require("../Stream");var Disposable=require("../disposable/Disposable");var MulticastSource=require("./MulticastSource");var PropagateTask=require("../scheduler/PropagateTask");exports.periodic=periodic;function periodic(period,value){return new Stream(new MulticastSource(new Periodic(period,value)))}function Periodic(period,value){this.period=period;this.value=value}Periodic.prototype.run=function(sink,scheduler){var task=scheduler.periodic(this.period,new PropagateTask(emit,this.value,sink));return new Disposable(cancelTask,task)};function cancelTask(task){task.cancel()}function emit(t,x,sink){sink.event(t,x)}},{"../Stream":5,"../disposable/Disposable":36,"../scheduler/PropagateTask":45,"./MulticastSource":52}],63:[function(require,module,exports){var Stream=require("../Stream");var Promise=require("../Promise");exports.unfold=unfold;function unfold(f,seed){return new Stream(new UnfoldSource(f,seed))}function UnfoldSource(f,seed){this.f=f;this.value=seed}UnfoldSource.prototype.run=function(sink,scheduler){return new Unfold(this.f,this.value,sink,scheduler)};function Unfold(f,x,sink,scheduler){this.f=f;this.sink=sink;this.scheduler=scheduler;this.active=true;var self=this;function err(e){self.sink.error(self.scheduler.now(),e)}function start(unfold){return stepUnfold(unfold,x)}Promise.resolve(this).then(start).catch(err)}Unfold.prototype.dispose=function(){this.active=false};function stepUnfold(unfold,x){var f=unfold.f;return Promise.resolve(f(x)).then(function(tuple){return continueUnfold(unfold,tuple)})}function continueUnfold(unfold,tuple){if(tuple.done){unfold.sink.end(unfold.scheduler.now(),tuple.value);return tuple.value}unfold.sink.event(unfold.scheduler.now(),tuple.value);if(!unfold.active){return tuple.value}return stepUnfold(unfold,tuple.seed)}},{"../Promise":3,"../Stream":5}],64:[function(require,module,exports){(function(define){"use strict";define(function(require){var makePromise=require("./makePromise");var Scheduler=require("./Scheduler");var async=require("./env").asap;return makePromise({scheduler:new Scheduler(async)})})})(typeof define==="function"&&define.amd?define:function(factory){module.exports=factory(require)})},{"./Scheduler":65,"./env":67,"./makePromise":69}],65:[function(require,module,exports){(function(define){"use strict";define(function(){function Scheduler(async){this._async=async;this._running=false;this._queue=this;this._queueLen=0;this._afterQueue={};this._afterQueueLen=0;var self=this;this.drain=function(){self._drain()}}Scheduler.prototype.enqueue=function(task){this._queue[this._queueLen++]=task;this.run()};Scheduler.prototype.afterQueue=function(task){this._afterQueue[this._afterQueueLen++]=task;this.run()};Scheduler.prototype.run=function(){if(!this._running){this._running=true;this._async(this.drain)}};Scheduler.prototype._drain=function(){var i=0;for(;i<this._queueLen;++i){this._queue[i].run();this._queue[i]=void 0}this._queueLen=0;this._running=false;for(i=0;i<this._afterQueueLen;++i){this._afterQueue[i].run();this._afterQueue[i]=void 0}this._afterQueueLen=0};return Scheduler})})(typeof define==="function"&&define.amd?define:function(factory){module.exports=factory()})},{}],66:[function(require,module,exports){(function(define){"use strict";define(function(require){var setTimer=require("../env").setTimer;var format=require("../format");return function unhandledRejection(Promise){var logError=noop;var logInfo=noop;var localConsole;if(typeof console!=="undefined"){localConsole=console;logError=typeof localConsole.error!=="undefined"?function(e){localConsole.error(e)}:function(e){localConsole.log(e)};logInfo=typeof localConsole.info!=="undefined"?function(e){localConsole.info(e)}:function(e){localConsole.log(e)}}Promise.onPotentiallyUnhandledRejection=function(rejection){enqueue(report,rejection)};Promise.onPotentiallyUnhandledRejectionHandled=function(rejection){enqueue(unreport,rejection)};Promise.onFatalRejection=function(rejection){enqueue(throwit,rejection.value)};var tasks=[];var reported=[];var running=null;function report(r){if(!r.handled){reported.push(r);logError("Potentially unhandled rejection ["+r.id+"] "+format.formatError(r.value))}}function unreport(r){var i=reported.indexOf(r);if(i>=0){reported.splice(i,1);logInfo("Handled previous rejection ["+r.id+"] "+format.formatObject(r.value))}}function enqueue(f,x){tasks.push(f,x);if(running===null){running=setTimer(flush,0)}}function flush(){running=null;while(tasks.length>0){tasks.shift()(tasks.shift())}}return Promise};function throwit(e){throw e}function noop(){}})})(typeof define==="function"&&define.amd?define:function(factory){module.exports=factory(require)})},{"../env":67,"../format":68}],67:[function(require,module,exports){(function(process){(function(define){"use strict";define(function(require){var MutationObs;var capturedSetTimeout=typeof setTimeout!=="undefined"&&setTimeout;var setTimer=function(f,ms){return setTimeout(f,ms)};var clearTimer=function(t){return clearTimeout(t)};var asap=function(f){return capturedSetTimeout(f,0)};if(isNode()){asap=function(f){return process.nextTick(f)}}else if(MutationObs=hasMutationObserver()){asap=initMutationObserver(MutationObs)}else if(!capturedSetTimeout){var vertxRequire=require;var vertx=vertxRequire("vertx");setTimer=function(f,ms){return vertx.setTimer(ms,f)};clearTimer=vertx.cancelTimer;asap=vertx.runOnLoop||vertx.runOnContext}return{setTimer:setTimer,clearTimer:clearTimer,asap:asap};function isNode(){return typeof process!=="undefined"&&Object.prototype.toString.call(process)==="[object process]"}function hasMutationObserver(){return typeof MutationObserver==="function"&&MutationObserver||typeof WebKitMutationObserver==="function"&&WebKitMutationObserver}function initMutationObserver(MutationObserver){var scheduled;var node=document.createTextNode("");var o=new MutationObserver(run);o.observe(node,{characterData:true});function run(){var f=scheduled;scheduled=void 0;f()}var i=0;return function(f){scheduled=f;node.data=i^=1}}})})(typeof define==="function"&&define.amd?define:function(factory){module.exports=factory(require)})}).call(this,require("_process"))},{_process:1}],68:[function(require,module,exports){(function(define){"use strict";define(function(){return{formatError:formatError,formatObject:formatObject,tryStringify:tryStringify};function formatError(e){var s=typeof e==="object"&&e!==null&&e.stack?e.stack:formatObject(e);return e instanceof Error?s:s+" (WARNING: non-Error used)"}function formatObject(o){var s=String(o);if(s==="[object Object]"&&typeof JSON!=="undefined"){s=tryStringify(o,s)}return s}function tryStringify(x,defaultValue){try{return JSON.stringify(x)}catch(e){return defaultValue}}})})(typeof define==="function"&&define.amd?define:function(factory){module.exports=factory()})},{}],69:[function(require,module,exports){(function(process){(function(define){"use strict";define(function(){return function makePromise(environment){var tasks=environment.scheduler;var emitRejection=initEmitRejection();var objectCreate=Object.create||function(proto){function Child(){}Child.prototype=proto;return new Child};function Promise(resolver,handler){this._handler=resolver===Handler?handler:init(resolver)}function init(resolver){var handler=new Pending;try{resolver(promiseResolve,promiseReject,promiseNotify)}catch(e){promiseReject(e)}return handler;function promiseResolve(x){handler.resolve(x)}function promiseReject(reason){handler.reject(reason)}function promiseNotify(x){handler.notify(x)}}Promise.resolve=resolve;Promise.reject=reject;Promise.never=never;Promise._defer=defer;Promise._handler=getHandler;function resolve(x){return isPromise(x)?x:new Promise(Handler,new Async(getHandler(x)))}function reject(x){return new Promise(Handler,new Async(new Rejected(x)))}function never(){return foreverPendingPromise}function defer(){return new Promise(Handler,new Pending)}Promise.prototype.then=function(onFulfilled,onRejected,onProgress){var parent=this._handler;var state=parent.join().state();if(typeof onFulfilled!=="function"&&state>0||typeof onRejected!=="function"&&state<0){return new this.constructor(Handler,parent)}var p=this._beget();var child=p._handler;parent.chain(child,parent.receiver,onFulfilled,onRejected,onProgress);return p};Promise.prototype["catch"]=function(onRejected){return this.then(void 0,onRejected)};Promise.prototype._beget=function(){return begetFrom(this._handler,this.constructor)};function begetFrom(parent,Promise){var child=new Pending(parent.receiver,parent.join().context);return new Promise(Handler,child)}Promise.all=all;Promise.race=race;Promise._traverse=traverse;function all(promises){return traverseWith(snd,null,promises)}function traverse(f,promises){return traverseWith(tryCatch2,f,promises)}function traverseWith(tryMap,f,promises){var handler=typeof f==="function"?mapAt:settleAt;var resolver=new Pending;var pending=promises.length>>>0;var results=new Array(pending);for(var i=0,x;i<promises.length&&!resolver.resolved;++i){x=promises[i];if(x===void 0&&!(i in promises)){--pending;continue}traverseAt(promises,handler,i,x,resolver)}if(pending===0){resolver.become(new Fulfilled(results))}return new Promise(Handler,resolver);function mapAt(i,x,resolver){if(!resolver.resolved){traverseAt(promises,settleAt,i,tryMap(f,x,i),resolver)}}function settleAt(i,x,resolver){results[i]=x;if(--pending===0){resolver.become(new Fulfilled(results))}}}function traverseAt(promises,handler,i,x,resolver){if(maybeThenable(x)){var h=getHandlerMaybeThenable(x);var s=h.state();if(s===0){h.fold(handler,i,void 0,resolver)}else if(s>0){handler(i,h.value,resolver)}else{resolver.become(h);visitRemaining(promises,i+1,h)}}else{handler(i,x,resolver)}}Promise._visitRemaining=visitRemaining;function visitRemaining(promises,start,handler){for(var i=start;i<promises.length;++i){markAsHandled(getHandler(promises[i]),handler)}}function markAsHandled(h,handler){if(h===handler){return}var s=h.state();if(s===0){h.visit(h,void 0,h._unreport)}else if(s<0){h._unreport()}}function race(promises){if(typeof promises!=="object"||promises===null){return reject(new TypeError("non-iterable passed to race()"))}return promises.length===0?never():promises.length===1?resolve(promises[0]):runRace(promises)}function runRace(promises){var resolver=new Pending;var i,x,h;for(i=0;i<promises.length;++i){x=promises[i];if(x===void 0&&!(i in promises)){continue}h=getHandler(x);if(h.state()!==0){resolver.become(h);visitRemaining(promises,i+1,h);break}else{h.visit(resolver,resolver.resolve,resolver.reject)}}return new Promise(Handler,resolver)}function getHandler(x){if(isPromise(x)){return x._handler.join()}return maybeThenable(x)?getHandlerUntrusted(x):new Fulfilled(x)}function getHandlerMaybeThenable(x){return isPromise(x)?x._handler.join():getHandlerUntrusted(x)}function getHandlerUntrusted(x){try{var untrustedThen=x.then;return typeof untrustedThen==="function"?new Thenable(untrustedThen,x):new Fulfilled(x)}catch(e){return new Rejected(e)}}function Handler(){}Handler.prototype.when=Handler.prototype.become=Handler.prototype.notify=Handler.prototype.fail=Handler.prototype._unreport=Handler.prototype._report=noop;Handler.prototype._state=0;Handler.prototype.state=function(){return this._state};Handler.prototype.join=function(){var h=this;while(h.handler!==void 0){h=h.handler}return h};Handler.prototype.chain=function(to,receiver,fulfilled,rejected,progress){this.when({resolver:to,receiver:receiver,fulfilled:fulfilled,rejected:rejected,progress:progress})};Handler.prototype.visit=function(receiver,fulfilled,rejected,progress){this.chain(failIfRejected,receiver,fulfilled,rejected,progress)};Handler.prototype.fold=function(f,z,c,to){this.when(new Fold(f,z,c,to))};function FailIfRejected(){}inherit(Handler,FailIfRejected);FailIfRejected.prototype.become=function(h){h.fail()};var failIfRejected=new FailIfRejected;function Pending(receiver,inheritedContext){Promise.createContext(this,inheritedContext);this.consumers=void 0;this.receiver=receiver;this.handler=void 0;this.resolved=false}inherit(Handler,Pending);Pending.prototype._state=0;Pending.prototype.resolve=function(x){this.become(getHandler(x))};Pending.prototype.reject=function(x){if(this.resolved){return}this.become(new Rejected(x))};Pending.prototype.join=function(){if(!this.resolved){return this}var h=this;while(h.handler!==void 0){h=h.handler;if(h===this){return this.handler=cycle()}}return h};Pending.prototype.run=function(){var q=this.consumers;var handler=this.handler;this.handler=this.handler.join();this.consumers=void 0;for(var i=0;i<q.length;++i){handler.when(q[i])}};Pending.prototype.become=function(handler){if(this.resolved){return}this.resolved=true;this.handler=handler;if(this.consumers!==void 0){tasks.enqueue(this)}if(this.context!==void 0){handler._report(this.context)}};Pending.prototype.when=function(continuation){if(this.resolved){tasks.enqueue(new ContinuationTask(continuation,this.handler))}else{if(this.consumers===void 0){this.consumers=[continuation]}else{this.consumers.push(continuation)}}};Pending.prototype.notify=function(x){if(!this.resolved){tasks.enqueue(new ProgressTask(x,this))}};Pending.prototype.fail=function(context){var c=typeof context==="undefined"?this.context:context;this.resolved&&this.handler.join().fail(c)};Pending.prototype._report=function(context){this.resolved&&this.handler.join()._report(context)};Pending.prototype._unreport=function(){this.resolved&&this.handler.join()._unreport();
};function Async(handler){this.handler=handler}inherit(Handler,Async);Async.prototype.when=function(continuation){tasks.enqueue(new ContinuationTask(continuation,this))};Async.prototype._report=function(context){this.join()._report(context)};Async.prototype._unreport=function(){this.join()._unreport()};function Thenable(then,thenable){Pending.call(this);tasks.enqueue(new AssimilateTask(then,thenable,this))}inherit(Pending,Thenable);function Fulfilled(x){Promise.createContext(this);this.value=x}inherit(Handler,Fulfilled);Fulfilled.prototype._state=1;Fulfilled.prototype.fold=function(f,z,c,to){runContinuation3(f,z,this,c,to)};Fulfilled.prototype.when=function(cont){runContinuation1(cont.fulfilled,this,cont.receiver,cont.resolver)};var errorId=0;function Rejected(x){Promise.createContext(this);this.id=++errorId;this.value=x;this.handled=false;this.reported=false;this._report()}inherit(Handler,Rejected);Rejected.prototype._state=-1;Rejected.prototype.fold=function(f,z,c,to){to.become(this)};Rejected.prototype.when=function(cont){if(typeof cont.rejected==="function"){this._unreport()}runContinuation1(cont.rejected,this,cont.receiver,cont.resolver)};Rejected.prototype._report=function(context){tasks.afterQueue(new ReportTask(this,context))};Rejected.prototype._unreport=function(){if(this.handled){return}this.handled=true;tasks.afterQueue(new UnreportTask(this))};Rejected.prototype.fail=function(context){this.reported=true;emitRejection("unhandledRejection",this);Promise.onFatalRejection(this,context===void 0?this.context:context)};function ReportTask(rejection,context){this.rejection=rejection;this.context=context}ReportTask.prototype.run=function(){if(!this.rejection.handled&&!this.rejection.reported){this.rejection.reported=true;emitRejection("unhandledRejection",this.rejection)||Promise.onPotentiallyUnhandledRejection(this.rejection,this.context)}};function UnreportTask(rejection){this.rejection=rejection}UnreportTask.prototype.run=function(){if(this.rejection.reported){emitRejection("rejectionHandled",this.rejection)||Promise.onPotentiallyUnhandledRejectionHandled(this.rejection)}};Promise.createContext=Promise.enterContext=Promise.exitContext=Promise.onPotentiallyUnhandledRejection=Promise.onPotentiallyUnhandledRejectionHandled=Promise.onFatalRejection=noop;var foreverPendingHandler=new Handler;var foreverPendingPromise=new Promise(Handler,foreverPendingHandler);function cycle(){return new Rejected(new TypeError("Promise cycle"))}function ContinuationTask(continuation,handler){this.continuation=continuation;this.handler=handler}ContinuationTask.prototype.run=function(){this.handler.join().when(this.continuation)};function ProgressTask(value,handler){this.handler=handler;this.value=value}ProgressTask.prototype.run=function(){var q=this.handler.consumers;if(q===void 0){return}for(var c,i=0;i<q.length;++i){c=q[i];runNotify(c.progress,this.value,this.handler,c.receiver,c.resolver)}};function AssimilateTask(then,thenable,resolver){this._then=then;this.thenable=thenable;this.resolver=resolver}AssimilateTask.prototype.run=function(){var h=this.resolver;tryAssimilate(this._then,this.thenable,_resolve,_reject,_notify);function _resolve(x){h.resolve(x)}function _reject(x){h.reject(x)}function _notify(x){h.notify(x)}};function tryAssimilate(then,thenable,resolve,reject,notify){try{then.call(thenable,resolve,reject,notify)}catch(e){reject(e)}}function Fold(f,z,c,to){this.f=f;this.z=z;this.c=c;this.to=to;this.resolver=failIfRejected;this.receiver=this}Fold.prototype.fulfilled=function(x){this.f.call(this.c,this.z,x,this.to)};Fold.prototype.rejected=function(x){this.to.reject(x)};Fold.prototype.progress=function(x){this.to.notify(x)};function isPromise(x){return x instanceof Promise}function maybeThenable(x){return(typeof x==="object"||typeof x==="function")&&x!==null}function runContinuation1(f,h,receiver,next){if(typeof f!=="function"){return next.become(h)}Promise.enterContext(h);tryCatchReject(f,h.value,receiver,next);Promise.exitContext()}function runContinuation3(f,x,h,receiver,next){if(typeof f!=="function"){return next.become(h)}Promise.enterContext(h);tryCatchReject3(f,x,h.value,receiver,next);Promise.exitContext()}function runNotify(f,x,h,receiver,next){if(typeof f!=="function"){return next.notify(x)}Promise.enterContext(h);tryCatchReturn(f,x,receiver,next);Promise.exitContext()}function tryCatch2(f,a,b){try{return f(a,b)}catch(e){return reject(e)}}function tryCatchReject(f,x,thisArg,next){try{next.become(getHandler(f.call(thisArg,x)))}catch(e){next.become(new Rejected(e))}}function tryCatchReject3(f,x,y,thisArg,next){try{f.call(thisArg,x,y,next)}catch(e){next.become(new Rejected(e))}}function tryCatchReturn(f,x,thisArg,next){try{next.notify(f.call(thisArg,x))}catch(e){next.notify(e)}}function inherit(Parent,Child){Child.prototype=objectCreate(Parent.prototype);Child.prototype.constructor=Child}function snd(x,y){return y}function noop(){}function initEmitRejection(){if(typeof process!=="undefined"&&process!==null&&typeof process.emit==="function"){return function(type,rejection){return type==="unhandledRejection"?process.emit(type,rejection.value,rejection):process.emit(type,rejection)}}else if(typeof self!=="undefined"&&typeof CustomEvent==="function"){return function(noop,self,CustomEvent){var hasCustomEvent=false;try{var ev=new CustomEvent("unhandledRejection");hasCustomEvent=ev instanceof CustomEvent}catch(e){}return!hasCustomEvent?noop:function(type,rejection){var ev=new CustomEvent(type,{detail:{reason:rejection.value,key:rejection},bubbles:false,cancelable:true});return!self.dispatchEvent(ev)}}(noop,self,CustomEvent)}return noop}return Promise}})})(typeof define==="function"&&define.amd?define:function(factory){module.exports=factory()})}).call(this,require("_process"))},{_process:1}],most:[function(require,module,exports){var Stream=require("./lib/Stream");var base=require("./lib/base");var core=require("./lib/source/core");var from=require("./lib/source/from").from;var periodic=require("./lib/source/periodic").periodic;exports.Stream=Stream;exports.of=Stream.of=core.of;exports.just=core.of;exports.empty=Stream.empty=core.empty;exports.never=core.never;exports.from=from;exports.periodic=periodic;var create=require("./lib/source/create");exports.create=create.create;var events=require("./lib/source/fromEvent");exports.fromEvent=events.fromEvent;var lift=require("./lib/combinator/lift").lift;exports.lift=lift;var observe=require("./lib/combinator/observe");exports.observe=observe.observe;exports.forEach=observe.observe;exports.drain=observe.drain;Stream.prototype.observe=Stream.prototype.forEach=function(f){return observe.observe(f,this)};Stream.prototype.drain=function(){return observe.drain(this)};var loop=require("./lib/combinator/loop").loop;exports.loop=loop;Stream.prototype.loop=function(stepper,seed){return loop(stepper,seed,this)};var accumulate=require("./lib/combinator/accumulate");exports.scan=accumulate.scan;exports.reduce=accumulate.reduce;Stream.prototype.scan=function(f,initial){return accumulate.scan(f,initial,this)};Stream.prototype.reduce=function(f,initial){return accumulate.reduce(f,initial,this)};var unfold=require("./lib/source/unfold");var iterate=require("./lib/source/iterate");var generate=require("./lib/source/generate");var build=require("./lib/combinator/build");exports.unfold=unfold.unfold;exports.iterate=iterate.iterate;exports.generate=generate.generate;exports.concat=build.cycle;exports.concat=build.concat;exports.startWith=build.cons;Stream.prototype.cycle=function(){return build.cycle(this)};Stream.prototype.concat=function(tail){return build.concat(this,tail)};Stream.prototype.startWith=function(x){return build.cons(x,this)};var transform=require("./lib/combinator/transform");var applicative=require("./lib/combinator/applicative");exports.map=transform.map;exports.constant=transform.constant;exports.tap=transform.tap;exports.ap=applicative.ap;Stream.prototype.map=function(f){return transform.map(f,this)};Stream.prototype.ap=function(xs){return applicative.ap(this,xs)};Stream.prototype.constant=function(x){return transform.constant(x,this)};Stream.prototype.tap=function(f){return transform.tap(f,this)};var transduce=require("./lib/combinator/transduce");exports.transduce=transduce.transduce;Stream.prototype.transduce=function(transducer){return transduce.transduce(transducer,this)};var flatMap=require("./lib/combinator/flatMap");exports.flatMap=exports.chain=flatMap.flatMap;exports.join=flatMap.join;Stream.prototype.flatMap=Stream.prototype.chain=function(f){return flatMap.flatMap(f,this)};Stream.prototype.join=function(){return flatMap.join(this)};var flatMapEnd=require("./lib/combinator/flatMapEnd").flatMapEnd;exports.flatMapEnd=flatMapEnd;Stream.prototype.flatMapEnd=function(f){return flatMapEnd(f,this)};var concatMap=require("./lib/combinator/concatMap").concatMap;exports.concatMap=concatMap;Stream.prototype.concatMap=function(f){return concatMap(f,this)};var merge=require("./lib/combinator/merge");exports.merge=merge.merge;Stream.prototype.merge=function(){return merge.mergeArray(base.cons(this,arguments))};var combine=require("./lib/combinator/combine");exports.combine=combine.combine;Stream.prototype.combine=function(f){return combine.combineArray(f,base.replace(this,0,arguments))};var sample=require("./lib/combinator/sample");exports.sample=sample.sample;exports.sampleWith=sample.sampleWith;Stream.prototype.sampleWith=function(sampler){return sample.sampleWith(sampler,this)};Stream.prototype.sample=function(f){return sample.sampleArray(f,this,base.tail(arguments))};var zip=require("./lib/combinator/zip");exports.zip=zip.zip;Stream.prototype.zip=function(f){return zip.zipArray(f,base.replace(this,0,arguments))};var switchLatest=require("./lib/combinator/switch").switch;exports.switch=switchLatest;exports.switchLatest=switchLatest;Stream.prototype.switch=Stream.prototype.switchLatest=function(){return switchLatest(this)};var filter=require("./lib/combinator/filter");exports.filter=filter.filter;exports.skipRepeats=exports.distinct=filter.skipRepeats;exports.skipRepeatsWith=exports.distinctBy=filter.skipRepeatsWith;Stream.prototype.filter=function(p){return filter.filter(p,this)};Stream.prototype.skipRepeats=function(){return filter.skipRepeats(this)};Stream.prototype.skipRepeatsWith=function(equals){return filter.skipRepeatsWith(equals,this)};var slice=require("./lib/combinator/slice");exports.take=slice.take;exports.skip=slice.skip;exports.slice=slice.slice;exports.takeWhile=slice.takeWhile;exports.skipWhile=slice.skipWhile;Stream.prototype.take=function(n){return slice.take(n,this)};Stream.prototype.skip=function(n){return slice.skip(n,this)};Stream.prototype.slice=function(start,end){return slice.slice(start,end,this)};Stream.prototype.takeWhile=function(p){return slice.takeWhile(p,this)};Stream.prototype.skipWhile=function(p){return slice.skipWhile(p,this)};var timeslice=require("./lib/combinator/timeslice");exports.until=exports.takeUntil=timeslice.takeUntil;exports.since=exports.skipUntil=timeslice.skipUntil;exports.during=timeslice.during;Stream.prototype.until=Stream.prototype.takeUntil=function(signal){return timeslice.takeUntil(signal,this)};Stream.prototype.since=Stream.prototype.skipUntil=function(signal){return timeslice.skipUntil(signal,this)};Stream.prototype.during=function(timeWindow){return timeslice.during(timeWindow,this)};var delay=require("./lib/combinator/delay").delay;exports.delay=delay;Stream.prototype.delay=function(delayTime){return delay(delayTime,this)};var timestamp=require("./lib/combinator/timestamp").timestamp;exports.timestamp=timestamp;Stream.prototype.timestamp=function(){return timestamp(this)};var limit=require("./lib/combinator/limit");exports.throttle=limit.throttle;exports.debounce=limit.debounce;Stream.prototype.throttle=function(period){return limit.throttle(period,this)};Stream.prototype.debounce=function(period){return limit.debounce(period,this)};var promises=require("./lib/combinator/promises");exports.fromPromise=promises.fromPromise;exports.await=promises.await;Stream.prototype.await=function(){return promises.await(this)};var errors=require("./lib/combinator/errors");exports.flatMapError=errors.flatMapError;exports.throwError=errors.throwError;Stream.prototype.flatMapError=function(f){return errors.flatMapError(f,this)};var multicast=require("./lib/combinator/multicast").multicast;exports.multicast=multicast;Stream.prototype.multicast=function(){return multicast(this)}},{"./lib/Stream":5,"./lib/base":6,"./lib/combinator/accumulate":7,"./lib/combinator/applicative":8,"./lib/combinator/build":9,"./lib/combinator/combine":10,"./lib/combinator/concatMap":11,"./lib/combinator/delay":12,"./lib/combinator/errors":13,"./lib/combinator/filter":14,"./lib/combinator/flatMap":15,"./lib/combinator/flatMapEnd":16,"./lib/combinator/lift":17,"./lib/combinator/limit":18,"./lib/combinator/loop":19,"./lib/combinator/merge":20,"./lib/combinator/multicast":22,"./lib/combinator/observe":23,"./lib/combinator/promises":24,"./lib/combinator/sample":25,"./lib/combinator/slice":26,"./lib/combinator/switch":27,"./lib/combinator/timeslice":28,"./lib/combinator/timestamp":29,"./lib/combinator/transduce":30,"./lib/combinator/transform":31,"./lib/combinator/zip":32,"./lib/source/core":54,"./lib/source/create":55,"./lib/source/from":56,"./lib/source/fromEvent":58,"./lib/source/generate":60,"./lib/source/iterate":61,"./lib/source/periodic":62,"./lib/source/unfold":63}]},{},[]);var through=require("through2").obj;var from=require("from2");var most=require("most");var count=0;var gen=function gen(size,next){if(count++<20){return next(null,{val:count})}};from({objectMode:true},gen);var fromReadableStream=function fromStream(stream){var finishEventName="end";return most.create(function(add,end,error){function dataHandler(data){add(data)}function errorHandler(err){error(err)}function endHandler(){console.log("called");end()}stream.addListener("data",dataHandler);stream.addListener("error",errorHandler);stream.addListener(finishEventName,endHandler);return function(){stream.removeListener("data",dataHandler);stream.removeListener("error",errorHandler);stream.removeListener(finishEventName,endHandler)}})};var source=fromReadableStream(from({objectMode:true},gen));source.observe(function(x){console.log(x)});
{
"name": "requirebin-sketch",
"version": "1.0.0",
"dependencies": {
"through2": "2.0.0",
"from2": "2.1.0",
"most": "0.15.0"
}
}
<!-- contents of this file will be placed inside the <body> -->
<!-- contents of this file will be placed inside the <head> -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment