# pattern-matched

> A pattern matching library for Typescript & JavaScript

Latest version **0.3.2** (published 2022-01-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install pattern-matched
pnpm add pattern-matched
yarn add pattern-matched
bun add pattern-matched
```

## Health

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

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

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.2 |
| Published | 2022-01-15 |
| First published | 2022-01-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 21.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Austin Golding |
| Maintainers | gol13014 |
| Keywords | pattern, matching, pattern matching |

## Links

- npm: https://www.npmjs.com/package/pattern-matched
- Repository: https://github.com/GoldingAustin/pattern-matched
- Homepage: https://github.com/GoldingAustin/pattern-matched#readme
- Issues: https://github.com/GoldingAustin/pattern-matched/issues
- npm.io page: https://npm.io/package/pattern-matched

## Recent versions

- 0.3.2 (latest) — 2022-01-15
- 0.3.1 — 2022-01-15
- 0.3.0 — 2022-01-15
- 0.2.0 — 2022-01-03

## README

## Pattern Match

A pattern matching library that supports primitives, objects and arrays.

```typescript
const value = 1;
match(value)
  .when(0, () => 1) // Similar to if (value === 0) return 1;
  .when(1, 2) // This is also valid
  .when(2, (matched) => console.log(matched)) // Access the matched value, this would log 2
  .else(); // Runs the match, infers result type to be 1, 2 or undefined. Can also be passed a default value.
```

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