# parse-accepts

> A tool to parse headers like Accept, Accept-Language, etc.

Latest version **0.1.1** (published 2018-05-04) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install parse-accepts
pnpm add parse-accepts
yarn add parse-accepts
bun add parse-accepts
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2018-05-04 |
| First published | 2018-01-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Ayon Lee |
| Maintainers | hyurl |
| Keywords | accept, parse |

## Links

- npm: https://www.npmjs.com/package/parse-accepts
- Repository: https://github.com/hyurl/parse-accepts
- Homepage: https://github.com/hyurl/parse-accepts#readme
- Issues: https://github.com/Hyurl/parse-accepts/issues
- npm.io page: https://npm.io/package/parse-accepts

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2018-05-04
- 0.1.0 — 2018-01-27

## README

# Parse-Accepts

**A tool to parse headers like Accept, Accept-Language, etc.**

## Install

```sh
npm install parse-accepts
```

## Example

```javascript
const { parse, parseValue } = require("parse-accepts");

var accept = "text/html, application/xhtml+xml, application/xml;q=0.7, */*;q=0.8",
    acceptLang = "zh-CN, zh;q=0.8, en-US;q=0.5, en;q=0.3";

console.log(parse(accept));
// [ { value: 'text/html', quality: 1 },
//   { value: 'application/xhtml+xml', quality: 1 },
//   { value: '*/*', quality: 0.8 },
//   { value: 'application/xml', quality: 0.7 } ]

console.log(parseValue(accept));
// [ 'text/html', 'application/xhtml+xml', '*/*', 'application/xml' ]

console.log(parse(acceptLang));
// [ { value: 'zh-CN', quality: 1 },
//   { value: 'zh', quality: 0.8 },
//   { value: 'en-US', quality: 0.5 },
//   { value: 'en', quality: 0.3 } ]

console.log(parseValue(acceptLang));
// [ 'zh-CN', 'zh', 'en-US', 'en' ]
```

**The sequence of the returning array will be ordered by their qualities.**

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