# simple-eta

> Progressively determine the eta of a process out of the percentage reported.

Latest version **3.0.2** (published 2020-01-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install simple-eta
pnpm add simple-eta
yarn add simple-eta
bun add simple-eta
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.2 |
| Published | 2020-01-13 |
| First published | 2018-09-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Stefan-Gabriel Muscalu |
| Maintainers | stefangab95 |
| Keywords | simple, progress, eta, progress eta, progress-eta, estimate, estimated, time, estimated time, estimated-time |

## Links

- npm: https://www.npmjs.com/package/simple-eta
- Repository: https://github.com/legraphista/eta
- Homepage: https://github.com/legraphista/eta#readme
- Issues: https://github.com/legraphista/eta/issues
- npm.io page: https://npm.io/package/simple-eta

## Alternatives

- [@js-joda/timezone](https://npm.io/package/@js-joda/timezone.md) — 383.4K weekly downloads
- [chartjs-adapter-moment](https://npm.io/package/chartjs-adapter-moment.md) — 210.8K weekly downloads
- [strftime](https://npm.io/package/strftime.md) — 171.2K weekly downloads
- [vue-flatpickr-component](https://npm.io/package/vue-flatpickr-component.md) — 115.8K weekly downloads
- [timepicker](https://npm.io/package/timepicker.md) — 51.0K weekly downloads

## Recent versions

- 3.0.2 (latest) — 2020-01-13
- 3.0.1 — 2019-06-19
- 3.0.0 — 2019-04-23
- 2.0.3 — 2019-01-08
- 2.0.2 — 2019-01-07
- 2.0.1 — 2018-12-17
- 1.0.2 — 2018-12-17
- 2.0.0 — 2018-12-13
- 1.0.0 — 2018-09-01

## README

# Simple ETA
_Progressively determine the eta of a process out of the percentage reported._<br/>
_Everything is customizable, no need to define checkpoints or any other shenanigans_

# Install
```
npm i simple-eta
```

```javascript
const makeEta = require('simple-eta');

const eta = makeEta({ min: 0, max: 100 });

eta.start();
for (let progress = 1; progress <= 100; i += 1) {
  // Operation that takes time
  eta.report(progress);
  console.log(`Aprox. ${eta.estimate()} seconds left`);
}
```

## Constructor
- min `{number=0}` - define the lower limit of your interval
- max `{number=1}` - define the upper limit of your interval
- historyTimeConstant `{number=2.5}` - define (in seconds) how far into the past to consider data points as still relevant
    - `higher history value`: more time stable. spikes in progress speed will affect ETA less
    - `lower  history value`: more adaptive to changes. spikes in progress speed will affect ETA more
- autostart `{boolean=true}` - add the first history point when the class is instantiated or reset

## Methods

### `.start():void`
Add the first point to the history. Equivalent to `.report(min)`. <br/>
Automatically called if `autostart` is `true`.

### `.reset():void`
Resets the history of the ETA.

### `.report(number):void`
Report the progress within the defined interval, adding a point to the history.<br/>
Values outside the interval will produce false results.

### `.estimate():number`
Estimates the time left from the last `.report` call to complete the interval.<br/>
Time is returned in seconds. Returns `Infinity` when an ETA is not available.

### `.rate():number`
Gets the estimated progress speed (progress per second).

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