Skip to content

Commit ea22b7b

Browse files
committed
perf: use text-table for less package size (#22)
1 parent 883a0dc commit ea22b7b

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"log-update": "^2.3.0",
4949
"pretty-time": "^1.1.0",
5050
"std-env": "^2.0.2",
51-
"table": "^5.1.0"
51+
"text-table": "^5.1.0"
5252
},
5353
"devDependencies": {
5454
"@commitlint/cli": "^7.2.1",

src/utils.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import path from 'path';
22

33
import chalk from 'chalk';
44
import figures from 'figures';
5-
import { table } from 'table';
5+
import textTable from 'text-table';
66
import prettyTime from 'pretty-time';
77

88
import getDescription from './description';
@@ -101,13 +101,19 @@ export const formatRequest = (request) => {
101101
return `${loaders}${NEXT}${request.file}`;
102102
};
103103

104+
function createTable(data) {
105+
return textTable(data, {
106+
align: data[0].map(() => 'l'),
107+
}).replace(/\n/g, '\n\n');
108+
}
109+
104110
export const formatStats = (allStats) => {
105111
const lines = [];
106112

107113
Object.keys(allStats).forEach((category) => {
108114
const stats = allStats[category];
109115

110-
lines.push(`Stats by ${chalk.bold(startCase(category))}`);
116+
lines.push(`> Stats by ${chalk.bold(startCase(category))}`);
111117

112118
let totalRequests = 0;
113119
const totalTime = [0, 0];
@@ -139,10 +145,10 @@ export const formatStats = (allStats) => {
139145

140146
data.push(['Total', totalRequests, prettyTime(totalTime), '', '']);
141147

142-
lines.push(table(data));
148+
lines.push(createTable(data));
143149
});
144150

145-
return lines.join('\n\n');
151+
return `${lines.join('\n\n')}\n`;
146152
};
147153

148154
export function ellipsis(str, n) {

0 commit comments

Comments
 (0)