npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

progresser

v1.0.3

Published

A simple yet intuitive progress bar for your terminal.

Downloads

7

Readme

Progresser

A simple yet intuitive progress bar.

Cover Image

CodeFactor

Progresser

Install with NPM:

npm i progresser
const { Progresser } = require('progresser');
const chalk = require('chalk');

let timer = null;
const bar = new Progresser(
  `Progress Bar: {bar} {spinner} {current}${chalk.gray(chalk.bold('/'))}{size} {percent}%`,
  {},
  () => {
    clearInterval(timer);
    console.log(chalk.blueBright(chalk.bold('Done!')));
  },
);

timer = setInterval(() => {
  if (bar.current === 10) {
    bar.interrupt('This is an example of an interruption.');
  }
  if (bar.current === 15) {
    bar.interrupt('Another example of an interruption!');
  }
  bar.tick();
}, 100);

Format

new Progresser(>format<, options, callback)

Progresser requires a format for the the progress bar. The format has tokens that are replaced with information.

  • {bar} - Is replaced with the actual progress bar.
  • {current} - Is replaced with the current tick number.
  • {size} - Is replaced with the size or total number of ticks.
  • {percent} - Is replaced with the percent of the bar completed.
  • {spinner} - If spinner is enable, then it is replaced with a spinner.

Options

new Progresser(format, >options<, callback)

These are options that can be enabled by passing an object in the second argument.

  • size - The size of the progress bar. Defaults to 20.
  • current - The amount of completed ticks in the progress bar. Defaults to 0.
  • spinner - Whether or not to enable the spinner. Defaults to true.
  • spinnerStyle - The style of the spinner. Defaults to dots.
  • stream - Which stream you want the progress bar to be. Defaults to process.stderr.
  • colored - Whether or not if you want the ticks in the progress bar to be colored. Defaults to true.
  • colors - The colors to use if the progress bar has colored enabled.
    • complete - The color for the completed tick. Defaults to chalk.blueBright.
    • incomplete - The color for the incomplete tick. Defaults to chalk.gray.
  • chars - The characters to use for different parts of the progress bar.
    • prefix - The character in front of the progress bar. Defaults to [.
    • suffix - The character at the end of the progress bar. Defaults to ].
    • complete - The character to use for completed ticks. Defaults to #.
    • incomplete - The character to use for incomplete ticks. Defaults to -.

Callback

new Progresser(format, options, >callback<)

The function that will be run run once the progress bar is complete.

Progresser.tick()

new Progresser(format, options, callback).tick(messageFormat)

A function which completes one tick of the progress bar. The format of the text after the progress bar can be changed with messageFormat.

Progresser.interrupt()

new Progresser(format, options, callback).interrupt(message)

A function which interrupts the progress bar and sends a message.

Progresser.terminate()

new Progresser(format, options, callback).terminate()

A function which ends the progress bar.

Spinner

new Spinner(style, stream, onProgressBar)

Along with a progress bar, progresser comes with a spinner.

Style

new Spinner(>style<, stream, onProgressBar)

The style of spinner. The available styles are listed here.

Style

new Spinner(style, >stream<, onProgressBar)

The stream in which the spinner will occur.

OnProgressBar

new Spinner(style, stream, >onProgressBar<)

An internal argument which is used to detect if the spinner is in a progress bar.

Spinner.insert()

new Spinner(style, stream, onProgressBar).insert(format)

Insert the spinner into a string and write it into the stream.

Spinner.insert() Format

new Spinner(style, stream, onProgressBar).insert(>format<)

The spinner also has tokens.

  • {spinner} - Is replaced with the spinner.

Spinner.spin()

new Spinner(style, stream, onProgressBar).spin()

Spin the spinner once. Used internally, so does not need to be called.

Spinner.current()

new Spinner(style, stream, onProgressBar).current()

Get the current spin state. Used internally for progress bar, so does not need to be called.

Spinner.terminate()

new Spinner(style, stream, onProgressBar).terminate()

Terminate the spinner.

License

MIT