# stream-to-string

> Pipe a stream into a string, collect value with callback or promise

Latest version **1.2.1** (published 2023-02-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install stream-to-string
pnpm add stream-to-string
yarn add stream-to-string
bun add stream-to-string
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2023-02-08 |
| First published | 2015-01-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 10.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Author | Jason Pincin |
| Maintainers | jasonpincin |
| Keywords | stream, string, buffer, callback, promise |

## Links

- npm: https://www.npmjs.com/package/stream-to-string
- Repository: https://github.com/jasonpincin/stream-to-string
- Issues: https://github.com/jasonpincin/stream-to-string/issues
- npm.io page: https://npm.io/package/stream-to-string

## Dependencies (1)

- [promise-polyfill](https://npm.io/package/promise-polyfill.md) ^1.1.6

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 1.2.1 (latest) — 2023-02-08
- 1.2.0 — 2019-01-17
- 1.1.0 — 2016-07-08
- 1.0.1 — 2015-07-28
- 1.0.0 — 2015-01-22

## README

# stream-to-string

[![NPM version](https://badge.fury.io/js/stream-to-string.png)](http://badge.fury.io/js/stream-to-string)
[![Build Status](https://travis-ci.org/jasonpincin/stream-to-string.svg?branch=master)](https://travis-ci.org/jasonpincin/stream-to-string)
[![Coverage Status](https://coveralls.io/repos/jasonpincin/stream-to-string/badge.png?branch=master)](https://coveralls.io/r/jasonpincin/stream-to-string?branch=master)

Pipe a stream into a string, collect value with callback or promise

## example

```javascript
var toString = require('..'),
    through2 = require('through2'),
    stream   = through2()

toString(stream, function (err, msg) {
    console.log(msg)
})

# or with promises
toString(stream).then(function (msg) {
    console.log(msg)
})

stream.write('this is a')
stream.write(' test')
stream.end()
```

## api

```javascript
var toString = require('stream-to-string')
```

### toString(stream[, enc][, cb])

Collects stream data into a string. Accepts an optional encoding argument used when converting the stream. Executes optional callback with `err, string`. Returns a promise.

## testing

`npm test [--dot | --spec] [--coverage | --grep=pattern]`

Specifying `--dot` or `--spec` will change the output from the default TAP style. 
Specifying `--coverage` will print a text coverage summary to the terminal after 
tests have ran, while `--pattern` will only run the test files that match the given 
pattern.

Open an html coverage report with `npm run view-cover`.

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