# babel-plugin-transform-sequence-discriminants

> Transforms switch cases into pattern-matching if-else statements.

Latest version **0.1.4** (published 2019-04-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-plugin-transform-sequence-discriminants
pnpm add babel-plugin-transform-sequence-discriminants
yarn add babel-plugin-transform-sequence-discriminants
bun add babel-plugin-transform-sequence-discriminants
```

## 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.1.4 |
| Published | 2019-04-12 |
| First published | 2019-04-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 17.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | mtso |
| Maintainers | mtso |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-transform-sequence-discriminants
- Repository: https://github.com/mtso/babel-plugin-transform-sequence-discriminants
- Homepage: https://github.com/mtso/babel-plugin-transform-sequence-discriminants#readme
- Issues: https://github.com/mtso/babel-plugin-transform-sequence-discriminants/issues
- npm.io page: https://npm.io/package/babel-plugin-transform-sequence-discriminants

## Dependencies (1)

- [@babel/core](https://npm.io/package/@babel/core.md) ^7.0.0-beta.42

## Recent versions

- 0.1.4 (latest) — 2019-04-12
- 0.1.3 — 2019-04-12
- 0.1.2 — 2019-04-12
- 0.1.1 — 2019-04-12
- 0.1.0 — 2019-04-12

## README

# babel-plugin-transform-sequence-discriminants

Transforms switch cases into pattern-matching if-else statements.

## Example

```js
const outsideVariable = 'foo';

switch ('foo', 'bar') {
  case 'foo', 'boo':
    console.log('not a match');
    break;
  case outsideVariable, 'bar':
    console.log('match!');
    break;
  case (x, y) => 'foobar' === x + y:
    console.log('match!');
    break;
  case (x) => 'FOO' === x.toUpperCase(), 'bar':
    console.log('match!');
    break;
  case 'foo', _:
    console.log('match!');
    break;
  case _, _:
    console.log('match!');
    break;
  default:
    console.log('match!');
    break;
}
```

Output:

```js
const outsideVariable = 'foo';

{
  const discriminant0 = 'foo',
        discriminant1 = 'bar';

  if (discriminant0 === 'foo' && discriminant1 === 'boo') {
    console.log('not a match');
  } else if (discriminant0 === outsideVariable && discriminant1 === 'bar') {
    console.log('match!');
  } else if (((x, y) => 'foobar' === x + y)(discriminant0, discriminant1)) {
    console.log('match!');
  } else if ((x => 'FOO' === x.toUpperCase())(discriminant0) && discriminant1 === 'bar') {
    console.log('match!');
  } else if (discriminant0 === 'foo' && true) {
    console.log('match!');
  } else if (true && true) {
    console.log('match!');
  } else {
    console.log('match!');
  }
}
```

---
_Source: https://npm.io/package/babel-plugin-transform-sequence-discriminants · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
