mirror of
https://github.com/nodejs/node.git
synced 2025-05-15 17:51:35 +00:00

PR-URL: https://github.com/nodejs/node/pull/41065 Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
27 lines
412 B
JavaScript
27 lines
412 B
JavaScript
const log = require('./log-shim.js')
|
|
|
|
let pulseTimer = null
|
|
const withPromise = async (promise) => {
|
|
pulseStart()
|
|
try {
|
|
return await promise
|
|
} finally {
|
|
pulseStop()
|
|
}
|
|
}
|
|
|
|
const pulseStart = () => {
|
|
pulseTimer = pulseTimer || setInterval(() => {
|
|
log.gauge.pulse('')
|
|
}, 150)
|
|
}
|
|
|
|
const pulseStop = () => {
|
|
clearInterval(pulseTimer)
|
|
pulseTimer = null
|
|
}
|
|
|
|
module.exports = {
|
|
withPromise,
|
|
}
|