# @ag1/return_switch

> a switch condition that return result

Latest version **1.1.1** (published 2020-04-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ag1/return_switch
pnpm add @ag1/return_switch
yarn add @ag1/return_switch
bun add @ag1/return_switch
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2020-04-16 |
| First published | 2018-06-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | agent one co., ltd. |
| Maintainers | kpping |
| Keywords | control-statement, typescript |

## Links

- npm: https://www.npmjs.com/package/@ag1/return_switch
- Repository: https://github.com/AgentOneCoLtd/return_switch
- npm.io page: https://npm.io/package/@ag1/return_switch

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.1.1 (latest) — 2020-04-16
- 1.1.0 — 2019-09-04
- 1.0.1 — 2019-03-18
- 1.0.0 — 2019-03-13
- 0.1.4 — 2018-09-20
- 0.1.3 — 2018-09-19
- 0.1.2 — 2018-08-31
- 0.1.1 — 2018-06-27
- 0.1.0 — 2018-06-25

## README

# Return Switch
![Node.js CI](https://github.com/AgentOneCoLtd/return_switch/workflows/Node.js%20CI/badge.svg)

Control Statement that can return result is cool. It can reduce ugly code. Some other libs have done this but they are too complicated for our need.

## Support

at least ES2015

## Install

```bash
yarn add @ag1/return_switch
```

## Usage

```ts
import { returnSwitch } from '@ag1/return_switch';
```

```ts
const foo = returnSwitch<string>('foo')([
    ['foo', 'foo'], // matched
    [true, 'bar'],
]);

console.log(foo); // foo
```

```ts
const bar = returnSwitch<string>('bar')([
    ['foo', 'foo'],
    [true, 'bar'], // default
]);

console.log(bar); // bar
```

```ts
const lorem = returnSwitch<string>('lorem')([
    ['foo', 'foo'],
    ['bar', 'bar'],
]); // NO_MATCH, throw error
```

## Test

```bash
yarn test
```

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