ansis
4.5.0 · 1 Nov 2026ISC56.7M / weekRepositoryHomepagenpmAtom feed
62 stable releases, newest first, by release line. Notes are quoted as the maintainers published them.
- 4.x · latest line
4.5.0
1 Nov 2026color-support: prevent colors in piped or redirected output when
COLORTERMis set, #54color-support: detect the color level for
FORCE_COLOR=trueand--colorin non-TTY output
Bug Fixes
color-support: prevent colors in piped or redirected output when
COLORTERMis set, #54color-support: detect the color level for
FORCE_COLOR=trueand--colorin non-TTY output
Behavior
Colors are enabled only for a TTY, CI, and the PM2 and Next.js runtimes. Output to a pipe or a file has no colors, even when
COLORTERMis set.COLORTERMsets only the color level.FORCE_COLOR=true,FORCE_COLOR=and--colorin non-TTY output now detect the level from the environment (COLORTERM,TERM, Windows) instead of always using 16 colors.Upgrade note
If your tests relied on
COLORTERMto get colors, setFORCE_COLORinstead, for exampleFORCE_COLOR=3 npm test. See Testing.4.4.0
13 Sep 2026Ansis now treats
TERM=dumbas no color before applyingCOLORTERM, CI detection, PM2, Next.js runtime detection, and platform-specific defaults, #49.Bug fixes
1.
TERM=dumbnow disables colors during auto-detectionAnsis now treats
TERM=dumbas no color before applyingCOLORTERM, CI detection, PM2, Next.js runtime detection, and platform-specific defaults, #49.Before,
COLORTERM=truecoloror other later auto-detection checks could still enable colors even when the environment reportedTERM=dumb. This could produce visible ANSI escape codes in environments such as EmacsM-x compile.COLORTERMremains a color capability hint.FORCE_COLORkeeps the highest priority and can still explicitly enable colors.Use case v4.3.1 v4.4.0 Notes TERM=dumb✅ may allow colors * ❌ no color TERM=dumbnow has higher priority inautoDetectLevel.TERM=dumb+COLORTERM=truecolor✅ allow colors ❌ no color COLORTERMno longer overridesTERM=dumb.TERM=dumb+ CI✅ allow colors ❌ no color CI detection runs after TERM=dumb.TERM=dumb+ PM2✅ may allow colors * ❌ no color PM2 detection runs after TERM=dumb.TERM=dumb+ Next.js runtime✅ may allow colors * ❌ no color Next.js detection runs after TERM=dumb.COLORTERMwithoutTERM=dumb✅ allow colors ✅ allow colors Unchanged. CI without TERM=dumb✅ allow colors ✅ allow colors Unchanged. PM2 without TERM=dumb✅ allow colors ✅ allow colors Unchanged. Next.js without TERM=dumb✅ allow colors ✅ allow colors Unchanged. *- Depends on additional conditions.4.3.1
31 May 2026Before,
resetwas treated like any other style with anopenand aclosecode, so it wrapped the value on both sides. That produced extra reset sequences in chained, nested, template literal, and multiline compositions, and the output did not match what a singleresetshould do.Bug fixes
1.
resetno longer appends a closing sequenceImportant
resetis now a single SGR command, not a paired open/close style.ansis.reset(value)prepends\x1b[0mand no longer appends a closing reset. If your code or snapshot tests relied on the trailing\x1b[0m, update them or add the reset explicitly (see below).Before,
resetwas treated like any other style with anopenand aclosecode, so it wrapped the value on both sides. That produced extra reset sequences in chained, nested, template literal, and multiline compositions, and the output did not match what a singleresetshould do.Before:
ansis.reset('foo'); // "\x1b[0mfoo\x1b[0m"Now:
ansis.reset('foo'); // "\x1b[0mfoo"If you need a trailing reset, add it explicitly:
ansis.reset`foo ${ansis.red('bar')} baz` + ansis.reset(); // "\x1b[0mfoo \x1b[31mbar\x1b[39m baz\x1b[0m"ansis.reset()without argument returns just the reset code\x1b[0m, which makes appending it easy.2.
strip()removes OSC 8 hyperlink sequencesstrip()did not clear the OSC 8 sequences produced bylink().
It now removes them and returns plain text:ansis.strip(ansis.link('https://example.com', 'text')); // "text"3. No style leakage between instances with different color levels
Styles created on one
Ansisinstance could appear on another instance that was created with a different color level. That could give output rendered at the wrong color level.
Now, instances are isolated, so each one keeps its own styles and level.import { Ansis } from 'ansis'; const noColor = new Ansis(0); const color = new Ansis(1); // Fixed: chained styles on `noColor` stay unstyled. noColor.red.bold('foo'); // -> 'foo' // Reference: a colored instance still renders the same chain with ANSI styles. color.red.bold('foo'); // -> '\x1b[31m\x1b[1mfoo\x1b[22m\x1b[39m'4.
.extend()no longer affects other instancesCalling
.extend()on one instance could override styles on other instances that use a different color level.
Now, the.extend()method stays local to the instance on which it is called.import { Ansis } from 'ansis'; const trueColor = new Ansis(3); const noColor = new Ansis(0); trueColor.extend({ pink: '#ff69b4', }); // Fixed: `extend()` stays local to `trueColor`. trueColor.red('foo'); // -> '\x1b[31mfoo\x1b[39m' // Fixed: extending `trueColor` does not leak styles or color level into `noColor`. noColor.red('foo'); // -> 'foo'4.3.0
11 May 2026Added
link(url, text?)for OSC 8 hyperlinks, supported by many terminal emulators, #44Added constructor overload to pass a mock
globalThisobject for controlled color auto-detection, #47import { Ansis } from 'ansis'; const color = new Ansis({ process: { env: { FORCE_COLOR: '1' }, argv: ['node', 'app.js'], stdout: { isTTY: false }, platform: 'linux', }, }); console.log(color.level); // 1
Features
Added
link(url, text?)for OSC 8 hyperlinks, supported by many terminal emulators, #44Added constructor overload to pass a mock
globalThisobject for controlled color auto-detection, #47import { Ansis } from 'ansis'; const color = new Ansis({ process: { env: { FORCE_COLOR: '1' }, argv: ['node', 'app.js'], stdout: { isTTY: false }, platform: 'linux', }, }); console.log(color.level); // 1
Bugfix
Fixed the handling edge cases for using ENV variables and CLI flags, #46
Fixed edge case Old behavior (bug) New behavior (correct) FORCE_COLOR=1,NO_COLOR=1disable color enable color ( FORCE_COLORtakes precedence overNO_COLOR)NO_COLOR=1,--colordisable color enable color (CLI color flags take precedence over NO_COLOR)FORCE_COLOR=1,--no-colordisable color enable color ( FORCE_COLORhas the highest priority)--no-color --colordisable color enable color (last flag wins) --colorwith no detected colorstruecolor 16 colors (auto-detect fallback uses the minimum color level, not truecolor) 4.2.0
28 Sep 2025Added support named truecolors via
ansis.extend()for both foreground and background.Feature
Added support named truecolors via
ansis.extend()for both foreground and background.Foreground methods are created from the provided color names, and matching background methods
bg*are generated automatically.output
Example:
import ansis from 'ansis'; import colorNames from 'css-color-names'; const color = ansis.extend(colorNames); console.log(color.orange('Orange foreground')); console.log(color.bgOrange('Orange background')); // auto-generated from "orange"Note
The css-color-names (~6 kB) package exports CSS color names with their hex values.
This release removes the last barrier for projects migrating from Chalk v4 that used named truecolors:
- chalk.keyword('orange')('text'); + color.orange('text'); - chalk.bgKeyword('orange')('text'); + color.bgOrange('text');Ansis provides this feature with a simpler, more intuitive API.
Important
Fallback for named truecolors
Ansis automatically interpolates named truecolors to the highest available color level supported by the current environment.
So you can safely use named truecolors anywhere without worrying about compatibility.4.1.0
28 May 2025Added readonly
levelproperty to get the detected color support level:Access to detected color level:
console.log('Detected color level: ', ansis.level);
4.0.0
8 May 2025- breaking
The
strikestyle was rarely (if ever) used and added unnecessary redundancy. - breaking
No usage of
ansis.strike()was found in public GitHub repositories. - breaking
Other ANSI libraries use the standard
strikethroughname exclusively.
Ansis v4 - Smaller package and cleaner API
Ansis v4 drops unused duplicate aliases and legacy baggage.
This release brings a stable and more compact ANSI library.
v4 is ~15.7% smaller than v3.17Follow the migration guide to upgrade.
Breaking changes
1) Dropped support for Deno 1.x (EOL - October 9, 2024)
This version now supports Deno 2.0 and above.
2) Removed non-standard
strikealias forstrikethroughstyleThe legacy
strikealias has been removed to clean up the API and stay consistent with ANSI style conventions.- breaking
The
strikestyle was rarely (if ever) used and added unnecessary redundancy. - breaking
No usage of
ansis.strike()was found in public GitHub repositories. - breaking
Other ANSI libraries use the standard
strikethroughname exclusively.
3) Removed redundant aliases:
grey,bgGrey,blackBrightandbgBlackBright- use the standardgrayandbgGrayinstead.Holywar:
grayvsgreyvsblackBrightAll these color names referred the same ANSI code.
However, keeping many separate names for the same color is too much for a small library.Why
grayonly, without aliases?ANSI codes for the gray color:
- breaking
90- officially "bright black" foreground (i.e.,gray) in terminal specs. - breaking
100- officially "bright black" background (i.e.,bgGray) in terminal specs.
Ansis prefers the more intuitive and commonly used names:
grayandbgGray.- breaking
❌
blackBright,bgBlackBright- Spec-style names for "bright black", less intuitive, never used, awkward for practical use
Note
Supporting both
grayandgrey(or even worse, verbose aliases likebgBlackBright) introduces unnecessary duplication.
Ansis v4 is focused on a clean, minimal API by intentionally avoiding redundant aliases.4) Using 256-color functions
The following legacy method aliases have been removed:
❌ Removed Method ✅ Use Instead ansi256(code)fg(code)bgAnsi256(code)bg(code)These aliases were originally added for compatibility with Chalk.
Starting with this release, Ansis focuses on a cleaner and compact API, free from duplicated methods and legacy layers.Why
fg()andbg()are better thanansi256()andbgAnsi256()Ansis has grown beyond being a Chalk-compatible alternative - it's now a modern and compact ANSI library with its own identity.
Clean API
- breaking
ansis.fg(code)andansis.bg(code)are shorter more elegant thanansis.ansi256(code)andansis.bgAnsi256(code) - breaking
fgandbgclearly describe their purpose: setting foreground and background colors - breaking
These method names align with conventions used by many other color libraries
- breaking
Introduced on Dec 2021,
fg()andbg()are already being used in GitHub projects - breaking
Removing duplicates makes the API cleaner and more compact
5) Removed the unused
AnsiColorsExtendtype.This type was intended to support extended theme colors, but it was never used in other projects.
If you relied on it in your own code (e.g. for typing custom styles), you can easily define it yourself.6) Improved
extend()methodThe
extend()method has been redesigned for better TypeScript support and flexibility.Old behavior
extend<U extends string>(colors: Record<U, string>): asserts this is Ansis & Record<U, Ansis>;
- breaking
Modifies the current instance in-place.
- breaking
Returns
void. - breaking
✅ Worked with default instance:
import ansis from 'ansis'; ansis.extend({ pink: '#FF75D1' }); console.log(ansis.pink('foo')); - breaking
❌ Limitation - Did not work with newly created instances:
import { Ansis } from 'ansis'; const ansis = new Ansis(); ansis.extend({ pink: '#FF75D1' }); // TS2775: Assertions require every name in the call target to be declared with an explicit type annotation. console.log(ansis.pink('Hello')); // TS2339: Property 'pink' does not exist
New behavior
extend<U extends string>(colors: Record<U, string >): Ansis & Record<U, Ansis>;
Returns an extended instance with full type support.
✅ Works with both
ansisandnew Ansis():import antis from 'ansis'; const colors = ansis.extend({ pink: '#FF75D1' }); console.log(colors.pink('foo'));import { Ansis } from 'ansis'; const ansis = new Ansis().extend({ pink: '#FF75D1' }); console.log(ansis.pink('foo'));
Why this change?
TypeScript cannot widen the type of an existing variable when using
asserts.
This means the old approach only worked for top-level constants likeansis, not new instances.
By returning the extended instance, the new approach enables full type inference in all scenarios.Summary:
- breaking
assertsversion removed - breaking
extend()now returns an instance with extended types - breaking
Cleaner, safer, and fully compatible with all usage patterns
Features
1) Support escape sequences in tagged template literals
Ansis now treats tagged template literals the same way as normal strings, returning the same result as the standard function call.
Example with
\n(newline, unescaped):red('prev\nnext') red`prev\nnext`Output:
prev next
Example with escaped backslash:
red('prev\\next') red`prev\\next`Output:
prev\next
2) Manually set the color level
Ansis automatically detects color support, but you can manually set the color level.
You can create a new instance ofAnsiswith the desired color level.Disable colors:
import { Ansis } from 'ansis'; const ansis = new Ansis(0); console.log(ansis.red`foo`); // Output: plain string, no ANSI codesUse only basic 16 colors:
import { Ansis } from 'ansis'; const ansis = new Ansis(1); console.log(ansis.hex('#FFAB40')`Orange`); // Output: fallback to yellowBright3) Simplified CI color detection
Affects: In rare CI environments, output may fallback to 16 colors or black & white.
Ansis provides basic support for standard
CIenvironments by checking the commonly usedCIenvironment variable. In these environments, Ansis assumes support for at least 16 colors. If your code uses 256-color or truecolor, Ansis automatically fallback to 16 colors or to black and white if no color support is detected.Ansis focuses on the most common scenarios, as specific
CIenvironments are rarely used in practice. This approach keeps the package lightweight without including unnecessary detection logic.GitHub Actionsis still detected as supportingtruecolor, as most Ansis users rely onGitHub CI.In general, color output in
CIenvironments is not critical and can gracefully fallback when needed.The
xterm-directdetection logic (introduced inv3.5.0) has been removed, as it's unnecessary for identifying truecolor-capable terminals.Note
No terminal emulator sets
TERM=xterm-directby default.
Modern terminals, including KDE Konsole, typically useTERM=xterm-256coloralong withCOLORTERM=truecolor
to indicate truecolor support.Bug Fixes
Defaults to 16 colors for unknown color support
Ansis now defaults uses 16 colors if it cannot detect support for 256 colors or truecolor.
Old behavior: Unknown terminal → used truecolor (could result in incorrect colors)
New behavior: Unknown terminal → uses only 16 colors (ensures broad compatibility)
Note
This is not a breaking change. Ansis gracefully interpolates higher color depths (truecolor and 256 colors)
down to 16 colors when using, e.g.,fg(),hex()orrgb().
To explicitly enable truecolor, set the environment variableCOLORTERM=24bitorFORCE_COLOR=3.- 3.x
3.17.0
2 Mar 2025Added support for older
typescriptversions (<5.6) to fix TS2526 error:3.16.0
21 Feb 2025Maintenance only: docs, tests, build or refactoring. Nothing changes in how you use it.
3.15.0
16 Feb 2025Reduce the package size by ~200 bytes.
Reduce the package size by ~200 bytes.
3.14.0
12 Feb 2025Added support for chromium-based browsers.\ Now you can use truecolor in the consoles of Chrome, Edge, Opera, Brave, Vivaldi and other Chromium-based browsers.
Browsers that do not support ANSI codes will display black and white text.Added support for
\nas a newline in template literals, e.g.:green`Hello\nWorld`renders:Hello World
Function
ansis.reset()returns the reset escape code\e[0m.
Cumulative Release v3.6.0 - v3.14.0
Features
Added support for chromium-based browsers.\ Now you can use truecolor in the consoles of Chrome, Edge, Opera, Brave, Vivaldi and other Chromium-based browsers.
Browsers that do not support ANSI codes will display black and white text.Added support for
\nas a newline in template literals, e.g.:green`Hello\nWorld`renders:Hello World
Function
ansis.reset()returns the reset escape code\e[0m.Enforce a specific color support by a
FORCE_COLORvalue:false - Disables colors
0 - Disables colors
true (or unset) - Auto detects the supported colors (if no color detected, enforce truecolor)
1 - Enables 16 colors
2 - Enables 256 colors
3 - Enables truecolor
Removed undocumented pointless dummy function
ansis(any).
Warning
This is not a BREAKING CHANGE because it was never officially documented!
import ansis from 'ansis'; ansis('text'); // <= now will occur the ERROR TS2349: This expression is not callable.This warning applies only to projects where Chalk was replaced with Ansis and something like
chalk('text')was used.Just replace
ansis('text')with'text'.The
ansis('text')function was a dummy and did nothing except return the same input string.Added support for legacy Node.js v14 (in package.json for npm was changed the
enginesto"node": ">=14").Micro optimisations for slight performance improvements.
Bug Fixes
If the function argument is an empty string should be returned an empty string w/o escape codes:
ansis.red('') => '', // returns empty string w/o escape codesCast falsy values
falseandNaNto a string.
In previous versions, the empty string''was returned for falsy values.Functions with argument
0, e.g.ansis.red(0), returning empty string'', now return colored value'0'
3.12.0
10 Feb 2025Add support for
\nas a newline in template literals, e.g.:green`Hello\nWorld`renders:Hello World
3.11.0
9 Feb 2025Add support for legacy Node.js v14 (in package.json for npm was changed the
enginesto"node": ">=14")
Add support for legacy Node.js v14 (in package.json for npm was changed the
enginesto"node": ">=14")
3.10.0
27 Jan 2025ansis.reset()returns the reset escape code\e[0mMicro optimisations for slight performance improvements
ansis.reset()returns the reset escape code\e[0mMicro optimisations for slight performance improvements
3.8.1
10 Jan 2025Maintenance only: docs, tests, build or refactoring. Nothing changes in how you use it.
3.8.0
9 Jan 2025Enforce a specific color support by a
FORCE_COLORvalue:If the function argument is an empty string should be returned an empty string w/o escape codes:
ansis.red('') => '', // returns empty string w/o escape codes
Enforce a specific color support by a
FORCE_COLORvalue:false - Disables colors
0 - Disables colors
true (or unset) - Auto detects the supported colors (if no color detected, enforce truecolor)
1 - Enables 16 colors
2 - Enables 256 colors
3 - Enables truecolor
If the function argument is an empty string should be returned an empty string w/o escape codes:
ansis.red('') => '', // returns empty string w/o escape codes
3.7.0
7 Jan 2025Cast falsy values
false,null,undefined,NaNto a string. In previous versions, the empty string''was returned for falsy values.Functions with argument
0, e.g.ansis.red(0), returning empty string'', now return colored value'0'
Cast falsy values
false,null,undefined,NaNto a string. In previous versions, the empty string''was returned for falsy values.Functions with argument
0, e.g.ansis.red(0), returning empty string'', now return colored value'0'
3.6.0
4 Jan 2025Remove undocumented pointless dummy function
ansis(any)
Remove undocumented pointless dummy function
ansis(any)
Warning
This is not a BREAKING CHANGE because it was never officially documented!
import ansis from 'ansis'; ansis('text'); // <= now will occur the ERROR TS2349: This expression is not callable.This warning applies only to projects where Chalk was replaced with Ansis and something like
chalk('text')was used.Just replace
ansis('text')with'text'.The
ansis('text')function was a dummy and did nothing except return the same input string.3.5.2
27 Dec 2024Optimised the npm package size from
10.3kB to7.0 kB.Now, Ansis is the
smallestyet most powerful library withrich functionality.
A slightly smaller ispicocolors(6.4 kB), but it offers onlybasic functionality.Added detection of the
xterm-directterminal as supportingtruecolor.Added support for the
COLORTERMenvironment variable with the following values:truecolor,24bit,ansi256,ansi(16 colors).
Features
Optimised the npm package size from
10.3kB to7.0 kB.Now, Ansis is the
smallestyet most powerful library withrich functionality.
A slightly smaller ispicocolors(6.4 kB), but it offers onlybasic functionality.Added detection of the
xterm-directterminal as supportingtruecolor.Added support for the
COLORTERMenvironment variable with the following values:truecolor,24bit,ansi256,ansi(16 colors).
Bug Fixes (TypeScript)
Fixed default import in
TypeScriptcompiled withtsc:import ansis from 'ansis'now works so well asimport * as ansis from 'ansis'.Fixed the TS2339: Property 'strip' does not exist on type when the
tscoptionmoduleisnode16.
3.5.1
26 Dec 2024Maintenance only: docs, tests, build or refactoring. Nothing changes in how you use it.
3.5.0
25 Dec 2024- removed
Remove detection environment variable
GPG_TTYintroduced in3.5.0-beta.0version, because it make no sense Add support the
COLORTERMvariable for values:truecolor,24bit,ansi256,ansi(16 colors)Add support the
xterm-directterminal to detect the truecolor
3.5.0 (2024-12-26) release
Add support the
COLORTERMvariable for values:truecolor,24bit,ansi256,ansi(16 colors)Add support the
xterm-directterminal to detect the truecolor- removed
Remove detection environment variable
GPG_TTYintroduced in3.5.0-beta.0version, because it make no sense Default import in TypeScript, compiled with
tsc:import ansis from 'ansis'now works so well asimport * as ansis from 'ansis'
3.4.0
14 Dec 2024Correct detect TTY on Windows platform.
Cumulative Release v3.3.2 - v3.4.0
Bug Fixes
Correct detect TTY on Windows platform.
3.3.2
23 Jul 2024Correct detect TTY on Windows platform
Correct detect TTY on Windows platform
3.2.1 – 3.3.13 releases with no change for you1 dependency updates, 2 maintenancepackage 3.3.0Show each
- 3.3.118 Jul 2024docs, tests or tooling
- 3.3.014 Jul 2024package 3.3.0
- 3.2.112 Jul 2024docs, tests or tooling
3.2.0
24 Apr 2024Added
ansis.isSupported()method to detect color support.
3.1.1
15 Apr 2024Added detection of color support when using PM2 process manager.
Correct interpret FORCE_COLOR=false or FORCE_COLOR=0 as force disable colors\ others values, e.g., FORCE_COLOR=true or FORCE_COLOR=1 - force enable colors.
See force-color.org.
Cumulative Release
v3.0.1-v3.1.1Features
Added detection of color support when using PM2 process manager.
Bug Fixes
Correct interpret FORCE_COLOR=false or FORCE_COLOR=0 as force disable colors\ others values, e.g., FORCE_COLOR=true or FORCE_COLOR=1 - force enable colors.
See force-color.org.
3.1.0
9 Apr 2024Add detection of color support when using PM2 process manager
3.0.0
29 Mar 2024- breaking
faint(alias for dim), replace in your code withdim - breaking
doubleUnderline, replace in your code withunderline - breaking
frame, replace in your code withunderline
Features
Added detection of color spaces support: TrueColor, 256 colors, 16 colors, no color (black & white).
Added fallback for supported color space: truecolor —> 256 colors —> 16 colors —> no colors.
Improved performance for the
hex()function.
Breaking change
In the new major version
3.xare removed unused styles and methods.⚠️ Warning
Before update, please check your code whether is used deleted styles and methods.
Support Node.js
Drop supports for Node <=
14. Minimal supported version is15.0.0(Released 2020-10-20).
In the theory thev3can works with Node12, but we can't test it.Deleted styles
The
not widely supportedstyles are deleted:- breaking
faint(alias for dim), replace in your code withdim - breaking
doubleUnderline, replace in your code withunderline - breaking
frame, replace in your code withunderline - breaking
encircle, replace in your code withunderline - breaking
overline, replace in your code withunderline
Deleted methods
The methods are deleted:
- breaking
ansi, replace in your code withansi256orfg - breaking
bgAnsi, replace in your code withbgAnsi256orbg
Deleted clamp in functions
The clamp (0, 255) for the ANSI 256 codes and RGB values is removed, because is unused.
You should self check the function arguments.The affected functions:
- breaking
ansi256andfg(alias to ansi256) - expected a code in the range0 - 255 - breaking
bgAnsi256andbg(alias to bgAnsi256) - expected a code in the range0 - 255 - breaking
rgb- expected r, g, b values in the range0 - 255 - breaking
bgRgb- expected r, g, b values in the range0 - 255
- 2.x
2.3.0
15 Feb 2024Added detection of additional terminals, thanks @dse, colors.js:issue #42.
Added supports the argument as
number.Added
bgGreyandbgGrayaliases forbgBlackBright.
Cumulative Release
v2.0.1-v2.3.0Features
Added detection of additional terminals, thanks @dse, colors.js:issue #42.
Added supports the argument as
number.Added
bgGreyandbgGrayaliases forbgBlackBright.
Bug Fixes
Fixed index.d.ts to use function overload to make the tagged template have the correct type, #16.
Fixed when could not be found a declaration file for module 'ansis'.
2.2.0
3 Feb 2024Add supports the argument as
number
Add supports the argument as
number
2.1.0
30 Jan 2024Add
bgGreyandbgGrayaliases forbgBlackBright
Add
bgGreyandbgGrayaliases forbgBlackBright
2.0.2
14 Nov 2023Could not find a declaration file for module 'ansis'
2.0.1
5 Nov 2023Missing exports of ansis.strip() and ansis.export() functions (issue was introduced in v2.0.0)
Missing exports of ansis.strip() and ansis.export() functions (issue was introduced in v2.0.0)
2.0.0
3 Nov 2023- deprecated
OLD named import
import { red } from 'ansis/colors'is deprecated, use the NEW named import. - deprecated
The barely used
ansi()function name is deprecated, useansi256()or aliasfg()instead. - deprecated
The barely used
bgAnsi()function name is deprecated, usebgAnsi256()or aliasbg()instead.
Features
Added support for Deno.
Added support for Next.js
edgeruntime.Added NEW named import for
ansis:import { red } from 'ansis';For example:
NEWv2.x.ximport ansis, { red } from 'ansis'; // default and named import ansis.red`error`; red`error`;OLD
v1.5.ximport ansis from 'ansis'; // default import import { red } from 'ansis/colors'; // named import ansis.red`error`; red`error`;Optimised named export into one file to avoid separate wraps files for CJS and ESM.
Reduced the size of
dist/directory by 50%.
BREAKING CHANGE (TypeScript only)
The deprecated OLD named import from
'ansis/colors'still works, but using TypeScript can be occurred the error:TS2307: Cannot find module ansis/colors ...
Solution: update your code, e.g.:
import { red } from 'ansis/colors'-->import { red } from 'ansis'DEPRECATIONS
- deprecated
OLD named import
import { red } from 'ansis/colors'is deprecated, use the NEW named import. - deprecated
The barely used
ansi()function name is deprecated, useansi256()or aliasfg()instead. - deprecated
The barely used
bgAnsi()function name is deprecated, usebgAnsi256()or aliasbg()instead.
- 1.x
1.5.6
21 Sep 2023Only updates dependencies, nothing else changes.
1.5.5
22 Sep 2022Added support for nested template literal syntax:
console.log(red`red ${yellow`yellow ${green`green`} yellow`} red`)Added named export of colors with support for chained syntax:
import { red, green, yellow } from 'ansis/colors'; console.log(red.bold.underline`text`);Added extending of base colors with named custom truecolor:
import ansis from 'ansis'; ansis.extend({ orange: '#FFAB40' }); console.log(ansis.orange.bold('text'));
Cumulative Release
v1.3.0-v1.5.5Features
Added support for nested template literal syntax:
console.log(red`red ${yellow`yellow ${green`green`} yellow`} red`)Added named export of colors with support for chained syntax:
import { red, green, yellow } from 'ansis/colors'; console.log(red.bold.underline`text`);Added extending of base colors with named custom truecolor:
import ansis from 'ansis'; ansis.extend({ orange: '#FFAB40' }); console.log(ansis.orange.bold('text'));Added the
strip()method to remove all ANSI codes from stringAdded support for both CommonJS and ESM
Added aliases:
.fg()for.ansi256()and.bg()for.bgAnsi256()methodsOptimized distributed code size to less than
4 KB.
Bug Fixes
Fixed
visiblestyle with nested template stringsSet correct aliases for
bgAnsiandfgmethods by named exportRegard the value of the environment variable
FORCE_COLOR=0to force disable colors
1.5.4
14 Sep 2022Visible style with nested template strings
1.5.3
14 Sep 2022Set correct aliases for bgAnsi and fg methods by named export
Set correct aliases for bgAnsi and fg methods by named export
1.5.2
9 Sep 2022Regard the value of the environment variable FORCE_COLOR=0 to force disable colors
Regard the value of the environment variable FORCE_COLOR=0 to force disable colors
1.5.1
8 Sep 2022Add missing export for CJS mode in package.json
Add missing export for CJS mode in package.json
1.5.0
8 Sep 2022- deprecated
DEPRECATE v1.5.0, because missing exports main for CJS mode, fixed in v1.5.1
1.4.0
2 Jul 2022Add method strip() to remove all ANSI codes from string
1.3.6
27 Apr 2022Maintenance only: docs, tests, build or refactoring. Nothing changes in how you use it.