From 724b7d23486f462a4310588419d02f4f072ef74f Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Mon, 10 Jan 2022 21:44:58 +0530 Subject: fix: fixes property matching + test changes --- src/eval/index.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/eval/index.ts') diff --git a/src/eval/index.ts b/src/eval/index.ts index 23832de..f1d6eae 100644 --- a/src/eval/index.ts +++ b/src/eval/index.ts @@ -39,7 +39,7 @@ export const matchAll = ( const next = (i: number = 1) => (curMatch: MatchGroupIndexed[]) => - [...curMatch, ...check(index + i, ls.slice(i), expr)] + [...curMatch, ...check(index + (i || 1), ls.slice(i), expr)] return pipe( expr, @@ -59,11 +59,11 @@ export const matchAll = ( (acc, exp) => pipe( acc, - chain(m => + chain(_m => pipe( check(index, [item], exp), res => res.length === 0 ? none : some(res), - map(ac => [...ac, ...m]), + map(ac => ac), // TODO: Doesn't seem right? ), ), ), @@ -78,6 +78,7 @@ export const matchAll = ( Object.prototype.hasOwnProperty.call(item, name) ? check(index, [item[name]], Expr.Group({ exprs })) : [], + res => res.length > 0 ? [group(item, index)] : [], // FIXME: doesn't allow nested matching next(), ), @@ -91,7 +92,7 @@ export const matchAll = ( //console.log(matches) return pipe( matches.length > 0 ? [group(matches, index)] : [], - next(matches.length || 1), + next(matches.length), ) }, -- cgit v1.3.1