From bf639c0eb723e6657acaf92c77b0b890c371e2b3 Mon Sep 17 00:00:00 2001 From: Sean O'Brien Date: Fri, 15 Dec 2017 17:04:06 -0500 Subject: [PATCH] Added missing interrupt function signature to ProgressBar class. --- types/progress/index.d.ts | 9 ++++++--- types/progress/progress-tests.ts | 13 +++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/types/progress/index.d.ts b/types/progress/index.d.ts index 1989ebbed8..74596c4c13 100644 --- a/types/progress/index.d.ts +++ b/types/progress/index.d.ts @@ -120,14 +120,17 @@ declare class ProgressBar { * overall completion to. */ update(ratio: number, tokens?: any): void; - + + /** + * "interrupt" the progress bar and write a message above it. + */ + interrupt(message: string): void; /** * Terminates a progress bar. - */ + */ terminate(): void; - /** * Completed status of progress (Boolean) */ diff --git a/types/progress/progress-tests.ts b/types/progress/progress-tests.ts index 12774e7183..561f226b64 100644 --- a/types/progress/progress-tests.ts +++ b/types/progress/progress-tests.ts @@ -27,3 +27,16 @@ bar.tick(2, { 'token1': "Goodbye", 'token2': "World!" }); + +/** + * Interrupt example from https://github.com/visionmedia/node-progress + */ +var bar = new ProgressBar(':bar :current/:total', { total: 10 }); +var timer = setInterval(function () { + bar.tick(); + if (bar.complete) { + clearInterval(timer); + } else if (bar.curr === 5) { + bar.interrupt('this message appears above the progress bar\ncurrent progress is ' + bar.curr + '/' + bar.total); + } +}, 1000); \ No newline at end of file