0.3.1 • Published 12 months ago

progress-estimator v0.3.1

Weekly downloads
55,517
License
MIT
Repository
github
Last release
12 months ago

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.
@adbayb/terminal-kit@giveerr/rollpkgtsdx-extrayh-pagegql_din_mod@infinitebrahmanuniverse/nolb-progexport-tsbloombotexpand-react-bridgemagneum@everything-registry/sub-chunk-2478youtube-execytdl-exec@leijingdao/tsdxmuyuan-cli@dvaji/tsdx@eliteswap/token-lists@kesplus/cli@known-as-bmf/tscli@lgfe/ls-template-cli-rollup-script@laconic/rollup-script@juxtacode/rollup-plugin-showprogress@bezael-challenge/innoit-date-format@astrocoders/docz-coresurfwaxsushi-sdk-ftm@behzadebrhm/utilsforeach-tsdx@bhzdbash/utils@bkwld/lightkeeper@design-systems/create-command@deepakvishwakarma/node-claat@developertown/tsdx@donapot/mylibtesttsdxtsdx-esmtsdx-sassts3xtsdx-with-svgtsdx2tsdxwtsdyts-firebase-rules@abdulkaderptp/tsdxes-react-bridge@aw-web-design/tcm-clistub-citystub-villageuxci-cliutsdxttsdxts-lib-toolsgrids-over-polygon@cute-apocalypse/react-tree@cyriacbr/tsdxtnpm-bridgetestapa@chance/tsdx@chancethedev/cli@ambroseus/tsdxex-ikon-components-librarysmoothsmooth-core@carbon/cligenerate-project-cli@breakinferno/tsdxfdskcorenews-release@a4to/yt-cli@bluelovers/tsdx@commercelayer/commercelayer-seeder-clijuejin-savewebcheegg-psyduck-clirollibrollpkgrollup-builderrollup-plugin-showprogressdts-cli@cryptocode99/token-listscomponent-template-builder@maujzs/branch-release@massivepixel/use-query@meysam213/react-leaflet@percent/percent-api-hooks@qandq/plugins-common@prismify/tsdx@moln/tsdx@n3tr/tsdx@mr-huang/node-cli-utils@epigraph/epigraph-analytics@obstinate/rollup-script@pain-org/rollup@neuraiproject/chains@pureadmin/cli@projectbabelfish/defikingdoms-sdk@reslow/cli@techstack/tcm-cli@thinkincoin-libs/token-lists@therebel/docz-core
0.3.1

12 months ago

0.3.0

4 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago