# pull-stringify

> JSON.stringify as pull-stream

Latest version **2.0.0** (published 2016-09-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install pull-stringify
pnpm add pull-stringify
yarn add pull-stringify
bun add pull-stringify
```

## 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 | 2.0.0 |
| Published | 2016-09-11 |
| First published | 2014-02-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Dominic Tarr |
| Maintainers | dominictarr |

## Links

- npm: https://www.npmjs.com/package/pull-stringify
- Repository: https://github.com/dominictarr/pull-stringify
- Issues: https://github.com/dominictarr/pull-stringify/issues
- npm.io page: https://npm.io/package/pull-stringify

## Dependencies (1)

- [defined](https://npm.io/package/defined.md) ^1.0.0

## Recent versions

- 2.0.0 (latest) — 2016-09-11
- 1.2.2 — 2014-10-21
- 1.1.1 — 2014-10-10
- 1.1.0 — 2014-10-09
- 1.0.1 — 2014-03-30
- 1.0.0 — 2014-02-17

## README

# pull-stringify

JSON.stringify as pull stream

## example

``` js
var pull = require('pull-stream')
var stringify = require('pull-stringify')
var toPull = require('stream-to-pull-stream')

pull(
  pull.values([A, B, C]),
  stringify(),
  toPull(process.stdout)
)
```

## usage

### `stringify = require('pull-stringify')`

``` js
pull(
  pull.values([A, B, C]),
  stringify.lines(),
  toPull(process.stdout)
)
```

### `stringify(options)`

`options` is an object with the following optional keys:

- `open`: string to be prepended to first output string
- `prefix`: string to be prepended to every non-first output string
- `suffix`: string to be appended to every output string
- `close`: string to be appended after stream is complete
- `indent`: passed as third argument to `JSON.stringify`
- `stringify`: custom function to use instead of `JSON.stringify`

`stringify(options)` returns a through [`pull-stream`](https://pull-stream.github.io).

defaults options are for [double newline delimited json](https://github.com/dominictarr/pull-json-doubleline/blob/master/index.js). double newline delimiting means you can use indented json as the stream format, which is more human readable.

```js
{
  open: '',
  prefix: '',
  suffix: '\n\n',
  close: '',
  indent: 2,
  stringify: JSON.stringify
}
```

### `stringify.ldjson(stringify)`

### `stringify.lines(stringify)`

for single newline delimited json use `stringify.ldjson()` or `stringify.lines()`:

```js
{
  suffix: '\n',
  indent: 0
}
```

you can pass a custom stringify as an argument.

```js
// compatible with JSON but supports buffers.
var JSONB = require('json-buffer')

// use defaults
stringify({ stringify: JSONB.stringify })

// or
stringify.lines(JSONB.stringify)
```


### `stringify.array(stringify)`

for a single json array use `stringify.array()`

```js
{
  open: '[',
  separator: ',\n',
  close: ']\n',
  indent: 2
}
```

## License

MIT

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