Skip to content

Instantly share code, notes, and snippets.

@andineck
Created February 11, 2015 16:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andineck/195650b39fdffa1acd1d to your computer and use it in GitHub Desktop.
Save andineck/195650b39fdffa1acd1d to your computer and use it in GitHub Desktop.
requirebin sketch
// require() some stuff from npm (like you were using browserify)
// and then hit Rebuild to run it on the right
var level = require('level-browserify')
// 1) Create our database, supply location and options.
// This will create or open the underlying LevelDB store/Indexedb Database
var db = window.levelDB = level('./mydb')
// 2) put a key & value
db.put('name', 'Level', function (err) {
if (err) return console.log('Ooops!', err) // some kind of I/O error
// 3) fetch by key
db.get('name', function (err, value) {
if (err) return console.log('Ooops!', err) // likely the key was not found
// ta da!
console.log('name=' + value)
})
})
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){module.exports=Array.isArray||function(arr){return Object.prototype.toString.call(arr)=="[object Array]"}},{}],9:[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")}},{}],10:[function(require,module,exports){module.exports=require("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":11}],11:[function(require,module,exports){(function(process){module.exports=Duplex;var objectKeys=Object.keys||function(obj){var keys=[];for(var key in obj)keys.push(key);return keys};var util=require("core-util-is");util.inherits=require("inherits");var Readable=require("./_stream_readable");var Writable=require("./_stream_writable");util.inherits(Duplex,Readable);forEach(objectKeys(Writable.prototype),function(method){if(!Duplex.prototype[method])Duplex.prototype[method]=Writable.prototype[method]});function Duplex(options){if(!(this instanceof Duplex))return new Duplex(options);Readable.call(this,options);Writable.call(this,options);if(options&&options.readable===false)this.readable=false;if(options&&options.writable===false)this.writable=false;this.allowHalfOpen=true;if(options&&options.allowHalfOpen===false)this.allowHalfOpen=false;this.once("end",onend)}function onend(){if(this.allowHalfOpen||this._writableState.ended)return;process.nextTick(this.end.bind(this))}function forEach(xs,f){for(var i=0,l=xs.length;i<l;i++){f(xs[i],i)}}}).call(this,require("_process"))},{"./_stream_readable":13,"./_stream_writable":15,_process:9,"core-util-is":16,inherits:7}],12:[function(require,module,exports){module.exports=PassThrough;var Transform=require("./_stream_transform");var util=require("core-util-is");util.inherits=require("inherits");util.inherits(PassThrough,Transform);function PassThrough(options){if(!(this instanceof PassThrough))return new PassThrough(options);Transform.call(this,options)}PassThrough.prototype._transform=function(chunk,encoding,cb){cb(null,chunk)}},{"./_stream_transform":14,"core-util-is":16,inherits:7}],13:[function(require,module,exports){(function(process){module.exports=Readable;var isArray=require("isarray");var Buffer=require("buffer").Buffer;Readable.ReadableState=ReadableState;var EE=require("events").EventEmitter;if(!EE.listenerCount)EE.listenerCount=function(emitter,type){return emitter.listeners(type).length};var Stream=require("stream");var util=require("core-util-is");util.inherits=require("inherits");var StringDecoder;util.inherits(Readable,Stream);function ReadableState(options,stream){options=options||{};var hwm=options.highWaterMark;this.highWaterMark=hwm||hwm===0?hwm:16*1024;this.highWaterMark=~~this.highWaterMark;this.buffer=[];this.length=0;this.pipes=null;this.pipesCount=0;this.flowing=false;this.ended=false;this.endEmitted=false;this.reading=false;this.calledRead=false;this.sync=true;this.needReadable=false;this.emittedReadable=false;this.readableListening=false;this.objectMode=!!options.objectMode;this.defaultEncoding=options.defaultEncoding||"utf8";this.ranOut=false;this.awaitDrain=0;this.readingMore=false;this.decoder=null;this.encoding=null;if(options.encoding){if(!StringDecoder)StringDecoder=require("string_decoder/").StringDecoder;this.decoder=new StringDecoder(options.encoding);this.encoding=options.encoding}}function Readable(options){if(!(this instanceof Readable))return new Readable(options);this._readableState=new ReadableState(options,this);this.readable=true;Stream.call(this)}Readable.prototype.push=function(chunk,encoding){var state=this._readableState;if(typeof chunk==="string"&&!state.objectMode){encoding=encoding||state.defaultEncoding;if(encoding!==state.encoding){chunk=new Buffer(chunk,encoding);encoding=""}}return readableAddChunk(this,state,chunk,encoding,false)};Readable.prototype.unshift=function(chunk){var state=this._readableState;return readableAddChunk(this,state,chunk,"",true)};function readableAddChunk(stream,state,chunk,encoding,addToFront){var er=chunkInvalid(state,chunk);if(er){stream.emit("error",er)}else if(chunk===null||chunk===undefined){state.reading=false;if(!state.ended)onEofChunk(stream,state)}else if(state.objectMode||chunk&&chunk.length>0){if(state.ended&&!addToFront){var e=new Error("stream.push() after EOF");stream.emit("error",e)}else if(state.endEmitted&&addToFront){var e=new Error("stream.unshift() after end event");stream.emit("error",e)}else{if(state.decoder&&!addToFront&&!encoding)chunk=state.decoder.write(chunk);state.length+=state.objectMode?1:chunk.length;if(addToFront){state.buffer.unshift(chunk)}else{state.reading=false;state.buffer.push(chunk)}if(state.needReadable)emitReadable(stream);maybeReadMore(stream,state)}}else if(!addToFront){state.reading=false}return needMoreData(state)}function needMoreData(state){return!state.ended&&(state.needReadable||state.length<state.highWaterMark||state.length===0)}Readable.prototype.setEncoding=function(enc){if(!StringDecoder)StringDecoder=require("string_decoder/").StringDecoder;this._readableState.decoder=new StringDecoder(enc);this._readableState.encoding=enc};var MAX_HWM=8388608;function roundUpToNextPowerOf2(n){if(n>=MAX_HWM){n=MAX_HWM}else{n--;for(var p=1;p<32;p<<=1)n|=n>>p;n++}return n}function howMuchToRead(n,state){if(state.length===0&&state.ended)return 0;if(state.objectMode)return n===0?0:1;if(n===null||isNaN(n)){if(state.flowing&&state.buffer.length)return state.buffer[0].length;else return state.length}if(n<=0)return 0;if(n>state.highWaterMark)state.highWaterMark=roundUpToNextPowerOf2(n);if(n>state.length){if(!state.ended){state.needReadable=true;return 0}else return state.length}return n}Readable.prototype.read=function(n){var state=this._readableState;state.calledRead=true;var nOrig=n;var ret;if(typeof n!=="number"||n>0)state.emittedReadable=false;if(n===0&&state.needReadable&&(state.length>=state.highWaterMark||state.ended)){emitReadable(this);return null}n=howMuchToRead(n,state);if(n===0&&state.ended){ret=null;if(state.length>0&&state.decoder){ret=fromList(n,state);state.length-=ret.length}if(state.length===0)endReadable(this);return ret}var doRead=state.needReadable;if(state.length-n<=state.highWaterMark)doRead=true;if(state.ended||state.reading)doRead=false;if(doRead){state.reading=true;state.sync=true;if(state.length===0)state.needReadable=true;this._read(state.highWaterMark);state.sync=false}if(doRead&&!state.reading)n=howMuchToRead(nOrig,state);if(n>0)ret=fromList(n,state);else ret=null;if(ret===null){state.needReadable=true;n=0}state.length-=n;if(state.length===0&&!state.ended)state.needReadable=true;if(state.ended&&!state.endEmitted&&state.length===0)endReadable(this);return ret};function chunkInvalid(state,chunk){var er=null;if(!Buffer.isBuffer(chunk)&&"string"!==typeof chunk&&chunk!==null&&chunk!==undefined&&!state.objectMode){er=new TypeError("Invalid non-string/buffer chunk")}return er}function onEofChunk(stream,state){if(state.decoder&&!state.ended){var chunk=state.decoder.end();if(chunk&&chunk.length){state.buffer.push(chunk);state.length+=state.objectMode?1:chunk.length}}state.ended=true;if(state.length>0)emitReadable(stream);else endReadable(stream)}function emitReadable(stream){var state=stream._readableState;state.needReadable=false;if(state.emittedReadable)return;state.emittedReadable=true;if(state.sync)process.nextTick(function(){emitReadable_(stream)});else emitReadable_(stream)}function emitReadable_(stream){stream.emit("readable")}function maybeReadMore(stream,state){if(!state.readingMore){state.readingMore=true;process.nextTick(function(){maybeReadMore_(stream,state)})}}function maybeReadMore_(stream,state){var len=state.length;while(!state.reading&&!state.flowing&&!state.ended&&state.length<state.highWaterMark){stream.read(0);if(len===state.length)break;else len=state.length}state.readingMore=false}Readable.prototype._read=function(n){this.emit("error",new Error("not implemented"))};Readable.prototype.pipe=function(dest,pipeOpts){var src=this;var state=this._readableState;switch(state.pipesCount){case 0:state.pipes=dest;break;case 1:state.pipes=[state.pipes,dest];break;default:state.pipes.push(dest);break}state.pipesCount+=1;var doEnd=(!pipeOpts||pipeOpts.end!==false)&&dest!==process.stdout&&dest!==process.stderr;var endFn=doEnd?onend:cleanup;if(state.endEmitted)process.nextTick(endFn);else src.once("end",endFn);dest.on("unpipe",onunpipe);function onunpipe(readable){if(readable!==src)return;cleanup()}function onend(){dest.end()}var ondrain=pipeOnDrain(src);dest.on("drain",ondrain);function cleanup(){dest.removeListener("close",onclose);dest.removeListener("finish",onfinish);dest.removeListener("drain",ondrain);dest.removeListener("error",onerror);dest.removeListener("unpipe",onunpipe);src.removeListener("end",onend);src.removeListener("end",cleanup);if(!dest._writableState||dest._writableState.needDrain)ondrain()}function onerror(er){unpipe();dest.removeListener("error",onerror);if(EE.listenerCount(dest,"error")===0)dest.emit("error",er)}if(!dest._events||!dest._events.error)dest.on("error",onerror);else if(isArray(dest._events.error))dest._events.error.unshift(onerror);else dest._events.error=[onerror,dest._events.error];function onclose(){dest.removeListener("finish",onfinish);unpipe()}dest.once("close",onclose);function onfinish(){dest.removeListener("close",onclose);unpipe()}dest.once("finish",onfinish);function unpipe(){src.unpipe(dest)}dest.emit("pipe",src);if(!state.flowing){this.on("readable",pipeOnReadable);state.flowing=true;process.nextTick(function(){flow(src)})}return dest};function pipeOnDrain(src){return function(){var dest=this;var state=src._readableState;state.awaitDrain--;if(state.awaitDrain===0)flow(src)}}function flow(src){var state=src._readableState;var chunk;state.awaitDrain=0;function write(dest,i,list){var written=dest.write(chunk);if(false===written){state.awaitDrain++}}while(state.pipesCount&&null!==(chunk=src.read())){if(state.pipesCount===1)write(state.pipes,0,null);else forEach(state.pipes,write);src.emit("data",chunk);if(state.awaitDrain>0)return}if(state.pipesCount===0){state.flowing=false;if(EE.listenerCount(src,"data")>0)emitDataEvents(src);return}state.ranOut=true}function pipeOnReadable(){if(this._readableState.ranOut){this._readableState.ranOut=false;flow(this)}}Readable.prototype.unpipe=function(dest){var state=this._readableState;if(state.pipesCount===0)return this;if(state.pipesCount===1){if(dest&&dest!==state.pipes)return this;if(!dest)dest=state.pipes;state.pipes=null;state.pipesCount=0;this.removeListener("readable",pipeOnReadable);state.flowing=false;if(dest)dest.emit("unpipe",this);return this}if(!dest){var dests=state.pipes;var len=state.pipesCount;state.pipes=null;state.pipesCount=0;this.removeListener("readable",pipeOnReadable);state.flowing=false;for(var i=0;i<len;i++)dests[i].emit("unpipe",this);return this}var i=indexOf(state.pipes,dest);if(i===-1)return this;state.pipes.splice(i,1);state.pipesCount-=1;if(state.pipesCount===1)state.pipes=state.pipes[0];dest.emit("unpipe",this);return this};Readable.prototype.on=function(ev,fn){var res=Stream.prototype.on.call(this,ev,fn);if(ev==="data"&&!this._readableState.flowing)emitDataEvents(this);if(ev==="readable"&&this.readable){var state=this._readableState;if(!state.readableListening){state.readableListening=true;state.emittedReadable=false;state.needReadable=true;if(!state.reading){this.read(0)}else if(state.length){emitReadable(this,state)}}}return res};Readable.prototype.addListener=Readable.prototype.on;Readable.prototype.resume=function(){emitDataEvents(this);this.read(0);this.emit("resume")};Readable.prototype.pause=function(){emitDataEvents(this,true);this.emit("pause")};function emitDataEvents(stream,startPaused){var state=stream._readableState;if(state.flowing){throw new Error("Cannot switch to old mode now.")}var paused=startPaused||false;var readable=false;stream.readable=true;stream.pipe=Stream.prototype.pipe;stream.on=stream.addListener=Stream.prototype.on;stream.on("readable",function(){readable=true;var c;while(!paused&&null!==(c=stream.read()))stream.emit("data",c);if(c===null){readable=false;stream._readableState.needReadable=true}});stream.pause=function(){paused=true;this.emit("pause")};stream.resume=function(){paused=false;if(readable)process.nextTick(function(){stream.emit("readable")});else this.read(0);this.emit("resume")};stream.emit("readable")}Readable.prototype.wrap=function(stream){var state=this._readableState;var paused=false;var self=this;stream.on("end",function(){if(state.decoder&&!state.ended){var chunk=state.decoder.end();if(chunk&&chunk.length)self.push(chunk)}self.push(null)});stream.on("data",function(chunk){if(state.decoder)chunk=state.decoder.write(chunk);if(state.objectMode&&(chunk===null||chunk===undefined))return;else if(!state.objectMode&&(!chunk||!chunk.length))return;var ret=self.push(chunk);if(!ret){paused=true;stream.pause()}});for(var i in stream){if(typeof stream[i]==="function"&&typeof this[i]==="undefined"){this[i]=function(method){return function(){return stream[method].apply(stream,arguments)}}(i)}}var events=["error","close","destroy","pause","resume"];forEach(events,function(ev){stream.on(ev,self.emit.bind(self,ev))});self._read=function(n){if(paused){paused=false;stream.resume()}};return self};Readable._fromList=fromList;function fromList(n,state){var list=state.buffer;var length=state.length;var stringMode=!!state.decoder;var objectMode=!!state.objectMode;var ret;if(list.length===0)return null;if(length===0)ret=null;else if(objectMode)ret=list.shift();else if(!n||n>=length){if(stringMode)ret=list.join("");else ret=Buffer.concat(list,length);list.length=0}else{if(n<list[0].length){var buf=list[0];ret=buf.slice(0,n);list[0]=buf.slice(n)}else if(n===list[0].length){ret=list.shift()}else{if(stringMode)ret="";else ret=new Buffer(n);var c=0;for(var i=0,l=list.length;i<l&&c<n;i++){var buf=list[0];var cpy=Math.min(n-c,buf.length);if(stringMode)ret+=buf.slice(0,cpy);else buf.copy(ret,c,0,cpy);if(cpy<buf.length)list[0]=buf.slice(cpy);else list.shift();c+=cpy}}}return ret}function endReadable(stream){var state=stream._readableState;if(state.length>0)throw new Error("endReadable called on non-empty stream");if(!state.endEmitted&&state.calledRead){state.ended=true;process.nextTick(function(){if(!state.endEmitted&&state.length===0){state.endEmitted=true;stream.readable=false;stream.emit("end")}})}}function forEach(xs,f){for(var i=0,l=xs.length;i<l;i++){f(xs[i],i)}}function indexOf(xs,x){for(var i=0,l=xs.length;i<l;i++){if(xs[i]===x)return i}return-1}}).call(this,require("_process"))},{_process:9,buffer:2,"core-util-is":16,events:6,inherits:7,isarray:8,stream:21,"string_decoder/":22}],14:[function(require,module,exports){module.exports=Transform;var Duplex=require("./_stream_duplex");var util=require("core-util-is");util.inherits=require("inherits");util.inherits(Transform,Duplex);function TransformState(options,stream){this.afterTransform=function(er,data){return afterTransform(stream,er,data)};this.needTransform=false;this.transforming=false;this.writecb=null;this.writechunk=null}function afterTransform(stream,er,data){var ts=stream._transformState;ts.transforming=false;var cb=ts.writecb;if(!cb)return stream.emit("error",new Error("no writecb in Transform class"));ts.writechunk=null;ts.writecb=null;if(data!==null&&data!==undefined)stream.push(data);if(cb)cb(er);var rs=stream._readableState;rs.reading=false;if(rs.needReadable||rs.length<rs.highWaterMark){stream._read(rs.highWaterMark)}}function Transform(options){if(!(this instanceof Transform))return new Transform(options);Duplex.call(this,options);var ts=this._transformState=new TransformState(options,this);var stream=this;this._readableState.needReadable=true;this._readableState.sync=false;this.once("finish",function(){if("function"===typeof this._flush)this._flush(function(er){done(stream,er)});else done(stream)})}Transform.prototype.push=function(chunk,encoding){this._transformState.needTransform=false;return Duplex.prototype.push.call(this,chunk,encoding)};Transform.prototype._transform=function(chunk,encoding,cb){throw new Error("not implemented")};Transform.prototype._write=function(chunk,encoding,cb){var ts=this._transformState;ts.writecb=cb;ts.writechunk=chunk;ts.writeencoding=encoding;if(!ts.transforming){var rs=this._readableState;if(ts.needTransform||rs.needReadable||rs.length<rs.highWaterMark)this._read(rs.highWaterMark)}};Transform.prototype._read=function(n){var ts=this._transformState;if(ts.writechunk!==null&&ts.writecb&&!ts.transforming){ts.transforming=true;this._transform(ts.writechunk,ts.writeencoding,ts.afterTransform)}else{ts.needTransform=true}};function done(stream,er){if(er)return stream.emit("error",er);var ws=stream._writableState;var rs=stream._readableState;var ts=stream._transformState;if(ws.length)throw new Error("calling transform done when ws.length != 0");if(ts.transforming)throw new Error("calling transform done when still transforming");return stream.push(null)}},{"./_stream_duplex":11,"core-util-is":16,inherits:7}],15:[function(require,module,exports){(function(process){module.exports=Writable;var Buffer=require("buffer").Buffer;Writable.WritableState=WritableState;var util=require("core-util-is");util.inherits=require("inherits");var Stream=require("stream");util.inherits(Writable,Stream);function WriteReq(chunk,encoding,cb){this.chunk=chunk;this.encoding=encoding;this.callback=cb}function WritableState(options,stream){options=options||{};var hwm=options.highWaterMark;this.highWaterMark=hwm||hwm===0?hwm:16*1024;this.objectMode=!!options.objectMode;this.highWaterMark=~~this.highWaterMark;this.needDrain=false;this.ending=false;this.ended=false;this.finished=false;var noDecode=options.decodeStrings===false;this.decodeStrings=!noDecode;this.defaultEncoding=options.defaultEncoding||"utf8";this.length=0;this.writing=false;this.sync=true;this.bufferProcessing=false;this.onwrite=function(er){onwrite(stream,er)};this.writecb=null;this.writelen=0;this.buffer=[];this.errorEmitted=false}function Writable(options){var Duplex=require("./_stream_duplex");if(!(this instanceof Writable)&&!(this instanceof Duplex))return new Writable(options);this._writableState=new WritableState(options,this);this.writable=true;Stream.call(this)}Writable.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))};function writeAfterEnd(stream,state,cb){var er=new Error("write after end");stream.emit("error",er);process.nextTick(function(){cb(er)})}function validChunk(stream,state,chunk,cb){var valid=true;if(!Buffer.isBuffer(chunk)&&"string"!==typeof chunk&&chunk!==null&&chunk!==undefined&&!state.objectMode){var er=new TypeError("Invalid non-string/buffer chunk");stream.emit("error",er);process.nextTick(function(){cb(er)});valid=false}return valid}Writable.prototype.write=function(chunk,encoding,cb){var state=this._writableState;var ret=false;if(typeof encoding==="function"){cb=encoding;encoding=null}if(Buffer.isBuffer(chunk))encoding="buffer";else if(!encoding)encoding=state.defaultEncoding;if(typeof cb!=="function")cb=function(){};if(state.ended)writeAfterEnd(this,state,cb);else if(validChunk(this,state,chunk,cb))ret=writeOrBuffer(this,state,chunk,encoding,cb);return ret};function decodeChunk(state,chunk,encoding){if(!state.objectMode&&state.decodeStrings!==false&&typeof chunk==="string"){chunk=new Buffer(chunk,encoding)}return chunk}function writeOrBuffer(stream,state,chunk,encoding,cb){chunk=decodeChunk(state,chunk,encoding);if(Buffer.isBuffer(chunk))encoding="buffer";var len=state.objectMode?1:chunk.length;state.length+=len;var ret=state.length<state.highWaterMark;if(!ret)state.needDrain=true;if(state.writing)state.buffer.push(new WriteReq(chunk,encoding,cb));else doWrite(stream,state,len,chunk,encoding,cb);return ret}function doWrite(stream,state,len,chunk,encoding,cb){state.writelen=len;state.writecb=cb;state.writing=true;state.sync=true;stream._write(chunk,encoding,state.onwrite);state.sync=false}function onwriteError(stream,state,sync,er,cb){if(sync)process.nextTick(function(){cb(er)});else cb(er);stream._writableState.errorEmitted=true;stream.emit("error",er)}function onwriteStateUpdate(state){state.writing=false;state.writecb=null;state.length-=state.writelen;state.writelen=0}function onwrite(stream,er){var state=stream._writableState;var sync=state.sync;var cb=state.writecb;onwriteStateUpdate(state);if(er)onwriteError(stream,state,sync,er,cb);else{var finished=needFinish(stream,state);if(!finished&&!state.bufferProcessing&&state.buffer.length)clearBuffer(stream,state);if(sync){process.nextTick(function(){afterWrite(stream,state,finished,cb)})}else{afterWrite(stream,state,finished,cb)}}}function afterWrite(stream,state,finished,cb){if(!finished)onwriteDrain(stream,state);cb();if(finished)finishMaybe(stream,state)}function onwriteDrain(stream,state){if(state.length===0&&state.needDrain){state.needDrain=false;stream.emit("drain")}}function clearBuffer(stream,state){state.bufferProcessing=true;for(var c=0;c<state.buffer.length;c++){var entry=state.buffer[c];var chunk=entry.chunk;var encoding=entry.encoding;var cb=entry.callback;var len=state.objectMode?1:chunk.length;doWrite(stream,state,len,chunk,encoding,cb);if(state.writing){c++;break}}state.bufferProcessing=false;if(c<state.buffer.length)state.buffer=state.buffer.slice(c);else state.buffer.length=0}Writable.prototype._write=function(chunk,encoding,cb){cb(new Error("not implemented"))};Writable.prototype.end=function(chunk,encoding,cb){var state=this._writableState;if(typeof chunk==="function"){cb=chunk;chunk=null;encoding=null}else if(typeof encoding==="function"){cb=encoding;encoding=null}if(typeof chunk!=="undefined"&&chunk!==null)this.write(chunk,encoding);if(!state.ending&&!state.finished)endWritable(this,state,cb)};function needFinish(stream,state){return state.ending&&state.length===0&&!state.finished&&!state.writing}function finishMaybe(stream,state){var need=needFinish(stream,state);if(need){state.finished=true;stream.emit("finish")}return need}function endWritable(stream,state,cb){state.ending=true;finishMaybe(stream,state);if(cb){if(state.finished)process.nextTick(cb);else stream.once("finish",cb)}state.ended=true}}).call(this,require("_process"))},{"./_stream_duplex":11,_process:9,buffer:2,"core-util-is":16,inherits:7,stream:21}],16:[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}],17:[function(require,module,exports){module.exports=require("./lib/_stream_passthrough.js")},{"./lib/_stream_passthrough.js":12}],18:[function(require,module,exports){var Stream=require("stream");exports=module.exports=require("./lib/_stream_readable.js");exports.Stream=Stream;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":11,"./lib/_stream_passthrough.js":12,"./lib/_stream_readable.js":13,"./lib/_stream_transform.js":14,"./lib/_stream_writable.js":15,stream:21}],19:[function(require,module,exports){module.exports=require("./lib/_stream_transform.js")},{"./lib/_stream_transform.js":14}],20:[function(require,module,exports){module.exports=require("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":15}],21:[function(require,module,exports){module.exports=Stream;var EE=require("events").EventEmitter;var inherits=require("inherits");inherits(Stream,EE);Stream.Readable=require("readable-stream/readable.js");Stream.Writable=require("readable-stream/writable.js");Stream.Duplex=require("readable-stream/duplex.js");Stream.Transform=require("readable-stream/transform.js");Stream.PassThrough=require("readable-stream/passthrough.js");Stream.Stream=Stream;function Stream(){EE.call(this)}Stream.prototype.pipe=function(dest,options){var source=this;function ondata(chunk){if(dest.writable){if(false===dest.write(chunk)&&source.pause){source.pause()}}}source.on("data",ondata);function ondrain(){if(source.readable&&source.resume){source.resume()}}dest.on("drain",ondrain);if(!dest._isStdio&&(!options||options.end!==false)){source.on("end",onend);source.on("close",onclose)}var didOnEnd=false;function onend(){if(didOnEnd)return;didOnEnd=true;dest.end()}function onclose(){if(didOnEnd)return;didOnEnd=true;if(typeof dest.destroy==="function")dest.destroy()}function onerror(er){cleanup();if(EE.listenerCount(this,"error")===0){throw er}}source.on("error",onerror);dest.on("error",onerror);function cleanup(){source.removeListener("data",ondata);dest.removeListener("drain",ondrain);source.removeListener("end",onend);source.removeListener("close",onclose);source.removeListener("error",onerror);dest.removeListener("error",onerror);source.removeListener("end",cleanup);source.removeListener("close",cleanup);dest.removeListener("close",cleanup)}source.on("end",cleanup);source.on("close",cleanup);dest.on("close",cleanup);dest.emit("pipe",source);return dest}},{events:6,inherits:7,"readable-stream/duplex.js":10,"readable-stream/passthrough.js":17,"readable-stream/readable.js":18,"readable-stream/transform.js":19,"readable-stream/writable.js":20}],22:[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}],23:[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"}},{}],24:[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":23,_process:9,inherits:7}],25:[function(require,module,exports){(function(Buffer){module.exports=Level;var IDB=require("idb-wrapper");var AbstractLevelDOWN=require("abstract-leveldown").AbstractLevelDOWN;var util=require("util");var Iterator=require("./iterator");var isBuffer=require("isbuffer");function Level(location){if(!(this instanceof Level))return new Level(location);if(!location)throw new Error("constructor requires at least a location argument");this.location=location}util.inherits(Level,AbstractLevelDOWN);Level.prototype._open=function(options,callback){var self=this;this.idb=new IDB({storeName:this.location,autoIncrement:false,keyPath:null,onStoreReady:function(){callback&&callback(null,self.idb)},onError:function(err){callback&&callback(err)}})};Level.prototype._get=function(key,options,callback){this.idb.get(key,function(value){if(value===undefined){return callback(new Error("NotFound"))}if(options.asBuffer!==false&&!Buffer.isBuffer(value))value=new Buffer(String(value));return callback(null,value,key)},callback)};Level.prototype._del=function(id,options,callback){this.idb.remove(id,callback,callback)};Level.prototype._put=function(key,value,options,callback){if(value instanceof ArrayBuffer){value=String.fromCharCode.apply(null,new Uint16Array(value))}this.idb.put(key,value,function(){callback()},callback)};Level.prototype.iterator=function(options){if(typeof options!=="object")options={};return new Iterator(this.idb,options)};Level.prototype._batch=function(array,options,callback){var op;var i;var k;var copiedOp;var currentOp;var modified=[];for(i=0;i<array.length;i++){copiedOp={};currentOp=array[i];modified[i]=copiedOp;for(k in currentOp){if(k==="type"&&currentOp[k]=="del"){copiedOp[k]="remove"}else{copiedOp[k]=currentOp[k]}}}return this.idb.batch(modified,function(){callback()},callback)};Level.prototype._close=function(callback){this.idb.db.close();callback()};Level.prototype._approximateSize=function(start,end,callback){var err=new Error("Not implemented");if(callback)return callback(err);throw err};Level.prototype._isBuffer=function(obj){return Buffer.isBuffer(obj)};var checkKeyValue=Level.prototype._checkKeyValue=function(obj,type){if(obj===null||obj===undefined)return new Error(type+" cannot be `null` or `undefined`");if(obj===null||obj===undefined)return new Error(type+" cannot be `null` or `undefined`");if(isBuffer(obj)&&obj.byteLength===0)return new Error(type+" cannot be an empty ArrayBuffer");if(String(obj)==="")return new Error(type+" cannot be an empty String");if(obj.length===0)return new Error(type+" cannot be an empty Array")}}).call(this,require("buffer").Buffer)},{"./iterator":26,"abstract-leveldown":29,buffer:2,"idb-wrapper":36,isbuffer:37,util:24}],26:[function(require,module,exports){var util=require("util");var AbstractIterator=require("abstract-leveldown").AbstractIterator;module.exports=Iterator;function Iterator(db,options){if(!options)options={};this.options=options;AbstractIterator.call(this,db);this._order=options.reverse?"DESC":"ASC";this._start=options.start;this._limit=options.limit;this._count=0;this._end=options.end;this._done=false;this._gt=options.gt;this._gte=options.gte;this._lt=options.lt;this._lte=options.lte}util.inherits(Iterator,AbstractIterator);Iterator.prototype.createIterator=function(){var self=this;var lower,upper;var onlyStart=typeof self._start!=="undefined"&&typeof self._end==="undefined";var onlyEnd=typeof self._start==="undefined"&&typeof self._end!=="undefined";var startAndEnd=typeof self._start!=="undefined"&&typeof self._end!=="undefined";if(onlyStart){var index=self._start;if(self._order==="ASC"){lower=index}else{upper=index}}else if(onlyEnd){var index=self._end;if(self._order==="DESC"){lower=index}else{upper=index}}else if(startAndEnd){lower=self._start;upper=self._end;if(self._start>self._end){lower=self._end;upper=self._start}}if(!lower){if(self._gte!=="undefined")lower=self._gte;else if(self._gt!=="undefined")lower=self._gt}if(!upper){if(self._lte!=="undefined")upper=self._lte;else if(self._lt!=="undefined")upper=self._lt}if(lower||upper){self._keyRange=self.options.keyRange||self.db.makeKeyRange({lower:lower,upper:upper})}self.iterator=self.db.iterate(function(){self.onItem.apply(self,arguments)},{keyRange:self._keyRange,autoContinue:false,order:self._order,onError:function(err){console.log("horrible error",err)}})};Iterator.prototype.onItem=function(value,cursor,cursorTransaction){if(!cursor&&this.callback){this.callback();this.callback=false;return}var shouldCall=true;if(!!this._limit&&this._limit>0&&this._count++>=this._limit)shouldCall=false;if(this._lt&&cursor.key>=this._lt||this._lte&&cursor.key>this._lte||this._gt&&cursor.key<=this._gt||this._gte&&cursor.key<this._gte)shouldCall=false;if(shouldCall)this.callback(false,cursor.key,cursor.value);if(cursor)cursor.continue()};Iterator.prototype._next=function(callback){if(!callback)return new Error("next() requires a callback argument");if(!this._started){this.createIterator();this._started=true}this.callback=callback}},{"abstract-leveldown":29,util:24}],27:[function(require,module,exports){(function(process){function AbstractChainedBatch(db){this._db=db;this._operations=[];this._written=false}AbstractChainedBatch.prototype._checkWritten=function(){if(this._written)throw new Error("write() already called on this batch")};AbstractChainedBatch.prototype.put=function(key,value){this._checkWritten();var err=this._db._checkKeyValue(key,"key",this._db._isBuffer);if(err)throw err;err=this._db._checkKeyValue(value,"value",this._db._isBuffer);if(err)throw err;if(!this._db._isBuffer(key))key=String(key);if(!this._db._isBuffer(value))value=String(value);if(typeof this._put=="function")this._put(key,value);else this._operations.push({type:"put",key:key,value:value});return this};AbstractChainedBatch.prototype.del=function(key){this._checkWritten();var err=this._db._checkKeyValue(key,"key",this._db._isBuffer);if(err)throw err;if(!this._db._isBuffer(key))key=String(key);if(typeof this._del=="function")this._del(key);else this._operations.push({type:"del",key:key});return this};AbstractChainedBatch.prototype.clear=function(){this._checkWritten();this._operations=[];if(typeof this._clear=="function")this._clear();return this};AbstractChainedBatch.prototype.write=function(options,callback){this._checkWritten();if(typeof options=="function")callback=options;if(typeof callback!="function")throw new Error("write() requires a callback argument");if(typeof options!="object")options={};this._written=true;if(typeof this._write=="function")return this._write(callback);if(typeof this._db._batch=="function")return this._db._batch(this._operations,options,callback);process.nextTick(callback)};module.exports=AbstractChainedBatch}).call(this,require("_process"))},{_process:9}],28:[function(require,module,exports){(function(process){function AbstractIterator(db){this.db=db;this._ended=false;this._nexting=false}AbstractIterator.prototype.next=function(callback){var self=this;if(typeof callback!="function")throw new Error("next() requires a callback argument");if(self._ended)return callback(new Error("cannot call next() after end()"));if(self._nexting)return callback(new Error("cannot call next() before previous next() has completed"));self._nexting=true;if(typeof self._next=="function"){return self._next(function(){self._nexting=false;callback.apply(null,arguments)})}process.nextTick(function(){self._nexting=false;callback()})};AbstractIterator.prototype.end=function(callback){if(typeof callback!="function")throw new Error("end() requires a callback argument");if(this._ended)return callback(new Error("end() already called on iterator"));this._ended=true;if(typeof this._end=="function")return this._end(callback);process.nextTick(callback)};module.exports=AbstractIterator}).call(this,require("_process"))},{_process:9}],29:[function(require,module,exports){(function(process,Buffer){var xtend=require("xtend"),AbstractIterator=require("./abstract-iterator"),AbstractChainedBatch=require("./abstract-chained-batch");function AbstractLevelDOWN(location){if(!arguments.length||location===undefined)throw new Error("constructor requires at least a location argument");if(typeof location!="string")throw new Error("constructor requires a location string argument");this.location=location}AbstractLevelDOWN.prototype.open=function(options,callback){if(typeof options=="function")callback=options;if(typeof callback!="function")throw new Error("open() requires a callback argument");if(typeof options!="object")options={};if(typeof this._open=="function")return this._open(options,callback);process.nextTick(callback)};AbstractLevelDOWN.prototype.close=function(callback){if(typeof callback!="function")throw new Error("close() requires a callback argument");if(typeof this._close=="function")return this._close(callback);process.nextTick(callback)};AbstractLevelDOWN.prototype.get=function(key,options,callback){var err;if(typeof options=="function")callback=options;if(typeof callback!="function")throw new Error("get() requires a callback argument");if(err=this._checkKeyValue(key,"key",this._isBuffer))return callback(err);if(!this._isBuffer(key))key=String(key);if(typeof options!="object")options={};if(typeof this._get=="function")return this._get(key,options,callback);process.nextTick(function(){callback(new Error("NotFound"))})};AbstractLevelDOWN.prototype.put=function(key,value,options,callback){var err;if(typeof options=="function")callback=options;if(typeof callback!="function")throw new Error("put() requires a callback argument");if(err=this._checkKeyValue(key,"key",this._isBuffer))return callback(err);if(err=this._checkKeyValue(value,"value",this._isBuffer))return callback(err);if(!this._isBuffer(key))key=String(key);if(!this._isBuffer(value)&&!process.browser)value=String(value);if(typeof options!="object")options={};if(typeof this._put=="function")return this._put(key,value,options,callback);process.nextTick(callback)};AbstractLevelDOWN.prototype.del=function(key,options,callback){var err;if(typeof options=="function")callback=options;if(typeof callback!="function")throw new Error("del() requires a callback argument");if(err=this._checkKeyValue(key,"key",this._isBuffer))return callback(err);if(!this._isBuffer(key))key=String(key);if(typeof options!="object")options={};if(typeof this._del=="function")return this._del(key,options,callback);process.nextTick(callback)};AbstractLevelDOWN.prototype.batch=function(array,options,callback){if(!arguments.length)return this._chainedBatch();if(typeof options=="function")callback=options;if(typeof callback!="function")throw new Error("batch(array) requires a callback argument");if(!Array.isArray(array))return callback(new Error("batch(array) requires an array argument"));if(typeof options!="object")options={};var i=0,l=array.length,e,err;for(;i<l;i++){e=array[i];if(typeof e!="object")continue;if(err=this._checkKeyValue(e.type,"type",this._isBuffer))return callback(err);if(err=this._checkKeyValue(e.key,"key",this._isBuffer))return callback(err);if(e.type=="put"){if(err=this._checkKeyValue(e.value,"value",this._isBuffer))return callback(err)}}if(typeof this._batch=="function")return this._batch(array,options,callback);process.nextTick(callback)};AbstractLevelDOWN.prototype.approximateSize=function(start,end,callback){if(start==null||end==null||typeof start=="function"||typeof end=="function"){throw new Error("approximateSize() requires valid `start`, `end` and `callback` arguments")}if(typeof callback!="function")throw new Error("approximateSize() requires a callback argument");if(!this._isBuffer(start))start=String(start);if(!this._isBuffer(end))end=String(end);if(typeof this._approximateSize=="function")return this._approximateSize(start,end,callback);process.nextTick(function(){callback(null,0)})};AbstractLevelDOWN.prototype._setupIteratorOptions=function(options){var self=this;options=xtend(options);["start","end","gt","gte","lt","lte"].forEach(function(o){if(options[o]&&self._isBuffer(options[o])&&options[o].length===0)delete options[o]});options.reverse=!!options.reverse;if(options.reverse&&options.lt)options.start=options.lt;if(options.reverse&&options.lte)options.start=options.lte;if(!options.reverse&&options.gt)options.start=options.gt;if(!options.reverse&&options.gte)options.start=options.gte;if(options.reverse&&options.lt&&!options.lte||!options.reverse&&options.gt&&!options.gte)options.exclusiveStart=true;return options};AbstractLevelDOWN.prototype.iterator=function(options){if(typeof options!="object")options={};options=this._setupIteratorOptions(options);if(typeof this._iterator=="function")return this._iterator(options);return new AbstractIterator(this)};AbstractLevelDOWN.prototype._chainedBatch=function(){return new AbstractChainedBatch(this)};AbstractLevelDOWN.prototype._isBuffer=function(obj){return Buffer.isBuffer(obj)};AbstractLevelDOWN.prototype._checkKeyValue=function(obj,type){if(obj===null||obj===undefined)return new Error(type+" cannot be `null` or `undefined`");if(obj===null||obj===undefined)return new Error(type+" cannot be `null` or `undefined`");if(this._isBuffer(obj)){if(obj.length===0)return new Error(type+" cannot be an empty Buffer")}else if(String(obj)==="")return new Error(type+" cannot be an empty String")};module.exports.AbstractLevelDOWN=AbstractLevelDOWN;module.exports.AbstractIterator=AbstractIterator;module.exports.AbstractChainedBatch=AbstractChainedBatch}).call(this,require("_process"),require("buffer").Buffer)},{"./abstract-chained-batch":27,"./abstract-iterator":28,_process:9,buffer:2,xtend:31}],30:[function(require,module,exports){module.exports=hasKeys;function hasKeys(source){return source!==null&&(typeof source==="object"||typeof source==="function")}},{}],31:[function(require,module,exports){var Keys=require("object-keys");var hasKeys=require("./has-keys");module.exports=extend;function extend(){var target={};for(var i=0;i<arguments.length;i++){var source=arguments[i];if(!hasKeys(source)){continue}var keys=Keys(source);for(var j=0;j<keys.length;j++){var name=keys[j];target[name]=source[name]}}return target}},{"./has-keys":30,"object-keys":33}],32:[function(require,module,exports){var hasOwn=Object.prototype.hasOwnProperty;var toString=Object.prototype.toString;var isFunction=function(fn){var isFunc=typeof fn==="function"&&!(fn instanceof RegExp)||toString.call(fn)==="[object Function]";if(!isFunc&&typeof window!=="undefined"){isFunc=fn===window.setTimeout||fn===window.alert||fn===window.confirm||fn===window.prompt}return isFunc};module.exports=function forEach(obj,fn){if(!isFunction(fn)){throw new TypeError("iterator must be a function")}var i,k,isString=typeof obj==="string",l=obj.length,context=arguments.length>2?arguments[2]:null;if(l===+l){for(i=0;i<l;i++){if(context===null){fn(isString?obj.charAt(i):obj[i],i,obj)}else{fn.call(context,isString?obj.charAt(i):obj[i],i,obj)}}}else{for(k in obj){if(hasOwn.call(obj,k)){if(context===null){fn(obj[k],k,obj)}else{fn.call(context,obj[k],k,obj)}}}}}},{}],33:[function(require,module,exports){module.exports=Object.keys||require("./shim")},{"./shim":35}],34:[function(require,module,exports){var toString=Object.prototype.toString;module.exports=function isArguments(value){var str=toString.call(value);var isArguments=str==="[object Arguments]";if(!isArguments){isArguments=str!=="[object Array]"&&value!==null&&typeof value==="object"&&typeof value.length==="number"&&value.length>=0&&toString.call(value.callee)==="[object Function]"}return isArguments}},{}],35:[function(require,module,exports){(function(){"use strict";var has=Object.prototype.hasOwnProperty,toString=Object.prototype.toString,forEach=require("./foreach"),isArgs=require("./isArguments"),hasDontEnumBug=!{toString:null}.propertyIsEnumerable("toString"),hasProtoEnumBug=function(){}.propertyIsEnumerable("prototype"),dontEnums=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],keysShim;keysShim=function keys(object){var isObject=object!==null&&typeof object==="object",isFunction=toString.call(object)==="[object Function]",isArguments=isArgs(object),theKeys=[];if(!isObject&&!isFunction&&!isArguments){throw new TypeError("Object.keys called on a non-object")}if(isArguments){forEach(object,function(value){theKeys.push(value)})}else{var name,skipProto=hasProtoEnumBug&&isFunction;for(name in object){if(!(skipProto&&name==="prototype")&&has.call(object,name)){theKeys.push(name)}}}if(hasDontEnumBug){var ctor=object.constructor,skipConstructor=ctor&&ctor.prototype===object;forEach(dontEnums,function(dontEnum){if(!(skipConstructor&&dontEnum==="constructor")&&has.call(object,dontEnum)){theKeys.push(dontEnum)}})}return theKeys};module.exports=keysShim})()},{"./foreach":32,"./isArguments":34}],36:[function(require,module,exports){(function(name,definition,global){if(typeof define==="function"){define(definition)}else if(typeof module!=="undefined"&&module.exports){module.exports=definition()}else{global[name]=definition()}})("IDBStore",function(){"use strict";var defaultErrorHandler=function(error){throw error};var defaults={storeName:"Store",storePrefix:"IDBWrapper-",dbVersion:1,keyPath:"id",autoIncrement:true,onStoreReady:function(){},onError:defaultErrorHandler,indexes:[]};var IDBStore=function(kwArgs,onStoreReady){if(typeof onStoreReady=="undefined"&&typeof kwArgs=="function"){onStoreReady=kwArgs}if(Object.prototype.toString.call(kwArgs)!="[object Object]"){kwArgs={}}for(var key in defaults){this[key]=typeof kwArgs[key]!="undefined"?kwArgs[key]:defaults[key]}this.dbName=this.storePrefix+this.storeName;this.dbVersion=parseInt(this.dbVersion,10)||1;onStoreReady&&(this.onStoreReady=onStoreReady);var env=typeof window=="object"?window:self;this.idb=env.indexedDB||env.webkitIndexedDB||env.mozIndexedDB;this.keyRange=env.IDBKeyRange||env.webkitIDBKeyRange||env.mozIDBKeyRange;this.features={hasAutoIncrement:!env.mozIndexedDB};this.consts={READ_ONLY:"readonly",READ_WRITE:"readwrite",VERSION_CHANGE:"versionchange",NEXT:"next",NEXT_NO_DUPLICATE:"nextunique",PREV:"prev",PREV_NO_DUPLICATE:"prevunique"};this.openDB()};IDBStore.prototype={constructor:IDBStore,version:"1.4.1",db:null,dbName:null,dbVersion:null,store:null,storeName:null,keyPath:null,autoIncrement:null,indexes:null,features:null,onStoreReady:null,onError:null,_insertIdCount:0,openDB:function(){var openRequest=this.idb.open(this.dbName,this.dbVersion);var preventSuccessCallback=false;openRequest.onerror=function(error){var gotVersionErr=false;if("error"in error.target){gotVersionErr=error.target.error.name=="VersionError"}else if("errorCode"in error.target){gotVersionErr=error.target.errorCode==12}if(gotVersionErr){this.onError(new Error("The version number provided is lower than the existing one."))}else{this.onError(error)}}.bind(this);openRequest.onsuccess=function(event){if(preventSuccessCallback){return}if(this.db){this.onStoreReady();return}this.db=event.target.result;if(typeof this.db.version=="string"){this.onError(new Error("The IndexedDB implementation in this browser is outdated. Please upgrade your browser."));return}if(!this.db.objectStoreNames.contains(this.storeName)){this.onError(new Error("Something is wrong with the IndexedDB implementation in this browser. Please upgrade your browser."));return}var emptyTransaction=this.db.transaction([this.storeName],this.consts.READ_ONLY);this.store=emptyTransaction.objectStore(this.storeName);var existingIndexes=Array.prototype.slice.call(this.getIndexList());this.indexes.forEach(function(indexData){var indexName=indexData.name;if(!indexName){preventSuccessCallback=true;this.onError(new Error("Cannot create index: No index name given."));return}this.normalizeIndexData(indexData);if(this.hasIndex(indexName)){var actualIndex=this.store.index(indexName);var complies=this.indexComplies(actualIndex,indexData);if(!complies){preventSuccessCallback=true;this.onError(new Error('Cannot modify index "'+indexName+'" for current version. Please bump version number to '+(this.dbVersion+1)+"."))}existingIndexes.splice(existingIndexes.indexOf(indexName),1)}else{preventSuccessCallback=true;this.onError(new Error('Cannot create new index "'+indexName+'" for current version. Please bump version number to '+(this.dbVersion+1)+"."))}},this);if(existingIndexes.length){preventSuccessCallback=true;this.onError(new Error('Cannot delete index(es) "'+existingIndexes.toString()+'" for current version. Please bump version number to '+(this.dbVersion+1)+"."))}preventSuccessCallback||this.onStoreReady()}.bind(this);openRequest.onupgradeneeded=function(event){this.db=event.target.result;if(this.db.objectStoreNames.contains(this.storeName)){this.store=event.target.transaction.objectStore(this.storeName)}else{var optionalParameters={autoIncrement:this.autoIncrement};if(this.keyPath!==null){optionalParameters.keyPath=this.keyPath}this.store=this.db.createObjectStore(this.storeName,optionalParameters)}var existingIndexes=Array.prototype.slice.call(this.getIndexList());this.indexes.forEach(function(indexData){var indexName=indexData.name;if(!indexName){preventSuccessCallback=true;this.onError(new Error("Cannot create index: No index name given."))}this.normalizeIndexData(indexData);if(this.hasIndex(indexName)){var actualIndex=this.store.index(indexName);var complies=this.indexComplies(actualIndex,indexData);if(!complies){this.store.deleteIndex(indexName);this.store.createIndex(indexName,indexData.keyPath,{unique:indexData.unique,multiEntry:indexData.multiEntry})
}existingIndexes.splice(existingIndexes.indexOf(indexName),1)}else{this.store.createIndex(indexName,indexData.keyPath,{unique:indexData.unique,multiEntry:indexData.multiEntry})}},this);if(existingIndexes.length){existingIndexes.forEach(function(_indexName){this.store.deleteIndex(_indexName)},this)}}.bind(this)},deleteDatabase:function(){if(this.idb.deleteDatabase){this.idb.deleteDatabase(this.dbName)}},put:function(key,value,onSuccess,onError){if(this.keyPath!==null){onError=onSuccess;onSuccess=value;value=key}onError||(onError=defaultErrorHandler);onSuccess||(onSuccess=noop);var hasSuccess=false,result=null,putRequest;var putTransaction=this.db.transaction([this.storeName],this.consts.READ_WRITE);putTransaction.oncomplete=function(){var callback=hasSuccess?onSuccess:onError;callback(result)};putTransaction.onabort=onError;putTransaction.onerror=onError;if(this.keyPath!==null){this._addIdPropertyIfNeeded(value);putRequest=putTransaction.objectStore(this.storeName).put(value)}else{putRequest=putTransaction.objectStore(this.storeName).put(value,key)}putRequest.onsuccess=function(event){hasSuccess=true;result=event.target.result};putRequest.onerror=onError;return putTransaction},get:function(key,onSuccess,onError){onError||(onError=defaultErrorHandler);onSuccess||(onSuccess=noop);var hasSuccess=false,result=null;var getTransaction=this.db.transaction([this.storeName],this.consts.READ_ONLY);getTransaction.oncomplete=function(){var callback=hasSuccess?onSuccess:onError;callback(result)};getTransaction.onabort=onError;getTransaction.onerror=onError;var getRequest=getTransaction.objectStore(this.storeName).get(key);getRequest.onsuccess=function(event){hasSuccess=true;result=event.target.result};getRequest.onerror=onError;return getTransaction},remove:function(key,onSuccess,onError){onError||(onError=defaultErrorHandler);onSuccess||(onSuccess=noop);var hasSuccess=false,result=null;var removeTransaction=this.db.transaction([this.storeName],this.consts.READ_WRITE);removeTransaction.oncomplete=function(){var callback=hasSuccess?onSuccess:onError;callback(result)};removeTransaction.onabort=onError;removeTransaction.onerror=onError;var deleteRequest=removeTransaction.objectStore(this.storeName)["delete"](key);deleteRequest.onsuccess=function(event){hasSuccess=true;result=event.target.result};deleteRequest.onerror=onError;return removeTransaction},batch:function(dataArray,onSuccess,onError){onError||(onError=defaultErrorHandler);onSuccess||(onSuccess=noop);if(Object.prototype.toString.call(dataArray)!="[object Array]"){onError(new Error("dataArray argument must be of type Array."))}var batchTransaction=this.db.transaction([this.storeName],this.consts.READ_WRITE);batchTransaction.oncomplete=function(){var callback=hasSuccess?onSuccess:onError;callback(hasSuccess)};batchTransaction.onabort=onError;batchTransaction.onerror=onError;var count=dataArray.length;var called=false;var hasSuccess=false;var onItemSuccess=function(){count--;if(count===0&&!called){called=true;hasSuccess=true}};dataArray.forEach(function(operation){var type=operation.type;var key=operation.key;var value=operation.value;var onItemError=function(err){batchTransaction.abort();if(!called){called=true;onError(err,type,key)}};if(type=="remove"){var deleteRequest=batchTransaction.objectStore(this.storeName)["delete"](key);deleteRequest.onsuccess=onItemSuccess;deleteRequest.onerror=onItemError}else if(type=="put"){var putRequest;if(this.keyPath!==null){this._addIdPropertyIfNeeded(value);putRequest=batchTransaction.objectStore(this.storeName).put(value)}else{putRequest=batchTransaction.objectStore(this.storeName).put(value,key)}putRequest.onsuccess=onItemSuccess;putRequest.onerror=onItemError}},this);return batchTransaction},putBatch:function(dataArray,onSuccess,onError){var batchData=dataArray.map(function(item){return{type:"put",value:item}});return this.batch(batchData,onSuccess,onError)},removeBatch:function(keyArray,onSuccess,onError){var batchData=keyArray.map(function(key){return{type:"remove",key:key}});return this.batch(batchData,onSuccess,onError)},getBatch:function(keyArray,onSuccess,onError,arrayType){onError||(onError=defaultErrorHandler);onSuccess||(onSuccess=noop);arrayType||(arrayType="sparse");if(Object.prototype.toString.call(keyArray)!="[object Array]"){onError(new Error("keyArray argument must be of type Array."))}var batchTransaction=this.db.transaction([this.storeName],this.consts.READ_ONLY);batchTransaction.oncomplete=function(){var callback=hasSuccess?onSuccess:onError;callback(result)};batchTransaction.onabort=onError;batchTransaction.onerror=onError;var data=[];var count=keyArray.length;var called=false;var hasSuccess=false;var result=null;var onItemSuccess=function(event){if(event.target.result||arrayType=="dense"){data.push(event.target.result)}else if(arrayType=="sparse"){data.length++}count--;if(count===0){called=true;hasSuccess=true;result=data}};keyArray.forEach(function(key){var onItemError=function(err){called=true;result=err;onError(err);batchTransaction.abort()};var getRequest=batchTransaction.objectStore(this.storeName).get(key);getRequest.onsuccess=onItemSuccess;getRequest.onerror=onItemError},this);return batchTransaction},getAll:function(onSuccess,onError){onError||(onError=defaultErrorHandler);onSuccess||(onSuccess=noop);var getAllTransaction=this.db.transaction([this.storeName],this.consts.READ_ONLY);var store=getAllTransaction.objectStore(this.storeName);if(store.getAll){this._getAllNative(getAllTransaction,store,onSuccess,onError)}else{this._getAllCursor(getAllTransaction,store,onSuccess,onError)}return getAllTransaction},_getAllNative:function(getAllTransaction,store,onSuccess,onError){var hasSuccess=false,result=null;getAllTransaction.oncomplete=function(){var callback=hasSuccess?onSuccess:onError;callback(result)};getAllTransaction.onabort=onError;getAllTransaction.onerror=onError;var getAllRequest=store.getAll();getAllRequest.onsuccess=function(event){hasSuccess=true;result=event.target.result};getAllRequest.onerror=onError},_getAllCursor:function(getAllTransaction,store,onSuccess,onError){var all=[],hasSuccess=false,result=null;getAllTransaction.oncomplete=function(){var callback=hasSuccess?onSuccess:onError;callback(result)};getAllTransaction.onabort=onError;getAllTransaction.onerror=onError;var cursorRequest=store.openCursor();cursorRequest.onsuccess=function(event){var cursor=event.target.result;if(cursor){all.push(cursor.value);cursor["continue"]()}else{hasSuccess=true;result=all}};cursorRequest.onError=onError},clear:function(onSuccess,onError){onError||(onError=defaultErrorHandler);onSuccess||(onSuccess=noop);var hasSuccess=false,result=null;var clearTransaction=this.db.transaction([this.storeName],this.consts.READ_WRITE);clearTransaction.oncomplete=function(){var callback=hasSuccess?onSuccess:onError;callback(result)};clearTransaction.onabort=onError;clearTransaction.onerror=onError;var clearRequest=clearTransaction.objectStore(this.storeName).clear();clearRequest.onsuccess=function(event){hasSuccess=true;result=event.target.result};clearRequest.onerror=onError;return clearTransaction},_addIdPropertyIfNeeded:function(dataObj){if(!this.features.hasAutoIncrement&&typeof dataObj[this.keyPath]=="undefined"){dataObj[this.keyPath]=this._insertIdCount++ +Date.now()}},getIndexList:function(){return this.store.indexNames},hasIndex:function(indexName){return this.store.indexNames.contains(indexName)},normalizeIndexData:function(indexData){indexData.keyPath=indexData.keyPath||indexData.name;indexData.unique=!!indexData.unique;indexData.multiEntry=!!indexData.multiEntry},indexComplies:function(actual,expected){var complies=["keyPath","unique","multiEntry"].every(function(key){if(key=="multiEntry"&&actual[key]===undefined&&expected[key]===false){return true}if(key=="keyPath"&&Object.prototype.toString.call(expected[key])=="[object Array]"){var exp=expected.keyPath;var act=actual.keyPath;if(typeof act=="string"){return exp.toString()==act}if(!(typeof act.contains=="function"||typeof act.indexOf=="function")){return false}if(act.length!==exp.length){return false}for(var i=0,m=exp.length;i<m;i++){if(!(act.contains&&act.contains(exp[i])||act.indexOf(exp[i]!==-1))){return false}}return true}return expected[key]==actual[key]});return complies},iterate:function(onItem,options){options=mixin({index:null,order:"ASC",autoContinue:true,filterDuplicates:false,keyRange:null,writeAccess:false,onEnd:null,onError:defaultErrorHandler},options||{});var directionType=options.order.toLowerCase()=="desc"?"PREV":"NEXT";if(options.filterDuplicates){directionType+="_NO_DUPLICATE"}var hasSuccess=false;var cursorTransaction=this.db.transaction([this.storeName],this.consts[options.writeAccess?"READ_WRITE":"READ_ONLY"]);var cursorTarget=cursorTransaction.objectStore(this.storeName);if(options.index){cursorTarget=cursorTarget.index(options.index)}cursorTransaction.oncomplete=function(){if(!hasSuccess){options.onError(null);return}if(options.onEnd){options.onEnd()}else{onItem(null)}};cursorTransaction.onabort=options.onError;cursorTransaction.onerror=options.onError;var cursorRequest=cursorTarget.openCursor(options.keyRange,this.consts[directionType]);cursorRequest.onerror=options.onError;cursorRequest.onsuccess=function(event){var cursor=event.target.result;if(cursor){onItem(cursor.value,cursor,cursorTransaction);if(options.autoContinue){cursor["continue"]()}}else{hasSuccess=true}};return cursorTransaction},query:function(onSuccess,options){var result=[];options=options||{};options.onEnd=function(){onSuccess(result)};return this.iterate(function(item){result.push(item)},options)},count:function(onSuccess,options){options=mixin({index:null,keyRange:null},options||{});var onError=options.onError||defaultErrorHandler;var hasSuccess=false,result=null;var cursorTransaction=this.db.transaction([this.storeName],this.consts.READ_ONLY);cursorTransaction.oncomplete=function(){var callback=hasSuccess?onSuccess:onError;callback(result)};cursorTransaction.onabort=onError;cursorTransaction.onerror=onError;var cursorTarget=cursorTransaction.objectStore(this.storeName);if(options.index){cursorTarget=cursorTarget.index(options.index)}var countRequest=cursorTarget.count(options.keyRange);countRequest.onsuccess=function(evt){hasSuccess=true;result=evt.target.result};countRequest.onError=onError;return cursorTransaction},makeKeyRange:function(options){var keyRange,hasLower=typeof options.lower!="undefined",hasUpper=typeof options.upper!="undefined",isOnly=typeof options.only!="undefined";switch(true){case isOnly:keyRange=this.keyRange.only(options.only);break;case hasLower&&hasUpper:keyRange=this.keyRange.bound(options.lower,options.upper,options.excludeLower,options.excludeUpper);break;case hasLower:keyRange=this.keyRange.lowerBound(options.lower,options.excludeLower);break;case hasUpper:keyRange=this.keyRange.upperBound(options.upper,options.excludeUpper);break;default:throw new Error('Cannot create KeyRange. Provide one or both of "lower" or "upper" value, or an "only" value.')}return keyRange}};var noop=function(){};var empty={};var mixin=function(target,source){var name,s;for(name in source){s=source[name];if(s!==empty[name]&&s!==target[name]){target[name]=s}}return target};IDBStore.version=IDBStore.prototype.version;return IDBStore},this)},{}],37:[function(require,module,exports){var Buffer=require("buffer").Buffer;module.exports=isBuffer;function isBuffer(o){return Buffer.isBuffer(o)||/\[object (.+Array|Array.+)\]/.test(Object.prototype.toString.call(o))}},{buffer:2}],38:[function(require,module,exports){const levelup=require("levelup");function packager(leveldown){function Level(location,options,callback){if(typeof options=="function")callback=options;if(typeof options!="object")options={};options.db=leveldown;return levelup(location,options,callback)}["destroy","repair"].forEach(function(m){if(typeof leveldown[m]=="function"){Level[m]=function(location,callback){leveldown[m](location,callback||function(){})}}});return Level}module.exports=packager},{levelup:43}],39:[function(require,module,exports){var util=require("./util"),WriteError=require("./errors").WriteError,getOptions=util.getOptions,dispatchError=util.dispatchError;function Batch(levelup,codec){this._levelup=levelup;this._codec=codec;this.batch=levelup.db.batch();this.ops=[]}Batch.prototype.put=function(key_,value_,options){options=getOptions(this._levelup,options);var key=this._codec.encodeKey(key_,options),value=this._codec.encodeValue(value_,options);try{this.batch.put(key,value)}catch(e){throw new WriteError(e)}this.ops.push({type:"put",key:key,value:value});return this};Batch.prototype.del=function(key_,options){options=getOptions(this._levelup,options);var key=this._codec.encodeKey(key_,options);try{this.batch.del(key)}catch(err){throw new WriteError(err)}this.ops.push({type:"del",key:key});return this};Batch.prototype.clear=function(){try{this.batch.clear()}catch(err){throw new WriteError(err)}this.ops=[];return this};Batch.prototype.write=function(callback){var levelup=this._levelup,ops=this.ops;try{this.batch.write(function(err){if(err)return dispatchError(levelup,new WriteError(err),callback);levelup.emit("batch",ops);if(callback)callback()})}catch(err){throw new WriteError(err)}};module.exports=Batch},{"./errors":42,"./util":45}],40:[function(require,module,exports){var encodings=require("./encodings");function getKeyEncoder(options,op){var type=op&&op.keyEncoding||options.keyEncoding||"utf8";return encodings[type]||type}function getValueEncoder(options,op){var type=op&&(op.valueEncoding||op.encoding)||options.valueEncoding||options.encoding||"utf8";return encodings[type]||type}function encodeKey(key,options,op){return getKeyEncoder(options,op).encode(key)}function encodeValue(value,options,op){return getValueEncoder(options,op).encode(value)}function decodeKey(key,options){return getKeyEncoder(options).decode(key)}function decodeValue(value,options){return getValueEncoder(options).decode(value)}function isValueAsBuffer(options,op){return getValueEncoder(options,op).buffer}function isKeyAsBuffer(options,op){return getKeyEncoder(options,op).buffer}module.exports={encodeKey:encodeKey,encodeValue:encodeValue,isValueAsBuffer:isValueAsBuffer,isKeyAsBuffer:isKeyAsBuffer,decodeValue:decodeValue,decodeKey:decodeKey}},{"./encodings":41}],41:[function(require,module,exports){(function(Buffer){var encodingNames=["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le"];module.exports=function(){function isBinary(data){return data===undefined||data===null||Buffer.isBuffer(data)}var encodings={};encodings.utf8=encodings["utf-8"]={encode:function(data){return isBinary(data)?data:String(data)},decode:function(data){return data},buffer:false,type:"utf8"};encodings.json={encode:JSON.stringify,decode:JSON.parse,buffer:false,type:"json"};encodings.binary={encode:function(data){return isBinary(data)?data:new Buffer(data)},decode:function(data){return data},buffer:true,type:"binary"};encodingNames.forEach(function(type){if(encodings[type])return;encodings[type]={encode:function(data){return isBinary(data)?data:new Buffer(data,type)},decode:function(buffer){return buffer.toString(type)},buffer:true,type:type}});return encodings}()}).call(this,require("buffer").Buffer)},{buffer:2}],42:[function(require,module,exports){var createError=require("errno").create,LevelUPError=createError("LevelUPError"),NotFoundError=createError("NotFoundError",LevelUPError);NotFoundError.prototype.notFound=true;NotFoundError.prototype.status=404;module.exports={LevelUPError:LevelUPError,InitializationError:createError("InitializationError",LevelUPError),OpenError:createError("OpenError",LevelUPError),ReadError:createError("ReadError",LevelUPError),WriteError:createError("WriteError",LevelUPError),NotFoundError:NotFoundError,EncodingError:createError("EncodingError",LevelUPError)}},{errno:53}],43:[function(require,module,exports){(function(process){var EventEmitter=require("events").EventEmitter,inherits=require("util").inherits,extend=require("xtend"),prr=require("prr"),DeferredLevelDOWN=require("deferred-leveldown"),WriteError=require("./errors").WriteError,ReadError=require("./errors").ReadError,NotFoundError=require("./errors").NotFoundError,OpenError=require("./errors").OpenError,EncodingError=require("./errors").EncodingError,InitializationError=require("./errors").InitializationError,ReadStream=require("./read-stream"),WriteStream=require("./write-stream"),util=require("./util"),Batch=require("./batch"),codec=require("./codec"),getOptions=util.getOptions,defaultOptions=util.defaultOptions,getLevelDOWN=util.getLevelDOWN,dispatchError=util.dispatchError,isDefined=util.isDefined;function getCallback(options,callback){return typeof options=="function"?options:callback}function LevelUP(location,options,callback){if(!(this instanceof LevelUP))return new LevelUP(location,options,callback);var error;EventEmitter.call(this);this.setMaxListeners(Infinity);if(typeof location=="function"){options=typeof options=="object"?options:{};options.db=location;location=null}else if(typeof location=="object"&&typeof location.db=="function"){options=location;location=null}if(typeof options=="function"){callback=options;options={}}if((!options||typeof options.db!="function")&&typeof location!="string"){error=new InitializationError("Must provide a location for the database");if(callback){return process.nextTick(function(){callback(error)})}throw error}options=getOptions(this,options);this.options=extend(defaultOptions,options);this._codec=options.codec||codec;this._status="new";prr(this,"location",location,"e");this.open(callback)}inherits(LevelUP,EventEmitter);LevelUP.prototype.open=function(callback){var self=this,dbFactory,db;if(this.isOpen()){if(callback)process.nextTick(function(){callback(null,self)});return this}if(this._isOpening()){return callback&&this.once("open",function(){callback(null,self)})}this.emit("opening");this._status="opening";this.db=new DeferredLevelDOWN(this.location);dbFactory=this.options.db||getLevelDOWN();db=dbFactory(this.location);db.open(this.options,function(err){if(err){return dispatchError(self,new OpenError(err),callback)}else{self.db.setDb(db);self.db=db;self._status="open";if(callback)callback(null,self);self.emit("open");self.emit("ready")}})};LevelUP.prototype.close=function(callback){var self=this;if(this.isOpen()){this._status="closing";this.db.close(function(){self._status="closed";self.emit("closed");if(callback)callback.apply(null,arguments)});this.emit("closing");this.db=null}else if(this._status=="closed"&&callback){return process.nextTick(callback)}else if(this._status=="closing"&&callback){this.once("closed",callback)}else if(this._isOpening()){this.once("open",function(){self.close(callback)})}};LevelUP.prototype.isOpen=function(){return this._status=="open"};LevelUP.prototype._isOpening=function(){return this._status=="opening"};LevelUP.prototype.isClosed=function(){return/^clos/.test(this._status)};function maybeError(db,options,callback){if(!db._isOpening()&&!db.isOpen()){dispatchError(db,new ReadError("Database is not open"),callback);return true}}function writeError(db,message,callback){dispatchError(db,new WriteError(message),callback)}function readError(db,message,callback){dispatchError(db,new ReadError(message),callback);return true}LevelUP.prototype.get=function(key_,options,callback){var self=this,key;callback=getCallback(options,callback);if(maybeError(this,options,callback))return;if(key_===null||key_===undefined||"function"!==typeof callback)return readError(this,"get() requires key and callback arguments",callback);options=util.getOptions(this,options);key=this._codec.encodeKey(key_,options);options.asBuffer=this._codec.isValueAsBuffer(options);this.db.get(key,options,function(err,value){if(err){if(/notfound/i.test(err)){err=new NotFoundError("Key not found in database ["+key_+"]",err)}else{err=new ReadError(err)}return dispatchError(self,err,callback)}if(callback){try{value=self._codec.decodeValue(value,options)}catch(e){return callback(new EncodingError(e))}callback(null,value)}})};LevelUP.prototype.put=function(key_,value_,options,callback){var self=this,key,value;callback=getCallback(options,callback);if(key_===null||key_===undefined||value_===null||value_===undefined)return writeError(this,"put() requires key and value arguments",callback);if(maybeError(this,options,callback))return;options=getOptions(this,options);key=this._codec.encodeKey(key_,options);value=this._codec.encodeValue(value_,options);this.db.put(key,value,options,function(err){if(err){return dispatchError(self,new WriteError(err),callback)}else{self.emit("put",key_,value_);if(callback)callback()}})};LevelUP.prototype.del=function(key_,options,callback){var self=this,key;callback=getCallback(options,callback);if(key_===null||key_===undefined)return writeError(this,"del() requires a key argument",callback);if(maybeError(this,options,callback))return;options=getOptions(this,options);key=this._codec.encodeKey(key_,options);this.db.del(key,options,function(err){if(err){return dispatchError(self,new WriteError(err),callback)}else{self.emit("del",key_);if(callback)callback()}})};LevelUP.prototype.batch=function(arr_,options,callback){var self=this,keyEnc,valueEnc,arr;if(!arguments.length)return new Batch(this,codec);callback=getCallback(options,callback);if(!Array.isArray(arr_))return writeError(this,"batch() requires an array argument",callback);if(maybeError(this,options,callback))return;options=getOptions(this,options);keyEnc=options.keyEncoding;valueEnc=options.valueEncoding;arr=arr_.map(function(e){if(e.type===undefined||e.key===undefined)return{};var kEnc=e.keyEncoding||keyEnc,vEnc=e.valueEncoding||e.encoding||valueEnc,o;if(kEnc!="utf8"&&kEnc!="binary"||vEnc!="utf8"&&vEnc!="binary"){o={type:e.type,key:self._codec.encodeKey(e.key,options,e)};if(e.value!==undefined)o.value=self._codec.encodeValue(e.value,options,e);return o}else{return e}});this.db.batch(arr,options,function(err){if(err){return dispatchError(self,new WriteError(err),callback)}else{self.emit("batch",arr_);if(callback)callback()}})};LevelUP.prototype.approximateSize=function(start_,end_,options,callback){var self=this,start,end;callback=getCallback(options,callback);options=getOptions(options,callback);if(start_===null||start_===undefined||end_===null||end_===undefined||"function"!==typeof callback)return readError(this,"approximateSize() requires start, end and callback arguments",callback);start=this._codec.encodeKey(start_,this.options);end=this._codec.encodeKey(end_,this.options);this.db.approximateSize(start,end,function(err,size){if(err){return dispatchError(self,new OpenError(err),callback)}else if(callback){callback(null,size)}})};LevelUP.prototype.readStream=LevelUP.prototype.createReadStream=function(options){var self=this;options=extend({keys:true,values:true},this.options,options);options.keyEncoding=options.keyEncoding||options.encoding;options.valueEncoding=options.valueEncoding||options.encoding;if(isDefined(options.start))options.start=this._codec.encodeKey(options.start,options);if(isDefined(options.end))options.end=this._codec.encodeKey(options.end,options);if(isDefined(options.gte))options.gte=this._codec.encodeKey(options.gte,options);if(isDefined(options.gt))options.gt=this._codec.encodeKey(options.gt,options);if(isDefined(options.lte))options.lte=this._codec.encodeKey(options.lte,options);if(isDefined(options.lt))options.lt=this._codec.encodeKey(options.lt,options);if("number"!==typeof options.limit)options.limit=-1;options.keyAsBuffer=this._codec.isKeyAsBuffer(options);options.valueAsBuffer=this._codec.isValueAsBuffer(options);var makeData=options.keys&&options.values?function(key,value){return{key:self._codec.decodeKey(key,options),value:self._codec.decodeValue(value,options)}}:options.keys?function(key){return self._codec.decodeKey(key,options)}:options.values?function(_,value){return self._codec.decodeValue(value,options)}:function(){};var stream=new ReadStream(options,makeData);if(this.isOpen())stream.setIterator(self.db.iterator(options));else this.once("ready",function(){stream.setIterator(self.db.iterator(options))});return stream};LevelUP.prototype.keyStream=LevelUP.prototype.createKeyStream=function(options){return this.createReadStream(extend(options,{keys:true,values:false}))};LevelUP.prototype.valueStream=LevelUP.prototype.createValueStream=function(options){return this.createReadStream(extend(options,{keys:false,values:true}))};LevelUP.prototype.writeStream=LevelUP.prototype.createWriteStream=function(options){return new WriteStream(extend(options),this)};LevelUP.prototype.toString=function(){return"LevelUP"};function utilStatic(name){return function(location,callback){getLevelDOWN()[name](location,callback||function(){})}}module.exports=LevelUP;module.exports.copy=util.copy;module.exports.destroy=utilStatic("destroy");module.exports.repair=utilStatic("repair")}).call(this,require("_process"))},{"./batch":39,"./codec":40,"./errors":42,"./read-stream":44,"./util":45,"./write-stream":46,_process:9,"deferred-leveldown":48,events:6,prr:54,util:24,xtend:65}],44:[function(require,module,exports){var Readable=require("readable-stream").Readable,inherits=require("util").inherits,extend=require("xtend"),EncodingError=require("./errors").EncodingError,util=require("./util");function ReadStream(options,makeData){if(!(this instanceof ReadStream))return new ReadStream(options,makeData);Readable.call(this,{objectMode:true,highWaterMark:options.highWaterMark});this._waiting=false;this._options=options;this._makeData=makeData}inherits(ReadStream,Readable);ReadStream.prototype.setIterator=function(it){var self=this;this._iterator=it;if(this._destroyed)return it.end(function(){});if(this._waiting){this._waiting=false;return this._read()}return this};ReadStream.prototype._read=function read(){var self=this;if(self._destroyed)return;if(!self._iterator)return this._waiting=true;self._iterator.next(function(err,key,value){if(err||key===undefined&&value===undefined){if(!err&&!self._destroyed)self.push(null);return self._cleanup(err)}try{value=self._makeData(key,value)}catch(e){return self._cleanup(new EncodingError(e))}if(!self._destroyed)self.push(value)})};ReadStream.prototype._cleanup=function(err){if(this._destroyed)return;this._destroyed=true;var self=this;if(err)self.emit("error",err);if(self._iterator){self._iterator.end(function(){self._iterator=null;self.emit("close")})}else{self.emit("close")}};ReadStream.prototype.destroy=function(){this._cleanup()};ReadStream.prototype.toString=function(){return"LevelUP.ReadStream"};module.exports=ReadStream},{"./errors":42,"./util":45,"readable-stream":64,util:24,xtend:65}],45:[function(require,module,exports){var extend=require("xtend"),LevelUPError=require("./errors").LevelUPError,encodings=require("./encodings"),defaultOptions={createIfMissing:true,errorIfExists:false,keyEncoding:"utf8",valueEncoding:"utf8",compression:true},leveldown,encodingOpts=function(){var eo={};for(var e in encodings)eo[e]={valueEncoding:encodings[e]};return eo}();function copy(srcdb,dstdb,callback){srcdb.readStream().pipe(dstdb.writeStream()).on("close",callback?callback:function(){}).on("error",callback?callback:function(err){throw err})}function getOptions(levelup,options){var s=typeof options=="string";if(!s&&options&&options.encoding&&!options.valueEncoding)options.valueEncoding=options.encoding;return extend(levelup&&levelup.options||{},s?encodingOpts[options]||encodingOpts[defaultOptions.valueEncoding]:options)}function getLevelDOWN(){if(leveldown)return leveldown;var requiredVersion=require("../package.json").devDependencies.leveldown,missingLevelDOWNError="Could not locate LevelDOWN, try `npm install leveldown`",leveldownVersion;try{leveldownVersion=require("leveldown/package").version}catch(e){throw new LevelUPError(missingLevelDOWNError)}if(!require("semver").satisfies(leveldownVersion,requiredVersion)){throw new LevelUPError("Installed version of LevelDOWN ("+leveldownVersion+") does not match required version ("+requiredVersion+")")}try{return leveldown=require("leveldown")}catch(e){throw new LevelUPError(missingLevelDOWNError)}}function dispatchError(levelup,error,callback){return typeof callback=="function"?callback(error):levelup.emit("error",error)}function isDefined(v){return typeof v!=="undefined"}module.exports={defaultOptions:defaultOptions,copy:copy,getOptions:getOptions,getLevelDOWN:getLevelDOWN,dispatchError:dispatchError,isDefined:isDefined}},{"../package.json":66,"./encodings":41,"./errors":42,leveldown:1,"leveldown/package":1,semver:1,xtend:65}],46:[function(require,module,exports){(function(process,global){var Stream=require("stream").Stream,inherits=require("util").inherits,extend=require("xtend"),bl=require("bl"),setImmediate=global.setImmediate||process.nextTick,getOptions=require("./util").getOptions,defaultOptions={type:"put"};function WriteStream(options,db){if(!(this instanceof WriteStream))return new WriteStream(options,db);Stream.call(this);this._options=extend(defaultOptions,getOptions(db,options));this._db=db;this._buffer=[];this._status="init";this._end=false;this.writable=true;this.readable=false;var self=this,ready=function(){if(!self.writable)return;self._status="ready";self.emit("ready");self._process()};if(db.isOpen())setImmediate(ready);else db.once("ready",ready)}inherits(WriteStream,Stream);WriteStream.prototype.write=function(data){if(!this.writable)return false;this._buffer.push(data);if(this._status!="init")this._processDelayed();if(this._options.maxBufferLength&&this._buffer.length>this._options.maxBufferLength){this._writeBlock=true;return false}return true};WriteStream.prototype.end=function(data){var self=this;if(data)this.write(data);setImmediate(function(){self._end=true;self._process()})};WriteStream.prototype.destroy=function(){this.writable=false;this.end()};WriteStream.prototype.destroySoon=function(){this.end()};WriteStream.prototype.add=function(entry){if(!entry.props)return;if(entry.props.Directory)entry.pipe(this._db.writeStream(this._options));else if(entry.props.File||entry.File||entry.type=="File")this._write(entry);return true};WriteStream.prototype._processDelayed=function(){var self=this;setImmediate(function(){self._process()})};WriteStream.prototype._process=function(){var buffer,self=this,cb=function(err){if(!self.writable)return;if(self._status!="closed")self._status="ready";if(err){self.writable=false;return self.emit("error",err)}self._process()};if(self._status!="ready"&&self.writable){if(self._buffer.length&&self._status!="closed")self._processDelayed();return}if(self._buffer.length&&self.writable){self._status="writing";buffer=self._buffer;self._buffer=[];self._db.batch(buffer.map(function(d){return{type:d.type||self._options.type,key:d.key,value:d.value,keyEncoding:d.keyEncoding||self._options.keyEncoding,valueEncoding:d.valueEncoding||d.encoding||self._options.valueEncoding}}),cb);if(self._writeBlock){self._writeBlock=false;self.emit("drain")}return}if(self._end&&self._status!="closed"){self._status="closed";self.writable=false;self.emit("close")}};WriteStream.prototype._write=function(entry){var key=entry.path||entry.props.path,self=this;if(!key)return;entry.pipe(bl(function(err,data){if(err){self.writable=false;return self.emit("error",err)}if(self._options.fstreamRoot&&key.indexOf(self._options.fstreamRoot)>-1)key=key.substr(self._options.fstreamRoot.length+1);self.write({key:key,value:data.slice(0)})}))};WriteStream.prototype.toString=function(){return"LevelUP.WriteStream"};module.exports=WriteStream}).call(this,require("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./util":45,_process:9,bl:47,stream:21,util:24,xtend:65}],47:[function(require,module,exports){(function(Buffer){var DuplexStream=require("readable-stream").Duplex,util=require("util");function BufferList(callback){if(!(this instanceof BufferList))return new BufferList(callback);
this._bufs=[];this.length=0;if(typeof callback=="function"){this._callback=callback;var piper=function(err){if(this._callback){this._callback(err);this._callback=null}}.bind(this);this.on("pipe",function(src){src.on("error",piper)});this.on("unpipe",function(src){src.removeListener("error",piper)})}else if(Buffer.isBuffer(callback))this.append(callback);else if(Array.isArray(callback)){callback.forEach(function(b){Buffer.isBuffer(b)&&this.append(b)}.bind(this))}DuplexStream.call(this)}util.inherits(BufferList,DuplexStream);BufferList.prototype._offset=function(offset){var tot=0,i=0,_t;for(;i<this._bufs.length;i++){_t=tot+this._bufs[i].length;if(offset<_t)return[i,offset-tot];tot=_t}};BufferList.prototype.append=function(buf){this._bufs.push(Buffer.isBuffer(buf)?buf:new Buffer(buf));this.length+=buf.length;return this};BufferList.prototype._write=function(buf,encoding,callback){this.append(buf);if(callback)callback()};BufferList.prototype._read=function(size){if(!this.length)return this.push(null);size=Math.min(size,this.length);this.push(this.slice(0,size));this.consume(size)};BufferList.prototype.end=function(chunk){DuplexStream.prototype.end.call(this,chunk);if(this._callback){this._callback(null,this.slice());this._callback=null}};BufferList.prototype.get=function(index){return this.slice(index,index+1)[0]};BufferList.prototype.slice=function(start,end){return this.copy(null,0,start,end)};BufferList.prototype.copy=function(dst,dstStart,srcStart,srcEnd){if(typeof srcStart!="number"||srcStart<0)srcStart=0;if(typeof srcEnd!="number"||srcEnd>this.length)srcEnd=this.length;if(srcStart>=this.length)return dst||new Buffer(0);if(srcEnd<=0)return dst||new Buffer(0);var copy=!!dst,off=this._offset(srcStart),len=srcEnd-srcStart,bytes=len,bufoff=copy&&dstStart||0,start=off[1],l,i;if(srcStart===0&&srcEnd==this.length){if(!copy)return Buffer.concat(this._bufs);for(i=0;i<this._bufs.length;i++){this._bufs[i].copy(dst,bufoff);bufoff+=this._bufs[i].length}return dst}if(bytes<=this._bufs[off[0]].length-start){return copy?this._bufs[off[0]].copy(dst,dstStart,start,start+bytes):this._bufs[off[0]].slice(start,start+bytes)}if(!copy)dst=new Buffer(len);for(i=off[0];i<this._bufs.length;i++){l=this._bufs[i].length-start;if(bytes>l){this._bufs[i].copy(dst,bufoff,start)}else{this._bufs[i].copy(dst,bufoff,start,start+bytes);break}bufoff+=l;bytes-=l;if(start)start=0}return dst};BufferList.prototype.toString=function(encoding,start,end){return this.slice(start,end).toString(encoding)};BufferList.prototype.consume=function(bytes){while(this._bufs.length){if(bytes>this._bufs[0].length){bytes-=this._bufs[0].length;this.length-=this._bufs[0].length;this._bufs.shift()}else{this._bufs[0]=this._bufs[0].slice(bytes);this.length-=bytes;break}}return this};BufferList.prototype.duplicate=function(){var i=0,copy=new BufferList;for(;i<this._bufs.length;i++)copy.append(this._bufs[i]);return copy};BufferList.prototype.destroy=function(){this._bufs.length=0;this.length=0;this.push(null)};(function(){var methods={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1};for(var m in methods){(function(m){BufferList.prototype[m]=function(offset){return this.slice(offset,offset+methods[m])[m](0)}})(m)}})();module.exports=BufferList}).call(this,require("buffer").Buffer)},{buffer:2,"readable-stream":64,util:24}],48:[function(require,module,exports){(function(process,Buffer){var util=require("util"),AbstractLevelDOWN=require("abstract-leveldown").AbstractLevelDOWN;function DeferredLevelDOWN(location){AbstractLevelDOWN.call(this,typeof location=="string"?location:"");this._db=undefined;this._operations=[]}util.inherits(DeferredLevelDOWN,AbstractLevelDOWN);DeferredLevelDOWN.prototype.setDb=function(db){this._db=db;this._operations.forEach(function(op){db[op.method].apply(db,op.args)})};DeferredLevelDOWN.prototype._open=function(options,callback){return process.nextTick(callback)};DeferredLevelDOWN.prototype._operation=function(method,args){if(this._db)return this._db[method].apply(this._db,args);this._operations.push({method:method,args:args})};"put get del batch approximateSize".split(" ").forEach(function(m){DeferredLevelDOWN.prototype["_"+m]=function(){this._operation(m,arguments)}});DeferredLevelDOWN.prototype._isBuffer=function(obj){return Buffer.isBuffer(obj)};DeferredLevelDOWN.prototype._iterator=function(){throw new TypeError("not implemented")};module.exports=DeferredLevelDOWN}).call(this,require("_process"),require("buffer").Buffer)},{_process:9,"abstract-leveldown":51,buffer:2,util:24}],49:[function(require,module,exports){(function(process){function AbstractChainedBatch(db){this._db=db;this._operations=[];this._written=false}AbstractChainedBatch.prototype._checkWritten=function(){if(this._written)throw new Error("write() already called on this batch")};AbstractChainedBatch.prototype.put=function(key,value){this._checkWritten();var err=this._db._checkKeyValue(key,"key",this._db._isBuffer);if(err)throw err;err=this._db._checkKeyValue(value,"value",this._db._isBuffer);if(err)throw err;if(!this._db._isBuffer(key))key=String(key);if(!this._db._isBuffer(value))value=String(value);if(typeof this._put=="function")this._put(key,value);else this._operations.push({type:"put",key:key,value:value});return this};AbstractChainedBatch.prototype.del=function(key){this._checkWritten();var err=this._db._checkKeyValue(key,"key",this._db._isBuffer);if(err)throw err;if(!this._db._isBuffer(key))key=String(key);if(typeof this._del=="function")this._del(key);else this._operations.push({type:"del",key:key});return this};AbstractChainedBatch.prototype.clear=function(){this._checkWritten();this._operations=[];if(typeof this._clear=="function")this._clear();return this};AbstractChainedBatch.prototype.write=function(options,callback){this._checkWritten();if(typeof options=="function")callback=options;if(typeof callback!="function")throw new Error("write() requires a callback argument");if(typeof options!="object")options={};this._written=true;if(typeof this._write=="function")return this._write(callback);if(typeof this._db._batch=="function")return this._db._batch(this._operations,options,callback);process.nextTick(callback)};module.exports=AbstractChainedBatch}).call(this,require("_process"))},{_process:9}],50:[function(require,module,exports){(function(process){function AbstractIterator(db){this.db=db;this._ended=false;this._nexting=false}AbstractIterator.prototype.next=function(callback){var self=this;if(typeof callback!="function")throw new Error("next() requires a callback argument");if(self._ended)return callback(new Error("cannot call next() after end()"));if(self._nexting)return callback(new Error("cannot call next() before previous next() has completed"));self._nexting=true;if(typeof self._next=="function"){return self._next(function(){self._nexting=false;callback.apply(null,arguments)})}process.nextTick(function(){self._nexting=false;callback()})};AbstractIterator.prototype.end=function(callback){if(typeof callback!="function")throw new Error("end() requires a callback argument");if(this._ended)return callback(new Error("end() already called on iterator"));this._ended=true;if(typeof this._end=="function")return this._end(callback);process.nextTick(callback)};module.exports=AbstractIterator}).call(this,require("_process"))},{_process:9}],51:[function(require,module,exports){(function(process,Buffer){var xtend=require("xtend"),AbstractIterator=require("./abstract-iterator"),AbstractChainedBatch=require("./abstract-chained-batch");function AbstractLevelDOWN(location){if(!arguments.length||location===undefined)throw new Error("constructor requires at least a location argument");if(typeof location!="string")throw new Error("constructor requires a location string argument");this.location=location}AbstractLevelDOWN.prototype.open=function(options,callback){if(typeof options=="function")callback=options;if(typeof callback!="function")throw new Error("open() requires a callback argument");if(typeof options!="object")options={};if(typeof this._open=="function")return this._open(options,callback);process.nextTick(callback)};AbstractLevelDOWN.prototype.close=function(callback){if(typeof callback!="function")throw new Error("close() requires a callback argument");if(typeof this._close=="function")return this._close(callback);process.nextTick(callback)};AbstractLevelDOWN.prototype.get=function(key,options,callback){var err;if(typeof options=="function")callback=options;if(typeof callback!="function")throw new Error("get() requires a callback argument");if(err=this._checkKeyValue(key,"key",this._isBuffer))return callback(err);if(!this._isBuffer(key))key=String(key);if(typeof options!="object")options={};if(typeof this._get=="function")return this._get(key,options,callback);process.nextTick(function(){callback(new Error("NotFound"))})};AbstractLevelDOWN.prototype.put=function(key,value,options,callback){var err;if(typeof options=="function")callback=options;if(typeof callback!="function")throw new Error("put() requires a callback argument");if(err=this._checkKeyValue(key,"key",this._isBuffer))return callback(err);if(err=this._checkKeyValue(value,"value",this._isBuffer))return callback(err);if(!this._isBuffer(key))key=String(key);if(!this._isBuffer(value)&&!process.browser)value=String(value);if(typeof options!="object")options={};if(typeof this._put=="function")return this._put(key,value,options,callback);process.nextTick(callback)};AbstractLevelDOWN.prototype.del=function(key,options,callback){var err;if(typeof options=="function")callback=options;if(typeof callback!="function")throw new Error("del() requires a callback argument");if(err=this._checkKeyValue(key,"key",this._isBuffer))return callback(err);if(!this._isBuffer(key))key=String(key);if(typeof options!="object")options={};if(typeof this._del=="function")return this._del(key,options,callback);process.nextTick(callback)};AbstractLevelDOWN.prototype.batch=function(array,options,callback){if(!arguments.length)return this._chainedBatch();if(typeof options=="function")callback=options;if(typeof callback!="function")throw new Error("batch(array) requires a callback argument");if(!Array.isArray(array))return callback(new Error("batch(array) requires an array argument"));if(typeof options!="object")options={};var i=0,l=array.length,e,err;for(;i<l;i++){e=array[i];if(typeof e!="object")continue;if(err=this._checkKeyValue(e.type,"type",this._isBuffer))return callback(err);if(err=this._checkKeyValue(e.key,"key",this._isBuffer))return callback(err);if(e.type=="put"){if(err=this._checkKeyValue(e.value,"value",this._isBuffer))return callback(err)}}if(typeof this._batch=="function")return this._batch(array,options,callback);process.nextTick(callback)};AbstractLevelDOWN.prototype.approximateSize=function(start,end,callback){if(start==null||end==null||typeof start=="function"||typeof end=="function"){throw new Error("approximateSize() requires valid `start`, `end` and `callback` arguments")}if(typeof callback!="function")throw new Error("approximateSize() requires a callback argument");if(!this._isBuffer(start))start=String(start);if(!this._isBuffer(end))end=String(end);if(typeof this._approximateSize=="function")return this._approximateSize(start,end,callback);process.nextTick(function(){callback(null,0)})};AbstractLevelDOWN.prototype._setupIteratorOptions=function(options){var self=this;options=xtend(options);["start","end","gt","gte","lt","lte"].forEach(function(o){if(options[o]&&self._isBuffer(options[o])&&options[o].length===0)delete options[o]});options.reverse=!!options.reverse;if(options.reverse&&options.lt)options.start=options.lt;if(options.reverse&&options.lte)options.start=options.lte;if(!options.reverse&&options.gt)options.start=options.gt;if(!options.reverse&&options.gte)options.start=options.gte;if(options.reverse&&options.lt&&!options.lte||!options.reverse&&options.gt&&!options.gte)options.exclusiveStart=true;return options};AbstractLevelDOWN.prototype.iterator=function(options){if(typeof options!="object")options={};options=this._setupIteratorOptions(options);if(typeof this._iterator=="function")return this._iterator(options);return new AbstractIterator(this)};AbstractLevelDOWN.prototype._chainedBatch=function(){return new AbstractChainedBatch(this)};AbstractLevelDOWN.prototype._isBuffer=function(obj){return Buffer.isBuffer(obj)};AbstractLevelDOWN.prototype._checkKeyValue=function(obj,type){if(obj===null||obj===undefined)return new Error(type+" cannot be `null` or `undefined`");if(this._isBuffer(obj)){if(obj.length===0)return new Error(type+" cannot be an empty Buffer")}else if(String(obj)==="")return new Error(type+" cannot be an empty String")};module.exports.AbstractLevelDOWN=AbstractLevelDOWN;module.exports.AbstractIterator=AbstractIterator;module.exports.AbstractChainedBatch=AbstractChainedBatch}).call(this,require("_process"),require("buffer").Buffer)},{"./abstract-chained-batch":49,"./abstract-iterator":50,_process:9,buffer:2,xtend:65}],52:[function(require,module,exports){var prr=require("prr");function init(type,message,cause){prr(this,{type:type,name:type,cause:typeof message!="string"?message:cause,message:!!message&&typeof message!="string"?message.message:message},"ewr")}function CustomError(message,cause){Error.call(this);if(Error.captureStackTrace)Error.captureStackTrace(this,arguments.callee);init.call(this,"CustomError",message,cause)}CustomError.prototype=new Error;function createError(errno,type,proto){var err=function(message,cause){init.call(this,type,message,cause);if(type=="FilesystemError"){this.code=this.cause.code;this.path=this.cause.path;this.errno=this.cause.errno;this.message=(errno.errno[this.cause.errno]?errno.errno[this.cause.errno].description:this.cause.message)+(this.cause.path?" ["+this.cause.path+"]":"")}Error.call(this);if(Error.captureStackTrace)Error.captureStackTrace(this,arguments.callee)};err.prototype=!!proto?new proto:new CustomError;return err}module.exports=function(errno){var ce=function(type,proto){return createError(errno,type,proto)};return{CustomError:CustomError,FilesystemError:ce("FilesystemError"),createError:ce}}},{prr:54}],53:[function(require,module,exports){var all=module.exports.all=[{errno:-1,code:"UNKNOWN",description:"unknown error"},{errno:0,code:"OK",description:"success"},{errno:1,code:"EOF",description:"end of file"},{errno:2,code:"EADDRINFO",description:"getaddrinfo error"},{errno:3,code:"EACCES",description:"permission denied"},{errno:4,code:"EAGAIN",description:"resource temporarily unavailable"},{errno:5,code:"EADDRINUSE",description:"address already in use"},{errno:6,code:"EADDRNOTAVAIL",description:"address not available"},{errno:7,code:"EAFNOSUPPORT",description:"address family not supported"},{errno:8,code:"EALREADY",description:"connection already in progress"},{errno:9,code:"EBADF",description:"bad file descriptor"},{errno:10,code:"EBUSY",description:"resource busy or locked"},{errno:11,code:"ECONNABORTED",description:"software caused connection abort"},{errno:12,code:"ECONNREFUSED",description:"connection refused"},{errno:13,code:"ECONNRESET",description:"connection reset by peer"},{errno:14,code:"EDESTADDRREQ",description:"destination address required"},{errno:15,code:"EFAULT",description:"bad address in system call argument"},{errno:16,code:"EHOSTUNREACH",description:"host is unreachable"},{errno:17,code:"EINTR",description:"interrupted system call"},{errno:18,code:"EINVAL",description:"invalid argument"},{errno:19,code:"EISCONN",description:"socket is already connected"},{errno:20,code:"EMFILE",description:"too many open files"},{errno:21,code:"EMSGSIZE",description:"message too long"},{errno:22,code:"ENETDOWN",description:"network is down"},{errno:23,code:"ENETUNREACH",description:"network is unreachable"},{errno:24,code:"ENFILE",description:"file table overflow"},{errno:25,code:"ENOBUFS",description:"no buffer space available"},{errno:26,code:"ENOMEM",description:"not enough memory"},{errno:27,code:"ENOTDIR",description:"not a directory"},{errno:28,code:"EISDIR",description:"illegal operation on a directory"},{errno:29,code:"ENONET",description:"machine is not on the network"},{errno:31,code:"ENOTCONN",description:"socket is not connected"},{errno:32,code:"ENOTSOCK",description:"socket operation on non-socket"},{errno:33,code:"ENOTSUP",description:"operation not supported on socket"},{errno:34,code:"ENOENT",description:"no such file or directory"},{errno:35,code:"ENOSYS",description:"function not implemented"},{errno:36,code:"EPIPE",description:"broken pipe"},{errno:37,code:"EPROTO",description:"protocol error"},{errno:38,code:"EPROTONOSUPPORT",description:"protocol not supported"},{errno:39,code:"EPROTOTYPE",description:"protocol wrong type for socket"},{errno:40,code:"ETIMEDOUT",description:"connection timed out"},{errno:41,code:"ECHARSET",description:"invalid Unicode character"},{errno:42,code:"EAIFAMNOSUPPORT",description:"address family for hostname not supported"},{errno:44,code:"EAISERVICE",description:"servname not supported for ai_socktype"},{errno:45,code:"EAISOCKTYPE",description:"ai_socktype not supported"},{errno:46,code:"ESHUTDOWN",description:"cannot send after transport endpoint shutdown"},{errno:47,code:"EEXIST",description:"file already exists"},{errno:48,code:"ESRCH",description:"no such process"},{errno:49,code:"ENAMETOOLONG",description:"name too long"},{errno:50,code:"EPERM",description:"operation not permitted"},{errno:51,code:"ELOOP",description:"too many symbolic links encountered"},{errno:52,code:"EXDEV",description:"cross-device link not permitted"},{errno:53,code:"ENOTEMPTY",description:"directory not empty"},{errno:54,code:"ENOSPC",description:"no space left on device"},{errno:55,code:"EIO",description:"i/o error"},{errno:56,code:"EROFS",description:"read-only file system"},{errno:57,code:"ENODEV",description:"no such device"},{errno:58,code:"ESPIPE",description:"invalid seek"},{errno:59,code:"ECANCELED",description:"operation canceled"}];module.exports.errno={"-1":all[0],0:all[1],1:all[2],2:all[3],3:all[4],4:all[5],5:all[6],6:all[7],7:all[8],8:all[9],9:all[10],10:all[11],11:all[12],12:all[13],13:all[14],14:all[15],15:all[16],16:all[17],17:all[18],18:all[19],19:all[20],20:all[21],21:all[22],22:all[23],23:all[24],24:all[25],25:all[26],26:all[27],27:all[28],28:all[29],29:all[30],31:all[31],32:all[32],33:all[33],34:all[34],35:all[35],36:all[36],37:all[37],38:all[38],39:all[39],40:all[40],41:all[41],42:all[42],44:all[43],45:all[44],46:all[45],47:all[46],48:all[47],49:all[48],50:all[49],51:all[50],52:all[51],53:all[52],54:all[53],55:all[54],56:all[55],57:all[56],58:all[57],59:all[58]};module.exports.code={UNKNOWN:all[0],OK:all[1],EOF:all[2],EADDRINFO:all[3],EACCES:all[4],EAGAIN:all[5],EADDRINUSE:all[6],EADDRNOTAVAIL:all[7],EAFNOSUPPORT:all[8],EALREADY:all[9],EBADF:all[10],EBUSY:all[11],ECONNABORTED:all[12],ECONNREFUSED:all[13],ECONNRESET:all[14],EDESTADDRREQ:all[15],EFAULT:all[16],EHOSTUNREACH:all[17],EINTR:all[18],EINVAL:all[19],EISCONN:all[20],EMFILE:all[21],EMSGSIZE:all[22],ENETDOWN:all[23],ENETUNREACH:all[24],ENFILE:all[25],ENOBUFS:all[26],ENOMEM:all[27],ENOTDIR:all[28],EISDIR:all[29],ENONET:all[30],ENOTCONN:all[31],ENOTSOCK:all[32],ENOTSUP:all[33],ENOENT:all[34],ENOSYS:all[35],EPIPE:all[36],EPROTO:all[37],EPROTONOSUPPORT:all[38],EPROTOTYPE:all[39],ETIMEDOUT:all[40],ECHARSET:all[41],EAIFAMNOSUPPORT:all[42],EAISERVICE:all[43],EAISOCKTYPE:all[44],ESHUTDOWN:all[45],EEXIST:all[46],ESRCH:all[47],ENAMETOOLONG:all[48],EPERM:all[49],ELOOP:all[50],EXDEV:all[51],ENOTEMPTY:all[52],ENOSPC:all[53],EIO:all[54],EROFS:all[55],ENODEV:all[56],ESPIPE:all[57],ECANCELED:all[58]};module.exports.custom=require("./custom")(module.exports);module.exports.create=module.exports.custom.createError},{"./custom":52}],54:[function(require,module,exports){(function(name,context,definition){if(typeof module!="undefined"&&module.exports)module.exports=definition();else context[name]=definition()})("prr",this,function(){var setProperty=typeof Object.defineProperty=="function"?function(obj,key,options){Object.defineProperty(obj,key,options);return obj}:function(obj,key,options){obj[key]=options.value;return obj},makeOptions=function(value,options){var oo=typeof options=="object",os=!oo&&typeof options=="string",op=function(p){return oo?!!options[p]:os?options.indexOf(p[0])>-1:false};return{enumerable:op("enumerable"),configurable:op("configurable"),writable:op("writable"),value:value}},prr=function(obj,key,value,options){var k;options=makeOptions(value,options);if(typeof key=="object"){for(k in key){if(Object.hasOwnProperty.call(key,k)){options.value=key[k];setProperty(obj,k,options)}}return obj}return setProperty(obj,key,options)};return prr})},{}],55:[function(require,module,exports){(function(process){module.exports=Duplex;var objectKeys=Object.keys||function(obj){var keys=[];for(var key in obj)keys.push(key);return keys};var util=require("core-util-is");util.inherits=require("inherits");var Readable=require("./_stream_readable");var Writable=require("./_stream_writable");util.inherits(Duplex,Readable);forEach(objectKeys(Writable.prototype),function(method){if(!Duplex.prototype[method])Duplex.prototype[method]=Writable.prototype[method]});function Duplex(options){if(!(this instanceof Duplex))return new Duplex(options);Readable.call(this,options);Writable.call(this,options);if(options&&options.readable===false)this.readable=false;if(options&&options.writable===false)this.writable=false;this.allowHalfOpen=true;if(options&&options.allowHalfOpen===false)this.allowHalfOpen=false;this.once("end",onend)}function onend(){if(this.allowHalfOpen||this._writableState.ended)return;process.nextTick(this.end.bind(this))}function forEach(xs,f){for(var i=0,l=xs.length;i<l;i++){f(xs[i],i)}}}).call(this,require("_process"))},{"./_stream_readable":57,"./_stream_writable":59,_process:9,"core-util-is":60,inherits:61}],56:[function(require,module,exports){arguments[4][12][0].apply(exports,arguments)},{"./_stream_transform":58,"core-util-is":60,dup:12,inherits:61}],57:[function(require,module,exports){(function(process){module.exports=Readable;var isArray=require("isarray");var Buffer=require("buffer").Buffer;Readable.ReadableState=ReadableState;var EE=require("events").EventEmitter;if(!EE.listenerCount)EE.listenerCount=function(emitter,type){return emitter.listeners(type).length};var Stream=require("stream");var util=require("core-util-is");util.inherits=require("inherits");var StringDecoder;util.inherits(Readable,Stream);function ReadableState(options,stream){options=options||{};var hwm=options.highWaterMark;this.highWaterMark=hwm||hwm===0?hwm:16*1024;this.highWaterMark=~~this.highWaterMark;this.buffer=[];this.length=0;this.pipes=null;this.pipesCount=0;this.flowing=false;this.ended=false;this.endEmitted=false;this.reading=false;this.calledRead=false;this.sync=true;this.needReadable=false;this.emittedReadable=false;this.readableListening=false;this.objectMode=!!options.objectMode;this.defaultEncoding=options.defaultEncoding||"utf8";this.ranOut=false;this.awaitDrain=0;this.readingMore=false;this.decoder=null;this.encoding=null;if(options.encoding){if(!StringDecoder)StringDecoder=require("string_decoder/").StringDecoder;this.decoder=new StringDecoder(options.encoding);this.encoding=options.encoding}}function Readable(options){if(!(this instanceof Readable))return new Readable(options);this._readableState=new ReadableState(options,this);this.readable=true;Stream.call(this)}Readable.prototype.push=function(chunk,encoding){var state=this._readableState;if(typeof chunk==="string"&&!state.objectMode){encoding=encoding||state.defaultEncoding;if(encoding!==state.encoding){chunk=new Buffer(chunk,encoding);encoding=""}}return readableAddChunk(this,state,chunk,encoding,false)};Readable.prototype.unshift=function(chunk){var state=this._readableState;return readableAddChunk(this,state,chunk,"",true)};function readableAddChunk(stream,state,chunk,encoding,addToFront){var er=chunkInvalid(state,chunk);if(er){stream.emit("error",er)}else if(chunk===null||chunk===undefined){state.reading=false;if(!state.ended)onEofChunk(stream,state)}else if(state.objectMode||chunk&&chunk.length>0){if(state.ended&&!addToFront){var e=new Error("stream.push() after EOF");stream.emit("error",e)}else if(state.endEmitted&&addToFront){var e=new Error("stream.unshift() after end event");stream.emit("error",e)}else{if(state.decoder&&!addToFront&&!encoding)chunk=state.decoder.write(chunk);state.length+=state.objectMode?1:chunk.length;if(addToFront){state.buffer.unshift(chunk)}else{state.reading=false;state.buffer.push(chunk)}if(state.needReadable)emitReadable(stream);maybeReadMore(stream,state)}}else if(!addToFront){state.reading=false}return needMoreData(state)}function needMoreData(state){return!state.ended&&(state.needReadable||state.length<state.highWaterMark||state.length===0)}Readable.prototype.setEncoding=function(enc){if(!StringDecoder)StringDecoder=require("string_decoder/").StringDecoder;this._readableState.decoder=new StringDecoder(enc);this._readableState.encoding=enc};var MAX_HWM=8388608;function roundUpToNextPowerOf2(n){if(n>=MAX_HWM){n=MAX_HWM}else{n--;for(var p=1;p<32;p<<=1)n|=n>>p;n++}return n}function howMuchToRead(n,state){if(state.length===0&&state.ended)return 0;if(state.objectMode)return n===0?0:1;if(n===null||isNaN(n)){if(state.flowing&&state.buffer.length)return state.buffer[0].length;else return state.length}if(n<=0)return 0;if(n>state.highWaterMark)state.highWaterMark=roundUpToNextPowerOf2(n);if(n>state.length){if(!state.ended){state.needReadable=true;return 0}else return state.length}return n}Readable.prototype.read=function(n){var state=this._readableState;state.calledRead=true;var nOrig=n;var ret;if(typeof n!=="number"||n>0)state.emittedReadable=false;if(n===0&&state.needReadable&&(state.length>=state.highWaterMark||state.ended)){emitReadable(this);return null}n=howMuchToRead(n,state);if(n===0&&state.ended){ret=null;if(state.length>0&&state.decoder){ret=fromList(n,state);state.length-=ret.length}if(state.length===0)endReadable(this);return ret}var doRead=state.needReadable;if(state.length-n<=state.highWaterMark)doRead=true;if(state.ended||state.reading)doRead=false;if(doRead){state.reading=true;state.sync=true;if(state.length===0)state.needReadable=true;this._read(state.highWaterMark);state.sync=false}if(doRead&&!state.reading)n=howMuchToRead(nOrig,state);if(n>0)ret=fromList(n,state);else ret=null;if(ret===null){state.needReadable=true;n=0}state.length-=n;if(state.length===0&&!state.ended)state.needReadable=true;if(state.ended&&!state.endEmitted&&state.length===0)endReadable(this);return ret};function chunkInvalid(state,chunk){var er=null;if(!Buffer.isBuffer(chunk)&&"string"!==typeof chunk&&chunk!==null&&chunk!==undefined&&!state.objectMode){er=new TypeError("Invalid non-string/buffer chunk")}return er}function onEofChunk(stream,state){if(state.decoder&&!state.ended){var chunk=state.decoder.end();if(chunk&&chunk.length){state.buffer.push(chunk);state.length+=state.objectMode?1:chunk.length}}state.ended=true;if(state.length>0)emitReadable(stream);else endReadable(stream)}function emitReadable(stream){var state=stream._readableState;state.needReadable=false;if(state.emittedReadable)return;state.emittedReadable=true;if(state.sync)process.nextTick(function(){emitReadable_(stream)});else emitReadable_(stream)}function emitReadable_(stream){stream.emit("readable")}function maybeReadMore(stream,state){if(!state.readingMore){state.readingMore=true;process.nextTick(function(){maybeReadMore_(stream,state)})}}function maybeReadMore_(stream,state){var len=state.length;while(!state.reading&&!state.flowing&&!state.ended&&state.length<state.highWaterMark){stream.read(0);if(len===state.length)break;else len=state.length}state.readingMore=false}Readable.prototype._read=function(n){this.emit("error",new Error("not implemented"))};Readable.prototype.pipe=function(dest,pipeOpts){var src=this;var state=this._readableState;switch(state.pipesCount){case 0:state.pipes=dest;break;case 1:state.pipes=[state.pipes,dest];break;default:state.pipes.push(dest);break}state.pipesCount+=1;var doEnd=(!pipeOpts||pipeOpts.end!==false)&&dest!==process.stdout&&dest!==process.stderr;var endFn=doEnd?onend:cleanup;if(state.endEmitted)process.nextTick(endFn);else src.once("end",endFn);dest.on("unpipe",onunpipe);function onunpipe(readable){if(readable!==src)return;cleanup()}function onend(){dest.end()}var ondrain=pipeOnDrain(src);dest.on("drain",ondrain);function cleanup(){dest.removeListener("close",onclose);dest.removeListener("finish",onfinish);dest.removeListener("drain",ondrain);dest.removeListener("error",onerror);dest.removeListener("unpipe",onunpipe);src.removeListener("end",onend);src.removeListener("end",cleanup);if(!dest._writableState||dest._writableState.needDrain)ondrain()}function onerror(er){unpipe();dest.removeListener("error",onerror);if(EE.listenerCount(dest,"error")===0)dest.emit("error",er)}if(!dest._events||!dest._events.error)dest.on("error",onerror);else if(isArray(dest._events.error))dest._events.error.unshift(onerror);else dest._events.error=[onerror,dest._events.error];function onclose(){dest.removeListener("finish",onfinish);unpipe()}dest.once("close",onclose);function onfinish(){dest.removeListener("close",onclose);unpipe()}dest.once("finish",onfinish);function unpipe(){src.unpipe(dest)}dest.emit("pipe",src);if(!state.flowing){this.on("readable",pipeOnReadable);state.flowing=true;process.nextTick(function(){flow(src)})}return dest};function pipeOnDrain(src){return function(){var dest=this;var state=src._readableState;state.awaitDrain--;if(state.awaitDrain===0)flow(src)}}function flow(src){var state=src._readableState;var chunk;state.awaitDrain=0;function write(dest,i,list){var written=dest.write(chunk);if(false===written){state.awaitDrain++}}while(state.pipesCount&&null!==(chunk=src.read())){if(state.pipesCount===1)write(state.pipes,0,null);else forEach(state.pipes,write);src.emit("data",chunk);if(state.awaitDrain>0)return}if(state.pipesCount===0){state.flowing=false;if(EE.listenerCount(src,"data")>0)emitDataEvents(src);return}state.ranOut=true}function pipeOnReadable(){if(this._readableState.ranOut){this._readableState.ranOut=false;flow(this)}}Readable.prototype.unpipe=function(dest){var state=this._readableState;if(state.pipesCount===0)return this;if(state.pipesCount===1){if(dest&&dest!==state.pipes)return this;if(!dest)dest=state.pipes;state.pipes=null;state.pipesCount=0;this.removeListener("readable",pipeOnReadable);state.flowing=false;if(dest)dest.emit("unpipe",this);return this}if(!dest){var dests=state.pipes;var len=state.pipesCount;state.pipes=null;state.pipesCount=0;this.removeListener("readable",pipeOnReadable);state.flowing=false;for(var i=0;i<len;i++)dests[i].emit("unpipe",this);return this}var i=indexOf(state.pipes,dest);if(i===-1)return this;state.pipes.splice(i,1);state.pipesCount-=1;if(state.pipesCount===1)state.pipes=state.pipes[0];dest.emit("unpipe",this);return this};Readable.prototype.on=function(ev,fn){var res=Stream.prototype.on.call(this,ev,fn);if(ev==="data"&&!this._readableState.flowing)emitDataEvents(this);if(ev==="readable"&&this.readable){var state=this._readableState;if(!state.readableListening){state.readableListening=true;state.emittedReadable=false;state.needReadable=true;if(!state.reading){this.read(0)}else if(state.length){emitReadable(this,state)}}}return res};Readable.prototype.addListener=Readable.prototype.on;Readable.prototype.resume=function(){emitDataEvents(this);this.read(0);this.emit("resume")};Readable.prototype.pause=function(){emitDataEvents(this,true);this.emit("pause")};function emitDataEvents(stream,startPaused){var state=stream._readableState;if(state.flowing){throw new Error("Cannot switch to old mode now.")}var paused=startPaused||false;var readable=false;stream.readable=true;stream.pipe=Stream.prototype.pipe;
stream.on=stream.addListener=Stream.prototype.on;stream.on("readable",function(){readable=true;var c;while(!paused&&null!==(c=stream.read()))stream.emit("data",c);if(c===null){readable=false;stream._readableState.needReadable=true}});stream.pause=function(){paused=true;this.emit("pause")};stream.resume=function(){paused=false;if(readable)process.nextTick(function(){stream.emit("readable")});else this.read(0);this.emit("resume")};stream.emit("readable")}Readable.prototype.wrap=function(stream){var state=this._readableState;var paused=false;var self=this;stream.on("end",function(){if(state.decoder&&!state.ended){var chunk=state.decoder.end();if(chunk&&chunk.length)self.push(chunk)}self.push(null)});stream.on("data",function(chunk){if(state.decoder)chunk=state.decoder.write(chunk);if(state.objectMode&&(chunk===null||chunk===undefined))return;else if(!state.objectMode&&(!chunk||!chunk.length))return;var ret=self.push(chunk);if(!ret){paused=true;stream.pause()}});for(var i in stream){if(typeof stream[i]==="function"&&typeof this[i]==="undefined"){this[i]=function(method){return function(){return stream[method].apply(stream,arguments)}}(i)}}var events=["error","close","destroy","pause","resume"];forEach(events,function(ev){stream.on(ev,self.emit.bind(self,ev))});self._read=function(n){if(paused){paused=false;stream.resume()}};return self};Readable._fromList=fromList;function fromList(n,state){var list=state.buffer;var length=state.length;var stringMode=!!state.decoder;var objectMode=!!state.objectMode;var ret;if(list.length===0)return null;if(length===0)ret=null;else if(objectMode)ret=list.shift();else if(!n||n>=length){if(stringMode)ret=list.join("");else ret=Buffer.concat(list,length);list.length=0}else{if(n<list[0].length){var buf=list[0];ret=buf.slice(0,n);list[0]=buf.slice(n)}else if(n===list[0].length){ret=list.shift()}else{if(stringMode)ret="";else ret=new Buffer(n);var c=0;for(var i=0,l=list.length;i<l&&c<n;i++){var buf=list[0];var cpy=Math.min(n-c,buf.length);if(stringMode)ret+=buf.slice(0,cpy);else buf.copy(ret,c,0,cpy);if(cpy<buf.length)list[0]=buf.slice(cpy);else list.shift();c+=cpy}}}return ret}function endReadable(stream){var state=stream._readableState;if(state.length>0)throw new Error("endReadable called on non-empty stream");if(!state.endEmitted&&state.calledRead){state.ended=true;process.nextTick(function(){if(!state.endEmitted&&state.length===0){state.endEmitted=true;stream.readable=false;stream.emit("end")}})}}function forEach(xs,f){for(var i=0,l=xs.length;i<l;i++){f(xs[i],i)}}function indexOf(xs,x){for(var i=0,l=xs.length;i<l;i++){if(xs[i]===x)return i}return-1}}).call(this,require("_process"))},{_process:9,buffer:2,"core-util-is":60,events:6,inherits:61,isarray:62,stream:21,"string_decoder/":63}],58:[function(require,module,exports){arguments[4][14][0].apply(exports,arguments)},{"./_stream_duplex":55,"core-util-is":60,dup:14,inherits:61}],59:[function(require,module,exports){(function(process){module.exports=Writable;var Buffer=require("buffer").Buffer;Writable.WritableState=WritableState;var util=require("core-util-is");util.inherits=require("inherits");var Stream=require("stream");util.inherits(Writable,Stream);function WriteReq(chunk,encoding,cb){this.chunk=chunk;this.encoding=encoding;this.callback=cb}function WritableState(options,stream){options=options||{};var hwm=options.highWaterMark;this.highWaterMark=hwm||hwm===0?hwm:16*1024;this.objectMode=!!options.objectMode;this.highWaterMark=~~this.highWaterMark;this.needDrain=false;this.ending=false;this.ended=false;this.finished=false;var noDecode=options.decodeStrings===false;this.decodeStrings=!noDecode;this.defaultEncoding=options.defaultEncoding||"utf8";this.length=0;this.writing=false;this.sync=true;this.bufferProcessing=false;this.onwrite=function(er){onwrite(stream,er)};this.writecb=null;this.writelen=0;this.buffer=[];this.errorEmitted=false}function Writable(options){var Duplex=require("./_stream_duplex");if(!(this instanceof Writable)&&!(this instanceof Duplex))return new Writable(options);this._writableState=new WritableState(options,this);this.writable=true;Stream.call(this)}Writable.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))};function writeAfterEnd(stream,state,cb){var er=new Error("write after end");stream.emit("error",er);process.nextTick(function(){cb(er)})}function validChunk(stream,state,chunk,cb){var valid=true;if(!Buffer.isBuffer(chunk)&&"string"!==typeof chunk&&chunk!==null&&chunk!==undefined&&!state.objectMode){var er=new TypeError("Invalid non-string/buffer chunk");stream.emit("error",er);process.nextTick(function(){cb(er)});valid=false}return valid}Writable.prototype.write=function(chunk,encoding,cb){var state=this._writableState;var ret=false;if(typeof encoding==="function"){cb=encoding;encoding=null}if(Buffer.isBuffer(chunk))encoding="buffer";else if(!encoding)encoding=state.defaultEncoding;if(typeof cb!=="function")cb=function(){};if(state.ended)writeAfterEnd(this,state,cb);else if(validChunk(this,state,chunk,cb))ret=writeOrBuffer(this,state,chunk,encoding,cb);return ret};function decodeChunk(state,chunk,encoding){if(!state.objectMode&&state.decodeStrings!==false&&typeof chunk==="string"){chunk=new Buffer(chunk,encoding)}return chunk}function writeOrBuffer(stream,state,chunk,encoding,cb){chunk=decodeChunk(state,chunk,encoding);if(Buffer.isBuffer(chunk))encoding="buffer";var len=state.objectMode?1:chunk.length;state.length+=len;var ret=state.length<state.highWaterMark;if(!ret)state.needDrain=true;if(state.writing)state.buffer.push(new WriteReq(chunk,encoding,cb));else doWrite(stream,state,len,chunk,encoding,cb);return ret}function doWrite(stream,state,len,chunk,encoding,cb){state.writelen=len;state.writecb=cb;state.writing=true;state.sync=true;stream._write(chunk,encoding,state.onwrite);state.sync=false}function onwriteError(stream,state,sync,er,cb){if(sync)process.nextTick(function(){cb(er)});else cb(er);stream._writableState.errorEmitted=true;stream.emit("error",er)}function onwriteStateUpdate(state){state.writing=false;state.writecb=null;state.length-=state.writelen;state.writelen=0}function onwrite(stream,er){var state=stream._writableState;var sync=state.sync;var cb=state.writecb;onwriteStateUpdate(state);if(er)onwriteError(stream,state,sync,er,cb);else{var finished=needFinish(stream,state);if(!finished&&!state.bufferProcessing&&state.buffer.length)clearBuffer(stream,state);if(sync){process.nextTick(function(){afterWrite(stream,state,finished,cb)})}else{afterWrite(stream,state,finished,cb)}}}function afterWrite(stream,state,finished,cb){if(!finished)onwriteDrain(stream,state);cb();if(finished)finishMaybe(stream,state)}function onwriteDrain(stream,state){if(state.length===0&&state.needDrain){state.needDrain=false;stream.emit("drain")}}function clearBuffer(stream,state){state.bufferProcessing=true;for(var c=0;c<state.buffer.length;c++){var entry=state.buffer[c];var chunk=entry.chunk;var encoding=entry.encoding;var cb=entry.callback;var len=state.objectMode?1:chunk.length;doWrite(stream,state,len,chunk,encoding,cb);if(state.writing){c++;break}}state.bufferProcessing=false;if(c<state.buffer.length)state.buffer=state.buffer.slice(c);else state.buffer.length=0}Writable.prototype._write=function(chunk,encoding,cb){cb(new Error("not implemented"))};Writable.prototype.end=function(chunk,encoding,cb){var state=this._writableState;if(typeof chunk==="function"){cb=chunk;chunk=null;encoding=null}else if(typeof encoding==="function"){cb=encoding;encoding=null}if(typeof chunk!=="undefined"&&chunk!==null)this.write(chunk,encoding);if(!state.ending&&!state.finished)endWritable(this,state,cb)};function needFinish(stream,state){return state.ending&&state.length===0&&!state.finished&&!state.writing}function finishMaybe(stream,state){var need=needFinish(stream,state);if(need){state.finished=true;stream.emit("finish")}return need}function endWritable(stream,state,cb){state.ending=true;finishMaybe(stream,state);if(cb){if(state.finished)process.nextTick(cb);else stream.once("finish",cb)}state.ended=true}}).call(this,require("_process"))},{"./_stream_duplex":55,_process:9,buffer:2,"core-util-is":60,inherits:61,stream:21}],60:[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}],61:[function(require,module,exports){arguments[4][7][0].apply(exports,arguments)},{dup:7}],62:[function(require,module,exports){arguments[4][8][0].apply(exports,arguments)},{dup:8}],63:[function(require,module,exports){arguments[4][22][0].apply(exports,arguments)},{buffer:2,dup:22}],64:[function(require,module,exports){arguments[4][18][0].apply(exports,arguments)},{"./lib/_stream_duplex.js":55,"./lib/_stream_passthrough.js":56,"./lib/_stream_readable.js":57,"./lib/_stream_transform.js":58,"./lib/_stream_writable.js":59,dup:18,stream:21}],65:[function(require,module,exports){module.exports=extend;function extend(){var target={};for(var i=0;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(source.hasOwnProperty(key)){target[key]=source[key]}}}return target}},{}],66:[function(require,module,exports){module.exports={name:"levelup",description:"Fast & simple storage - a Node.js-style LevelDB wrapper",version:"0.18.6",contributors:[{name:"Rod Vagg",email:"r@va.gg",url:"https://github.com/rvagg"},{name:"John Chesley",email:"john@chesl.es",url:"https://github.com/chesles/"},{name:"Jake Verbaten",email:"raynos2@gmail.com",url:"https://github.com/raynos"},{name:"Dominic Tarr",email:"dominic.tarr@gmail.com",url:"https://github.com/dominictarr"},{name:"Max Ogden",email:"max@maxogden.com",url:"https://github.com/maxogden"},{name:"Lars-Magnus Skog",email:"lars.magnus.skog@gmail.com",url:"https://github.com/ralphtheninja"},{name:"David Björklund",email:"david.bjorklund@gmail.com",url:"https://github.com/kesla"},{name:"Julian Gruber",email:"julian@juliangruber.com",url:"https://github.com/juliangruber"},{name:"Paolo Fragomeni",email:"paolo@async.ly",url:"https://github.com/hij1nx"},{name:"Anton Whalley",email:"anton.whalley@nearform.com",url:"https://github.com/No9"},{name:"Matteo Collina",email:"matteo.collina@gmail.com",url:"https://github.com/mcollina"},{name:"Pedro Teixeira",email:"pedro.teixeira@gmail.com",url:"https://github.com/pgte"},{name:"James Halliday",email:"mail@substack.net",url:"https://github.com/substack"}],repository:{type:"git",url:"https://github.com/rvagg/node-levelup.git"},homepage:"https://github.com/rvagg/node-levelup",keywords:["leveldb","stream","database","db","store","storage","json"],main:"lib/levelup.js",dependencies:{bl:"~0.8.1","deferred-leveldown":"~0.2.0",errno:"~0.1.1",prr:"~0.0.0","readable-stream":"~1.0.26",semver:"~2.3.1",xtend:"~3.0.0"},devDependencies:{leveldown:"~0.10.0",bustermove:"*",tap:"*",referee:"*",rimraf:"*",async:"*",fstream:"*",tar:"*",mkfiletree:"*",readfiletree:"*","slow-stream":">=0.0.4",delayed:"*",boganipsum:"*",du:"*",memdown:"*","msgpack-js":"*"},browser:{leveldown:false,"leveldown/package":false,semver:false},scripts:{test:"tap test/*-test.js --stderr",functionaltests:"node ./test/functional/fstream-test.js && node ./test/functional/binary-data-test.js && node ./test/functional/compat-test.js",alltests:"npm test && npm run-script functionaltests"},license:"MIT",readme:"LevelUP\n=======\n\n![LevelDB Logo](https://0.gravatar.com/avatar/a498b122aecb7678490a38bb593cc12d)\n\n**Fast & simple storage - a Node.js-style LevelDB wrapper**\n\n[![Build Status](https://secure.travis-ci.org/rvagg/node-levelup.png)](http://travis-ci.org/rvagg/node-levelup)\n\n[![NPM](https://nodei.co/npm/levelup.png?stars&downloads)](https://nodei.co/npm/levelup/) [![NPM](https://nodei.co/npm-dl/levelup.png)](https://nodei.co/npm/levelup/)\n\n\n * <a href=\"#intro\">Introduction</a>\n * <a href=\"#leveldown\">Relationship to LevelDOWN</a>\n * <a href=\"#platforms\">Tested &amp; supported platforms</a>\n * <a href=\"#basic\">Basic usage</a>\n * <a href=\"#api\">API</a>\n * <a href=\"#events\">Events</a>\n * <a href=\"#json\">JSON data</a>\n * <a href=\"#custom_encodings\">Custom encodings</a>\n * <a href=\"#extending\">Extending LevelUP</a>\n * <a href=\"#multiproc\">Multi-process access</a>\n * <a href=\"#support\">Getting support</a>\n * <a href=\"#contributing\">Contributing</a>\n * <a href=\"#licence\">Licence &amp; copyright</a>\n\n<a name=\"intro\"></a>\nIntroduction\n------------\n\n**[LevelDB](http://code.google.com/p/leveldb/)** is a simple key/value data store built by Google, inspired by BigTable. It's used in Google Chrome and many other products. LevelDB supports arbitrary byte arrays as both keys and values, singular *get*, *put* and *delete* operations, *batched put and delete*, bi-directional iterators and simple compression using the very fast [Snappy](http://code.google.com/p/snappy/) algorithm.\n\n**LevelUP** aims to expose the features of LevelDB in a **Node.js-friendly way**. All standard `Buffer` encoding types are supported, as is a special JSON encoding. LevelDB's iterators are exposed as a Node.js-style **readable stream** a matching **writeable stream** converts writes to *batch* operations.\n\nLevelDB stores entries **sorted lexicographically by keys**. This makes LevelUP's <a href=\"#createReadStream\"><code>ReadStream</code></a> interface a very powerful query mechanism.\n\n**LevelUP** is an **OPEN Open Source Project**, see the <a href=\"#contributing\">Contributing</a> section to find out what this means.\n\n<a name=\"leveldown\"></a>\nRelationship to LevelDOWN\n-------------------------\n\nLevelUP is designed to be backed by **[LevelDOWN](https://github.com/rvagg/node-leveldown/)** which provides a pure C++ binding to LevelDB and can be used as a stand-alone package if required.\n\n**As of version 0.9, LevelUP no longer requires LevelDOWN as a dependency so you must `npm install leveldown` when you install LevelUP.**\n\nLevelDOWN is now optional because LevelUP can be used with alternative backends, such as **[level.js](https://github.com/maxogden/level.js)** in the browser or [MemDOWN](https://github.com/rvagg/node-memdown) for a pure in-memory store.\n\nLevelUP will look for LevelDOWN and throw an error if it can't find it in its Node `require()` path. It will also tell you if the installed version of LevelDOWN is incompatible.\n\n**The [level](https://github.com/level/level) package is available as an alternative installation mechanism.** Install it instead to automatically get both LevelUP & LevelDOWN. It exposes LevelUP on its export (i.e. you can `var leveldb = require('level')`).\n\n\n<a name=\"platforms\"></a>\nTested & supported platforms\n----------------------------\n\n * **Linux**: including ARM platforms such as Raspberry Pi *and Kindle!*\n * **Mac OS**\n * **Solaris**: including Joyent's SmartOS & Nodejitsu\n * **Windows**: Node 0.10 and above only. See installation instructions for *node-gyp's* dependencies [here](https://github.com/TooTallNate/node-gyp#installation), you'll need these (free) components from Microsoft to compile and run any native Node add-on in Windows.\n\n<a name=\"basic\"></a>\nBasic usage\n-----------\n\nFirst you need to install LevelUP!\n\n```sh\n$ npm install levelup leveldown\n```\n\nOr\n\n```sh\n$ npm install level\n```\n\n*(this second option requires you to use LevelUP by calling `var levelup = require('level')`)*\n\n\nAll operations are asynchronous although they don't necessarily require a callback if you don't need to know when the operation was performed.\n\n```js\nvar levelup = require('levelup')\n\n// 1) Create our database, supply location and options.\n// This will create or open the underlying LevelDB store.\nvar db = levelup('./mydb')\n\n// 2) put a key & value\ndb.put('name', 'LevelUP', function (err) {\n if (err) return console.log('Ooops!', err) // some kind of I/O error\n\n // 3) fetch by key\n db.get('name', function (err, value) {\n if (err) return console.log('Ooops!', err) // likely the key was not found\n\n // ta da!\n console.log('name=' + value)\n })\n})\n```\n\n<a name=\"api\"></a>\n## API\n\n * <a href=\"#ctor\"><code><b>levelup()</b></code></a>\n * <a href=\"#open\"><code>db.<b>open()</b></code></a>\n * <a href=\"#close\"><code>db.<b>close()</b></code></a>\n * <a href=\"#put\"><code>db.<b>put()</b></code></a>\n * <a href=\"#get\"><code>db.<b>get()</b></code></a>\n * <a href=\"#del\"><code>db.<b>del()</b></code></a>\n * <a href=\"#batch\"><code>db.<b>batch()</b></code> *(array form)*</a>\n * <a href=\"#batch_chained\"><code>db.<b>batch()</b></code> *(chained form)*</a>\n * <a href=\"#isOpen\"><code>db.<b>isOpen()</b></code></a>\n * <a href=\"#isClosed\"><code>db.<b>isClosed()</b></code></a>\n * <a href=\"#createReadStream\"><code>db.<b>createReadStream()</b></code></a>\n * <a href=\"#createKeyStream\"><code>db.<b>createKeyStream()</b></code></a>\n * <a href=\"#createValueStream\"><code>db.<b>createValueStream()</b></code></a>\n * <a href=\"#createWriteStream\"><code>db.<b>createWriteStream()</b></code></a>\n\n### Special operations exposed by LevelDOWN\n\n * <a href=\"#approximateSize\"><code>db.db.<b>approximateSize()</b></code></a>\n * <a href=\"#getProperty\"><code>db.db.<b>getProperty()</b></code></a>\n * <a href=\"#destroy\"><code><b>leveldown.destroy()</b></code></a>\n * <a href=\"#repair\"><code><b>leveldown.repair()</b></code></a>\n\n\n--------------------------------------------------------\n<a name=\"ctor\"></a>\n### levelup(location[, options[, callback]])\n### levelup(options[, callback ])\n### levelup(db[, callback ])\n<code>levelup()</code> is the main entry point for creating a new LevelUP instance and opening the underlying store with LevelDB.\n\nThis function returns a new instance of LevelUP and will also initiate an <a href=\"#open\"><code>open()</code></a> operation. Opening the database is an asynchronous operation which will trigger your callback if you provide one. The callback should take the form: `function (err, db) {}` where the `db` is the LevelUP instance. If you don't provide a callback, any read & write operations are simply queued internally until the database is fully opened.\n\nThis leads to two alternative ways of managing a new LevelUP instance:\n\n```js\nlevelup(location, options, function (err, db) {\n if (err) throw err\n db.get('foo', function (err, value) {\n if (err) return console.log('foo does not exist')\n console.log('got foo =', value)\n })\n})\n\n// vs the equivalent:\n\nvar db = levelup(location, options) // will throw if an error occurs\ndb.get('foo', function (err, value) {\n if (err) return console.log('foo does not exist')\n console.log('got foo =', value)\n})\n```\n\nThe `location` argument is available as a read-only property on the returned LevelUP instance.\n\nThe `levelup(options, callback)` form (with optional `callback`) is only available where you provide a valid `'db'` property on the options object (see below). Only for back-ends that don't require a `location` argument, such as [MemDOWN](https://github.com/rvagg/memdown).\n\nFor example:\n\n```js\nvar levelup = require('levelup')\nvar memdown = require('memdown')\nvar db = levelup({ db: memdown })\n```\n\nThe `levelup(db, callback)` form (with optional `callback`) is only available where `db` is a factory function, as would be provided as a `'db'` property on an `options` object (see below). Only for back-ends that don't require a `location` argument, such as [MemDOWN](https://github.com/rvagg/memdown).\n\nFor example:\n\n```js\nvar levelup = require('levelup')\nvar memdown = require('memdown')\nvar db = levelup(memdown)\n```\n\n#### `options`\n\n`levelup()` takes an optional options object as its second argument; the following properties are accepted:\n\n* `'createIfMissing'` *(boolean, default: `true`)*: If `true`, will initialise an empty database at the specified location if one doesn't already exist. If `false` and a database doesn't exist you will receive an error in your `open()` callback and your database won't open.\n\n* `'errorIfExists'` *(boolean, default: `false`)*: If `true`, you will receive an error in your `open()` callback if the database exists at the specified location.\n\n* `'compression'` *(boolean, default: `true`)*: If `true`, all *compressible* data will be run through the Snappy compression algorithm before being stored. Snappy is very fast and shouldn't gain much speed by disabling so leave this on unless you have good reason to turn it off.\n\n* `'cacheSize'` *(number, default: `8 * 1024 * 1024`)*: The size (in bytes) of the in-memory [LRU](http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used) cache with frequently used uncompressed block contents. \n\n* `'keyEncoding'` and `'valueEncoding'` *(string, default: `'utf8'`)*: The encoding of the keys and values passed through Node.js' `Buffer` implementation (see [Buffer#toString()](http://nodejs.org/docs/latest/api/buffer.html#buffer_buf_tostring_encoding_start_end)).\n <p><code>'utf8'</code> is the default encoding for both keys and values so you can simply pass in strings and expect strings from your <code>get()</code> operations. You can also pass <code>Buffer</code> objects as keys and/or values and conversion will be performed.</p>\n <p>Supported encodings are: hex, utf8, ascii, binary, base64, ucs2, utf16le.</p>\n <p><code>'json'</code> encoding is also supported, see below.</p>\n\n* `'db'` *(object, default: LevelDOWN)*: LevelUP is backed by [LevelDOWN](https://github.com/rvagg/node-leveldown/) to provide an interface to LevelDB. You can completely replace the use of LevelDOWN by providing a \"factory\" function that will return a LevelDOWN API compatible object given a `location` argument. For further information, see [MemDOWN](https://github.com/rvagg/node-memdown/), a fully LevelDOWN API compatible replacement that uses a memory store rather than LevelDB. Also see [Abstract LevelDOWN](http://github.com/rvagg/node-abstract-leveldown), a partial implementation of the LevelDOWN API that can be used as a base prototype for a LevelDOWN substitute.\n\nAdditionally, each of the main interface methods accept an optional options object that can be used to override `'keyEncoding'` and `'valueEncoding'`.\n\n--------------------------------------------------------\n<a name=\"open\"></a>\n### db.open([callback])\n<code>open()</code> opens the underlying LevelDB store. In general **you should never need to call this method directly** as it's automatically called by <a href=\"#ctor\"><code>levelup()</code></a>.\n\nHowever, it is possible to *reopen* a database after it has been closed with <a href=\"#close\"><code>close()</code></a>, although this is not generally advised.\n\n--------------------------------------------------------\n<a name=\"close\"></a>\n### db.close([callback])\n<code>close()</code> closes the underlying LevelDB store. The callback will receive any error encountered during closing as the first argument.\n\nYou should always clean up your LevelUP instance by calling `close()` when you no longer need it to free up resources. A LevelDB store cannot be opened by multiple instances of LevelDB/LevelUP simultaneously.\n\n--------------------------------------------------------\n<a name=\"put\"></a>\n### db.put(key, value[, options][, callback])\n<code>put()</code> is the primary method for inserting data into the store. Both the `key` and `value` can be arbitrary data objects.\n\nThe callback argument is optional but if you don't provide one and an error occurs then expect the error to be thrown.\n\n#### `options`\n\nEncoding of the `key` and `value` objects will adhere to `'keyEncoding'` and `'valueEncoding'` options provided to <a href=\"#ctor\"><code>levelup()</code></a>, although you can provide alternative encoding settings in the options for `put()` (it's recommended that you stay consistent in your encoding of keys and values in a single store).\n\nIf you provide a `'sync'` value of `true` in your `options` object, LevelDB will perform a synchronous write of the data; although the operation will be asynchronous as far as Node is concerned. Normally, LevelDB passes the data to the operating system for writing and returns immediately, however a synchronous write will use `fsync()` or equivalent so your callback won't be triggered until the data is actually on disk. Synchronous filesystem writes are **significantly** slower than asynchronous writes but if you want to be absolutely sure that the data is flushed then you can use `'sync': true`.\n\n--------------------------------------------------------\n<a name=\"get\"></a>\n### db.get(key[, options][, callback])\n<code>get()</code> is the primary method for fetching data from the store. The `key` can be an arbitrary data object. If it doesn't exist in the store then the callback will receive an error as its first argument. A not-found err object will be of type `'NotFoundError'` so you can `err.type == 'NotFoundError'` or you can perform a truthy test on the property `err.notFound`.\n\n```js\ndb.get('foo', function (err, value) {\n if (err) {\n if (err.notFound) {\n // handle a 'NotFoundError' here\n return\n }\n // I/O or other error, pass it up the callback chain\n return callback(err)\n }\n\n // .. handle `value` here\n})\n```\n\n#### `options`\n\nEncoding of the `key` object will adhere to the `'keyEncoding'` option provided to <a href=\"#ctor\"><code>levelup()</code></a>, although you can provide alternative encoding settings in the options for `get()` (it's recommended that you stay consistent in your encoding of keys and values in a single store).\n\nLevelDB will by default fill the in-memory LRU Cache with data from a call to get. Disabling this is done by setting `fillCache` to `false`. \n\n--------------------------------------------------------\n<a name=\"del\"></a>\n### db.del(key[, options][, callback])\n<code>del()</code> is the primary method for removing data from the store.\n\n#### `options`\n\nEncoding of the `key` object will adhere to the `'keyEncoding'` option provided to <a href=\"#ctor\"><code>levelup()</code></a>, although you can provide alternative encoding settings in the options for `del()` (it's recommended that you stay consistent in your encoding of keys and values in a single store).\n\nA `'sync'` option can also be passed, see <a href=\"#put\"><code>put()</code></a> for details on how this works.\n\n--------------------------------------------------------\n<a name=\"batch\"></a>\n### db.batch(array[, options][, callback]) *(array form)*\n<code>batch()</code> can be used for very fast bulk-write operations (both *put* and *delete*). The `array` argument should contain a list of operations to be executed sequentially, although as a whole they are performed as an atomic operation inside LevelDB. Each operation is contained in an object having the following properties: `type`, `key`, `value`, where the *type* is either `'put'` or `'del'`. In the case of `'del'` the `'value'` property is ignored. Any entries with a `'key'` of `null` or `undefined` will cause an error to be returned on the `callback` and any `'type': 'put'` entry with a `'value'` of `null` or `undefined` will return an error.\n\n```js\nvar ops = [\n { type: 'del', key: 'father' }\n , { type: 'put', key: 'name', value: 'Yuri Irsenovich Kim' }\n , { type: 'put', key: 'dob', value: '16 February 1941' }\n , { type: 'put', key: 'spouse', value: 'Kim Young-sook' }\n , { type: 'put', key: 'occupation', value: 'Clown' }\n]\n\ndb.batch(ops, function (err) {\n if (err) return console.log('Ooops!', err)\n console.log('Great success dear leader!')\n})\n```\n\n#### `options`\n\nSee <a href=\"#put\"><code>put()</code></a> for a discussion on the `options` object. You can overwrite default `'keyEncoding'` and `'valueEncoding'` and also specify the use of `sync` filesystem operations.\n\nIn addition to encoding options for the whole batch you can also overwrite the encoding per operation, like:\n\n```js\nvar ops = [{\n type : 'put'\n , key : new Buffer([1, 2, 3])\n , value : { some: 'json' }\n , keyEncoding : 'binary'\n , valueEncoding : 'json'\n}]\n```\n\n--------------------------------------------------------\n<a name=\"batch_chained\"></a>\n### db.batch() *(chained form)*\n<code>batch()</code>, when called with no arguments will return a `Batch` object which can be used to build, and eventually commit, an atomic LevelDB batch operation. Depending on how it's used, it is possible to obtain greater performance when using the chained form of `batch()` over the array form.\n\n```js\ndb.batch()\n .del('father')\n .put('name', 'Yuri Irsenovich Kim')\n .put('dob', '16 February 1941')\n .put('spouse', 'Kim Young-sook')\n .put('occupation', 'Clown')\n .write(function () { console.log('Done!') })\n```\n\n<b><code>batch.put(key, value[, options])</code></b>\n\nQueue a *put* operation on the current batch, not committed until a `write()` is called on the batch.\n\nThe optional `options` argument can be used to override the default `'keyEncoding'` and/or `'valueEncoding'`.\n\nThis method may `throw` a `WriteError` if there is a problem with your put (such as the `value` being `null` or `undefined`).\n\n<b><code>batch.del(key[, options])</code></b>\n\nQueue a *del* operation on the current batch, not committed until a `write()` is called on the batch.\n\nThe optional `options` argument can be used to override the default `'keyEncoding'`.\n\nThis method may `throw` a `WriteError` if there is a problem with your delete.\n\n<b><code>batch.clear()</code></b>\n\nClear all queued operations on the current batch, any previous operations will be discarded.\n\n<b><code>batch.write([callback])</code></b>\n\nCommit the queued operations for this batch. All operations not *cleared* will be written to the database atomically, that is, they will either all succeed or fail with no partial commits. The optional `callback` will be called when the operation has completed with an *error* argument if an error has occurred; if no `callback` is supplied and an error occurs then this method will `throw` a `WriteError`.\n\n\n--------------------------------------------------------\n<a name=\"isOpen\"></a>\n### db.isOpen()\n\nA LevelUP object can be in one of the following states:\n\n * *\"new\"* - newly created, not opened or closed\n * *\"opening\"* - waiting for the database to be opened\n * *\"open\"* - successfully opened the database, available for use\n * *\"closing\"* - waiting for the database to be closed\n * *\"closed\"* - database has been successfully closed, should not be used\n\n`isOpen()` will return `true` only when the state is \"open\".\n\n--------------------------------------------------------\n<a name=\"isClosed\"></a>\n### db.isClosed()\n\n*See <a href=\"#put\"><code>isOpen()</code></a>*\n\n`isClosed()` will return `true` only when the state is \"closing\" *or* \"closed\", it can be useful for determining if read and write operations are permissible.\n\n--------------------------------------------------------\n<a name=\"createReadStream\"></a>\n### db.createReadStream([options])\n\nYou can obtain a **ReadStream** of the full database by calling the `createReadStream()` method. The resulting stream is a complete Node.js-style [Readable Stream](http://nodejs.org/docs/latest/api/stream.html#stream_readable_stream) where `'data'` events emit objects with `'key'` and `'value'` pairs. You can also use the `start`, `end` and `limit` options to control the range of keys that are streamed.\n\n```js\ndb.createReadStream()\n .on('data', function (data) {\n console.log(data.key, '=', data.value)\n })\n .on('error', function (err) {\n console.log('Oh my!', err)\n })\n .on('close', function () {\n console.log('Stream closed')\n })\n .on('end', function () {\n console.log('Stream closed')\n })\n```\n\nThe standard `pause()`, `resume()` and `destroy()` methods are implemented on the ReadStream, as is `pipe()` (see below). `'data'`, '`error'`, `'end'` and `'close'` events are emitted.\n\nAdditionally, you can supply an options object as the first parameter to `createReadStream()` with the following options:\n\n* `'gt'` (greater than), `'gte'` (greater than or equal) define the lower bound of the range to be streamed. Only records where the key is greater than (or equal to) this option will be included in the range. When `reverse=true` the order will be reversed, but the records streamed will be the same.\n\n* `'lt'` (less than), `'lte'` (less than or equal) define the higher bound of the range to be streamed. Only key/value pairs where the key is less than (or equal to) this option will be included in the range. When `reverse=true` the order will be reversed, but the records streamed will be the same.\n\n* `'start', 'end'` legacy ranges - instead use `'gte', 'lte'`\n\n* `'reverse'` *(boolean, default: `false`)*: a boolean, set true and the stream output will be reversed. Beware that due to the way LevelDB works, a reverse seek will be slower than a forward seek.\n\n* `'keys'` *(boolean, default: `true`)*: whether the `'data'` event should contain keys. If set to `true` and `'values'` set to `false` then `'data'` events will simply be keys, rather than objects with a `'key'` property. Used internally by the `createKeyStream()` method.\n\n* `'values'` *(boolean, default: `true`)*: whether the `'data'` event should contain values. If set to `true` and `'keys'` set to `false` then `'data'` events will simply be values, rather than objects with a `'value'` property. Used internally by the `createValueStream()` method.\n\n* `'limit'` *(number, default: `-1`)*: limit the number of results collected by this stream. This number represents a *maximum* number of results and may not be reached if you get to the end of the store or your `'end'` value first. A value of `-1` means there is no limit.\n\n* `'fillCache'` *(boolean, default: `false`)*: wheather LevelDB's LRU-cache should be filled with data read.\n\n* `'keyEncoding'` / `'valueEncoding'` *(string)*: the encoding applied to each read piece of data.\n\n--------------------------------------------------------\n<a name=\"createKeyStream\"></a>\n### db.createKeyStream([options])\n\nA **KeyStream** is a **ReadStream** where the `'data'` events are simply the keys from the database so it can be used like a traditional stream rather than an object stream.\n\nYou can obtain a KeyStream either by calling the `createKeyStream()` method on a LevelUP object or by passing passing an options object to `createReadStream()` with `keys` set to `true` and `values` set to `false`.\n\n```js\ndb.createKeyStream()\n .on('data', function (data) {\n console.log('key=', data)\n })\n\n// same as:\ndb.createReadStream({ keys: true, values: false })\n .on('data', function (data) {\n console.log('key=', data)\n })\n```\n\n--------------------------------------------------------\n<a name=\"createValueStream\"></a>\n### db.createValueStream([options])\n\nA **ValueStream** is a **ReadStream** where the `'data'` events are simply the values from the database so it can be used like a traditional stream rather than an object stream.\n\nYou can obtain a ValueStream either by calling the `createValueStream()` method on a LevelUP object or by passing passing an options object to `createReadStream()` with `values` set to `true` and `keys` set to `false`.\n\n```js\ndb.createValueStream()\n .on('data', function (data) {\n console.log('value=', data)\n })\n\n// same as:\ndb.createReadStream({ keys: false, values: true })\n .on('data', function (data) {\n console.log('value=', data)\n })\n```\n\n--------------------------------------------------------\n<a name=\"createWriteStream\"></a>\n### db.createWriteStream([options])\n\nA **WriteStream** can be obtained by calling the `createWriteStream()` method. The resulting stream is a complete Node.js-style [Writable Stream](http://nodejs.org/docs/latest/api/stream.html#stream_writable_stream) which accepts objects with `'key'` and `'value'` pairs on its `write()` method.\n\nThe WriteStream will buffer writes and submit them as a `batch()` operations where writes occur *within the same tick*.\n\n```js\nvar ws = db.createWriteStream()\n\nws.on('error', function (err) {\n console.log('Oh my!', err)\n})\nws.on('close', function () {\n console.log('Stream closed')\n})\n\nws.write({ key: 'name', value: 'Yuri Irsenovich Kim' })\nws.write({ key: 'dob', value: '16 February 1941' })\nws.write({ key: 'spouse', value: 'Kim Young-sook' })\nws.write({ key: 'occupation', value: 'Clown' })\nws.end()\n```\n\nThe standard `write()`, `end()`, `destroy()` and `destroySoon()` methods are implemented on the WriteStream. `'drain'`, `'error'`, `'close'` and `'pipe'` events are emitted.\n\nYou can specify encodings both for the whole stream and individual entries:\n\nTo set the encoding for the whole stream, provide an options object as the first parameter to `createWriteStream()` with `'keyEncoding'` and/or `'valueEncoding'`.\n\nTo set the encoding for an individual entry:\n\n```js\nwriteStream.write({\n key : new Buffer([1, 2, 3])\n , value : { some: 'json' }\n , keyEncoding : 'binary'\n , valueEncoding : 'json'\n})\n```\n\n#### write({ type: 'put' })\n\nIf individual `write()` operations are performed with a `'type'` property of `'del'`, they will be passed on as `'del'` operations to the batch.\n\n```js\nvar ws = db.createWriteStream()\n\nws.on('error', function (err) {\n console.log('Oh my!', err)\n})\nws.on('close', function () {\n console.log('Stream closed')\n})\n\nws.write({ type: 'del', key: 'name' })\nws.write({ type: 'del', key: 'dob' })\nws.write({ type: 'put', key: 'spouse' })\nws.write({ type: 'del', key: 'occupation' })\nws.end()\n```\n\n#### db.createWriteStream({ type: 'del' })\n\nIf the *WriteStream* is created with a `'type'` option of `'del'`, all `write()` operations will be interpreted as `'del'`, unless explicitly specified as `'put'`.\n\n```js\nvar ws = db.createWriteStream({ type: 'del' })\n\nws.on('error', function (err) {\n console.log('Oh my!', err)\n})\nws.on('close', function () {\n console.log('Stream closed')\n})\n\nws.write({ key: 'name' })\nws.write({ key: 'dob' })\n// but it can be overridden\nws.write({ type: 'put', key: 'spouse', value: 'Ri Sol-ju' })\nws.write({ key: 'occupation' })\nws.end()\n```\n\n#### Pipes and Node Stream compatibility\n\nA ReadStream can be piped directly to a WriteStream, allowing for easy copying of an entire database. A simple `copy()` operation is included in LevelUP that performs exactly this on two open databases:\n\n```js\nfunction copy (srcdb, dstdb, callback) {\n srcdb.createReadStream().pipe(dstdb.createWriteStream()).on('close', callback)\n}\n```\n\nThe ReadStream is also [fstream](https://github.com/isaacs/fstream)-compatible which means you should be able to pipe to and from fstreams. So you can serialize and deserialize an entire database to a directory where keys are filenames and values are their contents, or even into a *tar* file using [node-tar](https://github.com/isaacs/node-tar). See the [fstream functional test](https://github.com/rvagg/node-levelup/blob/master/test/functional/fstream-test.js) for an example. *(Note: I'm not really sure there's a great use-case for this but it's a fun example and it helps to harden the stream implementations.)*\n\nKeyStreams and ValueStreams can be treated like standard streams of raw data. If `'keyEncoding'` or `'valueEncoding'` is set to `'binary'` the `'data'` events will simply be standard Node `Buffer` objects straight out of the data store.\n\n\n--------------------------------------------------------\n<a name='approximateSize'></a>\n### db.db.approximateSize(start, end, callback)\n<code>approximateSize()</code> can used to get the approximate number of bytes of file system space used by the range `[start..end)`. The result may not include recently written data.\n\n```js\nvar db = require('level')('./huge.db')\n\ndb.db.approximateSize('a', 'c', function (err, size) {\n if (err) return console.error('Ooops!', err)\n console.log('Approximate size of range is %d', size)\n})\n```\n\n**Note:** `approximateSize()` is available via [LevelDOWN](https://github.com/rvagg/node-leveldown/), which by default is accessible as the `db` property of your LevelUP instance. This is a specific LevelDB operation and is not likely to be available where you replace LevelDOWN with an alternative back-end via the `'db'` option.\n\n\n--------------------------------------------------------\n<a name='getProperty'></a>\n### db.db.getProperty(property)\n<code>getProperty</code> can be used to get internal details from LevelDB. When issued with a valid property string, a readable string will be returned (this method is synchronous).\n\nCurrently, the only valid properties are:\n\n* <b><code>'leveldb.num-files-at-levelN'</code></b>: returns the number of files at level *N*, where N is an integer representing a valid level (e.g. \"0\").\n\n* <b><code>'leveldb.stats'</code></b>: returns a multi-line string describing statistics about LevelDB's internal operation.\n\n* <b><code>'leveldb.sstables'</code></b>: returns a multi-line string describing all of the *sstables* that make up contents of the current database.\n\n\n```js\nvar db = require('level')('./huge.db')\nconsole.log(db.db.getProperty('leveldb.num-files-at-level3'))\n// → '243'\n```\n\n**Note:** `getProperty()` is available via [LevelDOWN](https://github.com/rvagg/node-leveldown/), which by default is accessible as the `db` property of your LevelUP instance. This is a specific LevelDB operation and is not likely to be available where you replace LevelDOWN with an alternative back-end via the `'db'` option.\n\n\n--------------------------------------------------------\n<a name=\"destroy\"></a>\n### leveldown.destroy(location, callback)\n<code>destroy()</code> is used to completely remove an existing LevelDB database directory. You can use this function in place of a full directory *rm* if you want to be sure to only remove LevelDB-related files. If the directory only contains LevelDB files, the directory itself will be removed as well. If there are additional, non-LevelDB files in the directory, those files, and the directory, will be left alone.\n\nThe callback will be called when the destroy operation is complete, with a possible `error` argument.\n\n**Note:** `destroy()` is available via [LevelDOWN](https://github.com/rvagg/node-leveldown/) which you will have to install seperately, e.g.:\n\n```js\nrequire('leveldown').destroy('./huge.db', function (err) { console.log('done!') })\n```\n\n--------------------------------------------------------\n<a name=\"repair\"></a>\n### leveldown.repair(location, callback)\n<code>repair()</code> can be used to attempt a restoration of a damaged LevelDB store. From the LevelDB documentation:\n\n> If a DB cannot be opened, you may attempt to call this method to resurrect as much of the contents of the database as possible. Some data may be lost, so be careful when calling this function on a database that contains important information.\n\nYou will find information on the *repair* operation in the *LOG* file inside the store directory. \n\nA `repair()` can also be used to perform a compaction of the LevelDB log into table files.\n\nThe callback will be called when the repair operation is complete, with a possible `error` argument.\n\n**Note:** `repair()` is available via [LevelDOWN](https://github.com/rvagg/node-leveldown/) which you will have to install seperately, e.g.:\n\n```js\nrequire('leveldown').repair('./huge.db', function (err) { console.log('done!') })\n```\n\n--------------------------------------------------------\n\n<a name=\"events\"></a>\nEvents\n------\n\nLevelUP emits events when the callbacks to the corresponding methods are called.\n\n* `db.emit('put', key, value)` emitted when a new value is `'put'`\n* `db.emit('del', key)` emitted when a value is deleted\n* `db.emit('batch', ary)` emitted when a batch operation has executed\n* `db.emit('ready')` emitted when the database has opened (`'open'` is synonym)\n* `db.emit('closed')` emitted when the database has closed\n* `db.emit('opening')` emitted when the database is opening\n* `db.emit('closing')` emitted when the database is closing\n\nIf you do not pass a callback to an async function, and there is an error, LevelUP will `emit('error', err)` instead.\n\n<a name=\"json\"></a>\nJSON data\n---------\n\nYou specify `'json'` encoding for both keys and/or values, you can then supply JavaScript objects to LevelUP and receive them from all fetch operations, including ReadStreams. LevelUP will automatically *stringify* your objects and store them as *utf8* and parse the strings back into objects before passing them back to you.\n\n<a name=\"custom_encodings\"></a>\nCustom encodings\n----------------\n\nA custom encoding may be provided by passing in an object as an value for `keyEncoding` or `valueEncoding` (wherever accepted), it must have the following properties:\n\n```js\n{\n encode : function (val) { ... }\n , decode : function (val) { ... }\n , buffer : boolean // encode returns a buffer and decode accepts a buffer\n , type : String // name of this encoding type.\n}\n```\n\n<a name=\"extending\"></a>\nExtending LevelUP\n-----------------\n\nA list of <a href=\"https://github.com/rvagg/node-levelup/wiki/Modules\"><b>Node.js LevelDB modules and projects</b></a> can be found in the wiki.\n\nWhen attempting to extend the functionality of LevelUP, it is recommended that you consider using [level-hooks](https://github.com/dominictarr/level-hooks) and/or [level-sublevel](https://github.com/dominictarr/level-sublevel). **level-sublevel** is particularly helpful for keeping additional, extension-specific, data in a LevelDB store. It allows you to partition a LevelUP instance into multiple sub-instances that each correspond to discrete namespaced key ranges.\n\n<a name=\"multiproc\"></a>\nMulti-process access\n--------------------\n\nLevelDB is thread-safe but is **not** suitable for accessing with multiple processes. You should only ever have a LevelDB database open from a single Node.js process. Node.js clusters are made up of multiple processes so a LevelUP instance cannot be shared between them either.\n\nSee the <a href=\"https://github.com/rvagg/node-levelup/wiki/Modules\"><b>wiki</b></a> for some LevelUP extensions, including [multilevel](https://github.com/juliangruber/multilevel), that may help if you require a single data store to be shared across processes.\n\n<a name=\"support\"></a>\nGetting support\n---------------\n\nThere are multiple ways you can find help in using LevelDB in Node.js:\n\n * **IRC:** you'll find an active group of LevelUP users in the **##leveldb** channel on Freenode, including most of the contributors to this project.\n * **Mailing list:** there is an active [Node.js LevelDB](https://groups.google.com/forum/#!forum/node-levelup) Google Group.\n * **GitHub:** you're welcome to open an issue here on this GitHub repository if you have a question.\n\n<a name=\"contributing\"></a>\nContributing\n------------\n\nLevelUP is an **OPEN Open Source Project**. This means that:\n\n> Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project.\n\nSee the [CONTRIBUTING.md](https://github.com/rvagg/node-levelup/blob/master/CONTRIBUTING.md) file for more details.\n\n### Contributors\n\nLevelUP is only possible due to the excellent work of the following contributors:\n\n<table><tbody>\n<tr><th align=\"left\">Rod Vagg</th><td><a href=\"https://github.com/rvagg\">GitHub/rvagg</a></td><td><a href=\"http://twitter.com/rvagg\">Twitter/@rvagg</a></td></tr>\n<tr><th align=\"left\">John Chesley</th><td><a href=\"https://github.com/chesles/\">GitHub/chesles</a></td><td><a href=\"http://twitter.com/chesles\">Twitter/@chesles</a></td></tr>\n<tr><th align=\"left\">Jake Verbaten</th><td><a href=\"https://github.com/raynos\">GitHub/raynos</a></td><td><a href=\"http://twitter.com/raynos2\">Twitter/@raynos2</a></td></tr>\n<tr><th align=\"left\">Dominic Tarr</th><td><a href=\"https://github.com/dominictarr\">GitHub/dominictarr</a></td><td><a href=\"http://twitter.com/dominictarr\">Twitter/@dominictarr</a></td></tr>\n<tr><th align=\"left\">Max Ogden</th><td><a href=\"https://github.com/maxogden\">GitHub/maxogden</a></td><td><a href=\"http://twitter.com/maxogden\">Twitter/@maxogden</a></td></tr>\n<tr><th align=\"left\">Lars-Magnus Skog</th><td><a href=\"https://github.com/ralphtheninja\">GitHub/ralphtheninja</a></td><td><a href=\"http://twitter.com/ralphtheninja\">Twitter/@ralphtheninja</a></td></tr>\n<tr><th align=\"left\">David Björklund</th><td><a href=\"https://github.com/kesla\">GitHub/kesla</a></td><td><a href=\"http://twitter.com/david_bjorklund\">Twitter/@david_bjorklund</a></td></tr>\n<tr><th align=\"left\">Julian Gruber</th><td><a href=\"https://github.com/juliangruber\">GitHub/juliangruber</a></td><td><a href=\"http://twitter.com/juliangruber\">Twitter/@juliangruber</a></td></tr>\n<tr><th align=\"left\">Paolo Fragomeni</th><td><a href=\"https://github.com/hij1nx\">GitHub/hij1nx</a></td><td><a href=\"http://twitter.com/hij1nx\">Twitter/@hij1nx</a></td></tr>\n<tr><th align=\"left\">Anton Whalley</th><td><a href=\"https://github.com/No9\">GitHub/No9</a></td><td><a href=\"https://twitter.com/antonwhalley\">Twitter/@antonwhalley</a></td></tr>\n<tr><th align=\"left\">Matteo Collina</th><td><a href=\"https://github.com/mcollina\">GitHub/mcollina</a></td><td><a href=\"https://twitter.com/matteocollina\">Twitter/@matteocollina</a></td></tr>\n<tr><th align=\"left\">Pedro Teixeira</th><td><a href=\"https://github.com/pgte\">GitHub/pgte</a></td><td><a href=\"https://twitter.com/pgte\">Twitter/@pgte</a></td></tr>\n<tr><th align=\"left\">James Halliday</th><td><a href=\"https://github.com/substack\">GitHub/substack</a></td><td><a href=\"https://twitter.com/substack\">Twitter/@substack</a></td></tr>\n</tbody></table>\n\n### Windows\n\nA large portion of the Windows support comes from code by [Krzysztof Kowalczyk](http://blog.kowalczyk.info/) [@kjk](https://twitter.com/kjk), see his Windows LevelDB port [here](http://code.google.com/r/kkowalczyk-leveldb/). If you're using LevelUP on Windows, you should give him your thanks!\n\n\n<a name=\"license\"></a>\nLicense &amp; copyright\n-------------------\n\nCopyright (c) 2012-2014 LevelUP contributors (listed above).\n\nLevelUP is licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details.\n\n=======\n*LevelUP builds on the excellent work of the LevelDB and Snappy teams from Google and additional contributors. LevelDB and Snappy are both issued under the [New BSD Licence](http://opensource.org/licenses/BSD-3-Clause).*\n",readmeFilename:"README.md",bugs:{url:"https://github.com/rvagg/node-levelup/issues"},_id:"levelup@0.18.6",_from:"levelup@~0.18.0"}
},{}],"level-browserify":[function(require,module,exports){var Leveljs=require("level-js");module.exports=require("level-packager")(function(l){return new Leveljs(l)})},{"level-js":25,"level-packager":38}]},{},[]);var level=require("level-browserify");var db=window.levelDB=level("./mydb");db.put("name","Level",function(err){if(err)return console.log("Ooops!",err);db.get("name",function(err,value){if(err)return console.log("Ooops!",err);console.log("name="+value)})});
{
"name": "requirebin-sketch",
"version": "1.0.0",
"dependencies": {
"level-browserify": "0.18.1"
}
}
<style type='text/css'>html, body { margin: 0; padding: 0; border: 0; }
body, html { height: 100%; width: 100%; }</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment