| 7 | module.exports = class MultiBar extends _EventEmitter{ |
| 8 | |
| 9 | constructor(options, preset){ |
| 10 | super(); |
| 11 | |
| 12 | // list of bars |
| 13 | this.bars = []; |
| 14 | |
| 15 | // parse+store options |
| 16 | this.options = _options.parse(options, preset); |
| 17 | |
| 18 | // disable synchronous updates |
| 19 | this.options.synchronousUpdate = false; |
| 20 | |
| 21 | // store terminal instance |
| 22 | this.terminal = (this.options.terminal) ? this.options.terminal : new _Terminal(this.options.stream); |
| 23 | |
| 24 | // the update timer |
| 25 | this.timer = null; |
| 26 | |
| 27 | // progress bar active ? |
| 28 | this.isActive = false; |
| 29 | |
| 30 | // update interval |
| 31 | this.schedulingRate = (this.terminal.isTTY() ? this.options.throttleTime : this.options.notTTYSchedule); |
| 32 | |
| 33 | // logging output buffer |
| 34 | this.loggingBuffer = []; |
| 35 | |
| 36 | // callback used for gracefulExit |
| 37 | this.sigintCallback = null; |
| 38 | } |
| 39 | |
| 40 | // add a new bar to the stack |
| 41 | create(total, startValue, payload, barOptions={}){ |