Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

progress-estimator

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

progress-estimator

Animated progress bars with estimated durations

  • 0.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

progress-estimator

Logs a progress bar and estimation for how long a Promise will take to complete. This library tracks previous durations in order to provide more accurate estimates over time.

Demo

🎉 Become a sponsor or ☕ Buy me a coffee

Installation

# use npm
npm install progress-estimator

# use yarn
yarn add progress-estimator

Usage example

const createLogger = require('progress-estimator');
const { join } = require('path');

// All configuration keys are optional, but it's recommended to specify a storage location.
// Learn more about configuration options below.
const logger = createLogger({
  storagePath: join(__dirname, '.progress-estimator'),
});

async function run() {
  await logger(promiseOne, "This is a promise");
  await logger(
    promiseTwo,
    "This is another promise. I think it will take about 1 second",
    {
      estimate: 1000
    }
  );
}

API

createLogger(optionalConfiguration)

This method is the default package export. It creates and configures a logger function (documented below). The following configuration options are supported. (They apply only to the logger instance that's returned.)

nametypeDescription
logFunctionFunctionCustom logging function. Defaults to log-update. Must define .done() and .clear() methods.
spinnerobjectWhich spinner from the cli-spinners package to use. Defaults to dots.
storagePathstringWhere to record durations between runs. Defaults to os.tmpdir().
themeobjectCustom chalk theme. Look to the default theme for a list of required keys.

logger(promise, labelString, options)

This method logs a progress bar and estimated duration for a promise. It requires at least two parameters– a Promise and a label (e.g. "Running tests"). The label is SHA1 hashed in order to uniquely identify the promise.

An optional third parameter can be provided as well with the following keys:

nametypeDescription
estimateNumberEstimated duration of promise. (This value is used initially, until a history of actual durations have been recorded.)
idStringUniquely identifies the promise. This value is needed if the label string is not guaranteed to be unique.

Keywords

FAQs

Package last updated on 17 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc