# reaper

> manages serializers/deserializers for API content-types/media-types

Latest version **0.3.2** (published 2017-11-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install reaper
pnpm add reaper
yarn add reaper
bun add reaper
```

## 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.3.2 |
| Published | 2017-11-29 |
| First published | 2012-05-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | cainus |
| Keywords | api, rest, http, representation, media-type, media, content, content-type, negotiation, conneg |

## Links

- npm: https://www.npmjs.com/package/reaper
- Repository: https://github.com/cainus/reaper
- Homepage: https://github.com/cainus/reaper#readme
- Issues: https://github.com/cainus/reaper/issues
- npm.io page: https://npm.io/package/reaper

## Dependencies (2)

- [negotiator](https://npm.io/package/negotiator.md) ^0.6.1
- [underscore](https://npm.io/package/underscore.md)

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 0.3.2 (latest) — 2017-11-29
- 0.3.1 — 2013-05-14
- 0.3.0 — 2013-05-13
- 0.2.3 — 2012-08-25
- 0.2.2 — 2012-08-17
- 0.2.1 — 2012-08-17
- 0.2.0 — 2012-08-17
- 0.1.3 — 2012-08-14
- 0.1.2 — 2012-08-14
- 0.1.1 — 2012-06-01
- 0.1.0 — 2012-05-31

## README

# Reaper

[![Build
Status](https://secure.travis-ci.org/cainus/reaper.png?branch=master)](http://travis-ci.org/cainus/reaper)
[![Coverage
Status](https://coveralls.io/repos/cainus/reaper/badge.png?branch=master)](https://coveralls.io/r/cainus/reaper)
[![NPM
version](https://badge.fury.io/js/reaper.png)](http://badge.fury.io/js/reaper)


Reaper picks the correct media-type for a resource based on a
request's Accept header and what the resource or server supports.

It also allows the registration of serializers / deserializers for
automatic serialization and deserialization of any formats that might 
be automatically serializable/deserializable.


```javascript

var reaper = new Reaper();
reaper.register('application/json', 
                function(str){ return JSON.parse(str); },
                function(obj){ return JSON.stringify(obj); });

reaper.isAcceptable('application/json');   // returns true
reaper.isAcceptable('*/*');   // returns true
reaper.isAcceptable('application/xml');   // returns false

reaper.isRegistered('application/json');  // returns true
reaper.isRegistered('application/xml');  // returns false

reaper.input("application/json", '{"hello" : "world"}');  // returns {hello : "world"}
reaper.output("application/json", {hello : "world"});   // returns '{"hello" : "world"}'


```

Additionally Reaper comes with a connect-compatible middleware that attaches a `body` and `rawBody` object to your request object that automatically uses any deserializer you may have configured for the content-type to populate the `body` property.  The middleware will return errors in the case of bad deserialization, or unacceptable Accept / Content-Type headers.

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