NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
npm · #422 most downloaded on npm
The fastest Node.js library for formatting terminal text with ANSI colors~!
Last release 4 years ago
no release in 18 months
Ships unpredictably
gaps range from 2 weeks to 1.4 years
Nearly every release is documented
notes for 14 of 14 stable releases
7 versions withdrawn
withdrawn after publishing
8 years old
21 releases · first in 2018
Add "types" export conditions for Node16 TypeScript module resolution ( #57 ): 06f28e0 Thank you @calebeby ~!
Replace includes() usage with indexOf to allow support for older browsers ( #45 ): 86a7db8 No behavioral differences. Simply allows kleur to run in ol
One column per quarter.
Replace includes() usage with indexOf to allow support for older browsers (#45): 86a7db8
No behavioral differences. Simply allows kleur to run in old browsers (eg, IE8-11) without requiring a polyfill.
Thank you @Krinkle~!
Update benchmarks to reflect includes -> indexOf update: 19764d4
Add existence process.stdout check for browser-like polyfills ( #42 ): 01963cc Bundlers like parcel , webpack , and browserify polyfill process but do
process.stdout check for browser-like polyfills (#42): 01963ccparcel, webpack, and browserify polyfill process but don't include a stdout implementation.Ensure NO_COLOR disables colorization if any value is received ( #38 , #39 , #40 , #41 ): ef5d4a8 , b329629 Now properly adheres to the NO_COLOR spec.
(types): Ensure kleur/colors type definitions can be resolved: 06923d0 , cc66a6f
Add support for the NO_COLOR standard ( #37 ): d839af7 Thank you @stramel ~! 🎉
NO_COLOR standard (#37): d839af7Ensure process is defined before setting process -based values ( #36 ): 303e502 This allows for kleur to be imported into browsers without any bundle-
Disable colorization if inside a TTY context ( #33 ): 5c7353f Thank you @ai ~!
Disable colorization if inside a TTY context (#33): 5c7353f
Thank you @ai~!
# Before:
$ npx app.js > log.txt
#=> The `log.txt` filled with ANSI codes
# After:
$ npx app.js > log.txt
#=> The `log.txt` is plain text
# OVERRIDE:
$ FORCE_COLOR=1 npx app.js > log.txt
#=> The `log.txt` filled with ANSI codes; as requestedRevert to Node 6.x minimum support: 8c01d93 The code works perfectly in that environment, so there's no reason not to. Truth be told, it was only bump
Revert to Node 6.x minimum support: 8c01d93
The code works perfectly in that environment, so there's no reason not to.
Truth be told, it was only bumped to 10.x because of the test runner constraint.
(types) fix kleur/colors overloaded definition: f2f33a8
Original print order assumed that every export returned null, which is not true.
The minimum Node.js runtime increased from 6.x to 10.x since 10.x is the oldest active LTS version. If you need to continue supporting Node 6.x, eithe
The minimum Node.js runtime increased from 6.x to 10.x since 10.x is the oldest active LTS version.
If you need to continue supporting Node 6.x, either continue using kleur@3.x or ignore the "engines" constraint of kleur@4.x – its CommonJS files will still execute in a Node 6.x environment.
Added native ESM support with exports map (for Node 12.18.x, Node 14+) (#30): 2da16a9
Thank you @kristoferbaxter~!
Added module package entry (for bundler and PikaCDN) (#31): 2da16a9
Added new kleur/colors entry module: 049c080
These changes allow for import statements with kleur.
It's done in a way such that Node.js environments that natively support import will work. For those that don't and are using webpack/Rollup, the "module" entry is made available so that you can still take advantage of the ESM format.
We took this idea one step further with kleur/colors – which individually exports each color, modifier, and background function. This allows you to import only the methods you need, and the unused pieces of code are detached from your code. In other words, kleur/colors is 100% treeshakeable, which is a big advantage of the ESM format. Node.js (with native ESM support), Rollup, and webpack benefit from this, which means that your programs only include/load the kleur code you use.
If you're not ready to use ESM yet, require statements still work for both modules in all environments.
See the Individual Colors documentation for more info
import kleur from 'kleur';
import * as colors from 'kleur/colors';
console.log(
kleur.underline().green('kleur natively supports ESM~!')
);
console.log(
colors.white(colors.italic(`... so does "${ colors.green('kleur/colors') }"~!`))
);Add grey alias (#21): 59bdd40 _Thanks @lumio_
Add grey alias (#21): 59bdd40
Thanks @lumio
Types: Export all interfaces (#23): 70e682d Thanks @Hammster
Always reopen code on shared code.close sequence: 10981d2
Internal: Track chain segments by code.open value, not color name: e9dbd08
Internal: Initialize all codes inline within factory: e9dbd08
Internal: Check code.close existence before String.replace: b1b41a8
Internal: Only String.replace on unique contents: e9dbd08
code.open sequences: 896c801Ensure this context isn't overridden by global (#18): 3d3a4cb
this context isn't overridden by global (#18): 3d3a4cbFix: Set enumerable properties for object visibility (#18): 48b3027 _Thanks @marvinhagemeister~!_
Fix: Set enumerable properties for object visibility (#18): 48b3027 Thanks @marvinhagemeister~!
Fix: Improve TS typings for expected CommonJS behavior (#18): 48b3027 Thanks again @marvinhagemeister~!
> Important: The release of kleur@3.0 deprecates older kleur versions.
This version is an intentional departure from the Chalk-like syntax. Any previous kleur chains (those with more than one color) will not work with 3.0 and will require slight changes. Most libraries can expect to update their usage within a few minutes!
// Before:
kleur.red.bold.underline('bolded, underlined, and red~!');
// After:
kleur.red().bold().underline('bolded, underlined, and red~!');
However, should you prefer the old syntax, please consider using ansi-colors instead since (in most cases) it's a drop-in replacement for Chalk while staying significantly smaller and faster.
You can also replace kleur@2.x with ansi-colors without any code/syntax changes.
Important: The release of
kleur@3.0deprecates olderkleurversions.
Named Chains & Partial Requires
It's now possible to save color-chains directly as variables!
// Before:
const kleur = require('kleur');
const toError = msg => kleur.white.bold.bgRed(msg);
toError('Oops');
// After:
const { white } = require('kleur'); // now possible
const toError = white().bold().bgRed;
toError('Oops');
Detect Color Support (#13)
A (super) simple check for color support is now included, which sets the initial value for enabled.
Many libs attempt to toggle colors via
FORCE_COLORsince this ENV is used by Chalk. See alsoNODE_DISABLE_COLORS.
const { FORCE_COLOR, NODE_DISABLE_COLORS, TERM } = process.env;
const $ = {
enabled: !NODE_DISABLE_COLORS && TERM !== 'dumb' && FORCE_COLOR !== '0'
};
Improved TypeScript definitions (#14): 05ccfa8 _Thanks @Rich-Harris~!_
Handle Numbers safely as Strings: e7c96db, 1ed6120
Numbers safely as Strings: e7c96db, 1ed6120Nothing published for this version
Include TypeScript definitions: (#8): 0b44261 _Thank you @madhavarshney and @rogierschouten_
enabled example in README: 58496c9ansi-colors credits; with pitch & preference: 94d4f96Performance improvements: 9da1922, 9d1a735
Performance improvements: 9da1922, 9d1a735
CODES for legibility & ~700 op/s gainclorox@2.0: e865520Nothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →