use Number.parseInt

This commit is contained in:
Lhcfl 2024-04-12 16:55:34 +08:00
parent 695cb452bc
commit f422842aef
11 changed files with 31 additions and 31 deletions

View File

@ -100,9 +100,9 @@ const sum = (...arr) => arr.reduce((r, a) => r.map((b, i) => a[i] + b));
const negate = (arr) => arr.map((x) => -x);
const alpha = (hex, a) => {
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)!;
const r = parseInt(result[1], 16);
const g = parseInt(result[2], 16);
const b = parseInt(result[3], 16);
const r = Number.parseInt(result[1], 16);
const g = Number.parseInt(result[2], 16);
const b = Number.parseInt(result[3], 16);
return `rgba(${r}, ${g}, ${b}, ${a})`;
};

View File

@ -147,7 +147,7 @@ function get() {
};
const calcAfter = () => {
let base = parseInt(after.value);
let base = Number.parseInt(after.value);
switch (unit.value) {
case "day":
base *= 24;

View File

@ -271,7 +271,7 @@ function onHeaderMousedown(evt: MouseEvent) {
? evt.touches[0].clientY
: evt.clientY;
const moveBaseX = beforeMaximized
? parseInt(unMaximizedWidth, 10) / 2
? Number.parseInt(unMaximizedWidth, 10) / 2
: clickX - position.left; // TODO: parseInt
const moveBaseY = beforeMaximized ? 20 : clickY - position.top;
const browserWidth = window.innerWidth;
@ -321,8 +321,8 @@ function onTopHandleMousedown(evt) {
const main = rootEl.value;
const base = evt.clientY;
const height = parseInt(getComputedStyle(main, "").height, 10);
const top = parseInt(getComputedStyle(main, "").top, 10);
const height = Number.parseInt(getComputedStyle(main, "").height, 10);
const top = Number.parseInt(getComputedStyle(main, "").top, 10);
//
dragListen((me) => {
@ -349,8 +349,8 @@ function onRightHandleMousedown(evt) {
const main = rootEl.value;
const base = evt.clientX;
const width = parseInt(getComputedStyle(main, "").width, 10);
const left = parseInt(getComputedStyle(main, "").left, 10);
const width = Number.parseInt(getComputedStyle(main, "").width, 10);
const left = Number.parseInt(getComputedStyle(main, "").left, 10);
const browserWidth = window.innerWidth;
//
@ -375,8 +375,8 @@ function onBottomHandleMousedown(evt) {
const main = rootEl.value;
const base = evt.clientY;
const height = parseInt(getComputedStyle(main, "").height, 10);
const top = parseInt(getComputedStyle(main, "").top, 10);
const height = Number.parseInt(getComputedStyle(main, "").height, 10);
const top = Number.parseInt(getComputedStyle(main, "").top, 10);
const browserHeight = window.innerHeight;
//
@ -401,8 +401,8 @@ function onLeftHandleMousedown(evt) {
const main = rootEl.value;
const base = evt.clientX;
const width = parseInt(getComputedStyle(main, "").width, 10);
const left = parseInt(getComputedStyle(main, "").left, 10);
const width = Number.parseInt(getComputedStyle(main, "").width, 10);
const left = Number.parseInt(getComputedStyle(main, "").left, 10);
//
dragListen((me) => {

View File

@ -47,9 +47,9 @@ const props = defineProps<{
const alpha = (hex, a) => {
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)!;
const r = parseInt(result[1], 16);
const g = parseInt(result[2], 16);
const b = parseInt(result[3], 16);
const r = Number.parseInt(result[1], 16);
const g = Number.parseInt(result[2], 16);
const b = Number.parseInt(result[3], 16);
return `rgba(${r}, ${g}, ${b}, ${a})`;
};

View File

@ -47,9 +47,9 @@ const props = defineProps<{
const alpha = (hex, a) => {
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)!;
const r = parseInt(result[1], 16);
const g = parseInt(result[2], 16);
const b = parseInt(result[3], 16);
const r = Number.parseInt(result[1], 16);
const g = Number.parseInt(result[2], 16);
const b = Number.parseInt(result[3], 16);
return `rgba(${r}, ${g}, ${b}, ${a})`;
};

View File

@ -9,7 +9,7 @@ export function byteify(string: string, encoding: "ascii" | "base64" | "hex") {
);
case "hex":
return new Uint8Array(
string.match(/.{1,2}/g).map((byte) => parseInt(byte, 16)),
string.match(/.{1,2}/g).map((byte) => Number.parseInt(byte, 16)),
);
}
}

View File

@ -1,7 +1,7 @@
export const alpha = (hex: string, a: number): string => {
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)!;
const r = parseInt(result[1], 16);
const g = parseInt(result[2], 16);
const b = parseInt(result[3], 16);
const r = Number.parseInt(result[1], 16);
const g = Number.parseInt(result[2], 16);
const b = Number.parseInt(result[3], 16);
return `rgba(${r}, ${g}, ${b}, ${a})`;
};

View File

@ -183,7 +183,7 @@ export class Hpml {
}
if (expr.type === "number") {
return parseInt(expr.value as any, 10);
return Number.parseInt(expr.value as any, 10);
}
if (expr.type === "text" || expr.type === "multiLineText") {

View File

@ -505,7 +505,7 @@ export function initHpmlLib(
strReplace: (a: string, b: string, c: string) => a.split(b).join(c),
strReverse: (a: string) => a.split("").reverse().join(""),
join: (texts: string[], separator: string) => texts.join(separator || ""),
stringToNumber: (a: string) => parseInt(a),
stringToNumber: (a: string) => Number.parseInt(a),
numberToString: (a: number) => a.toString(),
splitStrByLine: (a: string) => a.split("\n"),
pick: (list: any[], i: number) => list[i - 1],
@ -534,7 +534,7 @@ export function initHpmlLib(
let totalFactor = 0;
for (const x of list) {
const parts = x.split(" ");
const factor = parseInt(parts.pop()!, 10);
const factor = Number.parseInt(parts.pop()!, 10);
const text = parts.join(" ");
totalFactor += factor;
xs.push({ factor, text });

View File

@ -65,10 +65,10 @@ export function physics(container: HTMLElement) {
const objs = [];
for (const objEl of objEls) {
const left = objEl.dataset.physicsX
? parseInt(objEl.dataset.physicsX)
? Number.parseInt(objEl.dataset.physicsX)
: objEl.offsetLeft;
const top = objEl.dataset.physicsY
? parseInt(objEl.dataset.physicsY)
? Number.parseInt(objEl.dataset.physicsY)
: objEl.offsetTop;
let obj;
@ -90,7 +90,7 @@ export function physics(container: HTMLElement) {
objEl.offsetHeight,
{
chamfer: {
radius: parseInt(style.borderRadius || "0", 10),
radius: Number.parseInt(style.borderRadius || "0", 10),
},
restitution: 0.5,
},

View File

@ -9,8 +9,8 @@ export function popout(path: string, w?: HTMLElement) {
url = appendQuery(url, "zen");
if (w) {
const position = w.getBoundingClientRect();
const width = parseInt(getComputedStyle(w, "").width, 10);
const height = parseInt(getComputedStyle(w, "").height, 10);
const width = Number.parseInt(getComputedStyle(w, "").width, 10);
const height = Number.parseInt(getComputedStyle(w, "").height, 10);
const x = window.screenX + position.left;
const y = window.screenY + position.top;
window.open(