Created
November 22, 2019 11:47
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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