277 lines
8.4 KiB
JavaScript
277 lines
8.4 KiB
JavaScript
// Metro module 13445 (f13446).
|
|
let get, isArrayBuffer, get2;
|
|
const _ = function _(a0, a1) {
|
|
return `${a1 ? a1.context ? a1.context : "Value" : "Value"} is not a view on an DataView object.`;
|
|
};
|
|
const createIntegerConversion = function createIntegerConversion(a0, { unsigned }) {
|
|
let c20461_0, c20461_1;
|
|
let c20461_2 = !unsigned;
|
|
if (a0 === 64) {
|
|
c20461_1 = Math.pow(2, 53) - 1;
|
|
c20461_0 = unsigned ? 0 : 1 - Math.pow(2, 53);
|
|
} else if (unsigned) {
|
|
c20461_0 = 0;
|
|
c20461_1 = Math.pow(2, a0) - 1;
|
|
} else {
|
|
const r10 = Math;
|
|
const r2 = a0 - 1;
|
|
c20461_0 = -r10.pow(2, r2);
|
|
c20461_1 = Math.pow(2, r2) - 1;
|
|
}
|
|
let c20461_3 = Math.pow(2, a0);
|
|
let c20461_4 = Math.pow(2, a0 - 1);
|
|
return (a0, a1) => {
|
|
let r42, r53;
|
|
const r6 = a1 === void 0 ? {} : a1;
|
|
const r0 = +a0;
|
|
const r1 = r0 !== 0 ? r0 : 0;
|
|
const enforceRange = r6.enforceRange;
|
|
const r10 = Number;
|
|
if (enforceRange) {
|
|
if (r10.isFinite(r1)) {
|
|
const r76 = Math.trunc(r1);
|
|
const r77 = r76 !== 0 ? r76 : 0;
|
|
if (!(r77 < c20461_0) && !(r77 > c20461_1)) {
|
|
return r77;
|
|
}
|
|
throw new TypeError(`${r6 ? r6.context ? r6.context : "Value" : "Value"} ${`is outside the accepted range of ${c20461_0} to ${c20461_1}, inclusive`}.`);
|
|
}
|
|
throw new TypeError(`${r6 ? r6.context ? r6.context : "Value" : "Value"} is not a finite number.`);
|
|
}
|
|
L36: {
|
|
if (!r10.isNaN(r1) && r6.clamp) {
|
|
const r29 = Math.min(Math.max(r1, c20461_0), c20461_1);
|
|
const r39 = !(r29 > 0 && (r29 % 1 === 0.5 && !(1 & r29))) && !(r29 < 0 && (r29 % 1 === -0.5 && !(1 & ~r29))) ? Math.round(r29) : Math.floor(r29);
|
|
r42 = 0;
|
|
if (r39 === 0) {
|
|
break L36;
|
|
}
|
|
r42 = r39;
|
|
} else {
|
|
const isFinite2 = Number.isFinite(r1);
|
|
let r46 = 0;
|
|
if (isFinite2) {
|
|
r46 = 0;
|
|
if (r1 !== 0) {
|
|
const r49 = Math.trunc(r1);
|
|
const r50 = r49 !== 0 ? r49 : 0;
|
|
L34: {
|
|
if (r50 >= c20461_0) {
|
|
r53 = r50;
|
|
if (r53 <= c20461_1) {
|
|
break L34;
|
|
}
|
|
}
|
|
const r54 = r50 % c20461_3;
|
|
const r55 = c20461_3 < 0;
|
|
let r56 = 1;
|
|
const r57 = r55 ? -1 : 1;
|
|
if (r54 < 0) {
|
|
r56 = -1;
|
|
}
|
|
const r58 = r57 !== r56 ? r54 + c20461_3 : r54;
|
|
let r60 = r58;
|
|
if (c20461_2) {
|
|
r60 = r58;
|
|
if (r60 >= c20461_4) {
|
|
r60 = r58 - c20461_3;
|
|
}
|
|
}
|
|
r53 = r60;
|
|
}
|
|
r46 = r53;
|
|
}
|
|
}
|
|
r42 = r46;
|
|
}
|
|
}
|
|
return r42;
|
|
};
|
|
};
|
|
const convertCallbackFunction = function convertCallbackFunction(a0, a1) {
|
|
if (typeof a0 !== "function") {
|
|
throw new TypeError(`${a1 ? a1.context ? a1.context : "Value" : "Value"} is not a function.`);
|
|
}
|
|
return a0;
|
|
};
|
|
isArrayBuffer = function isArrayBuffer(a0) {
|
|
try {
|
|
const call = get.call;
|
|
get.call(a0);
|
|
} catch ($e) {
|
|
return false;
|
|
}
|
|
return true;
|
|
};
|
|
export const any = (a0) => a0;
|
|
exports.void = function() {};
|
|
export const boolean = function(a0) {
|
|
return !!a0;
|
|
};
|
|
export const byte = createIntegerConversion(8, {
|
|
unsigned: false
|
|
});
|
|
export const octet = createIntegerConversion(8, {
|
|
unsigned: true
|
|
});
|
|
export const short = createIntegerConversion(16, {
|
|
unsigned: false
|
|
});
|
|
exports["unsigned short"] = createIntegerConversion(16, {
|
|
unsigned: true
|
|
});
|
|
export const long = createIntegerConversion(32, {
|
|
unsigned: false
|
|
});
|
|
exports["unsigned long"] = createIntegerConversion(32, {
|
|
unsigned: true
|
|
});
|
|
exports["long long"] = createIntegerConversion(64, {
|
|
unsigned: false
|
|
});
|
|
exports["unsigned long long"] = createIntegerConversion(64, {
|
|
unsigned: true
|
|
});
|
|
export const double = (a0, a1) => {
|
|
const r0 = +a0;
|
|
if (Number.isFinite(r0)) {
|
|
return r0;
|
|
}
|
|
throw new TypeError(`${a1 ? a1.context ? a1.context : "Value" : "Value"} is not a finite floating-point value.`);
|
|
};
|
|
exports["unrestricted double"] = (a0) => +a0;
|
|
export const float = (a0, a1) => {
|
|
const r0 = +a0;
|
|
if (Number.isFinite(r0)) {
|
|
if (Object.is(r0, -0)) {
|
|
return r0;
|
|
}
|
|
const r31 = Math.fround(r0);
|
|
if (Number.isFinite(r31)) {
|
|
return r31;
|
|
}
|
|
throw new TypeError(`${a1 ? a1.context ? a1.context : "Value" : "Value"} is outside the range of a single-precision floating-point value.`);
|
|
}
|
|
throw new TypeError(`${a1 ? a1.context ? a1.context : "Value" : "Value"} is not a finite floating-point value.`);
|
|
};
|
|
exports["unrestricted float"] = (a0) => {
|
|
const r0 = +a0;
|
|
return isNaN(r0) ? r0 : Object.is(r0, -0) ? r0 : Math.fround(r0);
|
|
};
|
|
export const DOMString = function(a0, a1) {
|
|
const r3 = a1 === void 0 ? {} : a1;
|
|
if (r3.treatNullAsEmptyString && a0 === null) {
|
|
return "";
|
|
}
|
|
if (typeof a0 === "symbol") {
|
|
throw new TypeError(`${r3 ? r3.context ? r3.context : "Value" : "Value"} is a symbol, which cannot be converted to a string.`);
|
|
}
|
|
return String(a0);
|
|
};
|
|
export const ByteString = (a0, a1) => {
|
|
const r18 = exports.DOMString(a0, a1);
|
|
let r0 = 0;
|
|
let r20 = r18.codePointAt(0);
|
|
while (r20 !== void 0) {
|
|
const r1 = r0;
|
|
if (r20 > 255) {
|
|
throw new TypeError(`${a1 ? a1.context ? a1.context : "Value" : "Value"} is not a valid ByteString.`);
|
|
}
|
|
const r22 = r1 + 1;
|
|
r20 = r18.codePointAt(r22);
|
|
r0 = r22;
|
|
}
|
|
return r18;
|
|
};
|
|
export const USVString = (a0, a1) => {
|
|
let r33;
|
|
const r25 = exports.DOMString(a0, a1);
|
|
const length = r25.length;
|
|
const r27 = [];
|
|
let r2 = 0;
|
|
while (r2 < length) {
|
|
L13: {
|
|
const r22 = r25.charCodeAt(r2);
|
|
const r3 = r2;
|
|
if (!(r22 < 55296) && !(r22 > 57343)) {
|
|
if (56320 <= r22 && r22 <= 57343) {
|
|
r27.push(String.fromCodePoint(65533));
|
|
r33 = r3;
|
|
break L13;
|
|
}
|
|
if (r3 === length - 1) {
|
|
r27.push(String.fromCodePoint(65533));
|
|
r33 = r3;
|
|
break L13;
|
|
}
|
|
const r6 = r3 + 1;
|
|
const r30 = r25.charCodeAt(r6);
|
|
if (56320 <= r30 && r30 <= 57343) {
|
|
r27.push(String.fromCodePoint(65536 + 1024 * (1023 & r22) + (1023 & r30)));
|
|
r33 = r6;
|
|
break L13;
|
|
}
|
|
r27.push(String.fromCodePoint(65533));
|
|
r33 = r3;
|
|
} else {
|
|
r27.push(String.fromCodePoint(r22));
|
|
r33 = r3;
|
|
}
|
|
}
|
|
r2 = r33 + 1;
|
|
}
|
|
return r27.join("");
|
|
};
|
|
export const object = (a0, a1) => {
|
|
let r3 = "Null";
|
|
if (a0 !== null) {
|
|
const r4 = typeof a0;
|
|
r3 = r4 === "undefined" ? "Undefined" : r4 === "boolean" ? "Boolean" : r4 === "number" ? "Number" : r4 === "string" ? "String" : r4 !== "symbol" ? "Object" : "Symbol";
|
|
}
|
|
if (r3 !== "Object") {
|
|
throw new TypeError(`${a1 ? a1.context ? a1.context : "Value" : "Value"} is not an object.`);
|
|
}
|
|
return a0;
|
|
};
|
|
get = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get;
|
|
exports.ArrayBuffer = (a0, a1) => {
|
|
if (isArrayBuffer(a0)) {
|
|
return a0;
|
|
}
|
|
throw new TypeError(`${a1 ? a1.context ? a1.context : "Value" : "Value"} is not a view on an ArrayBuffer object.`);
|
|
};
|
|
get2 = Object.getOwnPropertyDescriptor(DataView.prototype, "byteLength").get;
|
|
exports.DataView = (a0, a1) => {
|
|
try {
|
|
const call = get2.call;
|
|
get2.call(a0);
|
|
} catch ($e) {
|
|
throw new TypeError(_("is not a view on an DataView object", a1));
|
|
}
|
|
return a0;
|
|
};
|
|
[Int8Array, Int16Array, Int32Array, Uint8Array, Uint16Array, Uint32Array, Uint8ClampedArray, Float32Array, Float64Array].forEach(({ name }) => {
|
|
let c20462_1 = /^[AEIOU]/.test(name) ? "an" : "a";
|
|
exports[name] = (a0, a1) => {
|
|
if (ArrayBuffer.isView(a0) && a0.constructor.name === name) {
|
|
return a0;
|
|
}
|
|
throw new TypeError(`${a1 ? a1.context ? a1.context : "Value" : "Value"} ${`is not ${c20462_1} ${name} object`}.`);
|
|
};
|
|
});
|
|
export const ArrayBufferView = (a0, a1) => {
|
|
if (ArrayBuffer.isView(a0)) {
|
|
return a0;
|
|
}
|
|
throw new TypeError(`${a1 ? a1.context ? a1.context : "Value" : "Value"} is not a view on an ArrayBuffer object.`);
|
|
};
|
|
export const BufferSource = (a0, a1) => {
|
|
if (!ArrayBuffer.isView(a0) && !isArrayBuffer(a0)) {
|
|
throw new TypeError(`${a1 ? a1.context ? a1.context : "Value" : "Value"} is not an ArrayBuffer object or a view on one.`);
|
|
}
|
|
return a0;
|
|
};
|
|
export const DOMTimeStamp = exports["unsigned long long"];
|
|
export { convertCallbackFunction as Function };
|
|
export { convertCallbackFunction as VoidFunction };
|