Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

195
Views
Array#find() acting different when I use async tag
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.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!