# ansi-diff-stream

> A transform stream that diffs input buffers and outputs the diff as ANSI. If you pipe this to a terminal it will update the output with minimal changes.

Latest version **1.2.1** (published 2018-03-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install ansi-diff-stream
pnpm add ansi-diff-stream
yarn add ansi-diff-stream
bun add ansi-diff-stream
```

Provides the command `ansi-diff-stream`.

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2018-03-23 |
| First published | 2016-07-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/ansi-diff-stream) |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 7.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 109 |
| Author | Mathias Buus |
| Maintainers | mafintosh |

## Links

- npm: https://www.npmjs.com/package/ansi-diff-stream
- Repository: https://github.com/mafintosh/ansi-diff-stream
- Issues: https://github.com/mafintosh/ansi-diff-stream/issues
- npm.io page: https://npm.io/package/ansi-diff-stream

## Dependencies (3)

- [through2](https://npm.io/package/through2.md) ^2.0.1
- [ansi-regex](https://npm.io/package/ansi-regex.md) ^2.0.0
- [buffer-from](https://npm.io/package/buffer-from.md) ^1.0.0

## Recent versions

- 1.2.1 (latest) — 2018-03-23
- 1.2.0 — 2017-03-04
- 1.1.1 — 2016-08-12
- 1.1.0 — 2016-07-14
- 1.0.0 — 2016-07-14

## README

# ansi-diff-stream

A transform stream that diffs input buffers and outputs the diff as ANSI.
If you pipe this to a terminal it will update the output with minimal changes.

```
npm install ansi-diff-stream
```

[![build status](http://img.shields.io/travis/mafintosh/ansi-diff-stream.svg?style=flat)](http://travis-ci.org/mafintosh/ansi-diff-stream)

## Usage

``` js
var differ = require('ansi-diff-stream')
var diff = differ()

setInterval(function () {
  diff.write(
    'This is a demo\n' +
    'The time is: ' + new Date() + '\n' +
    'That is all'
  )
}, 500)

diff.pipe(process.stdout)
```

Running the above example will produce an output that looks like this:

```
This is a demo
The time is: Thu Jul 14 2016 19:46:56 GMT+0200 (CEST)
That is all
```

Every half second the time will update.
The diff produced by running the above means that the terminal will move the cursor to the beginning of the time stamp only update that part.

For a more advanced example see `example.js`.

## API

#### `var stream = differ()`

Create a new diff stream. You should pipe it to a ansi capable stream.

#### `stream.reset()`

Will reset the diff. Useful you print something manually inbetween updates.

#### `stream.clear()`

Clear the last printed output from the screen. Similar to doing `stream.write('')`.

## CLI

There is a command line tools available as

```
npm install -g ansi-diff-stream
nc -l 10000 | ansi-diff-stream
```

In another terminal

```
nc localhost 10000
hello
world
```

## License

MIT

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