1.0.2 • Published 5 years ago
@xornot/match v1.0.2
xornot.io match
Functional replacement for the switch statement.
With match:
const result = match<string, number>(value)
.if("foo", () => 1)
.if(["bar", "baz"], () => 2)
.else(() => 3);
Without match:
let result: number;
switch (value) {
case "foo":
result = 1;
break;
case "bar":
case "baz":
result = 2;
break;
default:
result = 3;
}