@chubbyts/chubbyts-negotiation
Version:
A simple negotiation library.
70 lines (47 loc) • 4.17 kB
Markdown
# chubbyts-negotiation
[](https://github.com/chubbyts/chubbyts-negotiation/actions?query=workflow%3ACI)
[](https://coveralls.io/github/chubbyts/chubbyts-negotiation?branch=master)
[](https://dashboard.stryker-mutator.io/reports/github.com/chubbyts/chubbyts-negotiation/master)
[](https://www.npmjs.com/package/@chubbyts/chubbyts-negotiation)
[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-negotiation)
[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-negotiation)
[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-negotiation)
[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-negotiation)
[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-negotiation)
[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-negotiation)
[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-negotiation)
[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-negotiation)
[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-negotiation)
[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-negotiation)
[](https://sonarcloud.io/dashboard?id=chubbyts_chubbyts-negotiation)
## Description
A simple negotiation library.
## Requirements
* node: 18
## Installation
Through [NPM](https://www.npmjs.com) as [@chubbyts/chubbyts-negotiation][1].
```ts
npm i @chubbyts/chubbyts-negotiation@^4.0.2
```
## Usage
### Accept-Language
```ts
import { createAcceptLanguageNegotiator } from '@chubbyts/chubbyts-negotiation/dist/accept-language-negotiator';
const negotiator = createAcceptLanguageNegotiator(['en', 'de']);
const value = negotiator.negotiate('de,en;q=0.3,en-US;q=0.7');
```
### Accept
```ts
import { createAcceptNegotiator } from '@chubbyts/chubbyts-negotiation/dist/accept-negotiator';
const negotiator = createAcceptNegotiator(['application/json', 'application/xml', 'application/x-yaml']);
const value = negotiator.negotiate('text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q =0.8');
```
### Content-Type
```ts
import { createContentTypeNegotiator } from '@chubbyts/chubbyts-negotiation/dist/content-type-negotiator';
const negotiator = createContentTypeNegotiator(['application/json', 'application/xml', 'application/x-yaml']);
const value = negotiator.negotiate('application/xml; charset=UTF-8');
```
## Copyright
2025 Dominik Zogg
[1]: https://www.npmjs.com/package/@chubbyts/chubbyts-negotiation