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

v1.2.0

Published

A module that diffs an input buffer with the previous one provided to it and outputs the diff as ANSI

Downloads

298,446

Readme

ansi-diff

A module that diffs an input buffer with the previous one provided to it and outputs the diff as ANSI. If you write out the diff to the terminal it will update the previous output with minimal changes

npm install ansi-diff

Build Status

Usage

var diff = require('ansi-diff')({
  // if you want to support word wrapping, provide the terminal width
  width: process.stdout.columns
})

// render now
render()

// render every 1s
setInterval(render, 1000)

function render () {
  // will update the terminal with minimal changes
  process.stdout.write(diff.update('hello world...\n' + new Date()))
}

It also has terminal resize support

process.stdout.on('resize', function () {
  diff.resize({width: process.stdout.columns})
  render()
})

API

var diff = ansiDiff([options])

Create a new differ. Options include:

{
  width: terminalWidth,
  height: terminalHeight
}

If you provide the terminal width ansi-diff will be able to support word wrapping done by the terminal. That means that if you print out a line that is too long to fit in the terminal the diff will still work.

var changes = diff.update(buffer, opts)

Update the buffer and return the diff between this and the previous one. The diff is returned in ANSI as a buffer so you can write it out to the terminal.

  • opts.moveTo - array of [column,row] to move the cursor after diffing the screen (in absolute coordinates)

diff.resize([options])

Update the terminal width / height. If you are writing to stdout you should update the width when process.stdout.on('resize') is fired.

Options should look like this:

{
  width: terminalWidth,
  height: terminalHeight
}

diff.toString()

Returns the last diffed string.

diff.width

Property containing the last set terminal width.

diff.height

Property containing the last set terminal height.

License