1.1.1 • Published 2 years ago

switch-ts v1.1.1

Weekly downloads
51
License
MIT
Repository
github
Last release
2 years ago

switch-ts

npm version TypeScript

Switch-case with support for complex conditions for TypeScript

Exapmle

import { when } from "switch-ts";

const result = when(1)
  .is(v => v === 1, () => "value1")
  .is(v => v === 2, () => "value2")
  .is(v => v === 3, () => "value3")
  .default(() => "default value");
// result -> "value1"
  • Helper functions is also provided.
    • then, eq, ne, gt, lt, ge, le
import { eq, then, when } from "switch-ts";

const result = when(1)
  .is(eq(1), then("value1"))
  .is(eq(2), then("value2"))
  .is(eq(3), then("value3"))
  .default(then("default value"));
// result -> "value1"
1.1.1

2 years ago

1.1.0

2 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago