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

strcolorize

v1.1.8

Published

A library for coloring strings in your terminal.

Downloads

11

Readme

🖍️ strcolorize

strcolorize is a simple and practical library for terminal output colorization that utilizes ANSI and hexadecimal codes for its operation. The way strcolorize operates is different, using inline formatting for its functionality.

Inline Formatting

Allows adding colors directly to text using codes (Hexadecimal and ANSI) around desired portions. This provides a simple way to highlight important information without compromising the text's structure. With strcolorize, this approach enables precise customization of text colors and styles.

📦 Installation

You can install this library using npm or yarn

npm install strcolorize@latest
yarn install strcolorize@latest

📌 How to usage

To utilize this library, first install it in your project and then import it into your file like this:

// Importing using es6
import colorize from 'strcolorize';

// Importing using commonjs
const colorize = require('strcolorize');

// Note: in place of 'colorize' you can set any name you want

After that, you can use it to colorize your strings like this:

// putting a text in bold and yellow
colorize('#bold yellow[The sun sets. Stars twinkle. Dreams awaken.
]');

// you can print to the console using the function itself
colorize('#bold yellow[The sun sets. Stars twinkle. Dreams awaken.
]', true);

// There's the possibility of nesting styles
colorize('#bold[The sun sets. #yellow[Stars twinkle]. Dreams awaken.
]');

// How to use hexadecimal codes to colorize your strings
colorize('#bold[The sun sets. #ff0[Stars twinkle]. Dreams awaken.
]');

📝 Method

colorize(text: string, terminal: boolean = false): string | void

  • text: The text to be colorized.
  • terminal: A boolean flag indicating whether to print the colorized text directly to the terminal.
  • return: is true, prints the colorized text to the terminal and returns void. Otherwise, returns the colorized text as a string.

💖 Contribuition

Your contributions are highly valued! Feel free to enhance this project by opening an issue to report any problems or submitting a pull request with your proposed changes.

Ansi Styles

| Names | Types | Description | |-------------------|-------------|-------------| | reset | modifier | Reset the current style | | bold | modifier | Make the text bold | | italic | modifier | Make the text italic | | dim | modifier | Make the text have lower opacity | | inverse | modifier | Invert background and foreground colors | | underline | modifier | Put a horizontal line below the text | | hidden | modifier | Print the text but make it invisible | | strikethrough | modifier | Puts a horizontal line through the center of the text | | overline | modifier | Put a horizontal line above the text | | black | color | Make the text turn black | | red | color | Make the text turn red | | green | color | Make the text turn green | | yellow | color | Make the text turn yellow | | blue | color | Make the text turn blue | | magenta | color | Make the text turn magenta | | cyan | color | Make the text turn cyan | | white | color | Make the text turn white | | blackBright | color | Make the text turn black bright | | redBright | color | Make the text turn red bright | | greenBright | color | Make the text turn green bright | | yellowBright | color | Make the text turn yellow bright | | blueBright | color | Make the text turn blue bright | | magentaBright | color | Make the text turn magenta bright | | cyanBright | color | Make the text turn cyan bright | | whiteBright | color | Make the text turn white bright | | bgBlack | background | Make the background of the text black | | bgRed | background | Make the background of the text red | | bgGreen | background | Make the background of the text green | | bgYellow | background | Make the background of the text yellow | | bgBlue | background | Make the background of the text blue | | bgMagenta | background | Make the background of the text magenta | | bgCyan | background | Make the background of the text cyan | | bgWhite | background | Make the background of the text white | | bgBlackBright | background | Make the background of the text black bright | | bgRedBright | background | Make the background of the text red bright | | bgGreenBright | background | Make the background of the text green bright | | bgYellowBright | background | Make the background of the text yellow bright | | bgBlueBright | background | Make the background of the text blue bright | | bgMagentaBright | background | Make the background of the text magenta bright | | bgCyanBright | background | Make the background of the text cyan bright | | bgWhiteBright | background | Make the background of the text white bright |