Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interruptBegin and interruptEnd methods #155

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ var timer = setInterval(function () {
}, 1000);
```

It's also possible to start and stop interrupts manually, allowing synchronous
logging between through the `interruptBegin` and `interruptEnd` methods:

```js
bar.interruptBegin();
console.log('message');
bar.interruptEnd();
```

You can see more examples in the `examples` folder.

## License
Expand Down
21 changes: 21 additions & 0 deletions lib/node-progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,27 @@ ProgressBar.prototype.interrupt = function (message) {
this.stream.write(this.lastDraw);
};

/**
* Begin a interrupt so the user can manually write messages above the bar.
*
* @api public
*/

ProgressBar.prototype.interruptBegin = function () {
this.stream.clearLine();
this.stream.cursorTo(0);
};

/**
* End a interrupt, rendering the last draw again.
*
* @api public
*/

ProgressBar.prototype.interruptEnd = function () {
this.stream.write(this.lastDraw);
};

/**
* Terminates a progress bar.
*
Expand Down