diff --git a/types/multi-progress/index.d.ts b/types/multi-progress/index.d.ts
index db15a15b1b..31dd11b710 100644
--- a/types/multi-progress/index.d.ts
+++ b/types/multi-progress/index.d.ts
@@ -5,10 +5,14 @@
///
-import ProgressBar, { ProgressBarOptions } from 'progress';
+import * as ProgressBar from 'progress';
import { Stream } from 'stream';
-export default class MultiProgress {
+export as namespace MultiProgress;
+
+export = MultiProgress;
+
+declare class MultiProgress {
/**
* Create a new @see MultiProgress with the given stream, or stderr by default
* @param stream A stream to write the progress bars to
@@ -18,7 +22,7 @@ export default class MultiProgress {
/**
* Add a new bar
*/
- newBar: (format: string, options: ProgressBarOptions) => ProgressBar;
+ newBar: (format: string, options: ProgressBar.ProgressBarOptions) => ProgressBar;
/**
* Close all bars
@@ -40,3 +44,5 @@ export default class MultiProgress {
*/
update: (index: number, value: number, options?: any) => void;
}
+
+declare namespace MultiProgress {}
diff --git a/types/multi-progress/multi-progress-tests.ts b/types/multi-progress/multi-progress-tests.ts
index 9dde27c16b..b14806b7c5 100644
--- a/types/multi-progress/multi-progress-tests.ts
+++ b/types/multi-progress/multi-progress-tests.ts
@@ -3,7 +3,7 @@
*/
// require the library
-import MultiProgress from 'multi-progress';
+import * as MultiProgress from 'multi-progress';
// spawn an instance with the optional stream to write to
// use of `new` is optional
diff --git a/types/progress/index.d.ts b/types/progress/index.d.ts
index 6f6e2ea33d..c1e199ec6c 100644
--- a/types/progress/index.d.ts
+++ b/types/progress/index.d.ts
@@ -1,67 +1,13 @@
-// Type definitions for node-progress v2.0.0
-// Project: https://github.com/tj/node-progress
+// Type definitions for node-progress 2.0
+// Project: https://github.com/visionmedia/node-progress
// Definitions by: Sebastian Lenz
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
///
+export as namespace ProgressBar;
-
-/**
- * These are keys in the options object you can pass to the progress bar along with total as seen in the example above.
- */
-export interface ProgressBarOptions {
- /**
- * Total number of ticks to complete.
- */
- total: number;
-
- /**
- * current completed index
- */
- curr?: number;
-
- /**
- * head character defaulting to complete character
- */
- head?: string;
-
- /**
- * The displayed width of the progress bar defaulting to total.
- */
- width?: number;
-
- /**
- * minimum time between updates in milliseconds defaulting to 16
- */
- renderThrottle?: number;
-
- /**
- * The output stream defaulting to stderr.
- */
- stream?: NodeJS.WritableStream;
-
- /**
- * Completion character defaulting to "=".
- */
- complete?: string;
-
- /**
- * Incomplete character defaulting to "-".
- */
- incomplete?: string;
-
- /**
- * Option to clear the bar on completion defaulting to false.
- */
- clear?: boolean;
-
- /**
- * Optional function to call when the progress bar completes.
- */
- callback?: Function;
-}
-
+export = ProgressBar;
/**
* Flexible ascii progress bar.
@@ -90,7 +36,7 @@ declare class ProgressBar {
* - `:eta` eta in seconds
*/
constructor(format: string, total: number);
- constructor(format: string, options: ProgressBarOptions);
+ constructor(format: string, options: ProgressBar.ProgressBarOptions);
/**
@@ -135,7 +81,71 @@ declare class ProgressBar {
* Completed status of progress (Boolean)
*/
complete: boolean;
-}
-declare namespace ProgressBar { }
-export default ProgressBar;
+ /**
+ * Current tick number.
+ */
+ curr: number;
+
+ /**
+ * Total number of ticks to complete.
+ */
+ total: number;
+}
+
+declare namespace ProgressBar {
+ /**
+ * These are keys in the options object you can pass to the progress bar along with total as seen in the example above.
+ */
+ interface ProgressBarOptions {
+ /**
+ * Total number of ticks to complete.
+ */
+ total: number;
+
+ /**
+ * current completed index
+ */
+ curr?: number;
+
+ /**
+ * head character defaulting to complete character
+ */
+ head?: string;
+
+ /**
+ * The displayed width of the progress bar defaulting to total.
+ */
+ width?: number;
+
+ /**
+ * minimum time between updates in milliseconds defaulting to 16
+ */
+ renderThrottle?: number;
+
+ /**
+ * The output stream defaulting to stderr.
+ */
+ stream?: NodeJS.WritableStream;
+
+ /**
+ * Completion character defaulting to "=".
+ */
+ complete?: string;
+
+ /**
+ * Incomplete character defaulting to "-".
+ */
+ incomplete?: string;
+
+ /**
+ * Option to clear the bar on completion defaulting to false.
+ */
+ clear?: boolean;
+
+ /**
+ * Optional function to call when the progress bar completes.
+ */
+ callback?: Function;
+ }
+}
diff --git a/types/progress/progress-tests.ts b/types/progress/progress-tests.ts
index 561f226b64..d93eb9bc3f 100644
--- a/types/progress/progress-tests.ts
+++ b/types/progress/progress-tests.ts
@@ -1,42 +1,48 @@
-var ProgressBar = require('progress');
+import * as ProgressBar from 'progress';
/**
- * Usage example from https://github.com/tj/node-progress
+ * Usage example from https://github.com/visionmedia/node-progress
+ * (in Typescript)
*/
-var bar = new ProgressBar(':bar', { total: 10 });
-var timer = setInterval(function () {
- bar.tick();
- if (bar.complete) {
+const usageBar = new ProgressBar(':bar', { total: 10 });
+const timer = setInterval(function () {
+ usageBar.tick();
+ if (usageBar.complete) {
console.log('\ncomplete\n');
clearInterval(timer);
}
}, 100);
-
/**
- * Custom token example from https://github.com/tj/node-progress
+ * Custom token example from https://github.com/visionmedia/node-progress
+ * (in Typescript)
*/
-var bar = new ProgressBar(':current: :token1 :token2', { total: 3 });
-
-bar.tick({
- 'token1': "Hello",
- 'token2': "World!\n"
-});
-
-bar.tick(2, {
- 'token1': "Goodbye",
- 'token2': "World!"
-});
+ const list = [
+ 'image01.jpg', 'image02.jpg', 'image03.jpg', 'image04.jpg', 'image05.jpg',
+ 'image06.jpg', 'image07.jpg', 'image08.jpg', 'image09.jpg', 'image10.jpg'
+ ];
+ const customTokenBar = new ProgressBar(':percent eta: :eta downloading :current/:total :file', {
+ total: list.length
+ });
+ const customInterval = setInterval(function (){
+ customTokenBar.tick({
+ 'file': list[customTokenBar.curr]
+ })
+ if (customTokenBar.complete) {
+ clearInterval(customInterval)
+ }
+ }, 500)
/**
* Interrupt example from https://github.com/visionmedia/node-progress
+ * (in Typescript)
*/
-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);
+const interruptBar = new ProgressBar(':bar :current/:total', { total: 10 });
+const interruptTimer = setInterval(function () {
+ interruptBar.tick();
+ if (interruptBar.complete) {
+ clearInterval(interruptTimer);
+ } else if (interruptBar.curr === 5 || interruptBar.curr === 8) {
+ interruptBar.interrupt('interrupt: current progress is ' + interruptBar.curr + '/' + interruptBar.total);
}
-}, 1000);
\ No newline at end of file
+}, 1000);