# stream-body

> parse a stream correctly (according to the content-type) using raw-body

Latest version **1.0.7** (published 2018-01-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install stream-body
pnpm add stream-body
yarn add stream-body
bun add stream-body
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2018-01-25 |
| First published | 2016-11-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | hij1nx |
| Maintainers | hij1nx |
| Keywords | streams, body, parser, extensible, response |

## Links

- npm: https://www.npmjs.com/package/stream-body
- Repository: https://github.com/0x00A/stream-body
- Homepage: https://github.com/0x00A/stream-body#readme
- Issues: https://github.com/0x00A/stream-body/issues
- npm.io page: https://npm.io/package/stream-body

## Dependencies (1)

- [raw-body](https://npm.io/package/raw-body.md) ^2.1.7

## 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

- 1.0.7 (latest) — 2018-01-25
- 1.0.6 — 2018-01-25
- 1.0.5 — 2017-02-15
- 1.0.4 — 2016-12-23
- 1.0.3 — 2016-12-22
- 1.0.2 — 2016-11-28
- 1.0.1 — 2016-11-28
- 1.0.0 — 2016-11-27

## README

# SYNOPSIS
Get the complete body from a stream and parse it automatically.

# MOTIVATION
A minimal wrapper around [raw-body](https://github.com/stream-utils/raw-body)
that provides you with the correct parser.

# BUILD STATUS
[![Build Status](https://travis-ci.org/0x00A/stream-body.svg?branch=master)](https://travis-ci.org/0x00A/stream-body)

# USAGE
This module detects the content type of the stream and parses it appropriately.
So for instance, if you request a resource with a `content-type` header which
has the value of `application/json`, the response body will be parsed as `JSON`.

```js
const http = require('http')
const body = require('stream-body')

const url = 'http://nodejs.org/dist/index.json'

http.get(url, res => body.parse(res, (err, data) => {

  // ...`data` will be a json object.
}))
```

# EXTENDING
This module exports an object that exposes all parsers. For instance, the `JSON`
parser implemintation is defined on the `parsers` member...

```js
const body = require('stream-body')

body.parsers['application/json'] = function (data, opts, cb) {

  // `data` is the raw data object
  // `opts` is any options passed in to the parse function
  // `cb` is called after the stream has ended
}
```

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