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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@averagejoeslab/ansi

v1.0.1

Published

ANSI escape sequence utilities for terminal applications

Downloads

273

Readme

@puppuccino/ansi

Low-level ANSI escape code utilities for terminal applications.

Installation

npm install @puppuccino/ansi

Or install from GitHub:

npm install github:averagejoeslab/ansi

Features

  • Cursor Control - Move, hide, show, save/restore cursor position
  • Screen Control - Clear screen, scroll, alternate buffer
  • Text Styling (SGR) - Bold, italic, underline, colors, and more
  • Color Support - 16 colors, 256 colors, and 24-bit RGB
  • String Width - Calculate visible width of strings with ANSI codes
  • OSC Sequences - Hyperlinks, window titles, notifications

Usage

Cursor Control

import { cursor } from '@puppuccino/ansi';

// Move cursor
process.stdout.write(cursor.move(10, 5));     // Move to column 10, row 5
process.stdout.write(cursor.up(2));           // Move up 2 lines
process.stdout.write(cursor.down(1));         // Move down 1 line
process.stdout.write(cursor.forward(5));      // Move right 5 columns
process.stdout.write(cursor.back(3));         // Move left 3 columns

// Hide/show cursor
process.stdout.write(cursor.hide);
process.stdout.write(cursor.show);

// Save/restore position
process.stdout.write(cursor.save);
process.stdout.write(cursor.restore);

Screen Control

import { screen } from '@puppuccino/ansi';

// Clear screen
process.stdout.write(screen.clear);           // Clear entire screen
process.stdout.write(screen.clearLine);       // Clear current line
process.stdout.write(screen.clearDown);       // Clear from cursor down

// Alternate buffer (for full-screen apps)
process.stdout.write(screen.altBuffer);       // Enter alternate buffer
process.stdout.write(screen.mainBuffer);      // Return to main buffer

// Scrolling
process.stdout.write(screen.scrollUp(5));     // Scroll up 5 lines
process.stdout.write(screen.scrollDown(3));   // Scroll down 3 lines

Text Styling (SGR)

import { sgr, style } from '@puppuccino/ansi';

// Apply styles
console.log(style.bold('Bold text'));
console.log(style.italic('Italic text'));
console.log(style.underline('Underlined'));
console.log(style.strikethrough('Crossed out'));

// Colors
console.log(style.red('Red text'));
console.log(style.bgBlue('Blue background'));
console.log(style.rgb(255, 128, 0, 'Orange text'));
console.log(style.bgRgb(0, 0, 128, 'Navy background'));

// Combine styles
console.log(style.bold(style.red('Bold red')));

// Using SGR codes directly
import { SGR } from '@puppuccino/ansi';
process.stdout.write(sgr(SGR.bold, SGR.fgRed) + 'Bold Red' + sgr(SGR.reset));

String Width

import { stringWidth, stripAnsi } from '@puppuccino/ansi';

const styled = style.bold('Hello') + ' ' + style.red('World');

// Get visible length (excluding ANSI codes)
console.log(stringWidth(styled));  // 11

// Strip all ANSI codes
console.log(stripAnsi(styled));    // "Hello World"

OSC Sequences

import { osc } from '@puppuccino/ansi';

// Set window title
process.stdout.write(osc.title('My App'));

// Create hyperlink
console.log(osc.link('https://example.com', 'Click here'));

// Desktop notification (terminal support varies)
process.stdout.write(osc.notify('Alert', 'Something happened'));

API Reference

Constants

  • CSI - Control Sequence Introducer (\x1b[)
  • OSC - Operating System Command (\x1b])
  • SGR - Select Graphic Rendition codes

Modules

  • cursor - Cursor movement and visibility
  • screen - Screen clearing and scrolling
  • style - Text styling with SGR codes
  • sgr() - Raw SGR sequence generator
  • osc - OSC sequence utilities
  • stringWidth() - Calculate visible string width
  • stripAnsi() - Remove ANSI codes from string

License

MIT