@gofreddo/eta
v1.1.1
Published
Calcutates estimated time remaining(ETA) estimated finish time and percent complete for large processes.
Downloads
10
Readme
gofreddo
Calcutates estimated time remaining(ETA) estimated finish time and percent complete for large processes.
Install
Install with npm
$ npm i @gofreddo/eta --save
Usage
const Eta = require('@gofreddo/eta');
const eta = new Eta({
total: 10,
});
eta.on('tick', (result) => {
console.log(`tick = ${JSON.stringify(result, null, 2)}`);
});
eta.on('finished', (result) => {
console.log(`finished = ${JSON.stringify(result, null, 2)}`);
});
const handle = setInterval(() => {
const result = eta.tick();
console.log(JSON.stringify(result, null, 2));
if (eta.count === 10) {
clearInterval(handle);
}
}, 1000);
tick = {
"startTime": "2017-01-30T00:10:48.387Z",
"eta": "2017-01-30T00:10:58.437Z",
"secondsRemaining": 0,
"percentComplete": 1,
"count": 10,
"total": 10,
"timeTo": "a few seconds ago",
"finishedAt": "2017-01-30T00:10:58.437Z"
}
finished = {
"startTime": "2017-01-30T00:10:48.387Z",
"eta": "2017-01-30T00:10:58.437Z",
"secondsRemaining": 0,
"percentComplete": 1,
"count": 10,
"total": 10,
"timeTo": "a few seconds ago",
"finishedAt": "2017-01-30T00:10:58.437Z"
}
Running tests
Install dev dependencies:
$ npm i -d && npm test
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Author
Jeff Wilde
License
Copyright © 2017 [Jeff Wilde](#Jeff Wilde) Licensed under the MIT license.
This file was generated by readme-generator on January 29, 2017.