Skip to content

Commit 3c4ba5a

Browse files
committed
Drop chalk
1 parent d139894 commit 3c4ba5a

File tree

15 files changed

+93
-109
lines changed

15 files changed

+93
-109
lines changed

pnpm-lock.yaml

Lines changed: 3 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: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"@esfx/equatable": "^1.0.2",
3131
"@stdlib/stats-base-dists-normal-cdf": "^0.2.2",
3232
"@ts-perf/core": "workspace:^",
33-
"chalk": "^4.1.2",
3433
"iterable-query": "1.0.0-pre.16",
3534
"power-options": "^0.3.4",
3635
"semver": "^7.7.3"

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { stripVTControlCharacters } from "node:util";
22

3-
import * as chalk from "chalk";
4-
53
import { Benchmark, Host, MeasurementComparisonPivot, MeasurementPivot, Scenario, Value } from "./model";
4+
5+
export type Color = (input: string | number | null | undefined) => string;
66
import { TimeSpan } from "./types";
77

88
export function formatMean(measurement: Value | MeasurementPivot) {
@@ -42,11 +42,11 @@ const percentFormat = new Intl.NumberFormat("en-US", {
4242
minimumFractionDigits: 2,
4343
});
4444

45-
export function formatPercent(value: number, options?: { sign?: boolean; pad?: number; color?: chalk.Chalk; }): string;
45+
export function formatPercent(value: number, options?: { sign?: boolean; pad?: number; color?: Color; }): string;
4646
export function formatPercent(value: number, sign?: boolean, pad?: number): string;
4747
export function formatPercent(
4848
value: number,
49-
options: { sign?: boolean; pad?: number; color?: chalk.Chalk; } | boolean = {},
49+
options: { sign?: boolean; pad?: number; color?: Color; } | boolean = {},
5050
pad?: number,
5151
) {
5252
if (typeof options !== "object") options = { sign: options, pad };

ts-perf/packages/commands/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"@ts-perf/profiler": "workspace:^",
3232
"@typescript/server-harness": "^0.3.5",
3333
"@vscode/test-electron": "^2.5.2",
34-
"chalk": "^4.1.2",
34+
"picocolors": "^1.1.1",
3535
"iterable-query": "1.0.0-pre.16",
3636
"iterable-query-linq": "^0.1.0",
3737
"power-options": "^0.3.4",

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { EOL } from "node:os";
22
import { stripVTControlCharacters } from "node:util";
33

44
import { Range, TimeSpan } from "@ts-perf/api";
5-
import chalk from "chalk";
65
import { from } from "iterable-query";
6+
import pc from "picocolors";
77
import * as table_style from "table-style";
88
import { Size, TableColumnDefinition } from "table-style";
99
import {
@@ -206,7 +206,7 @@ export namespace Table {
206206
}).render(from(values).take(limit));
207207
if (limit < values.length) {
208208
let footer = `Only showing ${limit} of ${values.length} values returned.`;
209-
if (term.useColor) footer = chalk.gray(footer);
209+
if (term.useColor) footer = pc.gray(footer);
210210
output += footer + EOL;
211211
}
212212
return output;

ts-perf/packages/commands/src/analyze/model/profiler/bailoutView.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import chalk from "chalk";
1+
import pc from "picocolors";
22

33
import { Table } from "../../decorators";
44
import { CpuProfileFunctionView } from "./functionView";
@@ -10,7 +10,7 @@ import { CpuProfile } from "./profile";
1010
columns: [
1111
{
1212
header: "function",
13-
expression: x => `${x.functionName || "(anonymous function)"} ${chalk.gray(`(${x.location})`)}`,
13+
expression: x => `${x.functionName || "(anonymous function)"} ${pc.gray(`(${x.location})`)}`,
1414
},
1515
{ header: "count", expression: x => x.count, align: "right" },
1616
{ header: "reason", expression: x => x.reason },

ts-perf/packages/commands/src/analyze/model/profiler/categoryView.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { fmt, Range, TimeSpan } from "@ts-perf/api";
2-
import chalk from "chalk";
32
import { fn, from, Lazy } from "iterable-query";
3+
import pc from "picocolors";
44

55
import { Table } from "../../decorators";
66
import { Category } from "./category";
@@ -41,29 +41,27 @@ interface TableContext {
4141
`duration (selection): ${
4242
fmt.formatMilliseconds(ctx.selectionDuration)
4343
}, ${ctx.selectionHitCount} samples ${
44-
chalk.gray(`(${fmt.formatPercent(ctx.selectionHitPercent)} of total)`)
44+
pc.gray(`(${fmt.formatPercent(ctx.selectionHitPercent)} of total)`)
4545
}`,
4646
},
4747
],
4848
columns: [
4949
{
5050
header: "category",
5151
key: "path",
52-
expression: x => `${x.name}${x.parent ? ` ${chalk.gray(`(${x.parent.name})`)}` : ``}`,
52+
expression: x => `${x.name}${x.parent ? ` ${pc.gray(`(${x.parent.name})`)}` : ``}`,
5353
},
5454
{
5555
header: "self time",
5656
expression: x =>
57-
`${fmt.formatMilliseconds(x.selfTime)} ${
58-
fmt.formatPercent(x.selfPercent, { pad: 7, color: chalk.gray })
59-
}`,
57+
`${fmt.formatMilliseconds(x.selfTime)} ${fmt.formatPercent(x.selfPercent, { pad: 7, color: pc.gray })}`,
6058
align: "right",
6159
},
6260
{
6361
header: "total time",
6462
expression: x =>
6563
`${fmt.formatMilliseconds(x.totalTime)} ${
66-
fmt.formatPercent(x.totalPercent, { pad: 7, color: chalk.gray })
64+
fmt.formatPercent(x.totalPercent, { pad: 7, color: pc.gray })
6765
}`,
6866
align: "right",
6967
},

ts-perf/packages/commands/src/analyze/model/profiler/event.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { fmt, TimeSpan } from "@ts-perf/api";
2-
import chalk from "chalk";
32
import { from, Lazy } from "iterable-query";
3+
import pc from "picocolors";
44

55
import { Table } from "../../decorators";
66
import { CpuProfileEvents } from "./events";
@@ -21,7 +21,7 @@ interface TableContext {
2121
{ header: "event", key: "eventName" },
2222
{
2323
header: "total count",
24-
expression: x => `${x.hitCount} ${fmt.formatPercent(x.hitPercent, { pad: 7, color: chalk.gray })}`,
24+
expression: x => `${x.hitCount} ${fmt.formatPercent(x.hitPercent, { pad: 7, color: pc.gray })}`,
2525
align: "right",
2626
},
2727
],

ts-perf/packages/commands/src/analyze/model/profiler/eventView.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { fmt, TimeSpan } from "@ts-perf/api";
2-
import chalk from "chalk";
32
import { from, Lazy } from "iterable-query";
3+
import pc from "picocolors";
44

55
import { Table } from "../../decorators";
66
import { CpuProfileNode } from "./node";
@@ -40,7 +40,7 @@ interface TableContext {
4040
`duration (selection): ${
4141
fmt.formatMilliseconds(ctx.selectionDuration)
4242
}, ${ctx.selectionHitCount} samples ${
43-
chalk.gray(`(${fmt.formatPercent(ctx.selectionHitPercent)} of total)`)
43+
pc.gray(`(${fmt.formatPercent(ctx.selectionHitPercent)} of total)`)
4444
}`,
4545
},
4646
],
@@ -50,9 +50,7 @@ interface TableContext {
5050
{
5151
header: "self time",
5252
expression: x =>
53-
`${fmt.formatMilliseconds(x.selfTime)} ${
54-
fmt.formatPercent(x.selfPercent, { pad: 7, color: chalk.gray })
55-
}`,
53+
`${fmt.formatMilliseconds(x.selfTime)} ${fmt.formatPercent(x.selfPercent, { pad: 7, color: pc.gray })}`,
5654
align: "right",
5755
},
5856
],

ts-perf/packages/commands/src/analyze/model/profiler/fileView.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { fmt, Range, TimeSpan } from "@ts-perf/api";
2-
import chalk from "chalk";
32
import { fn, from, Lazy } from "iterable-query";
3+
import pc from "picocolors";
44

55
import { Table } from "../../decorators";
66
import { Category } from "./category";
@@ -41,7 +41,7 @@ interface TableContext {
4141
`duration (selection): ${
4242
fmt.formatMilliseconds(ctx.selectionDuration)
4343
}, ${ctx.selectionHitCount} samples ${
44-
chalk.gray(`(${fmt.formatPercent(ctx.selectionHitPercent)} of total)`)
44+
pc.gray(`(${fmt.formatPercent(ctx.selectionHitPercent)} of total)`)
4545
}`,
4646
},
4747
],
@@ -50,9 +50,7 @@ interface TableContext {
5050
{
5151
header: "self time",
5252
expression: x =>
53-
`${fmt.formatMilliseconds(x.selfTime)} ${
54-
fmt.formatPercent(x.selfPercent, { pad: 7, color: chalk.gray })
55-
}`,
53+
`${fmt.formatMilliseconds(x.selfTime)} ${fmt.formatPercent(x.selfPercent, { pad: 7, color: pc.gray })}`,
5654
align: "right",
5755
},
5856
{

0 commit comments

Comments
 (0)