need to use async inside reduce function js code example
Example: async reduce javascript
const getNonSemverPatchPRs = async () => {
const allOpenPrs = await getAllOpenPRs();
return allOpenPrs.reduce(async (previousPromise, pr) => {
const collection = await previousPromise;
const allCommits = await getAllCommitsForaPR(pr.number);
const isNotSemverPatchPR = checkCommitMessageForPatch(allCommits[0]);
if (isNotSemverPatchPR) {
collection.push(pr);
}
return collection;
}, Promise.resolve([]));
};