xref: /third_party/node/deps/npm/lib/utils/pulse-till-done.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/deps/npm/lib/utils/
11cb0ef41Sopenharmony_ciconst log = require('./log-shim.js')
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_cilet pulseTimer = null
41cb0ef41Sopenharmony_ciconst withPromise = async (promise) => {
51cb0ef41Sopenharmony_ci  pulseStart()
61cb0ef41Sopenharmony_ci  try {
71cb0ef41Sopenharmony_ci    return await promise
81cb0ef41Sopenharmony_ci  } finally {
91cb0ef41Sopenharmony_ci    pulseStop()
101cb0ef41Sopenharmony_ci  }
111cb0ef41Sopenharmony_ci}
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ciconst pulseStart = () => {
141cb0ef41Sopenharmony_ci  pulseTimer = pulseTimer || setInterval(() => {
151cb0ef41Sopenharmony_ci    log.gauge.pulse('')
161cb0ef41Sopenharmony_ci  }, 150)
171cb0ef41Sopenharmony_ci}
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ciconst pulseStop = () => {
201cb0ef41Sopenharmony_ci  clearInterval(pulseTimer)
211cb0ef41Sopenharmony_ci  pulseTimer = null
221cb0ef41Sopenharmony_ci}
231cb0ef41Sopenharmony_ci
241cb0ef41Sopenharmony_cimodule.exports = {
251cb0ef41Sopenharmony_ci  withPromise,
261cb0ef41Sopenharmony_ci}
27

Indexes created Thu Nov 07 10:32:03 CST 2024