Created
August 14, 2023 03:19
-
-
Save ahmedrowaihi/3f16f9b626162faa30aefc101a33f482 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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