Gathering detailed insights and metrics for super-progress
Gathering detailed insights and metrics for super-progress
Gathering detailed insights and metrics for super-progress
Gathering detailed insights and metrics for super-progress
@babel/plugin-transform-object-super
Compile ES2015 object super to ES5
toastify-react-native
🎉 toastify-react-native allows you to add notifications to your react-native app (ios, android) with ease. No more nonsense!
request-progress
Tracks the download progress of a request made with mikeal/request, giving insight of various metrics including progress percent, download speed and time remaining
cli-progress
easy to use progress-bar for command-line/terminal applications
npm install super-progress
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
3 Stars
41 Commits
2 Watching
1 Branches
1 Contributors
Updated on 04 Mar 2023
TypeScript (98.62%)
JavaScript (1.38%)
Cumulative downloads
Total Downloads
Last day
0%
52
Compared to previous day
Last week
-19.5%
157
Compared to previous week
Last month
-25.8%
588
Compared to previous month
Last year
2,884.3%
6,476
Compared to previous year
2
Super progress bar is a CLI progress bar.
npm i -S super-progress
1import { Progress } from 'super-progress'; 2import { clearInterval } from 'timers'; 3import { EOL } from 'os'; 4 5const pb = Progress.create(process.stdout.columns - 1); 6 7let t = setInterval(() => { 8 pb.tick() 9 .then(() => { 10 if (pb.state.percentComplete >= 1.0) { 11 clearInterval(t); 12 process.stdout.write(EOL); 13 } 14 }) 15}, 100);
1const Progress = require('super-progress').Progress; 2// or 3const { Progress } = require('super-progress'); 4 5/* Same as above */
Super Progress Bar now includes support for streams. An instance will also act as a Transform stream operating in object mode. It emits arrays of strings (the same as the output from the render function).
1import { Progress, ConsoleAdapter } from 'super-progress'; 2 3const StreamTest = require('streamtest'); 4 5StreamTest['v2'].fromObjects(' '.repeat(100).split(''), 100) 6.pipe(Progress.create(process.stdout.columns! - 1)) 7.pipe(new ConsoleAdapter(1000)) 8.pipe(process.stdout);
Super Progress Bar accepts a pattern string that contains tokens that represent the different fields that can be output in the progress bar.
1// Default pattern string 2let pb = Progress.create( 3 width, 4 { 5 pattern: `[{spinner}] {bar} | Elapsed: {elapsed} | {percent}` 6 } 7);
It also accepts a set of custom token definitions that define the various tokens in the pattern string as well as how to render each token.
1// Example token definition 2{ 3 percent: { 4 render: (state: ProgressState, allowed: number): string => { 5 return (state.percentComplete * 100).toFixed(2) + '%'; 6 }, 7 width: () => 7 8 } 9}
Each token is specified within the pattern string by its key, surrounded by curly braces (ex. {bar}
). If a custom token has the same key as a default token, the default token is replaced.
Each token definition is composed of three parts:
Multiple instances of the same token are allowed in the pattern string.
The progress bar rendering function uses a two-pass process to render the whole bar.
On the first pass, each token is queried for its rendered width. If a token returns a -1 instead of a width, this indicates that the token is variable-width and will use the space allotted to it by the render function.
On the second pass, all of the widths of the known-width tokens and 'literal' characters (characters that are not a part of any known token) in the pattern string are added together and subtracted from the space available in the console. The amount left over (if any) is then divided evenly across all of the tokens that returned a -1 on the first pass. Every token's render function is then called with the current state of the progress bar and the allowed width per unknown-width token as arguments. The return value of each render function is then inserted in place of the token's placeholder(s) in the pattern string.
This can be passed to Progress.create() to customize the layout, token definitions, and capacity of the progress bar
1interface ProgressOptions { 2 total?: number; 3 pattern?: string; 4 renderInterval?: number; 5}
The capacity of the progress bar
The pattern string specifying where the tokens are to be inserted. Each token can be used as many times as needed.
For example:
'{spinner}--{spinner} {indeterminate} {bar} {indeterminate} {spinner}--{spinner}'
yields
The minimum amount of time (in ms) to wait between frames. This only applies if you use the display method provided in the Progress class.
This contains the current state of the progress bar. It can be saved and reused to restore the progress bar's state at a later time (for example, if the current process has to be interrupted).
1interface ProgressState { 2 startTime: number; 3 elapsedTime: number; 4 remainingTime: number; 5 nextRender: number; 6 7 percentComplete: number; 8 rateTicks: number; 9 currentTicks: number; 10 totalTicks: number; 11 ticksLeft: number; 12}
The time at which the progress bar was created, in the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC.
The amount of time (in ms) that has passed since the progress bar was created.
The estimated amount of time (in ms) remaining in the process.
The time at which the next render should take place. This only applies if you use the display method provided in the Progress class.
The amount of the process that has completed, as a percentage.
The rate of tick completion, calculated as ticks per millisecond.
The current number of ticks that have been completed.
The total number of ticks in the whole process (as provided to the Progress class constructor).
The total number of ticks that remain in the process.
Contains the definitions of the tokens in the progress bar.
1interface ProgressTokenDefinitions { 2 'key': { 3 render: (state: ProgressState, allowed: number) => string; 4 width: (state: ProgressState) => number; 5 } 6 . . . 7}
The string that, when surrounded by curly braces {}
and inserted into the pattern string, acts as the placeholder for the rendered content of the token.
The function that renders the token output. The current state and the space allowance are given as inputs.
This function indicates how much space the token will take up (in characters) when rendered. A return of -1 indicates that the token will take up as much space as is available to it.
Main class that represents the progress bar
1export class Progress { 2 public static create(width: number, options?: ProgressOptions, tokens?: ProgressTokenDefinitions, state?: ProgressState): Progress 3 public async display(rendered: string[], stream: Writable): Promise<void> 4 public async update(ticks: number = 1): Promise<void> 5 public async complete(): Promise<void> 6 public async render(): Promise<string[]> 7}
Creates a new Progress object using the specified parameters. The line width must be specified.
Default parameters:
1options = { 2 total: 100, 3 pattern: `[{spinner}] {bar} | Elapsed: {elapsed} | {percent}`, 4 renderInterval: 33 5} 6 7tokens = { 8 // the bar token displays a bar showing how much of a process has 9 // completed. It takes up as much space as the layout engine will 10 // allow. This is specified by returning -1 in the width function. 11 bar: {/*...*/}, 12 13 // the elapsed token displays the amount time that has elapsed since 14 // the beginning of the process. It is displayed in hh:mm:ss.sss format. 15 // Since we know the exact width of the desired output, we return it 16 // in the width function. 17 elapsed: {/*...*/}, 18 19 // the percent token displays the amount of the process that has been 20 // completed as a percentage. It shows 2 decimal places of precision. 21 percent: {/*...*/}, 22 23 // The spinner token simply displays an ascii 'wheel' that constantly 24 // spins as the process is occurring. 25 spinner: {/*...*/} 26} 27 28state = { 29 elapsedTime: 0, 30 remainingTime: 0, 31 percentComplete: 0, 32 currentTicks: 0, 33 rateTicks: 0, 34 nextRender: 0, 35 startTime: Date.now(), 36 totalTicks: 100, // or the value supplied in options, if supplied 37 ticksLeft: 100, // or the value supplied in options, if supplied 38}
This helper function updates, renders and outputs the progress bar on the given stream.
Displays the strings in rendered on the provided stream. Each entry in the array represents a line. This function joins the array with os.EOL, writes it to the stream and repositions the cursor to the beginning of the line on which it started.
Updates the state of the progress bar by the specified number of ticks.
Call this when the process is complete; it works like update.
Renders the progress bar in its current state. The width specified on progress bar creation controls how wide each output string is when rendered.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/26 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
68 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More