npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ansi-diff-stream

v1.2.1

Published

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.

Downloads

39,003

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

Usage

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