Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

Commit

Permalink
check size is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
fent committed Nov 23, 2014
1 parent 916e8da commit 0e67ef1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions example/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ var pos = 0;
video.on('data', function(data) {
pos += data.length;
// `size` should not be 0 here.
var percent = (pos / size * 100).toFixed(2);
process.stdout.cursorTo(0);
process.stdout.clearLine(1);
process.stdout.write(percent + '%');
if (size) {
var percent = (pos / size * 100).toFixed(2);
process.stdout.cursorTo(0);
process.stdout.clearLine(1);
process.stdout.write(percent + '%');
}
});

video.on('end', function() {
Expand Down

0 comments on commit 0e67ef1

Please sign in to comment.