Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

204
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda