Skip to content

Instantly share code, notes, and snippets.

@butackle
Created January 14, 2017 06:58
Show Gist options
  • Save butackle/8eb72b3359b046000062d3e79319591f to your computer and use it in GitHub Desktop.
Save butackle/8eb72b3359b046000062d3e79319591f to your computer and use it in GitHub Desktop.
const timeoutPromise = (sec, msg) => {
return new Promise((resolve, reject) => {
setTimeout(()=>{
console.log(msg);
resolve();
},sec)
});
}
timeoutPromise(4000,"4秒経過")
.then(() => timeoutPromise(3000,"7秒経過"))
.then(() => timeoutPromise(2000,"9秒経過"))
.then(() => timeoutPromise(1000,"10秒経過"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment