Skip to content

Commit 7525430

Browse files
committed
Update 01_console.js
Upstream some changes from nodejs/node#49205 Signed-off-by: Jordan Harband <[email protected]>
1 parent ae327d0 commit 7525430

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

ext/console/01_console.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -2753,34 +2753,34 @@ const HSL_PATTERN = new SafeRegExp(
27532753
);
27542754

27552755
function parseCssColor(colorString) {
2756-
if (MapPrototypeHas(colorKeywords, colorString)) {
2757-
colorString = MapPrototypeGet(colorKeywords, colorString);
2756+
if (colorKeywords.has(colorString)) {
2757+
colorString = colorKeywords.get(colorString);
27582758
}
27592759
// deno-fmt-ignore
27602760
const hashMatch = StringPrototypeMatch(colorString, HASH_PATTERN);
27612761
if (hashMatch != null) {
27622762
return [
2763-
Number(`0x${hashMatch[1]}`),
2764-
Number(`0x${hashMatch[2]}`),
2765-
Number(`0x${hashMatch[3]}`),
2763+
NumberParseInt(hashMatch[1], 16),
2764+
NumberParseInt(hashMatch[2], 16),
2765+
NumberParseInt(hashMatch[3], 16),
27662766
];
27672767
}
27682768
// deno-fmt-ignore
27692769
const smallHashMatch = StringPrototypeMatch(colorString, SMALL_HASH_PATTERN);
27702770
if (smallHashMatch != null) {
27712771
return [
2772-
Number(`0x${smallHashMatch[1]}${smallHashMatch[1]}`),
2773-
Number(`0x${smallHashMatch[2]}${smallHashMatch[2]}`),
2774-
Number(`0x${smallHashMatch[3]}${smallHashMatch[3]}`),
2772+
NumberParseInt(`${smallHashMatch[1]}${smallHashMatch[1]}`, 16),
2773+
NumberParseInt(`${smallHashMatch[2]}${smallHashMatch[2]}`, 16),
2774+
NumberParseInt(`${smallHashMatch[3]}${smallHashMatch[3]}`, 16),
27752775
];
27762776
}
27772777
// deno-fmt-ignore
27782778
const rgbMatch = StringPrototypeMatch(colorString, RGB_PATTERN);
27792779
if (rgbMatch != null) {
27802780
return [
2781-
MathRound(MathMax(0, MathMin(255, Number(rgbMatch[1])))),
2782-
MathRound(MathMax(0, MathMin(255, Number(rgbMatch[2])))),
2783-
MathRound(MathMax(0, MathMin(255, Number(rgbMatch[3])))),
2781+
MathRound(MathMax(0, MathMin(255, rgbMatch[1]))),
2782+
MathRound(MathMax(0, MathMin(255, rgbMatch[2]))),
2783+
MathRound(MathMax(0, MathMin(255, rgbMatch[3]))),
27842784
];
27852785
}
27862786
// deno-fmt-ignore
@@ -2791,8 +2791,8 @@ function parseCssColor(colorString) {
27912791
if (h < 0) {
27922792
h += 360;
27932793
}
2794-
const s = MathMax(0, MathMin(100, Number(hslMatch[2]))) / 100;
2795-
const l = MathMax(0, MathMin(100, Number(hslMatch[3]))) / 100;
2794+
const s = MathMax(0, MathMin(100, hslMatch[2])) / 100;
2795+
const l = MathMax(0, MathMin(100, hslMatch[3])) / 100;
27962796
const c = (1 - MathAbs(2 * l - 1)) * s;
27972797
const x = c * (1 - MathAbs((h / 60) % 2 - 1));
27982798
const m = l - c / 2;

0 commit comments

Comments
 (0)