diff options
Diffstat (limited to 'app/client/util/index.js')
| -rw-r--r-- | app/client/util/index.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/app/client/util/index.js b/app/client/util/index.js index 6ae1f64..75992d9 100644 --- a/app/client/util/index.js +++ b/app/client/util/index.js @@ -25,6 +25,19 @@ export function randrange(a,b){ return Math.random() * (b-a) + a } document.body.style.backgroundImage = 'linear-gradient(' + (randint(40)+40) + 'deg, #fde, #ffe)' +export const allProgress = (promises, progress_cb) => { + let d = 0; + progress_cb(0); + promises.forEach((p) => { + p.then((s) => { + d += 1 + progress_cb((d * 100) / promises.length, d, promises.length) + return s + }) + }) + return Promise.all(promises) +} + export function timeInSeconds(n){ return (n / 10).toFixed(1) + ' s.' } |
