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

cnp-progress

v1.0.1

Published

Flexible node progress bar for Windows/macOS/Linux.

Downloads

14

Readme

cnp-progress

Flexible node progress bar for Windows/macOS/Linux

image

Installation

npm install cnp-progress

Quickstart

var { Progress } = require('cnp-progress');

var total = 50,
  count = 0;

var progress = Progress.create({ total: total });

var iv = setInterval(function () {
  count++;
  progress.update();
  if (count == total) {
    clearInterval(iv);
  }
}, 150);

API

create(options)

Creates and returns new progress bar.

update(current?: number, message?: string)

Updates progress.

done()

Finishes progress regardless of progress stage. Optional.

Options

Progress bar accepts the following options on initialisation:

  • total: number - Total number of items to process.
  • pattern: string - Optional layout pattern, defaults to 'Progress: {bar} | Elapsed: {elapsed} | {percent}'. See Patterns
  • textColor: string - Optional text color. See Colors
  • title: string - Optional title to display above progress bar.
  • updateFrequency: number - Optional update frequency limit in milliseconds. See Update frequency.
// with default options
var progress = Progress.create({ total: 50 });

// with pattern
var progress = Progress.create({
  total: 50,
  pattern: 'Progress: {bar} | Remaining: {remaining} | {percent} ',
});

//with pattern and text color
var progress = Progress.create({
  total: 50,
  pattern:
    'Progress: {current}/{total} | Remaining: {remaining} | Elapsed: {elapsed} ',
  textColor: 'blue',
});

//with default options and title
var progress = Progress.create({ total: 50, title: 'Waiting for results' });

Update frequency

When set limits progress bar update rate. Used to limit refresh rate for quickly running tasks.

In the example below progress bar will only update every 150 milliseconds instead of updating 1000 times every millisecond. This will reduce resource allocation to progress bar.

var { Progress } = require('cnp-progress');

var total = 1000,
  count = 0;

var progress = Progress.create({ total: total, updateFrequency: 150 });

var iv = setInterval(function () {
  count++;
  progress.update();
  if (count == total) {
    clearInterval(iv);
  }
}, 1);

Patterns

The following tokens are supported:

  • {bar} - progress bar.
  • {elapsed} - elapsed time in seconds.
  • {remaining} - estimated remaining time in seconds.
  • {percent} - completion percentage
  • {memory} - process memory usage in megabytes.
  • {current} - current item.
  • {total} - total items.
  • {message} - message for current update.

Token customisation

Tokens can be customised to define color for each token. Progress bar token accepts two colors for remaining/done items as well as length.

Usage for all tokens except progress bar:

  • {token.color}

Usage for progress bar:

  • {bar.color.color.length} - default is {bar.white.green.20}
var progress = Progress.create({
  total: 50,
  pattern:
    'Progress: {bar.white.red.10} | Remaining: {remaining.red} | {percent.blue}',
});

Colors

Progress bar uses charm to render elements and supports charm string colors:

  • red
  • yellow
  • green
  • blue
  • cyan
  • magenta
  • black
  • white