summaryrefslogtreecommitdiff
path: root/cli/js/web/console_table.ts
diff options
context:
space:
mode:
authorSpeykious <speykious.the.king@gmail.com>2020-05-19 20:19:26 +0200
committerGitHub <noreply@github.com>2020-05-19 14:19:26 -0400
commit9752b853ddac3ba41378d0ae8a8604a28e285ffb (patch)
tree1082dc9786adf3dbbda04b39b67ff3f421a6736f /cli/js/web/console_table.ts
parentcdc9323cccdee544562712018f722026bdfbbd6c (diff)
Provide better ANSI colorized output when inspecting objects (#5404)
Diffstat (limited to 'cli/js/web/console_table.ts')
-rw-r--r--cli/js/web/console_table.ts9
1 files changed, 2 insertions, 7 deletions
diff --git a/cli/js/web/console_table.ts b/cli/js/web/console_table.ts
index dc22433af..55808cdc0 100644
--- a/cli/js/web/console_table.ts
+++ b/cli/js/web/console_table.ts
@@ -2,6 +2,7 @@
// Forked from Node's lib/internal/cli_table.js
import { hasOwnProperty } from "./util.ts";
+import { stripColor } from "../colors.ts";
const tableChars = {
middleMiddle: "─",
@@ -19,12 +20,6 @@ const tableChars = {
middle: " │ ",
};
-const colorRegExp = /\u001b\[\d\d?m/g;
-
-function removeColors(str: string): string {
- return str.replace(colorRegExp, "");
-}
-
function isFullWidthCodePoint(code: number): boolean {
// Code points are partially derived from:
// http://www.unicode.org/Public/UNIDATA/EastAsianWidth.txt
@@ -65,7 +60,7 @@ function isFullWidthCodePoint(code: number): boolean {
}
function getStringWidth(str: string): number {
- str = removeColors(str).normalize("NFC");
+ str = stripColor(str).normalize("NFC");
let width = 0;
for (const ch of str) {