Skip to content

Commit

Permalink
fix: avoid overflow error when computing overall progress
Browse files Browse the repository at this point in the history
  • Loading branch information
black-puppydog committed Jul 13, 2024
1 parent 18ce13a commit d90e73b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion db.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ module.exports = function db (dir, keys, opts) {
var c = db.views[name].since.value
current += (Number.isInteger(c) ? c : -1)
}
prog.current = ~~(current / n)
// we use Math.floor to avoid overflow errors
prog.current = Math.floor(current / n)
// if the progress bar is complete, move the starting point
// up to the current position!
if (prog.start <= 0) {
Expand Down

0 comments on commit d90e73b

Please sign in to comment.