Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

207
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda