# progress-estimator

> Animated progress bars with estimated durations

Latest version **0.3.1** (published 2023-04-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install progress-estimator
pnpm add progress-estimator
yarn add progress-estimator
bun add progress-estimator
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2023-04-17 |
| First published | 2018-11-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 13 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2128 |
| Author | Brian Vaughn |
| Maintainers | brianvaughn |
| Keywords | ascii, busy, cli, console, duration, idle, indicator, list, loading, progress, promise, task, term, terminal, timing, unicode, wait |

## Links

- npm: https://www.npmjs.com/package/progress-estimator
- Repository: https://github.com/bvaughn/progress-estimator
- Homepage: https://github.com/bvaughn/progress-estimator#readme
- Issues: https://github.com/bvaughn/progress-estimator/issues
- npm.io page: https://npm.io/package/progress-estimator

## Dependencies (4)

- [chalk](https://npm.io/package/chalk.md) ^2.4.1
- [log-update](https://npm.io/package/log-update.md) ^2.3.0
- [cli-spinners](https://npm.io/package/cli-spinners.md) ^1.3.1
- [humanize-duration](https://npm.io/package/humanize-duration.md) ^3.15.3

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 0.3.1 (latest) — 2023-04-17
- 0.3.0 — 2020-07-07
- 0.2.2 — 2018-11-26
- 0.2.1 — 2018-11-26
- 0.2.0 — 2018-11-26
- 0.1.3 — 2018-11-26
- 0.1.2 — 2018-11-26
- 0.1.1 — 2018-11-24
- 0.1.0 — 2018-11-24

## README

# 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](https://user-images.githubusercontent.com/29597/48986949-474e2400-f0cf-11e8-86d7-d201f8ad8eca.gif)

### 🎉 [Become a sponsor](https://github.com/sponsors/bvaughn/) or ☕ [Buy me a coffee](http://givebrian.coffee/)

## Installation

```shell
# use npm
npm install progress-estimator

# use yarn
yarn add progress-estimator
```

## Usage example

```js
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`](https://npmjs.com/package/log-update). Must define `.done()` and `.clear()` methods. |
| `spinner` | object | Which spinner from the [`cli-spinners`](https://npmjs.com/package/cli-spinners) package to use. Defaults to `dots`. |
| `storagePath` | string | Where to record durations between runs. Defaults to [`os.tmpdir()`](https://nodejs.org/api/os.html). |
| `theme` | object | Custom [`chalk`](https://npmjs.com/package/chalk) theme. Look to the [default theme](https://github.com/bvaughn/progress-estimator/blob/master/src/theme.js) 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. |

---
_Source: https://npm.io/package/progress-estimator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
