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

multi-progress-bars

v5.0.3

Published

Multiple progress bars with option for indefinite spinners

Downloads

25,669

Readme

multi-progress-bars

npm shield node shield

A node utility written in Typescript for displaying multiple progress bars, and preserving logged output. The progress bars can be anchored to the top or bottom of the terminal, with border options and indefinite progress display. A Promise will resolve when all tasks are done. This utility is enabled by a simple virtual console that intercepts the normal console. See the below demo .gifs.


Anchoring to the top. Notice how the logs are preserved:

MultiProgressBar top demo


Anchoring to the bottom:

MultiProgressBar bottom demo


Showing off borders customizability and overflow management:

MultiProgressBar extended demo

Install

npm install multi-progress-bars or yarn add multi-progress-bars

Quickstart

import { MultiProgressBars } from 'multi-progress-bars';
import * as chalk from 'chalk';

// Initialize mpb
const mpb = new MultiProgressBars({
    initMessage: ' $ Example Fullstack Build ',
    anchor: 'top',
    persist: true,
    border: true,
});

// Add tasks
mpb.addTask('Webpack Backend', { type: 'percentage', barColorFn: chalk.yellow });
mpb.addTask('Watcher', { type: 'indefinite', message: 'Watching for changes...' });

// Update tasks
mpb.updateTask('Webpack Backend', { percentage: 0.2 });
mpb.incrementTask('Webpack Backend', { percentage: 0.1 });

// Console logging is overridden and tracked with an interval buffer
console.log('Warning!');

setTimeout(() => { mpb.done('Webpack Backend', { message: 'Build finished.' })}, 5000);
setTimeout(() => { mpb.done('Watcher', { message: 'Build finished.' })}, 1000);

// Wait for all tasks to finish
await mpb.promise;
console.log('Finish');

See the Documentation for more information.

Version Changes

:warning: v4 -> v5 has breaking changes.

  • Library now defaults to ESM. Dependencies on chalk and related libraries are now updated to the latest, which default to ESM.
  • For building, node needs to be >14.18 because of Rollup 3

:warning: v3 -> v4 has breaking changes.

User-Facing Changes:

  • barColorFn is now barTransformFn, and a new property nameTransformFn has been added to transform task names appearance.
  • Number of progress bars displayed will be truncated to terminal height (accounting for borders)
  • Upon exiting, will dump the full untruncated list of progress bars if the above was true.
  • API added for removing tasks, with option to shift up the tasks or leave a blank line.
  • API added for getting the index of a specific task, or getting the name of a task given the index.
  • Extra border options in constructor as well as API to set or remove headers and footers.
  • Bottom-anchored progress bars now has bottom border if border is set to true in the constructor.

:warning: v2 -> v3 technically has breaking changes in behavior nuance, but should be backwards-compatible. The changes are the addition of anchor position, border, and persist. If you pass in true for persist, you should call mpb.close() when you are done, or on SIGINT for example. Multi-line init messages are now clamped to the first line.

Documentation

Hilbert Spinner

Included in this library is a (imo) cool Hilbert Curve / Space-Filling Curve spinner. It uses the Braille dots to do a little snake that crawls throughout the bar. There is probably a more efficient way to code the crawling, as this uses sort of an 'implicit' approach, instead of an 'explicit', which might require less calculation.

License

MIT

Like this utility? Support my hobby!

PayPal donation link