aboutsummaryrefslogtreecommitdiff
path: root/src/eval/index.ts
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2022-01-13 17:58:36 +0530
committerAkshay Nair <phenax5@gmail.com>2022-01-13 17:59:03 +0530
commite26086fef3cf142cffd145836a4c7c12cfeb9656 (patch)
tree3db5cbe208ac30b9281599fa61dbe6c910fe4163 /src/eval/index.ts
parent1a281a717fe5bab2694bf51c1b03a7569d8facb4 (diff)
downloadelxr-e26086fef3cf142cffd145836a4c7c12cfeb9656.tar.gz
elxr-e26086fef3cf142cffd145836a4c7c12cfeb9656.zip
refactor: propertymatch changed to use single expression (group)
Diffstat (limited to 'src/eval/index.ts')
-rw-r--r--src/eval/index.ts8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/eval/index.ts b/src/eval/index.ts
index 075ff81..0579579 100644
--- a/src/eval/index.ts
+++ b/src/eval/index.ts
@@ -82,10 +82,10 @@ const checkExpr = <T>(
)
},
- PropertyMatch: ({ name, exprs }) =>
+ PropertyMatch: ({ name, expr }) =>
pipe(
Object.prototype.hasOwnProperty.call(item ?? {}, name)
- ? checkExpr(Expr.Group({ exprs }), item[name], list, index)
+ ? checkExpr(expr, item[name], list, index)
: [],
res => (res.length > 0 ? [group(item, index)] : []), // FIXME: doesn't allow nested matching
skip(1),
@@ -146,8 +146,8 @@ export const find = <T>([startO, exprs, endO]: ListExpr, list: T[]): any => {
Truthy: _ => !!x,
Falsey: _ => !x,
Group: ({ exprs }) => exprs.every(e => check(e)(x, i, ls)),
- PropertyMatch: ({ name, exprs }) =>
- name in x && exprs.every(e => check(e)(x[name], i, ls)),
+ PropertyMatch: ({ name, expr }) =>
+ name in x && check(expr)(x[name], i, ls),
OneOrMore: ({ expr }) => {
// TODO: Nested quantified expression
const x = pipe(