Miss any of our Open RFC calls?Watch the recordings here! »

@xornot/match

1.0.2 • Public • Published

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;
}

Keywords

none

Install

npm i @xornot/match

DownloadsWeekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

10.4 kB

Total Files

17

Last publish

Collaborators

  • avatar