Based on the discussion in #28, I decided to improve how the Permissive implementation is handled to allow users to better customize how the data detection is implemented.
I do realize that as I add these capabilities, we might be making it slightly more difficult to maintain a fully compatible cross-language json-logic ecosystem, however, I'm comfortable supporting some of these extensions as long as it is clear to folks that these behaviors might not translate to other libraries by other authors.
Anyway:
I've changed the engine implementation to allow a user to specify how "data" is detected in one's logic.
class DataEngine extends LogicEngine {
isData (logic, firstKey) {
if (Object.keys(logic).length > 1) return true
return !(firstKey in this.methods)
}
}
You can extend logic engine and implement an isData method to specify if an object embedded in the logic should be treated as data, rather than treating it as a command.
This should give developers full flexibility in how they believe this should work, as there will be different opinions:
"Could it work via attaching a symbol to the object?"
"Could it treat it as data if it has more than 1 key?"
"Could it treat it as data if the function isn't recognized?"
Based on the discussion in #28, I decided to improve how the Permissive implementation is handled to allow users to better customize how the data detection is implemented.
I do realize that as I add these capabilities, we might be making it slightly more difficult to maintain a fully compatible cross-language json-logic ecosystem, however, I'm comfortable supporting some of these extensions as long as it is clear to folks that these behaviors might not translate to other libraries by other authors.
Anyway:
I've changed the engine implementation to allow a user to specify how "data" is detected in one's logic.
You can extend logic engine and implement an
isData
method to specify if an object embedded in the logic should be treated as data, rather than treating it as a command.This should give developers full flexibility in how they believe this should work, as there will be different opinions:
Etc.