* Ends the progress bar and cleans up any lose ends. * * @example Usage * ```ts ignore * import { ProgressBar } from "@std/cli/unstable-progress-bar"; * * const progressBar = new ProgressBar({ max: 100 }); * await progressBar.stop() * ```
()
| 294 | * ``` |
| 295 | */ |
| 296 | async stop(): Promise<void> { |
| 297 | clearInterval(this.#id); |
| 298 | try { |
| 299 | if (this.#clear) { |
| 300 | await this.#writer.write(LINE_CLEAR); |
| 301 | } else { |
| 302 | await this.#print(); |
| 303 | await this.#writer.write("\n"); |
| 304 | } |
| 305 | await this.#writer.close(); |
| 306 | await this.#pipePromise; |
| 307 | } catch { |
| 308 | // ignore |
| 309 | } |
| 310 | } |
| 311 | } |