| 43 | |
| 44 | |
| 45 | function Example2(onComplete){ |
| 46 | // EXAMPLE 2 --------------------------------------------- |
| 47 | console.log('\nExample 2 - Custom configuration'); |
| 48 | |
| 49 | // create new progress bar using default values |
| 50 | const b2 = new _progress.Bar({ |
| 51 | barCompleteChar: '#', |
| 52 | barIncompleteChar: '_', |
| 53 | format: ' |- Current Upload Progress: {percentage}%' + ' - ' + '||{bar}||', |
| 54 | fps: 5, |
| 55 | stream: process.stdout, |
| 56 | barsize: 30 |
| 57 | }); |
| 58 | b2.start(100, 0); |
| 59 | |
| 60 | // 50ms update rate |
| 61 | const timer = setInterval(function(){ |
| 62 | // increment value |
| 63 | b2.increment(); |
| 64 | |
| 65 | // set limit |
| 66 | if (b2.value >= b2.getTotal()){ |
| 67 | // stop timer |
| 68 | clearInterval(timer); |
| 69 | |
| 70 | b2.stop(); |
| 71 | |
| 72 | // run complete callback |
| 73 | onComplete.apply(this); |
| 74 | } |
| 75 | }, 50); |
| 76 | } |
| 77 | |
| 78 | function Example3(onComplete){ |
| 79 | // EXAMPLE 3 --------------------------------------------- |