Created
April 28, 2016 20:08
-
-
Save p-chan/e9494d942f3680c8ff2bb48da1e759fa 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
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