joewalnes/filtrex

Allow json params

arvigeus opened this issue · 2 comments

const expression = 'answer.index > 1 ? "Yes" : "No"';

const myfilter = filtrex(expression);

// Execute function
console.log(myfilter({ answer: { index: 2 } })); // returns "No"
m93a commented

Right now Filtrex takes . as a part of the identifier, so this would work:

console.log(myfilter({ 'answer.index': 2 })); // returns "Yes"

In my fork I've implemented an of operator – you'd use it like so:

const expression = 'index of answer > 1 ? "Yes" : "No"';

const myfilter = filtrex(expression);

// Execute function
console.log(myfilter({ answer: { index: 2 } })); // returns "Yes"
m93a commented

Version 1.0.0 that was published today on the official NPM supports the of operator, so you can use that. Would you please close this issue, I don't have moderator rights here 😅