Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Easily add color to your console.log
s in Node.js.
npm install colorboy
require("colorboy").addDefaults();
console.log("Globgogabgalab".red);
console.log("Potato chips".cyan.underline.italic);
console.log("The Eden Project".color("#067CB6").bgColor(25, 25, 150).bold);
Below you can see how to specify colors. To specify a background color, simply use .bgColor()
instead of .color()
.
addDefaults()
:
'Sonic'.cyan
Can be red
, black
, green
, yellow
, blue
, pink
, cyan
, white
or gray
'Sonic'.color('crimson')
'Sonic'.color('#FF00FF')
'Sonic'.color(220, 20, 60)
'Sonic'.color(220, 20, 60, 'rgb')
'Sonic'.color(32, 100, 100, 'hsl')
'Sonic'.color(32, 100, 50, 'hsv')
'Sonic'.color(32, 0, 50, 'hwb')
Passing arrays works too:
// the following are equivalent:
'Sonic'.color(220, 20, 60)
'Sonic'.color([220, 20, 60])
// the following are equivalent:
'Sonic'.color(32, 100, 100, 'hsl')
'Sonic'.color([32, 100, 100, 'hsl'])
Use styles added by addDefaults()
:
'Sonic'.bold
Can be bold
, dim
, italic
, underline
, inverse
and strikethrough
When specifying custom styles, you can pass a string or an array of strings. These are the possible strings:
"bold"
"dim"
"italic"
"underline"
"inverse"
"strikethrough"
"reset"
"hidden"
"visible"
let currentBgColor = 'red';
require('./index.js')
.addColor("crimson", {color:"crimson"})
.addColor('greenish', {
color: '#000000',
bgColor: '#00FE7C',
style: ['bold', 'italic'],
})
.addColorFunction('error', (color) => {
return {
color: color,
bgColor: currentBgColor,
}
})
console.log('Custom:');
console.log('Unlike Pluto'.greenish);
console.log('Unlike Pluto'.error('white'));
currentBgColor = 'cyan'
console.log('Unlike Pluto'.error('black'));
Adds the default colorboy colors & styles. Takes three optional arguments, all true by default.
functions
: Whether to add the default functions prototypes (color
, bgColor
and style
)colors
: Whether to add the default colors prototypes (red
, green
, etc)styles
: Whether to add the default styles prototypes (bold
, underline
, etc)Adds a color prototype.
name
: The prototype nameoptions
: A color object
(see below)name
: The prototype name.options
: A function that returns a color object
(see below).An object that defines colors and styles, in this format:
{
color: COLOR,
bgColor: COLOR,
style: STYLE
}
npm install
To test, run:
npm run test
npm version <version>
npm publish
2.1.0 - 2020 Sep 5
'Monstercat'.color(255, 0, 255)
FAQs
Easily add color to your console.log in Node.js
We found that colorboy 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.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.