From b3fc08cae05f997e71d846109d400e630b8a4c35 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Fri, 7 Jan 2022 17:51:12 +0530 Subject: feat: adds quantifier suffix parsing + recoverInput for combinators --- src/utils.ts | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/utils.ts') diff --git a/src/utils.ts b/src/utils.ts index e7392bf..9c4c97b 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -2,3 +2,8 @@ export const eq = (a: T) => (b: T): boolean => a === b + +export const match = + (pattern: { [key in K | '_']: () => R }) => + (k: K): R => + (pattern[k] || pattern._)() -- cgit v1.3.1