@jamesfancy/when
v1.0.3
Published
when expression for JS/TS
Downloads
3
Readme
when expression for JavaScript/TypeScript
Example
import { when } from "@jamesfancy/when";
function calcGrade(score: number) {
return when(score)(
[v => v >= 0 && v < 80, v => `B`],
[v => v >= 80 && v < 100, v => `A`],
[100, () => "S"],
[_ => true, v => `D`],
);
}