An open API service indexing awesome lists of open source software.

https://github.com/javierbyte/time-remaning-estimator

Estimate the remaining time for any process with known progress.
https://github.com/javierbyte/time-remaning-estimator

Last synced: 7 days ago
JSON representation

Estimate the remaining time for any process with known progress.

Awesome Lists containing this project

README

        

# Time Remaining Estimator.

Estimate the time remaining for any process with known progress (Exponentially Weighted Moving Average implementation).

# Usage

### Automatic Timestamp.
```js
const estimator = new TimeRemainingEstimator.auto({
maxValue: 100
})

onProgress(function(newProgressValue) {
/* once you register progress, you can add it to the estimate
* to improve estimation
*/
estimator.add({
value: newProgressValue
})

estimator.calculate()
// {finalDate: , remainingTime: }
})
```

### Absolute Timestamp.
```js
const estimator = new TimeRemainingEstimator.absolute({
maxValue: 100,
startTime: processStartDate
})

onProgress(function(newProgressValue) {
/* here you can add points at any time in any order
* new points with the same time will override previous ones
*/
estimator.add({
value: newProgressValue,
time: new Date()
})

estimator.calculate({
time: new Date()
})
// {finalDate: , remainingTime: }
})
```

### Functional Usage.
```
TimeRemainingEstimator.functional({
maxValue: 100,
startTime: ,
currentTime: ,
steps: [{
time: ,
value: 1
}, {
time: ,
value: 3
}, {
time: ,
value: 23
}, {
time: ,
value: 55
}]
})
// returns {finalDate: , remainingTime: }
```

## How it works.
Implementation of https://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average