aboutsummaryrefslogtreecommitdiff
path: root/src/utils.ts
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/utils.ts5
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._)()