diff options
| author | Akshay Nair <phenax5@gmail.com> | 2022-01-10 21:44:58 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2022-01-10 21:44:58 +0530 |
| commit | 724b7d23486f462a4310588419d02f4f072ef74f (patch) | |
| tree | b7685dc1be0fd2d4c5b22fb4e03cb212b69d4f09 /src/eval/index.ts | |
| parent | 20339806fdb2a0b396146e77ed1b4e568c244bbe (diff) | |
| download | elxr-724b7d23486f462a4310588419d02f4f072ef74f.tar.gz elxr-724b7d23486f462a4310588419d02f4f072ef74f.zip | |
fix: fixes property matching + test changes
Diffstat (limited to 'src/eval/index.ts')
| -rw-r--r-- | src/eval/index.ts | 9 |
1 files changed, 5 insertions, 4 deletions
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 = <T>( 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 = <T>( (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 = <T>( 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 = <T>( //console.log(matches) return pipe( matches.length > 0 ? [group(matches, index)] : [], - next(matches.length || 1), + next(matches.length), ) }, |
