bvaughn / progress-estimator
- вторник, 27 ноября 2018 г. в 00:15:49
JavaScript
Logs a progress bar and estimation for how long a Promise will take to complete
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.
const createLogger = require('progress-estimator');
// 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
}
);
}
The following values are configurable via the named configure
export. Note that all configuration is stored at the package level.
name | type | Description |
---|---|---|
logFunction |
Function | Custom logging function. Defaults to log-update . Must define .done() and .clear() methods. |
spinner |
object | Which spinner from the cli-spinners package to use. Defaults to dots . |
storagePath |
string | Where to record durations between runs. Defaults to os.tmpdir() . |
theme |
object | Custom chalk theme. Look to the default theme for a list of required keys. |