Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.23 KB | None | 0 0
  1. function timer(time) {
  2. return new Promise((resolve, reject) => {
  3. setTimeout(reject, time);
  4. });
  5. }
  6.  
  7. Promise.race([
  8. timer(1000),
  9. otherPromise
  10. ])
  11. .then(() => {
  12. console.log('ok.');
  13. })
  14. .catch(() => {
  15. console.log('Time's up!');
  16. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement