JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2196
  • Score
    100M100P100Q108398F
  • License MIT

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

Package Exports

  • simple-eta

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (simple-eta) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Simple ETA

Progressively determine the eta of a process out of the percentage reported.
Everything is customizable, no need to define checkpoints or any other shenanigans

Install

npm i simple-eta
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
  • history {number=100} - define how many points of historical data to use
    • higher history value: more accurate and time stable
    • lower history value: more adaptive and less memory
  • 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).
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.
Values outside the interval will produce false results.

.estimate():number

Estimates the time left from the last .report call to complete the interval.
Time is returned in seconds. Returns Infinity when an ETA is not available.