mirror of
https://github.com/swc-project/swc.git
synced 2024-12-28 16:13:34 +03:00
4 lines
23 KiB
TypeScript
4 lines
23 KiB
TypeScript
|
// Loaded from https://dev.jspm.io/npm:@jspm/core@1.1.1/nodelibs/buffer.js
|
||
|
|
||
|
|
||
|
for(var r={byteLength:function(r){var t=u(r),e=t[0],n=t[1];return 3*(e+n)/4-n},toByteArray:function(r){var t,o,a=u(r),h=a[0],c=a[1],d=new n(function(r,t,e){return 3*(t+e)/4-e}(0,h,c)),f=0,A=c>0?h-4:h;for(o=0;o<A;o+=4)t=e[r.charCodeAt(o)]<<18|e[r.charCodeAt(o+1)]<<12|e[r.charCodeAt(o+2)]<<6|e[r.charCodeAt(o+3)],d[f++]=t>>16&255,d[f++]=t>>8&255,d[f++]=255&t;2===c&&(t=e[r.charCodeAt(o)]<<2|e[r.charCodeAt(o+1)]>>4,d[f++]=255&t);1===c&&(t=e[r.charCodeAt(o)]<<10|e[r.charCodeAt(o+1)]<<4|e[r.charCodeAt(o+2)]>>2,d[f++]=t>>8&255,d[f++]=255&t);return d},fromByteArray:function(r){for(var e,n=r.length,o=n%3,a=[],h=0,u=n-o;h<u;h+=16383)a.push(c(r,h,h+16383>u?u:h+16383));1===o?(e=r[n-1],a.push(t[e>>2]+t[e<<4&63]+"==")):2===o&&(e=(r[n-2]<<8)+r[n-1],a.push(t[e>>10]+t[e>>4&63]+t[e<<2&63]+"="));return a.join("")}},t=[],e=[],n="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,h=o.length;a<h;++a)t[a]=o[a],e[o.charCodeAt(a)]=a;function u(r){var t=r.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=r.indexOf("=");return -1===e&&(e=t),[e,e===t?0:4-e%4]}function c(r,e,n){for(var o,a,h=[],u=e;u<n;u+=3)o=(r[u]<<16&16711680)+(r[u+1]<<8&65280)+(255&r[u+2]),h.push(t[(a=o)>>18&63]+t[a>>12&63]+t[a>>6&63]+t[63&a]);return h.join("")}e["-".charCodeAt(0)]=62,e["_".charCodeAt(0)]=63;var a$1={read:function(a,t,o,r,h){var M,f,p=8*h-r-1,w=(1<<p)-1,e=w>>1,i=-7,N=o?h-1:0,n=o?-1:1,u=a[t+N];for(N+=n,M=u&(1<<-i)-1,u>>=-i,i+=p;i>0;M=256*M+a[t+N],N+=n,i-=8);for(f=M&(1<<-i)-1,M>>=-i,i+=r;i>0;f=256*f+a[t+N],N+=n,i-=8);if(0===M)M=1-e;else {if(M===w)return f?NaN:1/0*(u?-1:1);f+=Math.pow(2,r),M-=e;}return (u?-1:1)*f*Math.pow(2,M-r)},write:function(a,t,o,r,h,M){var f,p,w,e=8*M-h-1,i=(1<<e)-1,N=i>>1,n=23===h?Math.pow(2,-24)-Math.pow(2,-77):0,u=r?0:M-1,l=r?1:-1,s=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(p=isNaN(t)?1:0,f=i):(f=Math.floor(Math.log(t)/Math.LN2),t*(w=Math.pow(2,-f))<1&&(f--,w*=2),(t+=f+N>=1?n/w:n*Math.pow(2,1-N))*w>=2&&(f++,w/=2),f+N>=i?(p=0,f=i):f+N>=1?(p=(t*w-1)*Math.pow(2,h),f+=N):(p=t*Math.pow(2,N-1)*Math.pow(2,h),f=0));h>=8;a[o+u]=255&p,u+=l,p/=256,h-=8);for(f=f<<h|p,e+=h;e>0;a[o+u]=255&f,u+=l,f/=256,e-=8);a[o+u-l]|=128*s;}};var e$1={},n$1=r,i=a$1,o$1="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e$1.Buffer=u$1,e$1.SlowBuffer=function(t){+t!=t&&(t=0);return u$1.alloc(+t)},e$1.INSPECT_MAX_BYTES=50;function f(t){if(t>2147483647)throw new RangeError('The value "'+t+'" is invalid for option "size"');var r=new Uint8Array(t);return Object.setPrototypeOf(r,u$1.prototype),r}function u$1(t,r,e){if("number"==typeof t){if("string"==typeof r)throw new TypeError('The "string" argument must be of type string. Received type number');return a$2(t)}return s(t,r,e)}function s(t,r,e){if("string"==typeof t)return function(t,r){"string"==typeof r&&""!==r||(r="utf8");if(!u$1.isEncoding(r))throw new TypeError("Unknown encoding: "+r);var e=0|y(t,r),n=f(e),i=n.write(t,r);i!==e&&(n=n.slice(0,i));return n}(t,r);if(ArrayBuffer.isView(t))return p(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(F(t,ArrayBuffer)||t&&F(t.buffer,ArrayBuffer))return c$1(t,r,e);if("undefined"!=typeof SharedArrayBuffer&&(F(t,SharedArrayBuffer)||t&&F(t.buffer,SharedArrayBuffer)))return c$1(t,r,e);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');var n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u$1.from(n,r,e);var i=function(t){if(u$1.isBuffer(t)){var r=0|l(t.length),e=f(r);return 0===e.length||t.copy(e,0,0,r),e}if(void 0!==t.length)return "number"!=typeof t.length||N(t.length)?f(0):p(t);if("Buffer"===t.type&&Array.isArray(t.data))return p(t.data)}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u$1.from(t[Symbol.toPrimitive]("string"),r,e);throw new TypeError("The first argume
|