chore: reformat with 2 spaces
This commit is contained in:
parent
d659e4bed9
commit
7670d7f808
1577 changed files with 70010 additions and 70042 deletions
|
@ -5,52 +5,52 @@
|
|||
import en from "../lang/en.json";
|
||||
|
||||
function setupPrimitives() {
|
||||
Object.defineProperties(Number, {
|
||||
isNumeric: {
|
||||
value: function (n: unknown) {
|
||||
if (n instanceof Array) return false;
|
||||
else if (([null, ""] as unknown[]).includes(n)) return false;
|
||||
// @ts-expect-error Abusing JavaScript a bit here, but it's the implementation from foundry
|
||||
return +n === +n;
|
||||
},
|
||||
},
|
||||
fromString: {
|
||||
value: function (str: unknown) {
|
||||
if (typeof str !== "string" || !str.length) return NaN;
|
||||
// Remove whitespace.
|
||||
str = str.replace(/\s+/g, "");
|
||||
return Number(str);
|
||||
},
|
||||
},
|
||||
});
|
||||
Object.defineProperties(Number, {
|
||||
isNumeric: {
|
||||
value: function (n: unknown) {
|
||||
if (n instanceof Array) return false;
|
||||
else if (([null, ""] as unknown[]).includes(n)) return false;
|
||||
// @ts-expect-error Abusing JavaScript a bit here, but it's the implementation from foundry
|
||||
return +n === +n;
|
||||
},
|
||||
},
|
||||
fromString: {
|
||||
value: function (str: unknown) {
|
||||
if (typeof str !== "string" || !str.length) return NaN;
|
||||
// Remove whitespace.
|
||||
str = str.replace(/\s+/g, "");
|
||||
return Number(str);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Object.defineProperties(Math, {
|
||||
clamped: {
|
||||
value: function (num: number, min: number, max: number) {
|
||||
return Math.min(max, Math.max(num, min));
|
||||
},
|
||||
},
|
||||
});
|
||||
Object.defineProperties(Math, {
|
||||
clamped: {
|
||||
value: function (num: number, min: number, max: number) {
|
||||
return Math.min(max, Math.max(num, min));
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function setupStubs() {
|
||||
class StubGame {
|
||||
constructor() {
|
||||
this.i18n = {
|
||||
localize: (key: string) => (key in en ? en[key as keyof typeof en] : key),
|
||||
};
|
||||
}
|
||||
i18n: {
|
||||
localize: (key: string) => string;
|
||||
};
|
||||
class StubGame {
|
||||
constructor() {
|
||||
this.i18n = {
|
||||
localize: (key: string) => (key in en ? en[key as keyof typeof en] : key),
|
||||
};
|
||||
}
|
||||
i18n: {
|
||||
localize: (key: string) => string;
|
||||
};
|
||||
}
|
||||
|
||||
const game = new StubGame();
|
||||
const game = new StubGame();
|
||||
|
||||
Object.defineProperties(globalThis, {
|
||||
game: { value: game },
|
||||
Game: { value: StubGame },
|
||||
});
|
||||
Object.defineProperties(globalThis, {
|
||||
game: { value: game },
|
||||
Game: { value: StubGame },
|
||||
});
|
||||
}
|
||||
|
||||
setupPrimitives();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue