Last active
October 11, 2022 23:49
-
-
Save ajcrites/db1ab9ee6a1ad81c90c4ff74e708d9b2 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
deleteStaleSpecials() { | |
const specialsDeletionStatus = Promise.allSettled( | |
this.specials | |
.filter(({ stale }) => stale) | |
.map((special) => this.deleteSpecial(special)) | |
); | |
const rejectedCheckPredicate = ({ status }) => status === 'rejected'; | |
if (specialsDeletionStatus.some(rejectedCheckPredicate) { | |
throw new Error(`Failed to delete some stale specials: ${ | |
specialsDeletionStatus | |
.filter(rejectedCheckPredicate) | |
.reduce((rejectionMessages, { reason }) => rejectionStatusMessages + reason, '') | |
}`); | |
} | |
return specialsDeletionStatus; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment