Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function timer(time) {
- return new Promise((resolve, reject) => {
- setTimeout(reject, time);
- });
- }
- Promise.race([
- timer(1000),
- otherPromise
- ])
- .then(() => {
- console.log('ok.');
- })
- .catch(() => {
- console.log('Time's up!');
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement