# diffs-to-string

> Turns an array of diffs into a string. You can generate a changes stream by using [sorted-diff-stream](github.com/maxogden/sorted-diff-stream).

Latest version **4.1.0** (published 2015-06-11) · BSD license · 0 weekly downloads

## Install

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

## 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 | 4.1.0 |
| Published | 2015-06-11 |
| First published | 2015-06-03 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Karissa McKelvey |
| Maintainers | karissa |
| Keywords | diff, string, console, print, tabular, diffing |

## Links

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

## Dependencies (2)

- [debug](https://npm.io/package/debug.md) ^2.2.0
- [inherits](https://npm.io/package/inherits.md) ^2.0.1

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 4.1.0 (latest) — 2015-06-11
- 4.0.2 — 2015-06-11
- 4.0.1 — 2015-06-05
- 4.0.0 — 2015-06-04
- 3.0.0 — 2015-06-04
- 2.1.0 — 2015-06-04
- 2.0.1 — 2015-06-04
- 2.0.0 — 2015-06-03
- 1.0.2 — 2015-06-03
- 1.0.1 — 2015-06-03
- 1.0.0 — 2015-06-03

## README

# diffs-to-string

Turns an array of diffs into a string. You can generate a changes stream by using [sorted-diff-stream](github.com/maxogden/sorted-diff-stream).

[![NPM](https://nodei.co/npm/diffs-to-string.png)](https://nodei.co/npm/diffs-to-string/)

### basic example
```js
var diffs2string = require('diffs-to-string')

var changes = [
  [ { country: 'germany', capital: null },
    { country: 'germany', code: 'de', capital: 'berlin' } ],
  [ { country: 'ireland', capital: 'dublin' },
    { country: 'ireland', code: 'ie', capital: 'dublin' } ],
  [ { country: 'france', capital: 'paris' },
    { country: null, code: 'fr', capital: 'paris'} ],
  [ { country: 'spain', capital: 'madrid' },
    { country: 'spain', code: 'es', capital: 'barcelona' } ]
]

var visual = diffs2string(changes)
console.log(visual)
```

Outputs:

```
row 1
    country: germany
  + capital: berlin
  + code: de
row 2
    country: ireland
    capital: dublin
  + code: ie
row 3
  - country: france
    capital: paris
  + code: fr
row 4
    country: spain
  ? capital: madrid -> barcelona
  + code: es
```


### with streams
```js
var diffs2string = require('diffs-to-string').stream
var diffStream = from.obj(changes)

diffStream.pipe(diffs2string())
```

### custom row path and row header

```js
function getRowValue (row) {
  return row.value
}

function getRowHeader (diff) {
  return 'this is row ' + diff['some-value'] + '\n'
}

var opts = {
  getRowValue: getRowValue,
  getRowHeader: getRowHeader
}

diffStream.pipe(diffs2string.stream(opts))
var visual = diffs2string(changes, opts)
```

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