Comments (8)
@jokeyrhyme So this was kind of a pain with gauge@1, but with the just released gauge@2 it's pretty easy... it'd be something like
var themes = require('gauge/themes')
var Gauge = require('gauge')
// Add the ability to include eta to all existing and future themes
themes.addToAllThemes({
eta: function (values, theme, width) {
// compute the eta here, in the example we just hard code it
// values.completed has the percent completion in it.
return 'eta 3m30s'
}
})
// add a new template that includes the eta
var etaTemplate = [
{type: 'progressbar', length: 20},
{type: 'eta', length: 9},
{type: 'activityIndicator', kerning: 1, length: 1},
{type: 'section', kerning: 1},
{type: 'subsection', kerning: 1}
]
var gauge = new Gauge(process.stderr, {template: etaTemplate})
I would be all for adding an eta
implementation to the base theme (adding it to the default template will require a little more tought, but I'm hesitantly for it).
from gauge.
@iarna thanks. I see if I can play with this soon. :)
from gauge.
@jokeyrhyme I updated the example to use the updated theme mixin support.
from gauge.
from gauge.
Thanks =)
I've fiddled a bit with adding ETA support and right now I'm seeing a lot more jitter in the estimates than I'd like, dejittering it requires some place for template functions to store state, which will require a bit of architectural fiddling, but it's on my mind.
from gauge.
Yeah, I've actually started wondering about a React renderer for the console. Not using blessed or ncurses, just something that renders (or re-renders) one line at a time for typical non-interactive console output. Then we could really treat everything on that line as a component, which might make things like progress bars and colours easier to manage. Hmmmm.....
from gauge.
My wip for this is over here:
https://github.com/iarna/gauge/tree/eta
from gauge.
It has render-template.js
half way converted to a class as template.js
. I'd like to finish that conversion before actually using that code.
It also has a pretty nice implementation of the eta
template item in https://github.com/iarna/gauge/blob/eta/eta.js
The jitter was easy enough to cleanup by just not updating the eta every tick (I, arbitrarily, chose once a second, and that feels a lot better).
themes.addToAllThemes({
'eta': function (values, theme, width) {
var eta = getEta(this)
var now = process.hrtime()
var sinceLast = elapsed(now, eta.last)
if (sinceLast >= 1 || !eta.remaining || eta.remaining < 1) {
var tillNow = elapsed(eta.last, eta.created)
var remaining = (tillNow / values.completed) - tillNow
eta.last = now
eta.remaining = remaining
}
return formatNumber(eta.remaining)
},
'elapsed': function (values, theme, width) {
var eta = getEta(this)
return formatNumber(elapsed(process.hrtime(), eta.created))
}
})
Originally I was using process.uptime()
and I'd probably go back to that, which means we can ditch the elapsed function.
from gauge.
Related Issues (20)
- New line before progress bar? HOT 6
- Disable if running in CI HOT 1
- Misspelling in Description, should be "gauge"
- Progress bar theme set to 'fallback' regardless of unicode locale on Fedora Linux HOT 5
- Make new release HOT 2
- npm does not store tarball URL in lockfile
- [BUG] Cannot find module 'object-assign' HOT 2
- [FEATURE] Dependencies should be updated to dedupe the tree for npm HOT 2
- [Question] Upgrade Dependencies to fix Vulnerability HOT 16
- [BUG] Themes no longer work from require
- Reporting a vulnerability HOT 1
- Image in readme is out of date!! HOT 1
- Help me bikeshed the gauge look HOT 15
- every time I use it, I expect show to pulse too HOT 1
- Display corruption on node 0.10/0.12 on Windows
- Progress bar not color with invert ansi/vt100 code in cmd.exe
- Temporary files on npm release HOT 4
- Am I using gauge wrong?
- MaxListenersExceededWarning HOT 4
- TypeError: Object.keys called on non-object HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gauge.