0.0.1 • Published 2 years ago
estimator v0.0.1
estimator
Estimate the time left of a process easily, with only 5 lines.
Install
Add estimator
to your project by writing:
npm i estimator --save
or
yarn add estimator
Usage
Create a new instance of the Estimator class:
const Estimator = require("./index");
const session = new Estimator(true);
Insert estimator.began();
where your process begins.
Insert estimator.ended();
where your process ends.
Write estimator.estimate(count, left);
with the number of times the process will be run, and then number of times the process has run.
Example
Refer to this demo program for more information.
const Estimator = require("./index");
const session = new Estimator(true);
let index = 10;
let completed = 0;
setInterval(async () => {
if(completed < index) {
session.began();
await setTimeout(() => {
session.ended();
console.log(`${session.estimate(index, completed)} ms left`);
completed += 1;
}, 5000);
}
}, 2000);
Credits
License
Copyright (c) William Gibson. All rights reserved.
Licensed under the MIT License.