Skip to content

Instantly share code, notes, and snippets.

@okabe-yuya
Created January 3, 2021 05:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save okabe-yuya/a6a96c5bacbc7b3fd3d1dfff63dd834e to your computer and use it in GitHub Desktop.
Save okabe-yuya/a6a96c5bacbc7b3fd3d1dfff63dd834e to your computer and use it in GitHub Desktop.
unawait interval
const sleep = (ms) => {
setTimeout(() => undefined, ms);
};
const intervalCount = (ms) => {
let counter = 0;
setInterval(() => {
console.log("[Info] count: ", counter)
counter++;
}, ms);
}
const main = () => {
const intervalMs = 3000;
console.log("start!!");
// 3秒毎にカウント
intervalCount(3000);
// 10カウントするまでwait
sleep(intervalMs * 10);
console.log("finish!!");
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment