Skip to content

Commit

Permalink
Fix: log wrapper for arrays doesnt log properly
Browse files Browse the repository at this point in the history
  • Loading branch information
lvancraen committed Jun 21, 2019
1 parent c0d5bf4 commit 7961e12
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion helpers/logging_iterator_wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ module.exports = (prefix, valueByKey, iteratee) => {
numberOfKeysDone += 1;

if (Date.now() - lastLogAt > interval && process.env.TEST === undefined) {
const percentageDone = (numberOfKeysDone / valueByKey.size) * 100;
let percentageDone;
if (valueByKey instanceof Array) {
percentageDone = (numberOfKeysDone / valueByKey.length) * 100;
} else {
percentageDone = (numberOfKeysDone / valueByKey.size) * 100;
}

infoLog(`[${prefix}] ${percentageDone.toPrecision(2)}% done`);

lastLogAt = Date.now();
Expand Down

0 comments on commit 7961e12

Please sign in to comment.