@jamesfancy/when
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

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`],
    );
}

Readme

Keywords

Package Sidebar

Install

npm i @jamesfancy/when

Weekly Downloads

0

Version

1.0.3

License

MulanPSL2

Unpacked Size

12.6 kB

Total Files

9

Last publish

Collaborators

  • jamesfancy