diff options
| author | Akshay Nair <phenax5@gmail.com> | 2022-01-07 17:51:12 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2022-01-07 17:52:33 +0530 |
| commit | b3fc08cae05f997e71d846109d400e630b8a4c35 (patch) | |
| tree | e3bf0ab1836aade74593123e978fe49b9a09b7df /src/utils.ts | |
| parent | ad8983655dc35b5401e810a9d4b61e933d35b783 (diff) | |
| download | elxr-b3fc08cae05f997e71d846109d400e630b8a4c35.tar.gz elxr-b3fc08cae05f997e71d846109d400e630b8a4c35.zip | |
feat: adds quantifier suffix parsing + recoverInput for combinators
Diffstat (limited to 'src/utils.ts')
| -rw-r--r-- | src/utils.ts | 5 |
1 files changed, 5 insertions, 0 deletions
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 = <T>(a: T) => (b: T): boolean => a === b + +export const match = + <R, K extends string>(pattern: { [key in K | '_']: () => R }) => + (k: K): R => + (pattern[k] || pattern._)() |
