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

sc-printer

v1.1.28

Published

Styled printing to console.

Downloads

87

Readme

README

Pretty printing for console. NB: Only tested on Mac.

Usage

var printer = require('sc-printer');

Functions

All below printing functions take a single string argument. Include "\n" to create a new line.

Foreground Colors

printer.black()
printer.red()
printer.green()
printer.yellow()
printer.blue()
printer.magenta()
printer.cyan()
printer.orange()
printer.purple()
printer.white()
printer.redBright()
printer.greenBright()
printer.yellowBright()
printer.blueBright()
printer.magentaBright()
printer.cyanBright()
printer.orangeBright()
printer.purpleBright()
printer.gray1()
printer.gray2()
printer.gray3()
printer.gray4()
printer.gray5()
printer.gray6()
printer.gray7()
printer.gray8()
printer.gray9()
printer.gray10()
printer.gray11()
printer.gray12()
printer.gray13()
printer.gray14()
printer.gray15()
printer.gray16()
printer.gray17()
printer.gray18()
printer.gray19()
printer.gray20()
printer.gray21()
printer.gray22()
printer.gray23()

Background Colors

printer.bgWhite()
printer.bgBlack()
printer.bgRed()
printer.bgGreen()
printer.bgYellow()
printer.bgBlue()
printer.bgMagenta()
printer.bgCyan()
printer.bgRedBright()
printer.bgGreenBright()
printer.bgYellowBright()
printer.bgBlueBright()
printer.bgMagentaBright()
printer.bgCyanBright()

Styles

printer.blink()
printer.bold()
printer.dim()
printer.underline()

Combining Colors and Styles

Colors and styles can be chained together, starting with the color, followed by an optional background color, followed by optional styles. eg,
printer.red.bold()
printer.red.bgBlue.bold.underline()

All styles can be combined in any order. eg,
printer.bold.underline()
printer.red.dim.bold()

Returning Strings

Return a string, as opposed to outputting to the console, by adding noprint() to the end of any style chain.

Random Character Colors

printer.random()
Prints a string with a random color for each character.

Process Progress

The Progress function animates printing of a progress message and provides methods to indicate success or error.

printer.Progress(msg [,ticker][,fn])
Shows an animated progress message in console.
msg {String} Initial message to display.
ticker {String[]} [optional] Elements for animation loop. Defaults to ["", ".", "..", "..."].
fn {Function} [optional] Formatting function. Defaults to printer.white().

Returns: A Progress object with additional methods defined:

reset(msg [,fn])
Resets progress message.
msg {String} Message to display.
fn {Function} [optional] Formatting function. Defaults to printer.white().

Returns: The Progress object.

success(msg [,fn])
Stops animated progress message and displays success message.
msg {String} Message to display.
fn {Function} [optional] Formatting function. Defaults to printer.green().

Returns: The Progress object.

error(msg [,fn])
Stops animated progress message and displays error message.
msg {String} Message to display.
fn {Function} [optional] Formatting function. Defaults to printer.red().

Returns: The Progress object.

Example

var printer = require('sc-printer');

var progress = new printer.Progress('Doing something');
progress.success('Something succeeded.');
progress.error('Something failed.');
progress.reset('Doing something else in blue.', printer.blue);