Skip to content

Instantly share code, notes, and snippets.

@BrunoGiubilei
Created November 22, 2019 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrunoGiubilei/89f1f5b687ed9c10ac85597aa1f3903f to your computer and use it in GitHub Desktop.
Save BrunoGiubilei/89f1f5b687ed9c10ac85597aa1f3903f to your computer and use it in GitHub Desktop.
Filtrar dentro de um array de objetos por qualquer propriedade e retornar um array com os indices do array inicial
items.filter(function(reg, i) {
reg.index = i;
return Object.values(reg).find(function(prop) {
return prop !== null && prop.toString().normalize('NFD').replace(/[\u0300-\u036f]/g, "").toUpperCase().indexOf(query.toUpperCase()) >= 0;
}) !== undefined;
}).map(function(reg) {return reg.index});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment