Skip to content

Instantly share code, notes, and snippets.

@ahmedrowaihi
Created August 14, 2023 03:19
Show Gist options
  • Save ahmedrowaihi/3f16f9b626162faa30aefc101a33f482 to your computer and use it in GitHub Desktop.
Save ahmedrowaihi/3f16f9b626162faa30aefc101a33f482 to your computer and use it in GitHub Desktop.
export function indecator() {
const spinner = ['-', '\\', '|', '/']
let i = 0
let interval
return {
stop(string) {
if (interval) clearInterval(interval)
if (string) process.stdout.write(`${string}\n`)
},
start(string) {
interval = setInterval(() => {
process.stdout.write(`\r${spinner[i++]} ${string}...`)
i &= 3
}, 100)
},
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment