text: (function(){"use strict";var e=function(e){return!!(e&&e!==null)},t=/^(\-|\+)?([0-9]+(\.[0-9]+)?|Infinity)$/,n=function(e){e=e.toLowerCase();return e==="true"||e==="false"};var i=function(e,i,o){var r="return ",s=function(e,i){if(t.test(e)){return"Number(values["+i+"]),"}else if(n(e)){return"Boolean(values["+i+"].toLowerCase() === 'true'),"}else{return"values["+i+"],"}},l;if(e==="object"){r+="{";for(l=0;l<i.length;++l){r+='"'+i[l]+'": '+s(o[l],l)}r=r.slice(0,-1)+"}"}else{r+="[";for(l=0;l<i.length;++l){r+=s(i[l],l)}r=r.slice(0,-1)+"]"}return new Function("values",r)};var CSV=function(t,n){n=e(n)?n:{};this.options={line:e(n.line)?n.line:"\r\n",delimiter:e(n.delimiter)?n.delimiter:",",header:e(n.header)?n.header:false,done:e(n.done)?n.done:undefined};this.action=t instanceof Array?"encode":"parse";this.data=t;var i=this.options.line,o=i.length-1,r=t.length-1,s=function(e,t){return e.charCodeAt(t)};if(this.action==="parse"&&s(t,r)!==s(i,o)){this.data+=i}return this};CSV.prototype.set=function(e,t){this.options[e]=t;return this};CSV.prototype.encode=function(e){if(this.data.length===0)return"";var n=this.data,i=[],o=this.options.delimiter,r=n[0]instanceof Array?"array":"object",s=this.options.header,l=this.options.done,a=function(e){return t.test(e)?e:'"'+e.replace(/\"/g,'""')+'"'},c=e?function(t){e(t.join(o))}:function(e){i.push(e.join(o))},f=n.length,u,h,d,p,g,w;if(r==="object"){d=Object.keys(n[0]);p=d.length}else{p=n[0].length}w=new Array(p);if(s){var y=s instanceof Array?s:d;for(h=0;h<p;++h){w[h]=a(y[h])}c(w)}if(r==="object"){for(u=0;u<f;++u){g=n[u];for(h=0;h<p;++h){w[h]=a(g[d[h]])}c(w)}}else{for(u=0;u<f;++u){g=n[u];for(h=0;h<p;++h){w[h]=a(g[h])}c(w)}}i=i.join(this.options.line);if(l)l(i);return i};CSV.prototype.parse=function(e){if(this.data.trim().length===0)return[];var t=this.data,n=[],o=this.options.done,r=this.options.header,s=r instanceof Array?r:[],l=this.options.line,a=s.length,c={row:[],cell:""},f={escaped:false,quote:false,cell:true},u,h=function(e){c.row.push((f.escaped?e.slice(1,-1).replace(/""/g,'"'):e).trim());c.cell="";f={escaped:false,quote:false,cell:true}},d=l.length===1?h:function(e){h(e.slice(0,1-l.length))},p=e?function(){e(new u(c.row))}:function(){n.push(new u(c.row))},g=function(){if(r){if(a){u=new i("object",s,c.row);p();g=p}else{s=c.row,a=s.length}}else{if(!u)u=new i("array",c.row);p();g=p}},w,y,m=t.length,v=l.charCodeAt(l.length-1),j=this.options.delimiter.charCodeAt(0),A;for(w=0,y=0;y<=m;++y){A=t.charCodeAt(y);if(f.cell){f.cell=false;if(A===34){f.escaped=true;continue}}if(f.escaped&&A===34){f.quote=!f.quote;continue}if(f.escaped&&f.quote||!f.escaped){if(A===j){h(c.cell+t.slice(w,y));w=y+1}else if(A===v){d(c.cell+t.slice(w,y));w=y+1;g();c.row=[]}}}if(o)o(n);return n};CSV.prototype.forEach=function(e){return this[this.action](e)};if(typeof define==="function"&&define.amd){define(CSV)}else if(typeof module==="object"&&module.exports){module.exports=CSV}else{this.CSV=CSV}}).call(this);