Created
September 13, 2022 05:11
-
-
Save monjer/408d1f37842e6a8b848503ba541a39eb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const progress = async (flag = '=') => { | |
const sleep = (timeout) => { | |
return new Promise((resovle) => { setTimeout(resovle, timeout) }); | |
} | |
const total = 100; | |
for (let j = 1; j <= total; j++) { | |
process.stdout.write(`\u001b[${10000}D`); | |
await sleep(50); | |
let start = ''; | |
let end = ''; | |
for (let i = 0; i < j; i++) { | |
start += `${flag}`; | |
} | |
for (let i = 0; i < total - j; i++) { | |
end += ' ' | |
} | |
process.stdout.write(`[\u001b[32m${start}\u001b[0m${end}] ${j}%`); | |
} | |
process.stdout.write(`\n`); | |
} | |
progress('-'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment