You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 line
572B

  1. var assert = require('assert');
  2. module.exports = function clear(opts) {
  3. if (typeof (opts) === 'boolean') {
  4. opts = {
  5. fullClear: opts
  6. };
  7. }
  8. opts = opts || {};
  9. assert(typeof (opts) === 'object', 'opts must be an object');
  10. opts.fullClear = opts.hasOwnProperty('fullClear') ?
  11. opts.fullClear : true;
  12. assert(typeof (opts.fullClear) === 'boolean',
  13. 'opts.fullClear must be a boolean');
  14. if (opts.fullClear === true) {
  15. process.stdout.write('\x1b[2J');
  16. }
  17. process.stdout.write('\x1b[0f');
  18. };