
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Coloriz is a lightweight extension of Chalk that enhances the String
prototype to make styling terminal output more intuitive and expressive.
Instead of calling functions like chalk.red("text")
, you can now simply write "text".red
or "text".bld.bgYellowBright
.
❗ Note: Coloriz is not a replacement for Chalk — it uses Chalk under the hood. It's a syntactic enhancement, not a standalone coloring engine.
String.prototype
with style and color properties.rgb()
, .hex()
, .ansi256()
, .clearANSI
, .transform()
property.chalk
)npm install coloriz
⚠️ Requires Node.js v16+
require("coloriz");
console.log("Hello".green);
console.log("Info".bgCyan.italic);
console.log("Error".red.underline);
console.log("Debug".bgBlackBright.dim);
// Custom text colros
console.log("Custom Color".rgb(128, 0, 128));
console.log("Custom Hex".hex("#ff5733"));
console.log("Ansi256".ansi256(45));
// Custom background colors
console.log("Custom Background color".bgRgb(128, 0, 128));
console.log("Custom Background Hex".bgHex("#ff5733"));
console.log("Custom Background Ansi256".bgAnsi256(45));
// Clear ANSI codes (ex: for writing in file)
console.log("Clear ANSI".green.clearANSI);
// transform function
const condition = true;
console.log(
"Hello, World!".transform(s => condition ? s.green : s.red)
)
// Retrieve the chalk instance
const chalk = "".chalk;
import "coloriz";
console.log("Hello".green);
console.log("Info".bgCyan.italic);
console.log("Error".red.underline);
console.log("Debug".bgBlackBright.dim);
// Custom text colros
console.log("Custom Color".rgb(128, 0, 128));
console.log("Custom Hex".hex("#ff5733"));
console.log("Ansi256".ansi256(45));
// Custom background colors
console.log("Custom Background color".bgRgb(128, 0, 128));
console.log("Custom Background Hex".bgHex("#ff5733"));
console.log("Custom Background Ansi256".bgAnsi256(45));
// Clear ANSI codes (ex: for writing in file)
console.log("Clear ANSI".green.clearANSI);
// transform function
const condition = true;
console.log(
"Hello, World!".transform(s => condition ? s.green : s.red)
)
// Retrieve the chalk instance
const chalk = "".chalk;
Property | Description |
---|---|
reset | Reset all styles |
bld | Bold |
dim | Dim |
italic | Italic |
underline | Underlined |
inverse | Inverted foreground/background |
hidden | Hidden |
strikethrough | Strike-through |
Color 16/32 | Bright Variant |
---|---|
black | |
red | redBright |
green | greenBright |
yellow | yellowBright |
blue | blueBright |
magenta | magentaBright |
cyan | cyanBright |
white | whiteBright |
gray | (bright black) |
Color 16/32 | Bright Variant |
---|---|
bgBlack | bgBlackBright |
bgRed | bgRedBright |
bgGreen | bgGreenBright |
bgYellow | bgYellowBright |
bgBlue | bgBlueBright |
bgMagenta | bgMagentaBright |
bgCyan | bgCyanBright |
bgWhite | bgWhiteBright |
You can also use functions to apply custom colors:
Function | Example usage |
---|---|
.rgb(r, g, b) | "hello".rgb(255, 0, 128) |
.hex("#RRGGBB") | "hi".hex("#ffcc00") |
.ansi256(n) | "good bye".ansi256(45) |
Function | Example usage |
---|---|
.bgRgb(r, g, b) | "hello".bgRgb(255, 0, 128) |
.bgHex("#RRGGBB") | "hi".bgHex("#ffcc00") |
.bgAnsi256(n) | "good bye".bgAnsi256(45) |
Name | Description |
---|---|
.clearANSI | String property to strip ANSI codes |
.transform(fn) | Apply a transformation function to the string |
.chalk | Retrieve the underlying Chalk instance |
"coloriz"
once in your entry point (e.g., main.ts
, index.js
)If you need to access the underlying Chalk instance, you can do so by extracting it from .chalk
to a string.
const chalk = "".chalk;
This allows you to use all Chalk methods and properties directly, without needing to install Chalk separately.
You still are!
Coloriz is built entirely on top of Chalk. It doesn't replace it — it simplifies how you use it.
Chalk | Coloriz |
---|---|
chalk.red("Hi") | "Hi".red |
chalk.bold.green("Ok") | "Ok".green.bld |
chalk.hex("#f00")("Hi") | "Hi".hex("#f00") |
--> Changelog
MIT © Oignontom8283
FAQs
String Extensions for Styling Text with Chalk
We found that coloriz demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.