i will try to explain this my best.
I have a data array from many many registers to work on
I have a configuration object, that object have this structure
{ "source": "original", "hof": "${0} && ${1} && ${2} && (${3} || (${4} && ${5} && ${6} && ${7} && ${8}))", "filters": { "0": { "path": "lead.consent", "fn": "exists", "toCompare": true }, "1": { "path": "metadata.employee", "fn": "exists", "toCompare": true }, "2": { "path": "metadata.employee.eligibilityStatus", "fn": "eq", "toCompare": "ELIGIBLE" } } }
Inside filters object every "fn" key is a function to apply, every call of those functions will return a boolean value.
So. You can think at HOF like a query to apply to filter the data
The question
Is there any way to do like
data.filter(d=>{
//HERE transform the hof into if statements
})
Example
HOF-> "${0} && ${2}"
data.filter(d => {
//0 is in the objectFilters[0].fn -> nameOfTheFunction -> exist
//2 is in the objectFilters[2].fn-> nameOfTheFunction -> eq
return (exist(d) && eq(d))
})
Thank you VERY much!