progress-estimator

Logs a progress bar and estimation for how long a Promise will take to complete

  • 所有者: bvaughn/progress-estimator
  • 平台:
  • 許可證:
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

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

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.), name, type, Description, ---, ---, ---, logFunction, Function, Custom logging function. Defaults to log-update. Must define .done() and .clear() methods., spinner, object, Which spinner from the cli-spinners package to use. Defaults to dots., storagePath, string, Where to record durations between runs. Defaults to os.tmpdir()., theme, object, Custom 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:, name, type, Description, ---, ---, ---, estimate, Number, Estimated duration of promise. (This value is used initially, until a history of actual durations have been recorded.), id, String, Uniquely identifies the promise. This value is needed if the label string is not guaranteed to be unique.

主要指標

概覽
名稱與所有者bvaughn/progress-estimator
主編程語言JavaScript
編程語言JavaScript (語言數: 2)
平台
許可證
所有者活动
創建於2018-11-24 21:01:38
推送於2023-04-17 19:08:07
最后一次提交2023-04-17 15:08:07
發布數1
最新版本名稱0.3.1 (發布於 2023-04-17 15:07:02)
第一版名稱0.3.1 (發布於 2023-04-17 15:07:02)
用户参与
星數2.1k
關注者數14
派生數49
提交數42
已啟用問題?
問題數11
打開的問題數0
拉請求數11
打開的拉請求數0
關閉的拉請求數3
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?