@serverless-devs/s-progress-bar
Version:
Serverless Devs Tool Core Component
78 lines (77 loc) • 2.19 kB
TypeScript
/// <reference types="node" />
export declare enum ProgressType {
Bar = 0,
Loading = 1
}
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 declare class ProgressService {
protected readonly type: ProgressType;
protected readonly options: ProgressBarOptions;
private bar;
private readonly progressType;
private backward;
/**
* @param type, Bar: a progress bar with total size known, Loading: a loading style with unknown total size
* @param format, format of progress bar
* @param options, options of progress bar, with type Loading, just set {width:50, total:100}
*/
constructor(type: ProgressType, options: ProgressBarOptions, format?: string);
private static initFormat;
private static initProgressBarOptions;
/**
* update progress status
* @param currentTransferred, when progress type is bar, increase progress ticks with
*/
update(currentTransferred?: number): void;
updateBarType(currentTransferred: number): void;
updateLoadingType(): void;
terminate(): void;
complete(): boolean;
curr(): number;
total(): number;
/**
* "interrupt" the progress bar and write a message above it.
*/
interrupt(message: string): void;
}