Skip to content

Instantly share code, notes, and snippets.

@p-chan
Created April 28, 2016 20:08
Show Gist options
  • Save p-chan/e9494d942f3680c8ff2bb48da1e759fa to your computer and use it in GitHub Desktop.
Save p-chan/e9494d942f3680c8ff2bb48da1e759fa to your computer and use it in GitHub Desktop.
const one = (msg) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log('1');
resolve();
}, 2000);
});
}
const sec = () => {
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log('2');
resolve();
}, 1000);
});
}
Promise.resolve()
.then(() => {
return one();
})
.then(() => {
return sec();
})
.then(() => {
process.exit(0);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment