await members.sort((a, b) => new Date(a.joinedAt) - new Date(b.joinedAt)).find(member => {
const inCache = cache.get(member.playerID);
if (!inCache) cache.set(member.playerID, {
avatarID: member.avatarID,
name: member.name
});
if (member.joinedAt.startsWith(`${currentDate.year}-${currentDate.month}`)) {
if (!inCache) publicIds.set(member.playerID, {
avatarID: member.avatarID,
joinedAt: member.joinedAt
});
}
})
// ... other codes
Summary of code: I have two maps called cache and publicIds: cache is global variable and publicIds is local variable. This code block is in async function and everything works normal as it should be but when I add async tag to the member parameter in find function code starting to act different. For instance without async tag find function returns all data, with async tag function only returns 9 value I just wonder why this is happening and how can I avoid from that scenario?
What I want: I just want to make another async operation inside in find function. Right now await members.sort blocks the code which is cool but find function doesn't.