i have a huge collection of data 700+ items in, and i want to filter by dynamic array of objects, lets say that user has typed ode and my script should search on every filter without i do something like filter.code == store.code
const hugeData = [{name:"store 1",code : "code 1", available : false},{name : "store 2",code : "simple_code",available : true},{name : "sto 3",code : "has no cde",available : true}...]
const filters = [{ code : "ode", name : "re" }]
the result that im expecting is
// output
[{name : "store 1", code : "code 1", available : false},{name : "store 2",code : "simple_code",available : true}]
i resolved this doing the following with lodash, but function is very slow, and code is poor, is there any other way that i can do this works?
const results = []
_.map(hugeData, store => {
_.map(filters, tag => {
Object.keys(tag).map(tagOb => {
if (store[tagOb] && store[tagOb].includes(tag[tagOb])) {
results.push(store);
}
});
});
});
filtersjust be a single object of key value pairs? why would it need to be in an array?ode?