PageSourceSearch

https://www.hamaspik.com/hubfs/hub_generated/template_assets/1/469…/1791496906687/template_csv2json.min.js

js hamaspik.com collected 2026-10-09 22:39:30 UTC 11,208 bytes, 2 lines download raw bytes

1(function(){var separators=[",",";","\t"],pegjsSeparatorNames={",":"comma",";":"semicolon","\t":"tab"};function zip(){var args=[].slice.call(arguments);return args.reduce(function(a,b){return a.length>b.length?a:b},[]).map(function(_,i){return args.map(function(array){return array[i]})})}function convert(csv,options){if(options||(options={}),0==csv.length)throw"Empty CSV. Please provide something.";var separator=options.separator||function(csv){var sepMax,counts={};return separators.forEach(function(sep,i){var re=new RegExp(sep,"g");counts[sep]=(csv.match(re)||[]).length,sepMax=!sepMax||counts[sep]>counts[sepMax]?sep:sepMax}),sepMax}(csv);if(!separator)throw"We could not detect the separator.";var a=[];try{a=csvParser.parse(csv,pegjsSeparatorNames[separator])}catch(error){var start=csv.lastIndexOf("\n",error.offset),end=csv.indexOf("\n",error.offset),line=csv.substring(start>=-1?start:0,end>-1?end:csv.length);throw error.message+" On line "+error.line+" and column "+error.column+".\n"+line}options.transpose&&(a=zip.apply(this,a));var keys=a.shift();if(0==keys.length)throw"Could not detect header. Ensure first row contains your column headers.";keys=function(keys){for(var counts={},i=0;i<keys.length;i++)void 0===counts[key=keys[i]]?counts[key]=0:counts[key]++;var result=[];for(i=keys.length-1;i>=0;i--){var key;counts[key=keys[i]]>0&&(key=key+"__"+counts[key]--),result.unshift(key)}return result}(keys=keys.map(function(key){return key.trim().replace(/(^")|("$)/g,"")}));for(var json=options.hash?{}:[],l=0;l<a.length;l++){for(var hashKey,row={},i=0;i<keys.length;i++){var value=(a[l][i]||"").trim().replace(/(^")|("$)/g,""),number=""===value?NaN:value-0;if(options.hash&&0==i)hashKey=value;else if(options.parseJSON||options.parseNumbers&&!isNaN(number))try{row[keys[i]]=JSON.parse(value)}catch(error){row[keys[i]]=value}else row[keys[i]]=value}options.hash?json[hashKey]=row:json.push(row)}return json}var csvParser=function(){function quote(s){return'"'+s.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g,escape)+'"'}var result={parse:function(input,startRule){var parseFunctions={comma:function(){var result0,result1,pos0,pos1;pos0=pos,pos1=pos,null!==(result0=function(){return separator=","}()?"":null)&&null!==(result1=parse_sv())?result0=[result0,result1]:(result0=null,pos=pos1);null!==result0&&(result0=result0[1]);null===result0&&(pos=pos0);return result0},semicolon:function(){var result0,result1,pos0,pos1;pos0=pos,pos1=pos,null!==(result0=function(){return separator=";"}()?"":null)&&null!==(result1=parse_sv())?result0=[result0,result1]:(result0=null,pos=pos1);null!==result0&&(result0=result0[1]);null===result0&&(pos=pos0);return result0},tab:function(){var result0,result1,pos0,pos1;pos0=pos,pos1=pos,null!==(result0=function(){return separator="\t"}()?"":null)&&null!==(result1=parse_sv())?result0=[result0,result1]:(result0=null,pos=pos1);null!==result0&&(result0=result0[1]);null===result0&&(pos=pos0);return result0},sv:parse_sv,line:parse_line,field:parse_field,char:parse_char};if(void 0!==startRule){if(void 0===parseFunctions[startRule])throw new Error("Invalid rule name: "+quote(startRule)+".")}else startRule="comma";var pos=0,reportFailures=0,rightmostFailuresPos=0,rightmostFailuresExpected=[];function matchFailed(failure){pos<rightmostFailuresPos||(pos>rightmostFailuresPos&&(rightmostFailuresPos=pos,rightmostFailuresExpected=[]),rightmostFailuresExpected.push(failure))}function parse_sv(){var result0,result1,result2,result3,result4,pos0,pos1,pos2,pos3,first,rest;for(pos0=pos,pos1=pos,result0=[],/^[\n\r]/.test(input.charAt(pos))?(result1=input.charAt(pos),pos++):(result1=null,0===reportFailures&&matchFailed("[\\n\\r]"));null!==result1;)result0.push(result1),/^[\n\r]/.test(input.charAt(pos))?(result1=input.charAt(pos),pos++):(result1=null,0===reportFailures&&matchFailed("[\\n\\r]"));if(null!==result0)if(null!==(result1=parse_line())){if(result2=[],pos2=pos,pos3=pos,/^[\n\r]/.test(input.charAt(pos))?(result4=input.charAt(pos),pos++):(result4=null,0===reportFailures&&matchFailed("[\\n\\r]")),null!==result4)for(result3=[];null!==result4;)result3.push(result4),/^[\n\r]/.test(input.charAt(pos))?(result4=input.charAt(pos),pos++):(result4=null,0===reportFailures&&matchFailed("[\\n\\r]"));else result3=null;for(null!==result3&&null!==(result4=parse_line())?result3=[result3,result4]:(result3=null,pos=pos3),null!==result3&&(result3=result3[1]),null===result3&&(pos=pos2);null!==result3;){if(result2.push(result3),pos2=pos,pos3=pos,/^[\n\r]/.test(input.charAt(pos))?(result4=input.charAt(pos),pos++):(result4=null,0===reportFailures&&matchFailed("[\\n\\r]")),null!==result4)for(result3=[];null!==result4;)result3.push(result4),/^[\n\r]/.test(input.charAt(pos))?(result4=input.charAt(pos),pos++):(result4=null,0===reportFailures&&matchFailed("[\\n\\r]"));else result3=null;null!==result3&&null!==(result4=parse_line())?result3=[result3,result4]:(result3=null,pos=pos3),null!==result3&&(result3=function(offset,data){return data}(0,result3[1])),null===result3&&(pos=pos2)}if(null!==result2){for(result3=[],/^[\n\r]/.test(input.charAt(pos))?(result4=input.charAt(pos),pos++):(result4=null,0===reportFailures&&matchFailed("[\\n\\r]"));null!==result4;)result3.push(result4),/^[\n\r]/.test(input.charAt(pos))?(result4=input.charAt(pos),pos++):(result4=null,0===reportFailures&&matchFailed("[\\n\\r]"));null!==result3?result0=[result0,result1,result2,result3]:(result0=null,pos=pos1)}else result0=null,pos=pos1}else result0=null,pos=pos1;else result0=null,pos=pos1;return null!==result0&&(first=result0[1],(rest=result0[2]).unshift(first),result0=rest),null===result0&&(pos=pos0),result0}function parse_line(){var result0,result1,result2,result3,result4,pos0,pos1,pos2,pos3,rest;if(pos0=pos,pos1=pos,null!==(result0=parse_field())){for(result1=[],pos2=pos,pos3=pos,input.length>pos?(result2=input.charAt(pos),pos++):(result2=null,0===reportFailures&&matchFailed("any character")),null!==result2&&null!==(result3=result2==separator?"":null)&&null!==(result4=parse_field())?result2=[result2,result3,result4]:(result2=null,pos=pos3),null!==result2&&(result2[0],result2=result2[2]),null===result2&&(pos=pos2);null!==result2;)result1.push(result2),pos2=pos,pos3=pos,input.length>pos?(result2=input.charAt(pos),pos++):(result2=null,0===reportFailures&&matchFailed("any character")),null!==result2?(result3=function(offset,char){return char==separator}(0,result2)?"":null,null!==result3&&null!==(result4=parse_field())?result2=[result2,result3,result4]:(result2=null,pos=pos3)):(result2=null,pos=pos3),null!==result2&&(result2=function(offset,char,text){return text}(0,result2[0],result2[2])),null===result2&&(pos=pos2);null!==result1?(rest=result1,null!==(result2=result0||rest.length?"":null)?result0=[result0,result1,result2]:(result0=null,pos=pos1)):(result0=null,pos=pos1)}else result0=null,pos=pos1;return null!==result0&&(result0=function(offset,first,rest){return rest.unshift(first),rest}(0,result0[0],result0[1])),null===result0&&(pos=pos0),result0}function parse_field(){var result0,result1,result2,pos0,pos1,pos2;if(pos0=pos,pos1=pos,34===input.charCodeAt(pos)?(result0='"',pos++):(result0=null,0===reportFailures&&matchFailed('"\\""')),null!==result0){for(result1=[],result2=parse_char();null!==result2;)result1.push(result2),result2=parse_char();null!==result1?(34===input.charCodeAt(pos)?(result2='"',pos++):(result2=null,0===reportFailures&&matchFailed('"\\""')),null!==result2?result0=[result0,result1,result2]:(result0=null,pos=pos1)):(result0=null,pos=pos1)}else result0=null,pos=pos1;if(null!==result0&&(result0=result0[1].join("")),null===result0&&(pos=pos0),null===result0){for(pos0=pos,result0=[],pos1=pos,pos2=pos,/^[^\n\r]/.test(input.charAt(pos))?(result1=input.charAt(pos),pos++):(result1=null,0===reportFailures&&matchFailed("[^\\n\\r]")),null!==result1&&null!==(result2=result1!=separator?"":null)?result1=[result1,result2]:(result1=null,pos=pos2),null!==result1&&(result1=function(offset,char){return char}(0,result1[0])),null===result1&&(pos=pos1);null!==result1;)result0.push(result1),pos1=pos,pos2=pos,/^[^\n\r]/.test(input.charAt(pos))?(result1=input.charAt(pos),pos++):(result1=null,0===reportFailures&&matchFailed("[^\\n\\r]")),null!==result1?(result2=function(offset,char){return char!=separator}(0,result1)?"":null,null!==result2?result1=[result1,result2]:(result1=null,pos=pos2)):(result1=null,pos=pos2),null!==result1&&(result1=function(offset,char){return char}(0,result1[0])),null===result1&&(pos=pos1);null!==result0&&(result0=function(offset,text){return text.join("")}(0,result0)),null===result0&&(pos=pos0)}return result0}function parse_char(){var result0,result1,pos0,pos1;return pos0=pos,pos1=pos,34===input.charCodeAt(pos)?(result0='"',pos++):(result0=null,0===reportFailures&&matchFailed('"\\""')),null!==result0?(34===input.charCodeAt(pos)?(result1='"',pos++):(result1=null,0===reportFailures&&matchFailed('"\\""')),null!==result1?result0=[result0,result1]:(result0=null,pos=pos1)):(result0=null,pos=pos1),null!==result0&&(result0='"'),null===result0&&(pos=pos0),null===result0&&(/^[^"]/.test(input.charAt(pos))?(result0=input.charAt(pos),pos++):(result0=null,0===reportFailures&&matchFailed('[^"]'))),result0}var separator=",",result=parseFunctions[startRule]();if(null===result||pos!==input.length){var offset=Math.max(pos,rightmostFailuresPos),found=offset<input.length?
1input.charAt(offset):null,errorPosition=function(){for(var line=1,column=1,seenCR=!1,i=0;i<Math.max(pos,rightmostFailuresPos);i++){var ch=input.charAt(i);"\n"===ch?(seenCR||line++,column=1,seenCR=!1):"\r"===ch||"\u2028"===ch||"\u2029"===ch?(line++,column=1,seenCR=!0):(column++,seenCR=!1)}return{line:line,column:column}}();throw new this.SyntaxError(function(expected){expected.sort();for(var lastExpected=null,cleanExpected=[],i=0;i<expected.length;i++)expected[i]!==lastExpected&&(cleanExpected.push(expected[i]),lastExpected=expected[i]);return cleanExpected}(rightmostFailuresExpected),found,offset,errorPosition.line,errorPosition.column)}return result},toSource:function(){return this._source},SyntaxError:function(expected,found,offset,line,column){this.name="SyntaxError",this.expected=expected,this.found=found,this.message=function(expected,found){var expectedHumanized;switch(expected.length){case 0:expectedHumanized="end of input";break;case 1:expectedHumanized=expected[0];break;default:expectedHumanized=expected.slice(0,expected.length-1).join(", ")+" or "+expected[expected.length-1]}return"Expected "+expectedHumanized+" but "+(found?quote(found):"end of input")+" found."}(expected,found),this.offset=offset,this.line=line,this.column=column}};return result.SyntaxError.prototype=Error.prototype,result}();"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=convert),exports.csv2json=convert):(this.CSVJSON||(this.CSVJSON={}),this.CSVJSON.csv2json=convert)}).call(this);
2//# sourceURL=https://8392017.fs1.hubspotusercontent-na1.net/hubfs/8392017/hub_generated/template_assets/1/46945870347/1791496906687/template_csv2json.js

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.