Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
ansi-colors-es6
Advanced tools
ES6+ module to easily add ANSI colors to your browser console and node terminal. A faster drop-in replacement for chalk, kleur and turbocolor (without the dependencies and rendering bugs).
Easily add ANSI colors to your node terminal or browser console. A faster drop-in replacement for chalk, colors, kleur and turbocolor (without the dependencies and rendering bugs). And a lighter ES6 implementation of
ansi-colors
that works everywhere ES6+ works without the need for transpiling, unless you want to.
Install with npm:
$ npm install --save ansi-colors-es6
ansi-colors-es6 is the fastest Node.js library for terminal and browser console styling. A more performant drop-in replacement for chalk, colors and ansi-colors with no dependencies.
String.prototype
like others.//use relative paths to allow code sharing with browsers
//this way the same exact files will work in all locations
import ansi from './node_modules/ansi-colors-es6/index.js';
console.log(ansi.red('This is a red string!'));
console.log(ansi.green('This is a red string!'));
console.log(ansi.cyan('This is a cyan string!'));
console.log(ansi.yellow('This is a yellow string!'));
//use relative paths to allow code sharing with browsers
//this way the same exact files will work in all locations
import ansi from './node_modules/ansi-colors-es6/index.js';
console.log(ansi.bold.red('this is a bold red message'));
console.log(ansi.bold.yellow.italic('this is a bold yellow italicized message'));
console.log(ansi.green.bold.underline('this is a bold green underlined message'));
//use relative paths to allow code sharing with browsers
//this way the same exact files will work in all locations
import ansi from './node_modules/ansi-colors-es6/index.js';
console.log(ansi.yellow(`foo ${ansi.red.bold('red')} bar ${ansi.cyan('cyan')} baz`));
Easily enable/disable colors.
//use relative paths to allow code sharing with browsers
//this way the same exact files will work in all locations
import ansi from './node_modules/ansi-colors-es6/index.js';
// disable colors manually
ansi.enabled = false;
// or use a library to automatically detect support
ansi.enabled = require('color-support').hasBasic;
console.log(ansi.red('I will only be colored red if the terminal supports colors'));
Use the .unstyle
method to strip ANSI codes from a string.
console.log(ansi.unstyle(ansi.blue.bold('foo bar baz')));
//=> 'foo bar baz'
Note that bright and bright-background colors are not always supported.
Colors | Background Colors | Bright Colors | Bright Background Colors |
---|---|---|---|
black | bgBlack | blackBright | bgBlackBright |
red | bgRed | redBright | bgRedBright |
green | bgGreen | greenBright | bgGreenBright |
yellow | bgYellow | yellowBright | bgYellowBright |
blue | bgBlue | blueBright | bgBlueBright |
magenta | bgMagenta | magentaBright | bgMagentaBright |
cyan | bgCyan | cyanBright | bgCyanBright |
white | bgWhite | whiteBright | bgWhiteBright |
gray | |||
grey |
(gray
is the U.S. spelling, grey
is more commonly used in the Canada and U.K.)
dim
bold
hidden
italic
underline
inverse
strikethrough
reset
Create custom aliases for styles.
//use relative paths to allow code sharing with browsers
//this way the same exact files will work in all locations
import ansi from './node_modules/ansi-colors-es6/index.js';
ansi.alias('primary', ansi.yellow);
ansi.alias('secondary', ansi.bold);
console.log(ansi.primary.secondary('Foo'));
A theme is an object of custom aliases.
//use relative paths to allow code sharing with browsers
//this way the same exact files will work in all locations
import ansi from './node_modules/ansi-colors-es6/index.js';
ansi.theme({
danger: ansi.red,
dark: ansi.dim.gray,
disabled: ansi.gray,
em: ansi.italic,
heading: ansi.bold.underline,
info: ansi.cyan,
muted: ansi.dim,
primary: ansi.blue,
strong: ansi.bold,
success: ansi.green,
underline: ansi.underline,
warning: ansi.yellow
});
// Now, we can use our custom styles alongside the built-in styles!
console.log(ansi.danger.strong.em('Error!'));
console.log(ansi.warning('Heads up!'));
console.log(ansi.info('Did you know...'));
console.log(ansi.success.bold('It worked!'));
Commits | Contributor |
---|---|
48 | jonschlinkert |
42 | doowb |
9 | RIAEvangelist |
6 | lukeed |
2 | Silic0nS0ldier |
1 | dwieeb |
1 | jorgebucaran |
1 | madhavarshney |
1 | chapterjason |
FAQs
ES6+ module to easily add ANSI colors to your browser console and node terminal. A faster drop-in replacement for chalk, kleur and turbocolor (without the dependencies and rendering bugs).
The npm package ansi-colors-es6 receives a total of 51 weekly downloads. As such, ansi-colors-es6 popularity was classified as not popular.
We found that ansi-colors-es6 demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.