Last active
April 12, 2021 18:51
-
-
Save gaurangrshah/4118fa0a066d79bf6c1e59f77635e610 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
export function handlePromises(promises = []) { | |
return Promise.all(promises) | |
.then((responses) => { | |
console.log('handlePromises Success', responses); | |
return responses; | |
}) | |
.catch((error) => | |
console.log( | |
`handlePromises Error ${JSON.stringify(error, null, 2)}` | |
) | |
); | |
} |
This file contains hidden or 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
function waitAtLeast (time, promise) { | |
const timeoutPromise = new Promise((resolve) => { | |
setTimeout(resolve, time) | |
}) | |
return Promise.all([promse, timeoutPromise]).then((values) => values[0]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment