解决unflags没有传入值时的错误

This commit is contained in:
枫谷剑仙 2024-04-26 05:55:17 +08:00
parent 6a6906f8c3
commit 3935862b46
2 changed files with 4 additions and 3 deletions

View File

@ -364,13 +364,14 @@ class Bin extends Set {
* @returns {number[]} 输出数组
*/
static unflags(number) {
const arr = [];
if (!number) return arr;
const inputType = typeof number;
if (inputType === "number" || inputType === "bigint"){
if (inputType === "number" && number > Number.MAX_SAFE_INTEGER) {
throw new RangeError(Bin.#rangeError_NotSafe);
}
const isBigint = inputType === "bigint";
const arr = [];
for (let i = 0, flag = isBigint ? 1n : 1; flag <= number; i++, flag = (isBigint ? 2n : 2) ** (isBigint ? BigInt(i) : i)) {
if (number & flag) {
arr.push(i);
@ -378,7 +379,7 @@ class Bin extends Set {
}
return arr;
} else {
throw new TypeError(Bin.#typeError_FlagsNum);
throw new TypeError(Bin.#typeError_FlagsNum + " " + number);
}
}
/**

View File

@ -25519,7 +25519,7 @@ const cachesMap = new Map([
],
[
"script-universal_function.js",
"4c6512cc2876102856ecf24775673805"
"c9f02f55722b4112a7625205c541d930"
],
[
"script.js",