Skip to content

Commit 03c827e

Browse files
committed
Remove strip-ansi in favor of stripVTControlCharacters
1 parent 2ebc53f commit 03c827e

File tree

6 files changed

+13
-20
lines changed

6 files changed

+13
-20
lines changed

pnpm-lock.yaml

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ts-perf/packages/api/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333
"chalk": "^4.1.2",
3434
"iterable-query": "1.0.0-pre.16",
3535
"power-options": "^0.3.4",
36-
"semver": "^7.7.1",
37-
"strip-ansi": "^6.0.1"
36+
"semver": "^7.7.1"
3837
},
3938
"devDependencies": {
4039
"@types/semver": "^7.5.8"

ts-perf/packages/api/src/format.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import { stripVTControlCharacters } from "node:util";
2+
13
import * as chalk from "chalk";
2-
import stripColor from "strip-ansi";
34

45
import { Benchmark, Host, MeasurementComparisonPivot, MeasurementPivot, Scenario, Value } from "./model";
56
import { TimeSpan } from "./types";
@@ -94,8 +95,8 @@ export function formatProgress(index: number, length: number) {
9495
}
9596

9697
export function padLeft(text: string, size: number, ch = " ") {
97-
let length = stripColor(text).length;
98-
const charLength = stripColor(ch).length;
98+
let length = stripVTControlCharacters(text).length;
99+
const charLength = stripVTControlCharacters(ch).length;
99100
while (length < size) {
100101
text = ch + text;
101102
length += charLength;
@@ -104,8 +105,8 @@ export function padLeft(text: string, size: number, ch = " ") {
104105
}
105106

106107
export function padRight(text: string, size: number, ch = " ") {
107-
let length = stripColor(text).length;
108-
const charLength = stripColor(ch).length;
108+
let length = stripVTControlCharacters(text).length;
109+
const charLength = stripVTControlCharacters(ch).length;
109110
while (length < size) {
110111
text = text + ch;
111112
length += charLength;

ts-perf/packages/commands/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
"iterable-query-linq": "^0.1.0",
3737
"power-options": "^0.3.4",
3838
"semver": "^7.7.1",
39-
"strip-ansi": "^6.0.1",
4039
"table-style": "^0.1.4",
4140
"tmp": "^0.2.3"
4241
},

ts-perf/packages/commands/src/analyze/decorators.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { EOL } from "node:os";
2+
import { stripVTControlCharacters } from "node:util";
23

34
import { Range, TimeSpan } from "@ts-perf/api";
45
import chalk from "chalk";
56
import { from } from "iterable-query";
6-
import stripColor from "strip-ansi";
77
import * as table_style from "table-style";
88
import { Size, TableColumnDefinition } from "table-style";
99
import {
@@ -164,7 +164,7 @@ export namespace Table {
164164
output += `${header.expression(context)}`;
165165
}
166166
}
167-
if (!term.useColor) output = stripColor(output);
167+
if (!term.useColor) output = stripVTControlCharacters(output);
168168
}
169169
if (output) output += EOL;
170170
let width = table.width;

ts-perf/packages/commands/src/analyze/model/types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as fs from "node:fs";
22
import { REPLServer } from "node:repl";
3+
import { stripVTControlCharacters } from "node:util";
34
import { Context, createContext } from "node:vm";
45

56
import { delay } from "@esfx/async-delay";
@@ -8,7 +9,6 @@ import { Range, TimeSpan } from "@ts-perf/api";
89
import chalk from "chalk";
910
import { fn, from, Query } from "iterable-query";
1011
import { parseAndExecuteQuery, startLinqRepl } from "iterable-query-linq";
11-
import stripColor from "strip-ansi";
1212

1313
import { formatValues } from "../decorators";
1414

@@ -107,7 +107,7 @@ export class Analyzer {
107107

108108
getTypeHelp(name = "", useColors = true) {
109109
const help = getHelp(this.getTypeAndTableNames(), "type", this.types, this._formattedTypes, name, formatType);
110-
return useColors ? help : stripColor(help);
110+
return useColors ? help : stripVTControlCharacters(help);
111111
}
112112

113113
getTableHelp(name = "", useColors = true) {
@@ -119,13 +119,13 @@ export class Analyzer {
119119
name,
120120
formatTable,
121121
);
122-
return useColors ? help : stripColor(help);
122+
return useColors ? help : stripVTControlCharacters(help);
123123
}
124124

125125
getUsageHelp(useColors = true) {
126126
const help = this._formattedUsage
127127
|| (this._formattedUsage = formatUsage(this.getTypeAndTableNames(), this.examples));
128-
return useColors ? help : stripColor(help);
128+
return useColors ? help : stripVTControlCharacters(help);
129129
}
130130

131131
private getTypeAndTableNames() {

0 commit comments

Comments
 (0)