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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@falaksingh/sketch

v1.0.0

Published

Terminal logs with styles

Readme

Sketch

sketch is a lightweight utility for styling terminal output with ANSI codes. It allows you to easily add colors, backgrounds, and text styles (bold, italic, underline) to your terminal logs.

Installation

You can install Sketch using npm:

npm install sketch

Usage

Basic Example

import { sketch } from 'sketch';

// Styling text
sketch('Hello, World!').bgRed.white.log();

This will output Hello, World! with a red background and white text.

Available Styles

Text Colors

  • black
  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan
  • white

Background Colors

  • bgBlack
  • bgRed
  • bgGreen
  • bgYellow
  • bgBlue
  • bgMagenta
  • bgCyan
  • bgWhite

Text Styles

  • bold
  • italic
  • underline

Chaining Styles

You can chain multiple styles together:

sketch('Warning!').bgYellow.black.bold.log();
sketch('Error!').bgRed.white.underline.log();

Logging to the Terminal

Use the .log() method to print the styled text to the terminal:

sketch('This is bold and blue').bold.blue.log();

Getting the Styled Text

If you don’t want to log the text immediately, you can use the .text property to get the styled string:

const styledText = sketch('Hello, World!').bgGreen.black.text;
console.log(styledText);

API

sketch(payload: string | object)

Creates a new Sketch instance.

  • payload: The text to style. If an object is provided, it will be converted to a JSON string.

Methods

  • .log(): Logs the styled text to the terminal.
  • .text: Returns the styled text as a string.

Properties

All style properties (e.g., red, bgBlue, bold) can be chained to apply styles.

Examples

Styling JSON Objects

You can style JSON objects for better readability:

const data = { name: 'Sketch', version: '1.0.0' };
sketch(data).bgCyan.white.log();

Combining Styles

Combine multiple styles for more complex outputs:

sketch('Success!').bgGreen.white.bold.log();
sketch('Failed!').bgRed.white.underline.log();

License

Sketch is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! If you find a bug or want to suggest a feature, please open an issue or submit a pull request.

Author

Falak Singh