csvtojson
Version:
A tool concentrating on converting csv data to JSON with customised parser supporting
3 lines • 118 kB
JavaScript
/*Automatically Generated. Do not modify.*/
!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){window&&(window.csvtojson=a("./index.js"),window.csvtojson.version=a("./package.json").version)},{"./index.js":2,"./package.json":130}],2:[function(a,b,c){b.exports=a("./libs/csv2json.js")},{"./libs/csv2json.js":24}],3:[function(a,b,c){function d(a,b,c){Error.call(this,""),this.err=a,this.line=b,this.extra=c,this.message="Error: "+a+". JSON Line number: "+b+(c?" near: "+c:""),this.name="CSV Error"}var e=a("util");b.exports=d,e.inherits(d,Error),d.prototype.toString=function(){return JSON.stringify([this.err,this.line,this.extra])},d.column_mismatched=function(a,b){return new d("column_mismatched",a,b)},d.unclosed_quote=function(a,b){return new d("unclosed_quote",a,b)},d.fromArray=function(a){return new d(a[0],a[1],a[2])}},{util:72}],4:[function(a,b,c){(function(c){function d(a,b){return g.call(this,b),_param=j(a),this._options=b||{},this.param=_param,this.param._options=this._options,this.started=!1,this.recordNum=0,this.lineNumber=0,this._csvLineBuffer="",this.lastIndex=0,this.param.forked&&(this.param.forked=!1,this.workerNum=2),this.flushCb=null,this.processEnd=!1,this.sequenceBuffer=[],this._needJson=null,this._needEmitResult=null,this._needEmitFinalResult=null,this._needEmitJson=null,this._needPush=null,this._needEmitCsv=null,this._csvTransf=null,this.finalResult=[],this.on("error",e(this)),this.on("end",e(this)),this.initWorker(),c.nextTick(function(){null===this._needEmitFinalResult&&(this._needEmitFinalResult=this.listeners("end_parsed").length>0),null===this._needEmitResult&&(this._needEmitResult=this.listeners("record_parsed").length>0),null===this._needEmitJson&&(this._needEmitJson=this.listeners("json").length>0),null===this._needEmitCsv&&(this._needEmitCsv=this.listeners("csv").length>0),null===this._needJson&&(this._needJson=this._needEmitJson||this._needEmitFinalResult||this._needEmitResult||this.transform||this._options.objectMode),null===this._needPush&&(this._needPush=this.listeners("data").length>0||this.listeners("readable").length>0),this.param._needParseJson=this._needJson||this._needPush}.bind(this)),this}function e(a){return function(b){c.nextTick(function(){a.emit("done",b)})}}var f=a("util"),g=a("stream").Transform,h=a("os"),i=h.EOL,j=a("./defParam"),k=(a("./csvline"),a("./fileline")),l=(a("./dataToCSVLine"),a("./fileLineToCSVLine")),m=a("./linesToJson"),n=a("./CSVError"),o=a("./workerMgr");f.inherits(d,g),d.prototype._transform=function(a,b,c){this.param.toArrayString&&this.started===!1&&(this.started=!0,this._needPush&&this.push("["+i,"utf8")),a=a.toString("utf8");var d=this;this.preProcessRaw(a,function(a){a&&a.length>0?d.processData(d.prepareData(a),c):c()})},d.prototype.prepareData=function(a){return this._csvLineBuffer+a},d.prototype.setPartialData=function(a){this._csvLineBuffer=a},d.prototype.processData=function(a,b){var c=this.param;c.ignoreEmpty&&!c._headers&&(a=a.trimLeft());var d=k(a,this.param);if(d.lines.length>0)if(this.preProcessLine&&"function"==typeof this.preProcessLine&&(d.lines=this._preProcessLines(d.lines,this.lastIndex)),c._headers)if(c.workerNum<=1){var e=l(d,c);this.setPartialData(e.partial);var f=m(e.lines,c,this.recordNum);this.processResult(f),this.lastIndex+=f.length,this.recordNum+=f.length,b()}else this.workerProcess(d,b);else this.processHead(d,b);else this.setPartialData(d.partial),b()},d.prototype._preProcessLines=function(a,b){for(var c=[],d=0;d<a.length;d++){var e=this.preProcessLine(a[d],b+d+1);"string"==typeof e?c.push(e):(c.push(a[d]),this.emit("error",new Error("preProcessLine should return a string but got: "+JSON.stringify(e))))}return c},d.prototype.initWorker=function(){var a=this.param.workerNum-1;a>0&&(this.workerMgr=o(),this.workerMgr.initWorker(a,this.param))},d.prototype.preRawData=function(a){return this.preProcessRaw=a,this},d.prototype.preFileLine=function(a){return this.preProcessLine=a,this},d.prototype.workerProcess=function(a,b){var c=this,d=a,e=this.getEol();this.setPartialData(d.partial),this.workerMgr.sendWorker(d.lines.join(e)+e,this.lastIndex,b,function(a,b){var d=c.sequenceBuffer[0];if(d.idx===b){d.result=a;for(var e=[];c.sequenceBuffer[0]&&c.sequenceBuffer[0].result;){var f=c.sequenceBuffer.shift();e=e.concat(f.result)}c.processResult(e),c.recordNum+=e.length}else for(var g=0;g<c.sequenceBuffer.length;g++){var f=c.sequenceBuffer[g];if(f.idx===b){f.result=a;break}}}),this.sequenceBuffer.push({idx:this.lastIndex,result:null}),this.lastIndex+=d.lines.length},d.prototype.processHead=function(a,b){var c=this.param;if(c._headers)b();else{var d=l(a,c);if(this.setPartialData(d.partial),c.noheader)c.headers?c._headers=c.headers:c._headers=[];else{var e=d.lines.shift();c.headers?c._headers=c.headers:c._headers=e}this.param.workerNum>1&&this.workerMgr.setParams(c);var f=m(d.lines,c,0);this.processResult(f),this.lastIndex+=f.length,this.recordNum+=f.length,b()}},d.prototype.processResult=function(a){for(var b=0;b<a.length;b++){var c=a[b];c.err?this.emit("error",c.err):this.emitResult(c)}},d.prototype.emitResult=function(a){var b=a.index,c=a.row,d=a.json,e=null,f=null;"string"==typeof d?f=d:e=d,null===e&&this._needJson&&(e=JSON.parse(f),"string"==typeof c&&(c=JSON.parse(c))),this.transform&&"function"==typeof this.transform&&(this.transform(e,c,b),f=null),this._needEmitJson&&this.emit("json",e,b),this._needEmitCsv&&("string"==typeof c&&(c=JSON.parse(c)),this.emit("csv",c,b)),this.param.constructResult&&this._needEmitFinalResult&&this.finalResult.push(e),this._needEmitResult&&this.emit("record_parsed",e,c,b),this.param.toArrayString&&b>0&&this._needPush&&this.push(","+i),this._options&&this._options.objectMode?this.push(e):this._needPush&&(null===f&&(f=JSON.stringify(e)),this.push(this.param.toArrayString?f:f+i,"utf8"))},d.prototype.preProcessRaw=function(a,b){b(a)},d.prototype.preProcessLine=function(a,b){return a},d.prototype._flush=function(a){var b=this;this.flushCb=function(){b.emit("end_parsed",b.finalResult),b.workerMgr&&b.workerMgr.destroyWorker(),a(),b._needPush||b.emit("end")},this._csvLineBuffer.length>0?(this._csvLineBuffer[this._csvLineBuffer.length-1]!=this.getEol()&&(this._csvLineBuffer+=this.getEol()),this.processData(this._csvLineBuffer,function(){this.checkAndFlush()}.bind(this))):this.checkAndFlush()},d.prototype.checkAndFlush=function(){0!==this._csvLineBuffer.length&&this.emit("error",n.unclosed_quote(this.recordNum,this._csvLineBuffer),this._csvLineBuffer),this.param.toArrayString&&this._needPush&&this.push(i+"]","utf8"),this.workerMgr&&this.workerMgr.isRunning()?this.workerMgr.drain=function(){this.flushCb()}.bind(this):this.flushCb()},d.prototype.getEol=function(a){if(!this.param.eol&&a){for(var b=0;b<a.length;b++){if("\r"===a[b])return"\n"===a[b+1]?this.param.eol="\r\n":this.param.eol="\r",this.param.eol;if("\n"===a[b])return this.param.eol="\n",this.param.eol}this.param.eol=i}return this.param.eol||i},d.prototype.fromFile=function(b,c){var d=a("fs"),e=null;return this.wrapCallback(c,function(){e&&e.destroy&&e.destroy()}),d.exists(b,function(a){a?(e=d.createReadStream(b),e.pipe(this)):this.emit("error",new Error("File not exist"))}.bind(this)),this},d.prototype.fromStream=function(a,b){return b&&"function"==typeof b&&this.wrapCallback(b),a.pipe(this),this},d.prototype.transf=function(a){return this.transform=a,this},d.prototype.fromString=function(a,b){return"string"!=typeof a?b(new Error("Passed CSV Data is not a string.")):(b&&"function"==typeof b&&this.wrapCallback(b,function(){}),c.nextTick(function(){this.end(a)}.bind(this)),this)},d.prototype.wrapCallback=function(a,b){void 0===b&&(b=function(){}),a&&"function"==typeof a&&this.once("end_parsed",function(b){this.hasError||a(null,b)}.bind(this)),this.once("error",function(c){this.hasError=!0,a&&"function"==typeof a&&a(c),b()}.bind(this))},b.exports=d}).call(this,a("_process"))},{"./CSVError":3,"./csvline":5,"./dataToCSVLine":6,"./defParam":7,"./fileLineToCSVLine":14,"./fileline":15,"./linesToJson":19,"./workerMgr":23,_process:41,fs:30,os:40,stream:59,util:72}],5:[function(a,b,c){var d=a("./getEol"),e=(a("./getDelimiter"),a("./fileline"),a("./rowSplit"));b.exports=function(a,b){for(var c=[],f="";a.length;){var g=f+a.shift(),h=e(g,b);h.closed?(c.push(h.cols),f=""):f=g+d(g,b)}return{lines:c,partial:f}}},{"./fileline":15,"./getDelimiter":16,"./getEol":17,"./rowSplit":22}],6:[function(a,b,c){var d=a("./fileline"),e=a("./csvline");b.exports=function(a,b){var c=d(a,b),f=c.lines,g=e(f,b);return{lines:g.lines,partial:g.partial+c.partial}}},{"./csvline":5,"./fileline":15}],7:[function(a,b,c){(function(a){function c(b,c){return a.env[b]?a.env[b]:c}b.exports=function(a){var b={constructResult:!0,delimiter:",",ignoreColumns:[],includeColumns:[],quote:'"',trim:!0,checkType:!1,toArrayString:!1,ignoreEmpty:!1,workerNum:c("CSV_WORKER",1),fork:!1,noheader:!1,headers:null,flatKeys:!1,maxRowLength:0,checkColumn:!1,escape:'"',_headerType:[],_headerTitle:[],_headerFlag:[],_headers:null,_needFilterRow:!1};a||(a={});for(var d in a)a.hasOwnProperty(d)&&(b[d]=a[d]);return(b.ignoreColumns.length||b.includeColumns.length)&&(b._needFilterRow=!0,b.ignoreColumns.sort(function(a,b){return b-a})),b}}).call(this,a("_process"))},{_process:41}],8:[function(a,b,c){b.exports=[a("./parser_array.js"),a("./parser_json.js"),a("./parser_omit.js"),a("./parser_jsonarray.js"),a("./parser_flat.js")]},{"./parser_array.js":9,"./parser_flat.js":10,"./parser_json.js":11,"./parser_jsonarray.js":12,"./parser_omit.js":13}],9:[function(a,b,c){b.exports={name:"array",processSafe:!0,regExp:/^\*array\*/,parserFunc:function(a){var b=a.head.replace(this.regExp,"");void 0===a.resultRow[b]&&(a.resultRow[b]=[]),a.resultRow[b].push(a.item)}}},{}],10:[function(a,b,c){b.exports={name:"flat",processSafe:!0,regExp:/^\*flat\*/,parserFunc:function(a){var b=this.getHeadStr(),c=a.item;a.resultRow[b]=c}}},{}],11:[function(a,b,c){function d(a,b,c,d){for(var e,f,g;b.length>1;)e=b.shift(),f=d?!1:e.match(c),f?(void 0===a[e.replace(f[0],"")]&&(a[e.replace(f[0],"")]=[]),g=f[1],a=a[e.replace(f[0],"")],""===g&&(g=a.length),a[g]||(a[g]={}),a=a[g]):(void 0===a[e]&&(a[e]={}),a=a[e]);return a}var e=/\[([0-9]*)\]/;b.exports={name:"json",processSafe:!0,regExp:/^\*json\*/,parserFunc:function(a){var b,c,f,g,h=this.getHeadStr(),i=a.config&&a.config.flatKeys?[h]:h.split("."),g=d(a.resultRow,i,e,a.config&&a.config.flatKeys);if(f=i.shift(),b=a.config&&a.config.flatKeys?!1:f.match(e))try{f=f.replace(b[0],""),g[f]&&g[f]instanceof Array||(g[f]=[]),g[f]?(c=b[1],""===c&&(c=g[f].length),g[f][c]=a.item):a.resultRow[h]=a.item}catch(j){a.resultRow[h]=a.item}else"string"==typeof g?a.resultRow[h]=a.item:g[f]=a.item}}},{}],12:[function(a,b,c){b.exports={name:"jsonarray",processSafe:!0,regExp:/^\*jsonarray\*/,parserFunc:function(a){for(var b=a.head.replace(this.regExp,""),c=b.split("."),d=a.resultRow;c.length>1;){var e=c.shift();void 0===d[e]&&(d[e]={}),d=d[e]}var f=c.shift();void 0===d[f]&&(d[f]=[]),d[f].push(a.item)}}},{}],13:[function(a,b,c){b.exports={name:"omit",regExp:/^\*omit\*/,processSafe:!0,parserFunc:function(){}}},{}],14:[function(a,b,c){var d=a("./csvline");b.exports=function(a,b){var c=a.lines,e=d(c,b);return{lines:e.lines,partial:e.partial+a.partial}}},{"./csvline":5}],15:[function(a,b,c){var d=a("./getEol");b.exports=function(a,b){var c=d(a,b),e=a.split(c),f=e.pop();return{lines:e,partial:f}}},{"./getEol":17}],16:[function(a,b,c){function d(a,b){var c;if("auto"===b.delimiter)c=e;else{if(!(b.delimiter instanceof Array))return b.delimiter;c=b.delimiter}var d=0,f=",";return c.forEach(function(b){var c=a.split(b).length;c>d&&(f=b,d=c)}),f}b.exports=d;var e=[",","|"," ",";",":"]},{}],17:[function(a,b,c){var d=a("os").EOL;b.exports=function(a,b){if(!b.eol&&a){for(var c=0;c<a.length;c++){if("\r"===a[c])return"\n"===a[c+1]?b.eol="\r\n":b.eol="\r",b.eol;if("\n"===a[c])return b.eol="\n",b.eol}b.eol=d}return b.eol}},{os:40}],18:[function(a,b,c){function d(a,c){return new b.exports.Converter(a,c)}b.exports=d,b.exports.Converter=a("./Converter.js")},{"./Converter.js":4}],19:[function(a,b,c){function d(a,b,c){for(var d=[],e=0;e<a.length;e++)d.push({err:null,json:{},index:c++,row:a[e]});return d}function e(a,b,c){for(var d=(a.length,[]),e=0;e<a.length;e++){var g=f(a[e],b,c++);g&&d.push(g)}return d}function f(a,b,c){var d=b.parseRules;if(b.checkColumn&&a.length!=d.length)return{err:s.column_mismatched(c)};var e=b._headers,f=g(a,e,b);return f?{json:f,index:c,row:a}:null}function g(a,b,c){var d=!1,e={};for(i=0;i<a.length;i++)if(item=a[i],!c.ignoreEmpty||""!==item){d=!0,head=b[i],head&&""!==head||(head=b[i]="field"+(i+1));var f=j(head,i,c);if("omit"!==f){c.checkType&&(convertFunc=l(item,head,i,c),item=convertFunc(item));var g=k(head,i,c);"flat"===f||c.flatKeys?e[g]=item:h(e,g,item)}}return d?e:!1}function h(b,c,d){var e=a("lodash/set"),f=c.split(".");1===f.length?b[c]=d:e(b,c,d)}function j(a,b,c){return"string"==typeof c._headerFlag[b]?c._headerFlag[b]:a.indexOf("*omit*")>-1?c._headerFlag[b]="omit":a.indexOf("*flat*")>-1?c._headerFlag[b]="flat":c._headerFlag[b]=""}function k(a,b,c){if(c._headerTitle[b])return c._headerTitle[b];var d=j(a,b,c),e=a.replace(d,"");return e=e.replace("string#!","").replace("number#!",""),c._headerTitle[b]=e}function l(a,b,c,d){return d._headerType[c]?d._headerType[c]:b.indexOf("number#!")>-1?d._headerType[c]=m:b.indexOf("string#!")>-1?d._headerType[c]=n:d.checkType?d._headerType[c]=o:d._headerType[c]=n}function m(a){var b=parseFloat(a);return isNaN(b)?a:b}function n(a){return a.toString()}function o(a){var b=a.trim();return""===b?n(a):t.test(b)?m(a):5===b.length&&"false"===b.toLowerCase()||4===b.length&&"true"===b.toLowerCase()?p(a):"{"===b[0]&&"}"===b[b.length-1]||"["===b[0]&&"]"===b[b.length-1]?q(a):n(a)}function p(a){var b=a.trim();return 5===b.length&&"false"===b.toLowerCase()?!1:!0}function q(a){try{return JSON.parse(a)}catch(b){return a}}var r=a("./parserMgr.js"),s=(a("./parser"),a("./CSVError")),t=/^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/;b.exports=function(a,b,c){if(b._needParseJson){if(b._headers||(b._headers=[]),!b.parseRules){var f=b._headers;b.parseRules=r.initParsers(f,b)}return e(a,b,c)}return d(a,b,c)}},{"./CSVError":3,"./parser":20,"./parserMgr.js":21,"lodash/set":128}],20:[function(a,b,c){function d(a,b,c,d){this.name="undefined"==typeof a?"Default":a,this.regExp=null,this.type="",this.processSafe=d,"undefined"!=typeof b&&("string"==typeof b?this.regExp=new RegExp(b):this.regExp=b),"undefined"!=typeof c&&(this.parse=c)}var e=["number","string"];d.prototype.convertType=function(a){var b=this.type;if("number"===b){var c=parseFloat(a);return isNaN(c)?0:c}if(this.param&&this.param.checkType&&""===b){var d=a.trim();if(""===d)return d;if(!isNaN(d))return parseFloat(d);if(5===d.length&&"false"===d.toLowerCase())return!1;if(4===d.length&&"true"===d.toLowerCase())return!0;if(!("{"===d[0]&&"}"===d[d.length-1]||"["===d[0]&&"]"===d[d.length-1]))return a;try{return JSON.parse(d)}catch(e){return a}}return a},d.prototype.setParam=function(a){this.param=a},d.prototype.test=function(a){return this.regExp&&this.regExp.test(a)},d.prototype.parse=function(a){a.resultRow[a.head]=a.item},d.prototype.getHeadStr=function(){if(this.headStr)return this.headStr;var a=this.head;return this.headStr=a.replace(this.regExp,""),this.headStr||(this.headStr="Unknown Header"),this.getHeadStr()},d.prototype.getHead=function(){return this.head},d.prototype.initHead=function(a){this.head=a;var b=a.replace(this.regExp,""),c=b.split("#!");if(1===c.length)this.headStr=c[0];else{var d=c.shift();e.indexOf(d.toLowerCase())>-1?(this.type=d,this.headStr=c.join("#!")):this.headStr=b}this.headStr||(this.headStr=b?b:"Unknown Head")},d.prototype.clone=function(){var a=Object.create(this),b=new d;for(var c in a)b[c]=a[c];return b},d.prototype.getName=function(){return this.name},b.exports=d},{}],21:[function(a,b,c){function d(a){a instanceof i&&-1===h.indexOf(a)&&h.push(a)}function e(a,b){function c(a){var b;if(h.forEach(function(c){c.getName()===a&&(b=c)}),b){var c=b.clone();return c}return new i}var d,e;return a=a?a:"",h.forEach(function(b){b.test(a)&&(e=b)}),e?(d=e.clone(),d.head=a):d=c("json",a),d.setParam(b),d.initHead(a),d}function f(a,b,c){var e=new i(a,b,c,!1);d(e)}function g(a,b){var c=[];return a.forEach(function(a){c.push(e(a,b))}),c}var h=[],i=a("./parser.js"),j=a("./defaultParsers");j.forEach(function(a){f(a.name,a.regExp,a.parserFunc,a.processSafe)}),b.exports.addParser=f,b.exports.initParsers=g,b.exports.getParser=e},{"./defaultParsers":8,"./parser.js":20}],22:[function(a,b,c){function d(a,b){if(b.ignoreColumns instanceof Array&&b.ignoreColumns.length>0)for(var c=0;c<b.ignoreColumns.length;c++)b.ignoreColumns[c]>=0&&a.splice(b.ignoreColumns[c],1);if(b.includeColumns instanceof Array&&b.includeColumns.length>0){for(var d=[],c=0;c<b.includeColumns.length;c++)b.includeColumns[c]>=0&&d.push(a[b.includeColumns[c]]);a=d}return a}function e(a,b){var c=b.quote,d=b.escape;return a[0]===c&&(a[1]!==c||a[1]===d&&(a[2]===c||2===a.length))}function f(a,b){for(var c=b.quote,d=0,e=a.length-1,f=b.escape;a[e]===c||a[e]===f;)e--,d++;return d%2!==0}function g(a,b,c){var d="es|"+b+"|"+c;void 0===i[d]&&("\\"===c&&(c="\\\\"),i[d]=new RegExp(c+b,"g"));var e=i[d];return a.replace(e,b)}var h=a("./getDelimiter");b.exports=function(a,b){if(""===a)return{cols:[],closed:!0};var c=b.quote,i=b.trim,j=b.escape;(b.delimiter instanceof Array||"auto"===b.delimiter.toLowerCase())&&(b.delimiter=h(a,b));var k=b.delimiter,l=a.split(k);if("off"===c)return{cols:l,closed:!0};for(var m=[],n=!1,o="",p=0;p<l.length;p++){var q=l[p];!n&&i&&(q=q.trim());var r=q.length;if(n)f(q,b)?(n=!1,q=q.substr(0,r-1),o+=k+q,o=g(o,c,j),i&&(o=o.trimRight()),m.push(o),o=""):o+=k+q;else{if(e(q,b)){if(q=q.substr(1),f(q,b)){q=q.substring(0,q.length-1),q=g(q,c,j),m.push(q);continue}n=!0,o+=q;continue}m.push(q)}}return!n&&b._needFilterRow&&(m=d(m,b)),{cols:m,closed:!n}};var i={}},{"./getDelimiter":16}],23:[function(a,b,c){(function(c,d){function e(){function a(a,b){i=[],j=0,k=null;for(var c=0;a>c;c++)i.push(new f(b))}function b(){return j>0}function d(){i.forEach(function(a){a.destroy()})}function e(a,b,d,f){if(i.length>0){var g=i.shift();j++,g.parse(a,b,function(a){i.push(g),f(a,b),j--,null===k&&0===j?h.drain():k&&(e.apply(this,k),k=null)}),c.nextTick(d)}else k=[a,b,d,f]}function g(a){i.forEach(function(b){b.setParams(a)})}var h={initWorker:a,sendWorker:e,setParams:g,drain:function(){},isRunning:b,destroyWorker:d},i=[],j=0,k=null;return h}function f(a){this.cp=g(c.execPath,[d+"/worker.js"],{env:{child:!0},stdio:["pipe","pipe",2,"ipc"]}),this.setParams(a),this.cp.on("message",this.onChildMsg.bind(this)),this.buffer="";var b=this;this.cp.stdout.on("data",function(a){for(var c=a.toString("utf8"),d=b.buffer+c,e=d.split(h);e.length>1;)b.onChildMsg(e.shift());b.buffer=e[0]})}b.exports=e;var g=a("child_process").spawn,h="",i="",j="",k=a("./CSVError");f.prototype.setParams=function(a){var b="0"+JSON.stringify(a);this.sendMsg(b)},f.prototype.onChildMsg=function(a){if(a){var b=a[0],c=a.substr(1);switch(b){case"0":if(this.cbLine){var d=c.split("|"),e=parseInt(d[0]),f=d[1];this.cbLine(e,f)}break;case"1":if(this.cbResult){var g=c.split(i);g.pop();var h=[];g.forEach(function(a){var b=a.split(j);h.push({index:b[0],row:b[1],err:b[2]?k.fromArray(JSON.parse(b[2])):null,json:b[3]})}),this.cbResult(h)}}}},f.prototype.parse=function(a,b,c){this.cbResult=c;var d="1"+b+"|"+a;this.sendMsg(d)},f.prototype.destroy=function(){this.cp.kill()},f.prototype.sendMsg=function(a){this.cp.stdin.write(a+h,"utf8")}}).call(this,a("_process"),"/libs/core")},{"./CSVError":3,_process:41,child_process:30}],24:[function(a,b,c){b.exports.core=a("./core"),b.exports=a("./core"),b.exports.interfaces=a("./interfaces")},{"./core":18,"./interfaces":27}],25:[function(a,b,c){b.exports=a("./main.js")},{"./main.js":26}],26:[function(a,b,c){(function(c){function d(){var a=new g,b=!1,d=c.stdout;return a.on("record_parsed",function(a){b&&d.write(",\n"),d.write(JSON.stringify(a)),b===!1&&(b=!0)}),d.write("[\n"),a.on("end_parsed",function(){d.write("\n]")}),a.on("error",function(a){console.error(a),c.exit(-1)}),a}function e(a){var b=d();b.from(a)}function f(a){var b=d();b.from(a)}var g=a("../../core/Converter.js");b.exports.convertFile=e,b.exports.convertString=f}).call(this,a("_process"))},{"../../core/Converter.js":4,_process:41}],27:[function(a,b,c){b.exports.web=a("./web"),b.exports.cli=a("./cli")},{"./cli":25,"./web":28}],28:[function(a,b,c){b.exports=a("./webServer.js")},{"./webServer.js":29}],29:[function(a,b,c){function d(a){a=a||{};var b={port:a.port||"8801",urlpath:a.urlpath||"/parseCSV"},c=e.createServer();return c.on("request",function(a,c){a.url===b.urlpath&&"POST"===a.method?a.pipe(new f({constructResult:!1})).pipe(c):c.end("Please post data to: "+b.urlpath)}),c.listen(b.port),console.log("CSV Web Server Listen On:"+b.port),console.log("POST to "+b.urlpath+" with CSV data to get parsed."),c}var e=a("http"),f=a("../../core/Converter.js");b.exports.startWebServer=d},{"../../core/Converter.js":4,http:60}],30:[function(a,b,c){},{}],31:[function(a,b,c){arguments[4][30][0].apply(c,arguments)},{dup:30}],32:[function(a,b,c){(function(b){"use strict";function d(){function a(){}try{var b=new Uint8Array(1);return b.foo=function(){return 42},b.constructor=a,42===b.foo()&&b.constructor===a&&"function"==typeof b.subarray&&0===b.subarray(1,1).byteLength}catch(c){return!1}}function e(){return f.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function f(a){return this instanceof f?(f.TYPED_ARRAY_SUPPORT||(this.length=0,this.parent=void 0),"number"==typeof a?g(this,a):"string"==typeof a?h(this,a,arguments.length>1?arguments[1]:"utf8"):i(this,a)):arguments.length>1?new f(a,arguments[1]):new f(a)}function g(a,b){if(a=p(a,0>b?0:0|q(b)),!f.TYPED_ARRAY_SUPPORT)for(var c=0;b>c;c++)a[c]=0;return a}function h(a,b,c){("string"!=typeof c||""===c)&&(c="utf8");var d=0|s(b,c);return a=p(a,d),a.write(b,c),a}function i(a,b){if(f.isBuffer(b))return j(a,b);if(Y(b))return k(a,b);if(null==b)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(b.buffer instanceof ArrayBuffer)return l(a,b);if(b instanceof ArrayBuffer)return m(a,b)}return b.length?n(a,b):o(a,b)}function j(a,b){var c=0|q(b.length);return a=p(a,c),b.copy(a,0,0,c),a}function k(a,b){var c=0|q(b.length);a=p(a,c);for(var d=0;c>d;d+=1)a[d]=255&b[d];return a}function l(a,b){var c=0|q(b.length);a=p(a,c);for(var d=0;c>d;d+=1)a[d]=255&b[d];return a}function m(a,b){return f.TYPED_ARRAY_SUPPORT?(b.byteLength,a=f._augment(new Uint8Array(b))):a=l(a,new Uint8Array(b)),a}function n(a,b){var c=0|q(b.length);a=p(a,c);for(var d=0;c>d;d+=1)a[d]=255&b[d];return a}function o(a,b){var c,d=0;"Buffer"===b.type&&Y(b.data)&&(c=b.data,d=0|q(c.length)),a=p(a,d);for(var e=0;d>e;e+=1)a[e]=255&c[e];return a}function p(a,b){f.TYPED_ARRAY_SUPPORT?(a=f._augment(new Uint8Array(b)),a.__proto__=f.prototype):(a.length=b,a._isBuffer=!0);var c=0!==b&&b<=f.poolSize>>>1;return c&&(a.parent=Z),a}function q(a){if(a>=e())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+e().toString(16)+" bytes");return 0|a}function r(a,b){if(!(this instanceof r))return new r(a,b);var c=new f(a,b);return delete c.parent,c}function s(a,b){"string"!=typeof a&&(a=""+a);var c=a.length;if(0===c)return 0;for(var d=!1;;)switch(b){case"ascii":case"binary":case"raw":case"raws":return c;case"utf8":case"utf-8":return R(a).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*c;case"hex":return c>>>1;case"base64":return U(a).length;default:if(d)return R(a).length;b=(""+b).toLowerCase(),d=!0}}function t(a,b,c){var d=!1;if(b=0|b,c=void 0===c||c===1/0?this.length:0|c,a||(a="utf8"),0>b&&(b=0),c>this.length&&(c=this.length),b>=c)return"";for(;;)switch(a){case"hex":return F(this,b,c);case"utf8":case"utf-8":return B(this,b,c);case"ascii":return D(this,b,c);case"binary":return E(this,b,c);case"base64":return A(this,b,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return G(this,b,c);default:if(d)throw new TypeError("Unknown encoding: "+a);a=(a+"").toLowerCase(),d=!0}}function u(a,b,c,d){c=Number(c)||0;var e=a.length-c;d?(d=Number(d),d>e&&(d=e)):d=e;var f=b.length;if(f%2!==0)throw new Error("Invalid hex string");d>f/2&&(d=f/2);for(var g=0;d>g;g++){var h=parseInt(b.substr(2*g,2),16);if(isNaN(h))throw new Error("Invalid hex string");a[c+g]=h}return g}function v(a,b,c,d){return V(R(b,a.length-c),a,c,d)}function w(a,b,c,d){return V(S(b),a,c,d)}function x(a,b,c,d){return w(a,b,c,d)}function y(a,b,c,d){return V(U(b),a,c,d)}function z(a,b,c,d){return V(T(b,a.length-c),a,c,d)}function A(a,b,c){return 0===b&&c===a.length?W.fromByteArray(a):W.fromByteArray(a.slice(b,c))}function B(a,b,c){c=Math.min(a.length,c);for(var d=[],e=b;c>e;){var f=a[e],g=null,h=f>239?4:f>223?3:f>191?2:1;if(c>=e+h){var i,j,k,l;switch(h){case 1:128>f&&(g=f);break;case 2:i=a[e+1],128===(192&i)&&(l=(31&f)<<6|63&i,l>127&&(g=l));break;case 3:i=a[e+1],j=a[e+2],128===(192&i)&&128===(192&j)&&(l=(15&f)<<12|(63&i)<<6|63&j,l>2047&&(55296>l||l>57343)&&(g=l));break;case 4:i=a[e+1],j=a[e+2],k=a[e+3],128===(192&i)&&128===(192&j)&&128===(192&k)&&(l=(15&f)<<18|(63&i)<<12|(63&j)<<6|63&k,l>65535&&1114112>l&&(g=l))}}null===g?(g=65533,h=1):g>65535&&(g-=65536,d.push(g>>>10&1023|55296),g=56320|1023&g),d.push(g),e+=h}return C(d)}function C(a){var b=a.length;if($>=b)return String.fromCharCode.apply(String,a);for(var c="",d=0;b>d;)c+=String.fromCharCode.apply(String,a.slice(d,d+=$));return c}function D(a,b,c){var d="";c=Math.min(a.length,c);for(var e=b;c>e;e++)d+=String.fromCharCode(127&a[e]);return d}function E(a,b,c){var d="";c=Math.min(a.length,c);for(var e=b;c>e;e++)d+=String.fromCharCode(a[e]);return d}function F(a,b,c){var d=a.length;(!b||0>b)&&(b=0),(!c||0>c||c>d)&&(c=d);for(var e="",f=b;c>f;f++)e+=Q(a[f]);return e}function G(a,b,c){for(var d=a.slice(b,c),e="",f=0;f<d.length;f+=2)e+=String.fromCharCode(d[f]+256*d[f+1]);return e}function H(a,b,c){if(a%1!==0||0>a)throw new RangeError("offset is not uint");if(a+b>c)throw new RangeError("Trying to access beyond buffer length")}function I(a,b,c,d,e,g){if(!f.isBuffer(a))throw new TypeError("buffer must be a Buffer instance");if(b>e||g>b)throw new RangeError("value is out of bounds");if(c+d>a.length)throw new RangeError("index out of range")}function J(a,b,c,d){0>b&&(b=65535+b+1);for(var e=0,f=Math.min(a.length-c,2);f>e;e++)a[c+e]=(b&255<<8*(d?e:1-e))>>>8*(d?e:1-e)}function K(a,b,c,d){0>b&&(b=4294967295+b+1);for(var e=0,f=Math.min(a.length-c,4);f>e;e++)a[c+e]=b>>>8*(d?e:3-e)&255}function L(a,b,c,d,e,f){if(b>e||f>b)throw new RangeError("value is out of bounds");if(c+d>a.length)throw new RangeError("index out of range");if(0>c)throw new RangeError("index out of range")}function M(a,b,c,d,e){return e||L(a,b,c,4,3.4028234663852886e38,-3.4028234663852886e38),X.write(a,b,c,d,23,4),c+4}function N(a,b,c,d,e){return e||L(a,b,c,8,1.7976931348623157e308,-1.7976931348623157e308),X.write(a,b,c,d,52,8),c+8}function O(a){if(a=P(a).replace(aa,""),a.length<2)return"";for(;a.length%4!==0;)a+="=";return a}function P(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}function Q(a){return 16>a?"0"+a.toString(16):a.toString(16)}function R(a,b){b=b||1/0;for(var c,d=a.length,e=null,f=[],g=0;d>g;g++){if(c=a.charCodeAt(g),c>55295&&57344>c){if(!e){if(c>56319){(b-=3)>-1&&f.push(239,191,189);continue}if(g+1===d){(b-=3)>-1&&f.push(239,191,189);continue}e=c;continue}if(56320>c){(b-=3)>-1&&f.push(239,191,189),e=c;continue}c=(e-55296<<10|c-56320)+65536}else e&&(b-=3)>-1&&f.push(239,191,189);if(e=null,128>c){if((b-=1)<0)break;f.push(c)}else if(2048>c){if((b-=2)<0)break;f.push(c>>6|192,63&c|128)}else if(65536>c){if((b-=3)<0)break;f.push(c>>12|224,c>>6&63|128,63&c|128)}else{if(!(1114112>c))throw new Error("Invalid code point");if((b-=4)<0)break;f.push(c>>18|240,c>>12&63|128,c>>6&63|128,63&c|128)}}return f}function S(a){for(var b=[],c=0;c<a.length;c++)b.push(255&a.charCodeAt(c));return b}function T(a,b){for(var c,d,e,f=[],g=0;g<a.length&&!((b-=2)<0);g++)c=a.charCodeAt(g),d=c>>8,e=c%256,f.push(e),f.push(d);return f}function U(a){return W.toByteArray(O(a))}function V(a,b,c,d){for(var e=0;d>e&&!(e+c>=b.length||e>=a.length);e++)b[e+c]=a[e];return e}var W=a("base64-js"),X=a("ieee754"),Y=a("isarray");c.Buffer=f,c.SlowBuffer=r,c.INSPECT_MAX_BYTES=50,f.poolSize=8192;var Z={};f.TYPED_ARRAY_SUPPORT=void 0!==b.TYPED_ARRAY_SUPPORT?b.TYPED_ARRAY_SUPPORT:d(),f.TYPED_ARRAY_SUPPORT?(f.prototype.__proto__=Uint8Array.prototype,f.__proto__=Uint8Array):(f.prototype.length=void 0,f.prototype.parent=void 0),f.isBuffer=function(a){return!(null==a||!a._isBuffer)},f.compare=function(a,b){if(!f.isBuffer(a)||!f.isBuffer(b))throw new TypeError("Arguments must be Buffers");if(a===b)return 0;for(var c=a.length,d=b.length,e=0,g=Math.min(c,d);g>e&&a[e]===b[e];)++e;return e!==g&&(c=a[e],d=b[e]),d>c?-1:c>d?1:0},f.isEncoding=function(a){switch(String(a).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!0;default:return!1}},f.concat=function(a,b){if(!Y(a))throw new TypeError("list argument must be an Array of Buffers.");if(0===a.length)return new f(0);var c;if(void 0===b)for(b=0,c=0;c<a.length;c++)b+=a[c].length;var d=new f(b),e=0;for(c=0;c<a.length;c++){var g=a[c];g.copy(d,e),e+=g.length}return d},f.byteLength=s,f.prototype.toString=function(){var a=0|this.length;return 0===a?"":0===arguments.length?B(this,0,a):t.apply(this,arguments)},f.prototype.equals=function(a){if(!f.isBuffer(a))throw new TypeError("Argument must be a Buffer");return this===a?!0:0===f.compare(this,a)},f.prototype.inspect=function(){var a="",b=c.INSPECT_MAX_BYTES;return this.length>0&&(a=this.toString("hex",0,b).match(/.{2}/g).join(" "),this.length>b&&(a+=" ... ")),"<Buffer "+a+">"},f.prototype.compare=function(a){if(!f.isBuffer(a))throw new TypeError("Argument must be a Buffer");return this===a?0:f.compare(this,a)},f.prototype.indexOf=function(a,b){function c(a,b,c){for(var d=-1,e=0;c+e<a.length;e++)if(a[c+e]===b[-1===d?0:e-d]){if(-1===d&&(d=e),e-d+1===b.length)return c+d}else d=-1;return-1}if(b>2147483647?b=2147483647:-2147483648>b&&(b=-2147483648),b>>=0,0===this.length)return-1;if(b>=this.length)return-1;if(0>b&&(b=Math.max(this.length+b,0)),"string"==typeof a)return 0===a.length?-1:String.prototype.indexOf.call(this,a,b);if(f.isBuffer(a))return c(this,a,b);if("number"==typeof a)return f.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,a,b):c(this,[a],b);throw new TypeError("val must be string, number or Buffer")},f.prototype.get=function(a){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(a)},f.prototype.set=function(a,b){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(a,b)},f.prototype.write=function(a,b,c,d){if(void 0===b)d="utf8",c=this.length,b=0;else if(void 0===c&&"string"==typeof b)d=b,c=this.length,b=0;else if(isFinite(b))b=0|b,isFinite(c)?(c=0|c,void 0===d&&(d="utf8")):(d=c,c=void 0);else{var e=d;d=b,b=0|c,c=e}var f=this.length-b;if((void 0===c||c>f)&&(c=f),a.length>0&&(0>c||0>b)||b>this.length)throw new RangeError("attempt to write outside buffer bounds");d||(d="utf8");for(var g=!1;;)switch(d){case"hex":return u(this,a,b,c);case"utf8":case"utf-8":return v(this,a,b,c);case"ascii":return w(this,a,b,c);case"binary":return x(this,a,b,c);case"base64":return y(this,a,b,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return z(this,a,b,c);default:if(g)throw new TypeError("Unknown encoding: "+d);
d=(""+d).toLowerCase(),g=!0}},f.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var $=4096;f.prototype.slice=function(a,b){var c=this.length;a=~~a,b=void 0===b?c:~~b,0>a?(a+=c,0>a&&(a=0)):a>c&&(a=c),0>b?(b+=c,0>b&&(b=0)):b>c&&(b=c),a>b&&(b=a);var d;if(f.TYPED_ARRAY_SUPPORT)d=f._augment(this.subarray(a,b));else{var e=b-a;d=new f(e,void 0);for(var g=0;e>g;g++)d[g]=this[g+a]}return d.length&&(d.parent=this.parent||this),d},f.prototype.readUIntLE=function(a,b,c){a=0|a,b=0|b,c||H(a,b,this.length);for(var d=this[a],e=1,f=0;++f<b&&(e*=256);)d+=this[a+f]*e;return d},f.prototype.readUIntBE=function(a,b,c){a=0|a,b=0|b,c||H(a,b,this.length);for(var d=this[a+--b],e=1;b>0&&(e*=256);)d+=this[a+--b]*e;return d},f.prototype.readUInt8=function(a,b){return b||H(a,1,this.length),this[a]},f.prototype.readUInt16LE=function(a,b){return b||H(a,2,this.length),this[a]|this[a+1]<<8},f.prototype.readUInt16BE=function(a,b){return b||H(a,2,this.length),this[a]<<8|this[a+1]},f.prototype.readUInt32LE=function(a,b){return b||H(a,4,this.length),(this[a]|this[a+1]<<8|this[a+2]<<16)+16777216*this[a+3]},f.prototype.readUInt32BE=function(a,b){return b||H(a,4,this.length),16777216*this[a]+(this[a+1]<<16|this[a+2]<<8|this[a+3])},f.prototype.readIntLE=function(a,b,c){a=0|a,b=0|b,c||H(a,b,this.length);for(var d=this[a],e=1,f=0;++f<b&&(e*=256);)d+=this[a+f]*e;return e*=128,d>=e&&(d-=Math.pow(2,8*b)),d},f.prototype.readIntBE=function(a,b,c){a=0|a,b=0|b,c||H(a,b,this.length);for(var d=b,e=1,f=this[a+--d];d>0&&(e*=256);)f+=this[a+--d]*e;return e*=128,f>=e&&(f-=Math.pow(2,8*b)),f},f.prototype.readInt8=function(a,b){return b||H(a,1,this.length),128&this[a]?-1*(255-this[a]+1):this[a]},f.prototype.readInt16LE=function(a,b){b||H(a,2,this.length);var c=this[a]|this[a+1]<<8;return 32768&c?4294901760|c:c},f.prototype.readInt16BE=function(a,b){b||H(a,2,this.length);var c=this[a+1]|this[a]<<8;return 32768&c?4294901760|c:c},f.prototype.readInt32LE=function(a,b){return b||H(a,4,this.length),this[a]|this[a+1]<<8|this[a+2]<<16|this[a+3]<<24},f.prototype.readInt32BE=function(a,b){return b||H(a,4,this.length),this[a]<<24|this[a+1]<<16|this[a+2]<<8|this[a+3]},f.prototype.readFloatLE=function(a,b){return b||H(a,4,this.length),X.read(this,a,!0,23,4)},f.prototype.readFloatBE=function(a,b){return b||H(a,4,this.length),X.read(this,a,!1,23,4)},f.prototype.readDoubleLE=function(a,b){return b||H(a,8,this.length),X.read(this,a,!0,52,8)},f.prototype.readDoubleBE=function(a,b){return b||H(a,8,this.length),X.read(this,a,!1,52,8)},f.prototype.writeUIntLE=function(a,b,c,d){a=+a,b=0|b,c=0|c,d||I(this,a,b,c,Math.pow(2,8*c),0);var e=1,f=0;for(this[b]=255&a;++f<c&&(e*=256);)this[b+f]=a/e&255;return b+c},f.prototype.writeUIntBE=function(a,b,c,d){a=+a,b=0|b,c=0|c,d||I(this,a,b,c,Math.pow(2,8*c),0);var e=c-1,f=1;for(this[b+e]=255&a;--e>=0&&(f*=256);)this[b+e]=a/f&255;return b+c},f.prototype.writeUInt8=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,1,255,0),f.TYPED_ARRAY_SUPPORT||(a=Math.floor(a)),this[b]=255&a,b+1},f.prototype.writeUInt16LE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[b]=255&a,this[b+1]=a>>>8):J(this,a,b,!0),b+2},f.prototype.writeUInt16BE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[b]=a>>>8,this[b+1]=255&a):J(this,a,b,!1),b+2},f.prototype.writeUInt32LE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[b+3]=a>>>24,this[b+2]=a>>>16,this[b+1]=a>>>8,this[b]=255&a):K(this,a,b,!0),b+4},f.prototype.writeUInt32BE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[b]=a>>>24,this[b+1]=a>>>16,this[b+2]=a>>>8,this[b+3]=255&a):K(this,a,b,!1),b+4},f.prototype.writeIntLE=function(a,b,c,d){if(a=+a,b=0|b,!d){var e=Math.pow(2,8*c-1);I(this,a,b,c,e-1,-e)}var f=0,g=1,h=0>a?1:0;for(this[b]=255&a;++f<c&&(g*=256);)this[b+f]=(a/g>>0)-h&255;return b+c},f.prototype.writeIntBE=function(a,b,c,d){if(a=+a,b=0|b,!d){var e=Math.pow(2,8*c-1);I(this,a,b,c,e-1,-e)}var f=c-1,g=1,h=0>a?1:0;for(this[b+f]=255&a;--f>=0&&(g*=256);)this[b+f]=(a/g>>0)-h&255;return b+c},f.prototype.writeInt8=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,1,127,-128),f.TYPED_ARRAY_SUPPORT||(a=Math.floor(a)),0>a&&(a=255+a+1),this[b]=255&a,b+1},f.prototype.writeInt16LE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[b]=255&a,this[b+1]=a>>>8):J(this,a,b,!0),b+2},f.prototype.writeInt16BE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[b]=a>>>8,this[b+1]=255&a):J(this,a,b,!1),b+2},f.prototype.writeInt32LE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,4,2147483647,-2147483648),f.TYPED_ARRAY_SUPPORT?(this[b]=255&a,this[b+1]=a>>>8,this[b+2]=a>>>16,this[b+3]=a>>>24):K(this,a,b,!0),b+4},f.prototype.writeInt32BE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,4,2147483647,-2147483648),0>a&&(a=4294967295+a+1),f.TYPED_ARRAY_SUPPORT?(this[b]=a>>>24,this[b+1]=a>>>16,this[b+2]=a>>>8,this[b+3]=255&a):K(this,a,b,!1),b+4},f.prototype.writeFloatLE=function(a,b,c){return M(this,a,b,!0,c)},f.prototype.writeFloatBE=function(a,b,c){return M(this,a,b,!1,c)},f.prototype.writeDoubleLE=function(a,b,c){return N(this,a,b,!0,c)},f.prototype.writeDoubleBE=function(a,b,c){return N(this,a,b,!1,c)},f.prototype.copy=function(a,b,c,d){if(c||(c=0),d||0===d||(d=this.length),b>=a.length&&(b=a.length),b||(b=0),d>0&&c>d&&(d=c),d===c)return 0;if(0===a.length||0===this.length)return 0;if(0>b)throw new RangeError("targetStart out of bounds");if(0>c||c>=this.length)throw new RangeError("sourceStart out of bounds");if(0>d)throw new RangeError("sourceEnd out of bounds");d>this.length&&(d=this.length),a.length-b<d-c&&(d=a.length-b+c);var e,g=d-c;if(this===a&&b>c&&d>b)for(e=g-1;e>=0;e--)a[e+b]=this[e+c];else if(1e3>g||!f.TYPED_ARRAY_SUPPORT)for(e=0;g>e;e++)a[e+b]=this[e+c];else a._set(this.subarray(c,c+g),b);return g},f.prototype.fill=function(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),b>c)throw new RangeError("end < start");if(c!==b&&0!==this.length){if(0>b||b>=this.length)throw new RangeError("start out of bounds");if(0>c||c>this.length)throw new RangeError("end out of bounds");var d;if("number"==typeof a)for(d=b;c>d;d++)this[d]=a;else{var e=R(a.toString()),f=e.length;for(d=b;c>d;d++)this[d]=e[d%f]}return this}},f.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(f.TYPED_ARRAY_SUPPORT)return new f(this).buffer;for(var a=new Uint8Array(this.length),b=0,c=a.length;c>b;b+=1)a[b]=this[b];return a.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var _=f.prototype;f._augment=function(a){return a.constructor=f,a._isBuffer=!0,a._set=a.set,a.get=_.get,a.set=_.set,a.write=_.write,a.toString=_.toString,a.toLocaleString=_.toString,a.toJSON=_.toJSON,a.equals=_.equals,a.compare=_.compare,a.indexOf=_.indexOf,a.copy=_.copy,a.slice=_.slice,a.readUIntLE=_.readUIntLE,a.readUIntBE=_.readUIntBE,a.readUInt8=_.readUInt8,a.readUInt16LE=_.readUInt16LE,a.readUInt16BE=_.readUInt16BE,a.readUInt32LE=_.readUInt32LE,a.readUInt32BE=_.readUInt32BE,a.readIntLE=_.readIntLE,a.readIntBE=_.readIntBE,a.readInt8=_.readInt8,a.readInt16LE=_.readInt16LE,a.readInt16BE=_.readInt16BE,a.readInt32LE=_.readInt32LE,a.readInt32BE=_.readInt32BE,a.readFloatLE=_.readFloatLE,a.readFloatBE=_.readFloatBE,a.readDoubleLE=_.readDoubleLE,a.readDoubleBE=_.readDoubleBE,a.writeUInt8=_.writeUInt8,a.writeUIntLE=_.writeUIntLE,a.writeUIntBE=_.writeUIntBE,a.writeUInt16LE=_.writeUInt16LE,a.writeUInt16BE=_.writeUInt16BE,a.writeUInt32LE=_.writeUInt32LE,a.writeUInt32BE=_.writeUInt32BE,a.writeIntLE=_.writeIntLE,a.writeIntBE=_.writeIntBE,a.writeInt8=_.writeInt8,a.writeInt16LE=_.writeInt16LE,a.writeInt16BE=_.writeInt16BE,a.writeInt32LE=_.writeInt32LE,a.writeInt32BE=_.writeInt32BE,a.writeFloatLE=_.writeFloatLE,a.writeFloatBE=_.writeFloatBE,a.writeDoubleLE=_.writeDoubleLE,a.writeDoubleBE=_.writeDoubleBE,a.fill=_.fill,a.inspect=_.inspect,a.toArrayBuffer=_.toArrayBuffer,a};var aa=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":33,ieee754:34,isarray:35}],33:[function(a,b,c){var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(a){"use strict";function b(a){var b=a.charCodeAt(0);return b===g||b===l?62:b===h||b===m?63:i>b?-1:i+10>b?b-i+26+26:k+26>b?b-k:j+26>b?b-j+26:void 0}function c(a){function c(a){j[l++]=a}var d,e,g,h,i,j;if(a.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var k=a.length;i="="===a.charAt(k-2)?2:"="===a.charAt(k-1)?1:0,j=new f(3*a.length/4-i),g=i>0?a.length-4:a.length;var l=0;for(d=0,e=0;g>d;d+=4,e+=3)h=b(a.charAt(d))<<18|b(a.charAt(d+1))<<12|b(a.charAt(d+2))<<6|b(a.charAt(d+3)),c((16711680&h)>>16),c((65280&h)>>8),c(255&h);return 2===i?(h=b(a.charAt(d))<<2|b(a.charAt(d+1))>>4,c(255&h)):1===i&&(h=b(a.charAt(d))<<10|b(a.charAt(d+1))<<4|b(a.charAt(d+2))>>2,c(h>>8&255),c(255&h)),j}function e(a){function b(a){return d.charAt(a)}function c(a){return b(a>>18&63)+b(a>>12&63)+b(a>>6&63)+b(63&a)}var e,f,g,h=a.length%3,i="";for(e=0,g=a.length-h;g>e;e+=3)f=(a[e]<<16)+(a[e+1]<<8)+a[e+2],i+=c(f);switch(h){case 1:f=a[a.length-1],i+=b(f>>2),i+=b(f<<4&63),i+="==";break;case 2:f=(a[a.length-2]<<8)+a[a.length-1],i+=b(f>>10),i+=b(f>>4&63),i+=b(f<<2&63),i+="="}return i}var f="undefined"!=typeof Uint8Array?Uint8Array:Array,g="+".charCodeAt(0),h="/".charCodeAt(0),i="0".charCodeAt(0),j="a".charCodeAt(0),k="A".charCodeAt(0),l="-".charCodeAt(0),m="_".charCodeAt(0);a.toByteArray=c,a.fromByteArray=e}("undefined"==typeof c?this.base64js={}:c)},{}],34:[function(a,b,c){c.read=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<<h)-1,j=i>>1,k=-7,l=c?e-1:0,m=c?-1:1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?NaN:(n?-1:1)*(1/0);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.write=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<<j)-1,l=k>>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?0:f-1,o=d?1:-1,p=0>b||0===b&&0>1/b?1:0;for(b=Math.abs(b),isNaN(b)||b===1/0?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<<e|h,j+=e;j>0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],35:[function(a,b,c){var d={}.toString;b.exports=Array.isArray||function(a){return"[object Array]"==d.call(a)}},{}],36:[function(a,b,c){function d(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function e(a){return"function"==typeof a}function f(a){return"number"==typeof a}function g(a){return"object"==typeof a&&null!==a}function h(a){return void 0===a}b.exports=d,d.EventEmitter=d,d.prototype._events=void 0,d.prototype._maxListeners=void 0,d.defaultMaxListeners=10,d.prototype.setMaxListeners=function(a){if(!f(a)||0>a||isNaN(a))throw TypeError("n must be a positive number");return this._maxListeners=a,this},d.prototype.emit=function(a){var b,c,d,f,i,j;if(this._events||(this._events={}),"error"===a&&(!this._events.error||g(this._events.error)&&!this._events.error.length)){if(b=arguments[1],b instanceof Error)throw b;throw TypeError('Uncaught, unspecified "error" event.')}if(c=this._events[a],h(c))return!1;if(e(c))switch(arguments.length){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(d=arguments.length,f=new Array(d-1),i=1;d>i;i++)f[i-1]=arguments[i];c.apply(this,f)}else if(g(c)){for(d=arguments.length,f=new Array(d-1),i=1;d>i;i++)f[i-1]=arguments[i];for(j=c.slice(),d=j.length,i=0;d>i;i++)j[i].apply(this,f)}return!0},d.prototype.addListener=function(a,b){var c;if(!e(b))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",a,e(b.listener)?b.listener:b),this._events[a]?g(this._events[a])?this._events[a].push(b):this._events[a]=[this._events[a],b]:this._events[a]=b,g(this._events[a])&&!this._events[a].warned){var c;c=h(this._maxListeners)?d.defaultMaxListeners:this._maxListeners,c&&c>0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),"function"==typeof console.trace&&console.trace())}return this},d.prototype.on=d.prototype.addListener,d.prototype.once=function(a,b){function c(){this.removeListener(a,c),d||(d=!0,b.apply(this,arguments))}if(!e(b))throw TypeError("listener must be a function");var d=!1;return c.listener=b,this.on(a,c),this},d.prototype.removeListener=function(a,b){var c,d,f,h;if(!e(b))throw TypeError("listener must be a function");if(!this._events||!this._events[a])return this;if(c=this._events[a],f=c.length,d=-1,c===b||e(c.listener)&&c.listener===b)delete this._events[a],this._events.removeListener&&this.emit("removeListener",a,b);else if(g(c)){for(h=f;h-- >0;)if(c[h]===b||c[h].listener&&c[h].listener===b){d=h;break}if(0>d)return this;1===c.length?(c.length=0,delete this._events[a]):c.splice(d,1),this._events.removeListener&&this.emit("removeListener",a,b)}return this},d.prototype.removeAllListeners=function(a){var b,c;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[a]&&delete this._events[a],this;if(0===arguments.length){for(b in this._events)"removeListener"!==b&&this.removeAllListeners(b);return this.removeAllListeners("removeListener"),this._events={},this}if(c=this._events[a],e(c))this.removeListener(a,c);else for(;c.length;)this.removeListener(a,c[c.length-1]);return delete this._events[a],this},d.prototype.listeners=function(a){var b;return b=this._events&&this._events[a]?e(this._events[a])?[this._events[a]]:this._events[a].slice():[]},d.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?e(a._events[b])?1:a._events[b].length:0}},{}],37:[function(a,b,c){"function"==typeof Object.create?b.exports=function(a,b){a.super_=b,a.prototype=Object.create(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})}:b.exports=function(a,b){a.super_=b;var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a}},{}],38:[function(a,b,c){b.exports=function(a){return!(null==a||!(a._isBuffer||a.constructor&&"function"==typeof a.constructor.isBuffer&&a.constructor.isBuffer(a)))}},{}],39:[function(a,b,c){b.exports=Array.isArray||function(a){return"[object Array]"==Object.prototype.toString.call(a)}},{}],40:[function(a,b,c){c.endianness=function(){return"LE"},c.hostname=function(){return"undefined"!=typeof location?location.hostname:""},c.loadavg=function(){return[]},c.uptime=function(){return 0},c.freemem=function(){return Number.MAX_VALUE},c.totalmem=function(){return Number.MAX_VALUE},c.cpus=function(){return[]},c.type=function(){return"Browser"},c.release=function(){return"undefined"!=typeof navigator?navigator.appVersion:""},c.networkInterfaces=c.getNetworkInterfaces=function(){return{}},c.arch=function(){return"javascript"},c.platform=function(){return"browser"},c.tmpdir=c.tmpDir=function(){return"/tmp"},c.EOL="\n"},{}],41:[function(a,b,c){function d(){k=!1,h.length?j=h.concat(j):l=-1,j.length&&e()}function e(){if(!k){var a=setTimeout(d);k=!0;for(var b=j.length;b;){for(h=j,j=[];++l<b;)h&&h[l].run();l=-1,b=j.length}h=null,k=!1,clearTimeout(a)}}function f(a,b){this.fun=a,this.array=b}function g(){}var h,i=b.exports={},j=[],k=!1,l=-1;i.nextTick=function(a){var b=new Array(arguments.length-1);if(arguments.length>1)for(var c=1;c<arguments.length;c++)b[c-1]=arguments[c];j.push(new f(a,b)),1!==j.length||k||setTimeout(e,0)},f.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=g,i.addListener=g,i.once=g,i.off=g,i.removeListener=g,i.removeAllListeners=g,i.emit=g,i.binding=function(a){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(a){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},{}],42:[function(a,b,c){(function(a){!function(d){function e(a){throw new RangeError(H[a])}function f(a,b){for(var c=a.length,d=[];c--;)d[c]=b(a[c]);return d}function g(a,b){var c=a.split("@"),d="";c.length>1&&(d=c[0]+"@",a=c[1]),a=a.replace(G,".");var e=a.split("."),g=f(e,b).join(".");return d+g}function h(a){for(var b,c,d=[],e=0,f=a.length;f>e;)b=a.charCodeAt(e++),b>=55296&&56319>=b&&f>e?(c=a.charCodeAt(e++),56320==(64512&c)?d.push(((1023&b)<<10)+(1023&c)+65536):(d.push(b),e--)):d.push(b);return d}function i(a){return f(a,function(a){var b="";return a>65535&&(a-=65536,b+=K(a>>>10&1023|55296),a=56320|1023&a),b+=K(a)}).join("")}function j(a){return 10>a-48?a-22:26>a-65?a-65:26>a-97?a-97:w}function k(a,b){return a+22+75*(26>a)-((0!=b)<<5)}function l(a,b,c){var d=0;for(a=c?J(a/A):a>>1,a+=J(a/b);a>I*y>>1;d+=w)a=J(a/I);return J(d+(I+1)*a/(a+z))}function m(a){var b,c,d,f,g,h,k,m,n,o,p=[],q=a.length,r=0,s=C,t=B;for(c=a.lastIndexOf(D),0>c&&(c=0),d=0;c>d;++d)a.charCodeAt(d)>=128&&e("not-basic"),p.push(a.charCodeAt(d));for(f=c>0?c+1:0;q>f;){for(g=r,h=1,k=w;f>=q&&e("invalid-input"),m=j(a.charCodeAt(f++)),(m>=w||m>J((v-r)/h))&&e("overflow"),r+=m*h,n=t>=k?x:k>=t+y?y:k-t,!(n>m);k+=w)o=w-n,h>J(v/o)&&e("overflow"),h*=o;b=p.length+1,t=l(r-g,b,0==g),J(r/b)>v-s&&e("overflow"),s+=J(r/b),r%=b,p.splice(r++,0,s)}return i(p)}function n(a){var b,c,d,f,g,i,j,m,n,o,p,q,r,s,t,u=[];for(a=h(a),q=a.length,b=C,c=0,g=B,i=0;q>i;++i)p=a[i],128>p&&u.push(K(p));for(d=f=u.length,f&&u.push(D);q>d;){for(j=v,i=0;q>i;++i)p=a[i],p>=b&&j>p&