-
-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
Error occurs in node 14.x. process.stdout.clearLine and cursorTo not found ...
Fix: ProgressBar.js
class LoadingBar { constructor() { this.interval = 100; this.currentIndex = 0; this.fill = '█'; this.empty = '⣿'; this.bar_length = 50; this.loop = null; this.flip = 1; this.chunksDownloaded = "0"; this.isRunning = false; this.success = ' √'; this.failed = ' X'; this.message = ''; this.messageSize = 0; } reset() { this.constructor(); } next() { this.clear(); this.currentIndex += this.flip; if (this.currentIndex === this.bar_length || this.currentIndex === 0) { this.flip *= -1; } let _left = this.currentIndex - 1; _left = _left < 0 ? 0 : _left; let _right = this.bar_length - _left - 1; const _str = `${this.message}${this.chunksDownloaded} :` + chalk.green(` ${this.empty.repeat(_left)}${this.fill}${this.empty.repeat(_right)}`); this.messageSize = _str.length; process.stdout.write(_str); } clear() { if ('undefined'!=typeof(process.stdout.clearLine)) { //@ts-ignore process.stdout.clearLine(); //@ts-ignore process.stdout.cursorTo(0); } else { if (this.currentIndex>0) process.stdout.write('\b'.repeat(this.messageSize)); } } . . . .
Metadata
Metadata
Assignees
Labels
No labels