@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 1.44 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
function e(e,n,t,r=!0){if(n%4!=0||t%4!=0){const i=new ArrayBuffer(4*Math.ceil(t/4)),o=new Uint8Array(i),l=new Uint8Array(e,n,t);if(r)for(let e=0;e<o.length;e+=4)o[e]=l[e+3],o[e+1]=l[e+2],o[e+2]=l[e+1],o[e+3]=l[e];else o.set(l);return new Uint32Array(o.buffer)}if(r){const r=new Uint8Array(e,n,t),i=new Uint8Array(r.length);for(let e=0;e<i.length;e+=4)i[e]=r[e+3],i[e+1]=r[e+2],i[e+2]=r[e+1],i[e+3]=r[e];return new Uint32Array(i.buffer)}return new Uint32Array(e,n,t/4)}function n(){const e=[];for(let n=0;n<=257;n++)e[n]=[n];return e}function t(e,n){for(let t=0;t<n.length;t++)e.push(n[t])}const r=new Set;function i(i,o,l,f=!0){const s=e(i,o,l,f);let a=9,c=n(),u=32,h=c.length,d=[],w=1,g=s[0],y=0;const A=s.length,U=8*(4*A-l),p=[];for(;null!=g;){if(u>=a)u-=a,y=g>>>32-a,g<<=a;else{y=g>>>32-u,g=s[w++];const e=a-u;u=32-e,y=(y<<e)+(g>>>u),g<<=e}if(257===y)break;if(256===y){a=9,c=n(),h=c.length,d=[];continue}const e=c[y];if(null==e){if(y>c.length)throw new Error("data integrity issue: code does not exist on code page");d.push(d[0]),c[h++]=d.slice(),t(p,d)}else t(p,e),d.push(e[0]),d.length>1&&(c[h++]=d.slice()),d=e.slice();if(r.has(h)&&a++,0===u&&(g=s[w++],u=32),w>A||w===A&&u<=U)break}return new Uint8Array(p)}r.add(511),r.add(1023),r.add(2047),r.add(4095),r.add(8191);export{i as decode};