-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJSONSlick.min.js
More file actions
2 lines (2 loc) · 3.24 KB
/
JSONSlick.min.js
File metadata and controls
2 lines (2 loc) · 3.24 KB
1
2
/* Copyright 2020 by Jon Michael Galindo | Use of this source code is governed by a MIT-style license that can be found in the license file or at https://opensource.org/licenses/MIT. */
const JSONSlick=(()=>{const a1=(a2)=>{let [a3,a4=" ",a5=1,]=a2.data;if(a2.data.length===0){self.postMessage({result: `Error calling formatJSON(json:string,tab:unset|string,codesLineLength:unset|(int>0))\njson:string was of type <unset> but was expected to be of type <string>.`,error: "Type Error"});return}if(typeof a3 !== "string"){self.postMessage({result:`Error calling formatJSON(json:string,tab:unset|string,codesLineLength:unset|(int>0))\njson:string was of type <${typeof a3}> but was expected to be of type <string>.`,error: "Type Error"});return}if(a2.data.length>=2&&typeof a4!=="string"){self.postMessage({result:`Error calling formatJSON(json:string,tab:unset|string,codesLineLength:unset|(int>0))\ntab:unset|string was of type <${typeof a4}> but was expected to be of type <unset> or of type <string>.`,error: "Type Error"});return}if(a2.data.length>=3&&typeof a5!=="number"){self.postMessage({result:`Error calling formatJSON(json:string,tab:unset|string,codesLineLength:unset|(int>0))\ncodesLineLength:unset|(int>0) was of type <${typeof a5}> but was expected to be of type <unset> or of type <(int>0)>.`,error: "Type Error"});return}if(a2.data.length>=3&&typeof a5==="number"&&parseInt(a5)!==a5){self.postMessage({result:`Error calling formatJSON(json:string,tab:unset|string,codesLineLength:unset|(int>0))\ncodesLineLength:unset|(int>0) was of type <float> but was expected to be of type <unset> or of type <(int>0)>.`,error: "Type Error"});return}if(a2.data.length>=3&&typeof a5==="number"&&parseInt(a5)===a5&&a5<=0){self.postMessage({result:`Error calling formatJSON(json:string,tab:unset|string,codesLineLength:unset|(int>0))\ncodesLineLength:unset|(int>0) was of type <(int<=0)> but was expected to be of type <unset> or of type <(int>0)>.`,error: "Type Error"});return}a3=a3.replace(/\s/gm,"");const a6=/["[{]]/gm;let i=0,a7="",a8=false,a9=false,b1=0,b2=false,b3="";while(i<a3.length){const ch=a3.charAt(i),b4=(i<a3.length-1)?a3.charAt(i+1):null,b5=(i>0)?a3.charAt(i-1):null;if(a8===false){if(ch==='"'){a8=true;a7+=ch;}else if(ch==="{"||ch==="[") {if(b4==="}"||b4==="]"){a7+=ch;}else{a7+=ch;a7+="\n";b3+=a4;a7+=b3;if(a5&&ch==="["){if(a3.substring(i,a3.indexOf("]",i)).match(a6)===null)a9=true;}}}else if(ch===","){a7+=ch;if(a9===true){++b1;if(b1===a5){a7+="\n";a7+=b3;b1=0;}else a7+=a4;}else{a7+="\n";a7+=b3;}}else if(ch===":"){a7+=ch;a7+=a4;}else if(ch==="}"||ch==="]"){if(b5==="{"||b5==="["){a7+=ch;}else{a7+="\n";b3=b3.replace(a4,"");a7+=b3;a7+=ch;if(a9===true&&ch==="]"){a9=false;}}}else a7+=ch;}else{if(b2===false&&ch==='\\'){b2=true;a7+=ch;}else if(b2===true&&ch==='\\'){b2=false;a7+=ch;}else if(b2===false&&ch==='"'){a8=false;a7+=ch;}else a7+=ch;}++i;}self.postMessage({result:a7})};const b6=`"use strict";onmessage=${a1.toLocaleString()}`,b7=new Blob([b6],{type:"text/javascript"}),b8=URL.createObjectURL(b7),b9=new Worker(b8);URL.revokeObjectURL(b8);const c1=(...c2)=>{return new Promise((c3,c4)=>{b9.onmessage=c5=>{const{result,error}=c5.data;if(error)c4(c5.data);else c3(result)};b9.postMessage(c2)})},c6=`"use strict";return(${c1.toLocaleString()})`,c7=Function("b9",c6),c8=c7(b9);return c8;})();