pages/ludwig/assets/engine.io-parser.3f360695.js

2 lines
1.9 KiB
JavaScript
Raw Normal View History

const o=Object.create(null);o.open="0";o.close="1";o.ping="2";o.pong="3";o.message="4";o.upgrade="5";o.noop="6";const a=Object.create(null);Object.keys(o).forEach(e=>{a[o[e]]=e});const B={type:"error",data:"parser error"},w=typeof Blob=="function"||typeof Blob!="undefined"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",b=typeof ArrayBuffer=="function",E=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,C=({type:e,data:t},n,r)=>w&&t instanceof Blob?n?r(t):d(t,r):b&&(t instanceof ArrayBuffer||E(t))?n?r(t):d(new Blob([t]),r):r(o[e]+(t||"")),d=(e,t)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];t("b"+(r||""))},n.readAsDataURL(e)},A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=typeof Uint8Array=="undefined"?[]:new Uint8Array(256);for(let e=0;e<A.length;e++)u[A.charCodeAt(e)]=e;const R=e=>{let t=e.length*.75,n=e.length,r,c=0,f,s,i,y;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);const p=new ArrayBuffer(t),l=new Uint8Array(p);for(r=0;r<n;r+=4)f=u[e.charCodeAt(r)],s=u[e.charCodeAt(r+1)],i=u[e.charCodeAt(r+2)],y=u[e.charCodeAt(r+3)],l[c++]=f<<2|s>>4,l[c++]=(s&15)<<4|i>>2,l[c++]=(i&3)<<6|y&63;return p},P=typeof ArrayBuffer=="function",T=(e,t)=>{if(typeof e!="string")return{type:"message",data:h(e,t)};const n=e.charAt(0);return n==="b"?{type:"message",data:O(e.substring(1),t)}:a[n]?e.length>1?{type:a[n],data:e.substring(1)}:{type:a[n]}:B},O=(e,t)=>{if(P){const n=R(e);return h(n,t)}else return{base64:!0,data:e}},h=(e,t)=>{switch(t){case"blob":return e instanceof ArrayBuffer?new Blob([e]):e;case"arraybuffer":default:return e}},g=String.fromCharCode(30),S=(e,t)=>{const n=e.length,r=new Array(n);let c=0;e.forEach((f,s)=>{C(f,!1,i=>{r[s]=i,++c===n&&t(r.join(g))})})},m=(e,t)=>{const n=e.split(g),r=[];for(let c=0;c<n.length;c++){const f=T(n[c],t);if(r.push(f),f.type==="error")break}return r},j=4;export{m as a,C as b,T as d,S as e,j as p};