Gathering detailed insights and metrics for colors
Gathering detailed insights and metrics for colors
Gathering detailed insights and metrics for colors
Gathering detailed insights and metrics for colors
npm install colors
98.8
Supply Chain
100
Quality
75.8
Maintenance
100
Vulnerability
100
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
5,176 Stars
259 Commits
448 Forks
53 Watching
2 Branches
43 Contributors
Updated on 25 Nov 2024
Minified
Minified + Gzipped
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-11%
3,303,030
Compared to previous day
Last week
1.5%
20,184,763
Compared to previous week
Last month
16.6%
81,389,477
Compared to previous month
Last year
-18.5%
890,864,482
Compared to previous year
2
Please check out the roadmap for upcoming features and releases. Please open Issues to provide feedback, and check the develop
branch for the latest bleeding-edge updates.
npm install colors
By popular demand, colors
now ships with two types of usages!
The super nifty way
1var colors = require('colors'); 2 3console.log('hello'.green); // outputs green text 4console.log('i like cake and pies'.underline.red); // outputs red underlined text 5console.log('inverse the color'.inverse); // inverses the color 6console.log('OMG Rainbows!'.rainbow); // rainbow 7console.log('Run the trap'.trap); // Drops the bass 8
or a slightly less nifty way which doesn't extend String.prototype
1var colors = require('colors/safe'); 2 3console.log(colors.green('hello')); // outputs green text 4console.log(colors.red.underline('i like cake and pies')); // outputs red underlined text 5console.log(colors.inverse('inverse the color')); // inverses the color 6console.log(colors.rainbow('OMG Rainbows!')); // rainbow 7console.log(colors.trap('Run the trap')); // Drops the bass 8
I prefer the first way. Some people seem to be afraid of extending String.prototype
and prefer the second way.
If you are writing good code you will never have an issue with the first approach. If you really don't want to touch String.prototype
, the second usage will not touch String
native object.
The package will auto-detect whether your terminal can use colors and enable/disable accordingly. When colors are disabled, the color functions do nothing. You can override this with a command-line flag:
1node myapp.js --no-color 2node myapp.js --color=false 3 4node myapp.js --color 5node myapp.js --color=true 6node myapp.js --color=always 7 8FORCE_COLOR=1 node myapp.js
Or in code:
1var colors = require('colors'); 2colors.enable(); 3colors.disable();
1var name = 'Marak'; 2console.log(colors.green('Hello %s'), name); 3// outputs -> 'Hello Marak'
1 2var colors = require('colors'); 3 4colors.setTheme({ 5 silly: 'rainbow', 6 input: 'grey', 7 verbose: 'cyan', 8 prompt: 'grey', 9 info: 'green', 10 data: 'grey', 11 help: 'cyan', 12 warn: 'yellow', 13 debug: 'blue', 14 error: 'red' 15}); 16 17// outputs red text 18console.log("this is an error".error); 19 20// outputs yellow text 21console.log("this is a warning".warn);
1var colors = require('colors/safe'); 2 3// set single property 4var error = colors.red; 5error('this is red'); 6 7// set theme 8colors.setTheme({ 9 silly: 'rainbow', 10 input: 'grey', 11 verbose: 'cyan', 12 prompt: 'grey', 13 info: 'green', 14 data: 'grey', 15 help: 'cyan', 16 warn: 'yellow', 17 debug: 'blue', 18 error: 'red' 19}); 20 21// outputs red text 22console.log(colors.error("this is an error")); 23 24// outputs yellow text 25console.log(colors.warn("this is a warning")); 26
1var colors = require('colors'); 2 3colors.setTheme({ 4 custom: ['red', 'underline'] 5}); 6 7console.log('test'.custom);
Protip: There is a secret undocumented style in colors
. If you find the style you can summon him.
The latest stable version of the package.
Stable Version
3
7.5/10
Summary
Infinite Loop in colors.js
Affected Versions
>= 1.4.1
Patched Versions
0/10
Summary
Infinite loop causing Denial of Service in colors
Affected Versions
= 1.4.44-liberty-2
Patched Versions
0/10
Summary
Infinite loop causing Denial of Service in colors
Affected Versions
>= 1.4.1, <= 1.4.2
Patched Versions
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 5/24 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
15 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More