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

chalk-flags

v1.0.5

Published

Declarative styling inside the text itself.

Downloads

3

Readme


Features

  • All core colors, background colors, and text styles are supported
  • Customizable syntax*
  • Flag chaining and coverage
  • Performant**

Installation Process

From npm (recommended)

npm install --save chalk-flags

From source

git clone https://github.com/rainwashed/chalk-flags.git

or

gh repo clone rainwashed/chalk-flags

and import the src/index.js file or the src/index.min.js
ex:

import ChalkFlags from "./src/index.js"

Syntax

ChalkFlags requires a very declarative syntax. The default settings of the ChalkFlags syntax are the syntaxRules.flagSplit = "/" and syntaxRules.flagEnd = "end" meaning the "/" splits the flags and the actual main text, and the "end" declare the end of a ChalkFlag chunk.
ex:

flags/main text content/end
      ^                  ^
syntaxRules.flagSplit    syntaxRules.flagEnd

Flags

Flags have a simple structure, and are often characterized as either one or two characters combined with "modifiers".
(Note: Modifiers can also stand on their own)

Color

r - Red
g - Green
y - Yellow
b - Blue
m - Magenta
c - Cyan
w - White
bk - Black
gr - Gray

Modifiers

ii - Italics
bb - Bold
un - Underline
st - ~~Strikethrough~~
in - Inverse
bt^ - Bright
bg^ - Background

^: bt and bg behave differently compared to the other modifiers, but are classified as such due to their pattern. Their use will be described more in-depth later.

The flags come before the main text content. Refer back to this structure later:

flags/main text content/end
      ^                  ^
syntaxRules.flagSplit    syntaxRules.flagEnd

The flags come before the syntaxRules.flagSplit and are conjoined using +. A simple example would be a bold and red text consisting of the string Hello World.
For this to be represented in the ChalkFlags syntax, it goes as follows:

r+bb/Hello World/end

For modifiers such as bt and bg, they are appended to other flags rather than standing on their own. bt will brighten whatever color it is attached to (ex: Light Cyan = c_bt). bt will always require an _ to attach itself to a flag, so if the Light Cyan flag was written as cbt, it would not work.

bg also attaches to another flag, but it makes the color the background color instead. bg requires that the B in the bg be capitalized during the flag statement (ex: Cyan Background = cBg). bg should always follow the color flag, not come before it.

Documentation

chalk-flags exports one class which is the ChalkFlag class, but since it is the default export, the name can be whatever during import. The ChalkFlag class must be initialized for the project to run as each ChalkFlag class can contain its own settings and syntax, making chalk-flags very versatile.

constructor(verboseLogging=false, customSplitRule=" ", syntaxRules={ flagSplit: "/", flagEnd: "end" })

This will initialize ChalkFlag for usage with the parse function.
verboseLogging must be a boolean type.
customSplitRule must be a string type.
syntaxRules must be an object type with the flagSplit and flagEnd must be strings.

  • verboseLogging determines if ChalkFlag should do verbose logging such as the lexer system, what it is processing, etc.

  • customSplitRule (kinda redundant) determines how two different flag declarations should be handled. (Ex: r+ii/Hello World/end b+ii/Goodbye World/end)

  • syntaxRules (kinda redundant) determines how the flag declaration syntax should be handled. The flagSplit properties tells where the flags and the main text content should split and the flagEnd property tells where the end of the flag chunk is

returns a ChalkFlag object/class

parse(string)

The parse function takes in the input string that is the type of string and is the chalk declaration meaning the flags + text + flag ending.

returns a properly, color-formatted string to be console.log

Example

import ChalkFlag from "chalk-flags"

const cf = new ChalkFlag();
const formattedString = cf.parse("r/Hello World/end");

console.log(formattedString);

// Console log red colored "Hello World"

Caveats

  • * The syntax is still quite limiting and I hope to expand the syntax to enable custom colors/hexadecimal codes.
  • ** The performance I have still not measured to other packages, but from all the testing I've done, it seems to run quite fast.

TODO

TODO.md

BUGS

BUGS.md

Contributors

// No one has contributed yet

Contribution Process

Anyone is welcome and free to contribute to the project. Just clone the repository, create a separate branch (use your username as the branch name), make your changes, and send a pull request

License

This project is under the MIT license (same as chalk) and more information can be found in the LICENSE file.