# brief-switch

> The shortest syntax for functional switch-case

Latest version **0.2.0** (published 2018-05-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install brief-switch
pnpm add brief-switch
yarn add brief-switch
bun add brief-switch
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2018-05-16 |
| First published | 2018-04-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 52 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | John Klimov |
| Maintainers | klimcode |
| Keywords | brief, shortest, syntax, switch, functional, no-dependencies |

## Links

- npm: https://www.npmjs.com/package/brief-switch
- Repository: https://github.com/klimcode/brief-switch
- Homepage: https://github.com/klimcode/brief-switch#readme
- Issues: https://github.com/klimcode/brief-switch/issues
- npm.io page: https://npm.io/package/brief-switch

## Alternatives

- [@oh-my-pi/pi-natives](https://npm.io/package/@oh-my-pi/pi-natives.md) — 51.8K weekly downloads
- [@capgo/capacitor-light-sensor](https://npm.io/package/@capgo/capacitor-light-sensor.md) — 3.0K weekly downloads
- [@heyhuynhgiabuu/pi-diff](https://npm.io/package/@heyhuynhgiabuu/pi-diff.md) — 492 weekly downloads
- [@lotsa/verdant-lang-asm](https://npm.io/package/@lotsa/verdant-lang-asm.md) — 38 weekly downloads
- [new-era-syntax](https://npm.io/package/new-era-syntax.md) — 20 weekly downloads

## Recent versions

- 0.2.0 (latest) — 2018-05-16
- 0.1.0 — 2018-04-07

## README

# Brief-Switch

1. The shortest syntax for functional "switch"-style comparison.
2. The fastest possible function designed to replace built-in "switch" statement.
3. A list of cases may be generated and mutated in the runtime.

## Installation

```bash
npm i -S brief-switch
```

## Example

```js
const switchB = require('brief-switch');
function fn1() { /*smth.*/ }
function fn2() { return 5; }

const cases = [
  'foo', 'bar',
  1, 2,
  3, fn2(),
  fn1, fn2,
  'default',
];
const result = switchB(3, cases); // 5
```

## Explanation

Every odd value in the "cases" array is a **test**. Every even value is a **result**. The last value is an analog of built-in "switch" statement's "**default**".

---
_Source: https://npm.io/package/brief-switch · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
