From 18435f58f82849dcc86ab2042491828b2873b39a Mon Sep 17 00:00:00 2001 From: Florrie Date: Fri, 5 Jan 2018 23:20:58 -0400 Subject: WIP(?) metadata processing tool --- src/general-util.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/general-util.js (limited to 'src/general-util.js') diff --git a/src/general-util.js b/src/general-util.js new file mode 100644 index 0000000..67f53e3 --- /dev/null +++ b/src/general-util.js @@ -0,0 +1,16 @@ +module.exports.showTrackProcessStatus = function( + total, doneCount, noLineBreak = false +) { + // Log a status line which tells how many tracks are processed and what + // percent is completed. (Uses non-specific language: it doesn't say + // "how many tracks downloaded" or "how many tracks processed", but + // rather, "how many tracks completed".) Pass noLineBreak = true to skip + // the \n character (you'll probably also want to log \r after). + + const percent = Math.trunc(doneCount / total * 10000) / 100 + process.stdout.write( + `\x1b[1m${percent}% completed ` + + `(${doneCount}/${total} tracks)\x1b[0m` + + (noLineBreak ? '' : '\n') + ) +} -- cgit 1.3.0-6-gf8a5