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

111
Visualizações
Search nested JS object using object-scan lib to find grand parent elements

Using Object-Scan JS lib, want to find all the grand parent elements that have key "referenceField". Any help is much appreciated.

JS Fiddle Link

const find = (item, input) => objectScan(['**'], {
    abort: true,
    rtn: 'parent',
    filterFn: ({
      key
    }) => key === item.key
  })(input);

console.log(find('referenceField', data));

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Object-scan was somehow not returning grand parent using gparent option, but based on the assumption that your properties will always have the same nesting, you can take help of parents option and change your code to this-

const find = (item, input) => objectScan([`**.${item}`], {
    abort: true,
    rtn: 'parents'
})(input)[1];
about 4 years ago · Juan Pablo Isaza Relatório
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