Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: use built-in padStart instead of padString #17120

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions tools/lint-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,12 @@ if (cluster.isMaster) {

// Calculate and format the data for displaying
const elapsed = process.hrtime(startTime)[0];
const mins = padString(Math.floor(elapsed / 60), 2, '0');
const secs = padString(elapsed % 60, 2, '0');
const passed = padString(successes, 6, ' ');
const failed = padString(failures, 6, ' ');
const mins = `${Math.floor(elapsed / 60)}`.padStart(2, '0');
const secs = `${elapsed % 60}`.padStart(2, '0');
const passed = `${successes}`.padStart(6);
const failed = `${failures}`.padStart(6);
var pct = Math.ceil(((totalPaths - paths.length) / totalPaths) * 100);
pct = padString(pct, 3, ' ');
pct = `${pct}`.padStart(3);

var line = `[${mins}:${secs}|%${pct}|+${passed}|-${failed}]: ${curPath}`;

Expand All @@ -233,13 +233,6 @@ if (cluster.isMaster) {

outFn(line);
}

function padString(str, len, chr) {
str = `${str}`;
if (str.length >= len)
return str;
return chr.repeat(len - str.length) + str;
}
} else {
// Worker

Expand Down