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

awesome-progress

v0.0.6

Published

Command-line progress bar and progress metrics. Helps you measure the 'pace' and erros during long-running scripts. Forked from https://github.com/cpsubrian/pace

Downloads

11

Readme

Pace

A node.js module that outputs a progress bar and other metrics to the command-line. It was originally conceived to help measure the 'pace' of long running scripts.

We've used it to optimize scripts that would have taken hours to complete down to minutes, without having to wait the hours before knowing that the script could use some optimization.

Screenshot with Error Feature

Note: This module is not longer maintained but you are welcome to PR or fork. You might want to check:

Installation

$ npm install pace

Example

Running the following code:

var total = 50000,
    count = 0,
    pace = require('pace')(total);

while (count++ < total) {
  pace.op();

  // Cause some work to be done.
  for (var i = 0; i < 1000000; i++) {
    count = count;
  }
}

Usage

Pace object

The module exports a factory function to generate instances of Pace objects. So require('pace')(<options>) creates an instance of Pace, passing options to the constructor.

Options

Options can either be an object literal, or an integer. If its an integer then it is the same as passing options with only the total specified.

require('pace')(100);

// Same as

require('pace')({total: 100});

Supported Options:

  • total - The total number of operations that YOUR script will execute.
  • maxBurden - The maximum 'burden' that the progress bar should incur. See more about burden below.
  • showBurden - Mostly for debugging. Show the current burden / skipped steps with the other metrics.
  • hideFinishMessage - Hides the message displayed when the progress bar finishes. Default: False
  • finishMessage - Pass a custom message to display when the progress bar finishes. Default: Finished!
  • errorMessage - Pass a custom message to display when a signal error has been passed.

pace.op([count])

Signal to pace that an operation was completed in your script by calling pace.op().

If you would rather track the progress in your own logic, you can call pace.op(<count>) where <count> is the current operation interation (for example step # 50 of a 100 step process).

pace.op({errors: count})

Signal to pace that an error has happened. This will automatically signal a normal count increase but will also increase the error counter shown under the progress bar. Note: The errors count can be passed to be more than one, however each error signal triggers one op() count.

pace.total

If your script has a dynamic amount of work to do (for example, depending on the results of previous operation there may be more steps to complete), you can freely change the value of pace.total. Just set the value like: pace.total = 200.

Burden

Depending on how intensive your operations are, calculating, formatting, and printing the progress bar might be much more expensive than the work you are doing. It would be silly if printing a progress bar caused your job to take significantly longer than it would have otherwise. Pace tracks a stat called 'burden', which is basically a percentage of the overall execution time that is being spent inside the progress bar logic itself.

The default maxBurden is 0.5, which translates to 0.5% of the total execution time. If this low burden is causing you to see progress reported less often than you would prefer, you can raise it to something like 20 (20%) via the maxBurden option.

Examples

The test/ folder contains some simple test scripts you can run to see the progress bar in action.

Common Issues

Multiple writes and wrong progress bar rendering

If you have multiple instances of pace running in various parts of your application, from the second run onwards you might notice that the progress bar is not rendered correctly with duplicate output. This effect is additive for each time pace is required with the same stream.

Cause: The problem is with pace dependency charm. In node.js 0.10 the EventEmitter constructor explicitly initializes this._events, so going Charm.prototype = new Stream; causes all Charm instances to share the same _events property.

Fix: Change the charm main module file index.js and replace Charm.prototype = new Stream; with Charm.prototype = Stream.prototype;

References: