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

cute-print

v1.0.4

Published

Enjoyable and colored printing in the console with node

Downloads

48

Readme

Enjoyable library for colorful printing in the console

cute-print is an alternative to well-known libraries like chalk which focus on less typing, more readability and confort of use.

Note that colors will not display on windows console. If you work on windows, you should really consider using an external terminal tool like cmder or hyper.

Also see cute-dump if you need to pretty-dump an object.

Usage

Import print :

import print from 'cute-print'
// or
const print = require('cute-print')

Print a colored value :

print `Hello [red: world]!`
print `Hello [red.bgWhite: world]!`

let who = 'world'
print `Hello [green.bold:${who}]!`

// the default style is 'bold'. Both are identical :
print `Hello [:${who}]!`
print `Hello [bold:${who}]!`

You can nest colors - although it becomes easily complex : (you should consider using the next syntax)

print `Hello [red: world and [bold:universe]]!`

You can use a tag without the : - that will affect the string up to the end.

print `Hello [red] world and [bold] universe!`

You can use [reset] to reset the style :

print `Hello [red.bold] world and [reset] universe!`

You can also use a default styling for the whole string :

print.red `Hello red world!`
print.red.bgWhite `Hello red world on white background!`

Printing on the error or warning streams :

print.warn `You are a cute dangerous guy`
print.error `Something wrong happened`
print.error.red `Something wrong happened`

Comparison with chalk

Remember that every library has its pros and cons - and everyone has its own preferences.

  • chalk has support for true colors
  • chalk can be used to manipulate any strings where cute-print purpose is only to print in the console
  • cute-print has no dependencies
  • cute-print is written in Typescript and so can be used in any Typescript project with zero effort
  • cute-print has a cleaner syntax :

The exemples are actually from my own code. I had a lot of logs to do and the syntax started to be painful so I decided to create this utilitary library.

// chalk : 74 characters (~ +50%)
console.log(chalk.green('\n-' + chalk.bold(' The mole starts to sniff!')))
// cute-print : 50 characters
print.green `\n- [bold] The mole starts to sniff!`
// chalk : 58 characters (~ +25%)
console.log(chalk.blueBright('Entities :'), total - empty)
// cute-print : 46 characters
print.brightBlue `Entities : ${total - empty}`

Tag reference

You can mix any tag anytime by using a dot . as separator.

| Color | Bright color | Background color | |---------|---------------|------------------| | black | brightBlack | bgBlack | | red | brightRed | bgRed | | green | brightGreen | bgGreen | | yellow | brightYellow | bgYellow | | blue | brightBlue | bgBlue | | magenta | brightMagenta | bgMagenta | | cyan | brightCyan | bgCyan | | white | brightWhite | bgWhite |

All tags marked with an asterisk * are not supported in many consoles.

| Style | Effect | |-----------|---------------------------------------| | reset | Reset all style and color | | bold | Increase intensity | | dim | Decrease intensity | | italic* | | | underline | | | blink* | | | fastblink*| | | reverse | Swap foreground and background colors | | hidden* | Hide the given text | | stroke* | Strike text | | default | |