{% macro section(data) %} {{ data.comments | toc }}
{% for name, comment in data.comments %} {{ comment | docEntry }} {% endfor %} {% endmacro %}
npm install @orioro/expression
Framework of expression interpreters.
Main modules: comparison
and object
const person = {
givenName: 'João',
middleName: 'Cruz',
familyName: 'Silva',
age: 32,
interests: ['sport', 'music', 'books'],
mother: {
givenName: 'Maria',
familyName: 'Cruz',
age: 57
},
father: {
givenName: 'Pedro',
familyName: 'Silva',
age: 56
}
}
const context = {
interpreters,
scope: { $$VALUE: person }
}
// Simple equality comparison
evaluate(context, ['$objectMatches', { givenName: 'João' }]) // true
evaluate(context, ['$objectMatches', { givenName: 'Maria' }]) // false
// Use dot (.) path notation to access nested properties
evaluate(context, ['$objectMatches', {
'mother.age': { $gte: 20, $lte: 50 },
'father.age': { $gte: 20, $lte: 50 }
}]) // false
TODO
TODO
// const context = {
// interpreters,
// scope: {
// $$VALUE: {
// name: 'João',
// interests: ['music', 'sports']
// age: 30
// }
// }
// }
// const cases = [
// [['$objectMatches', {
// interests: {
// $arrayIncludes: 'music'
// }
// }]]
// ]
Built-in expressions:
External expression modules:
{{ section(files['src/expressions/array.ts']) }}
{{ section(files['src/expressions/boolean.ts']) }}
{{ section(files['src/expressions/comparison.ts']) }}
{{ section(files['src/expressions/functional.ts']) }}
{{ section(files['src/expressions/logical.ts']) }}
{{ section(files['src/expressions/math.ts']) }}
{{ section(files['src/expressions/number.ts']) }}
{{ section(files['src/expressions/object.ts']) }}
{{ section(files['src/expressions/string.ts']) }}
{{ section(files['src/expressions/type.ts']) }}
{{ section(files['src/expressions/value.ts']) }}