MCPcopy Create free account
hub / github.com/npkgz/cli-progress / create

Method create

lib/multi-bar.js:41–87  ·  view source on GitHub ↗
(total, startValue, payload, barOptions={})

Source from the content-addressed store, hash-verified

39
40 // add a new bar to the stack
41 create(total, startValue, payload, barOptions={}){
42 // create new bar element
43 const bar = new _BarElement(Object.assign({}, this.options, barOptions));
44
45 // store bar
46 this.bars.push(bar);
47
48 // progress updates are only visible in TTY mode!
49 if (this.options.noTTYOutput === false && this.terminal.isTTY() === false){
50 return bar;
51 }
52
53 // add handler to restore cursor settings (stop the bar) on SIGINT/SIGTERM ?
54 if (this.sigintCallback === null && this.options.gracefulExit){
55 this.sigintCallback = this.stop.bind(this);
56 process.once('SIGINT', this.sigintCallback);
57 process.once('SIGTERM', this.sigintCallback);
58 }
59
60 // multiprogress already active ?
61 if (!this.isActive){
62 // hide the cursor ?
63 if (this.options.hideCursor === true){
64 this.terminal.cursor(false);
65 }
66
67 // disable line wrapping ?
68 if (this.options.linewrap === false){
69 this.terminal.lineWrapping(false);
70 }
71
72 // initialize update timer
73 this.timer = setTimeout(this.update.bind(this), this.schedulingRate);
74 }
75
76 // set flag
77 this.isActive = true;
78
79 // start progress bar
80 bar.start(total, startValue, payload);
81
82 // trigger event
83 this.emit('start');
84
85 // return new instance
86 return bar;
87 }
88
89 // remove a bar from the stack
90 remove(bar){

Callers 3

runMultibarFunction · 0.95
example-logging.jsFile · 0.80

Calls 4

isTTYMethod · 0.80
cursorMethod · 0.80
lineWrappingMethod · 0.80
startMethod · 0.45

Tested by

no test coverage detected