forked from WebReflection/flatted
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmin.js
1 lines (1 loc) · 3.81 KB
/
min.js
1
var TeleportJS=function(r,e){var a="_",n=a+"0",t={undefined:"u",number:"n",bigint:"b",symbol:"s",Map:"M",Set:"S",Date:"D",RegExp:"R",Buffer:"B",Int8Array:"H",Uint8Array:"I",Uint8ClampedArray:"J",Int16Array:"P",Uint16Array:"Q",Int32Array:"F",Uint32Array:"G",Float32Array:"K",Float64Array:"L"},i={parse:function(e,t){var i=JSON.parse(e,o).map(c),f=i.length,p=f>1?i[f-1]:[],u=i[0],l=t||s,A="object"==typeof u&&u?function e(n,t,i,s,f){return Object.keys(s).reduce((function(s,c){var o=s[c];if(o instanceof r){if(o.startsWith(a)){var p=o.substring(1);return t[p]instanceof r&&y(t,p),s[c]=t[p],s}var u=n[o];"object"!=typeof u||i.has(u)?s[c]=f.call(s,c,u):(i.add(u),s[c]=f.call(s,c,e(n,t,i,u,f)))}else s[c]=f.call(s,c,o);return s}),s)}(i,p,new Set,u,l):u===n&&p.length?y(p,0):u;return l.call({"":A},"",A)},stringify:function(n,y,c){for(var o,p=new Map,u=new Map,l=[],A=[],b=[],g=y&&typeof y==typeof A?function(r,e){if(""===r||y.indexOf(r)>-1)return e}:y||s,S=+f(p,A,g.call({"":n},"",n)),J=function(n,s){var y=g.call(this,n,s),c=function(e,n,s,y,f){var c,o;switch(typeof y){case"string":f[s]instanceof Date&&(c=t.Date+y);break;case"undefined":c=t.undefined;break;case"number":Number.isFinite(y)||(c=t.number+r(y));break;case"bigint":c=t.bigint+r(y);break;case"symbol":var p=r(y);c=t.symbol+p.substring(7,p.length-1);break;case"object":if(null===y)break;if("Buffer"===y.type&&y.data&&Buffer.isBuffer(f[s]))c=t.Buffer+JSON.stringify(y.data);else if(y instanceof RegExp)c=t.RegExp+r(y);else if(y instanceof Map){var u=[];for(o of y.entries())u.push(o);c=t.Map+i.stringify(u)}else if(y instanceof Set){var l=[];for(o of y.values())l.push(o);c=t.Set+i.stringify(l)}else y instanceof Int8Array?c=t.Int8Array+JSON.stringify(Array.apply([],y)):y instanceof Uint8Array?c=t.Uint8Array+JSON.stringify(Array.apply([],y)):y instanceof Uint8ClampedArray?c=t.Uint8ClampedArray+JSON.stringify(Array.apply([],y)):y instanceof Int16Array?c=t.Int16Array+JSON.stringify(Array.apply([],y)):y instanceof Uint16Array?c=t.Uint16Array+JSON.stringify(Array.apply([],y)):y instanceof Int32Array?c=t.Int32Array+JSON.stringify(Array.apply([],y)):y instanceof Uint32Array?c=t.Uint32Array+JSON.stringify(Array.apply([],y)):y instanceof Float32Array?c=t.Float32Array+JSON.stringify(Array.apply([],y)):y instanceof Float64Array&&(c=t.Float64Array+JSON.stringify(Array.apply([],y)))}if(!c)return;var A=e.get(c);if(A)return A;return A=a+r(n.push(c)-1),e.set(c,A),A}(u,l,n,y,this);if(c)return c;if(o)return o=!o,s;switch(typeof y){case"object":if(null===y)return y;case e:return p.get(y)||f(p,A,y)}return y};S<A.length;S++)o=!0,b[S]=JSON.stringify(A[S],J,c);return l.length&&b.push(JSON.stringify(l)),"["+b.join(",")+"]"}};return i;function s(r,e){return e}function y(r,e){var a=r[e].substring(1);switch(r[e].charAt(0)){case t.undefined:r[e]=void 0;break;case t.number:r[e]=Number(a);break;case t.bigint:r[e]=BigInt(a);break;case t.symbol:r[e]=Symbol.for(a);break;case t.RegExp:var n=/\/(.*)\/(.*)/.exec(a);r[e]=new RegExp(n[1],n[2]);break;case t.Buffer:r[e]=Buffer.from(JSON.parse(a));break;case t.Date:r[e]=new Date(a);break;case t.Map:r[e]=new Map(i.parse(a));break;case t.Set:r[e]=new Set(i.parse(a));break;case t.Int8Array:r[e]=new Int8Array(JSON.parse(a));break;case t.Uint8Array:r[e]=new Uint8Array(JSON.parse(a));break;case t.Uint8ClampedArray:r[e]=new Uint8ClampedArray(JSON.parse(a));break;case t.Int16Array:r[e]=new Int16Array(JSON.parse(a));break;case t.Uint16Array:r[e]=new Uint16Array(JSON.parse(a));break;case t.Int32Array:r[e]=new Int32Array(JSON.parse(a));break;case t.Uint32Array:r[e]=new Uint32Array(JSON.parse(a));break;case t.Float32Array:r[e]=new Float32Array(JSON.parse(a));break;case t.Float64Array:r[e]=new Float64Array(JSON.parse(a))}return r[e]}function f(e,a,n){var t=r(a.push(n)-1);return e.set(n,t),t}function c(e){return e instanceof r?r(e):e}function o(a,n){return typeof n===e?new r(n):n}}(String,"string");