From c4eb683020e880a78ef2a531f7af12c9f846f709 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Sat, 18 Nov 2017 18:26:51 +0100 Subject: [PATCH] tools: use built-in padStart instead of padString MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/17120 Reviewed-By: Timothy Gu Reviewed-By: Michaƫl Zasso Reviewed-By: Colin Ihrig Reviewed-By: Anatoli Papirovski Reviewed-By: Gireesh Punathil Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- tools/lint-js.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/tools/lint-js.js b/tools/lint-js.js index 5143aea0369112..202f0f062d5330 100644 --- a/tools/lint-js.js +++ b/tools/lint-js.js @@ -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}`; @@ -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