Skip to content

JSDoc Documentation #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion multi-progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,34 @@

var ProgressBar = require("progress");

/**
* @typedef MultiProgress
* @property {(schema: string, options: ProgressBarOptions) => ProgressBar} newBar Create a new progressbar
* @property {() => void} terminate Terminate the progress bars
* @property {(index: number) => void} move Move the progress bars
* @property {(index: number, value: number, options?: any) => void} tick Tick a progres bar
* @property {(index: number, value: number, options?: any) => void} update Update a progress bar
* @property {boolean} isTTY
*/
/**
* @typedef ProgressBarOptions
* These are keys in the options object you can pass to the progress bar along with total as seen in the example above.
* @property {number} total Total number of ticks to complete.
* @property {number} [curr] current completed index
* @property {string} [head] head character defaulting to complete character
* @property {number} [width] The displayed width of the progress bar defaulting to total.
* @property {number} [renderThrottle] minimum time between updates in milliseconds defaulting to 16
* @property {NodeJS.WritableStream} [stream] The output stream defaulting to stderr.
* @property {string} [complete] Completion character defaulting to "=".
* @property {string} [incomplete] Incomplete character defaulting to "-".
* @property {boolean} [clear] Option to clear the bar on completion defaulting to false.
* @property {Function} [callback] Optional function to call when the progress bar completes.
*/


/**
* @type {MultiProgress}
*/
var emptyObj = {
newBar: function () {
return {
Expand All @@ -16,9 +44,15 @@ var emptyObj = {
move: function () {},
tick: function () {},
update: function () {},
isTTY: false,
isTTY: false
};

/**
* spawn an instance with the optional stream to write to
* (use of `new` is optional)
* @param {NodeJS.WriteStream} stream
* @returns {MultiProgress}
*/
function MultiProgress(stream) {
var multi = Object.create(MultiProgress.prototype);
multi.stream = stream || process.stderr;
Expand All @@ -34,6 +68,7 @@ function MultiProgress(stream) {
return multi;
}


MultiProgress.prototype = {
newBar: function(schema, options) {
options.stream = this.stream;
Expand Down