cleanup, patterns

This commit is contained in:
Oli Sturm
2026-04-27 13:08:40 +01:00
parent d0c9466170
commit 3194231879
8 changed files with 66 additions and 36 deletions
+9
View File
@@ -0,0 +1,9 @@
export type Predicate<T> = (value: T) => boolean;
export type Handler<T, R> = (value: T) => R;
export type Branch<T, R> = [Predicate<T>, Handler<T, R>];
export declare const match: <T, R>(...branches: Branch<T, R>[]) => (value: T) => R;
export declare const when: <T, R>(predicate: Predicate<T>, handler: Handler<T, R>) => Branch<T, R>;
export declare const any: Predicate<any>;