segundo commit

This commit is contained in:
root 2025-11-06 19:19:45 +00:00
parent 6b8b75863a
commit d2e79d63a5
13601 changed files with 1117197 additions and 0 deletions

47
node_modules/ssb-server/lib/progress.js generated vendored Normal file
View file

@ -0,0 +1,47 @@
//poll the progress() function and report how much waiting there is...
//just whipped this up, obviously room for improvement here.
module.exports = function (progress) {
function bar (r) {
var s = '\r', M = 50
for(var i = 0; i < M; i++)
s += i < M*r ? '*' : '.'
return s
}
function round (n, p) {
return Math.round(n * p) / p
}
function percent (n) {
return (round(n, 1000)*100).toString().substring(0, 4)+'%'
}
function rate (prog) {
if(prog.target == prog.current) return 1
return (prog.current - prog.start) / (prog.target - prog.start)
}
var prog = -1
var int = setInterval(function () {
var p = progress()
var r = 1, c = 0
var tasks = []
for(var k in p) {
var _r = rate(p[k])
if(_r < 1)
tasks.push(k+':'+percent(_r))
r = Math.min(_r, r)
c++
}
if(r != prog) {
prog = r
var msg = tasks.join(', ')
process.stdout.write('\r'+bar(prog) + ' ('+msg+')\x1b[K\r')
}
}, 333)
int.unref && int.unref()
}