(percent: number, width: number)
| 23 | * Draws a coloured bar of specified width |
| 24 | */ |
| 25 | export const bar = (percent: number, width: number): string => { |
| 26 | const partials = ['▏', '▎', '▍', '▌', '▋', '▊', '▉']; |
| 27 | let ticks = percent * width; |
| 28 | if (ticks < 0) { |
| 29 | ticks = 0; |
| 30 | } |
| 31 | let filled = Math.floor(ticks); |
| 32 | let open = width - filled; |
| 33 | |
| 34 | return ( |
| 35 | (percentToColor(percent) + '▉').repeat(filled) + |
| 36 | partials[Math.floor((ticks - filled) * partials.length)] + |
| 37 | ' '.repeat(open) |
| 38 | ); |
| 39 | }; |
| 40 | |
| 41 | /** |
| 42 | * Draws a spinner and a message that is updated on success or failure |
no test coverage detected