Gathering detailed insights and metrics for @poppinss/colors
Gathering detailed insights and metrics for @poppinss/colors
Gathering detailed insights and metrics for @poppinss/colors
Gathering detailed insights and metrics for @poppinss/colors
npm install @poppinss/colors
Update dependencies
Published on 28 Mar 2024
Updating dependencies
Published on 15 Dec 2023
Publish source map and use TSC for generating types
Published on 06 Nov 2023
Publish under latest release
Published on 14 Oct 2023
Use tsup for bundling
Published on 23 Sept 2023
Update dependencies
Published on 29 Jun 2023
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
5 Stars
92 Commits
2 Forks
4 Watching
2 Branches
4 Contributors
Updated on 27 Dec 2023
TypeScript (99.49%)
Shell (0.51%)
Cumulative downloads
Total Downloads
Last day
6%
9,972
Compared to previous day
Last week
15.6%
54,345
Compared to previous week
Last month
6.9%
210,147
Compared to previous month
Last year
101.4%
2,055,657
Compared to previous year
Wrapper over kleur with better support for testing
This package is a wrapper over kleur with additional implementations to make testing easier and work seamlessly with terminals/stdout streams that do not support colors.
Install the package from the npm registry as follows.
1npm i @poppinss/colors
And use it as follows. The ansi
method returns an instance of the kleur package.
1import useColors from '@poppinss/colors' 2const colors = useColors.ansi() 3 4console.log(colors.red('this is an error')) 5console.log(colors.cyan('hello world'))
Chaining methods
1const colors = useColors.ansi() 2console.log(colors.red().bgBlack('this is an error'))
The raw implementation is ideal for testing. Instead of outputting ANSI escape codes, we wrap the string with transformation names. For example:
1import useColors from '@poppinss/colors' 2const colors = useColors.raw() 3 4console.log(colors.red('hello world')) 5// OUTPUT: red(hello world) 6 7console.log(colors.bgBlack().red('hello world')) 8// OUTPUT: bgBlack(red(hello world))
As you can notice, the output is a plain text value, so it is easier to write assertions against it.
1assert.equal(colors.red('hello world'), 'red(hello world)')
The silent mode does not perform any transformations on the string and returns the value. This is helpful when the output terminal or stdout stream does not support colors.
1import useColors from '@poppinss/colors' 2const colors = useColors.silent() 3 4console.log(colors.red('hello world')) 5// OUTPUT: hello world 6 7console.log(colors.bgBlack().red('hello world')) 8// OUTPUT: hello world
Ideally, you will use one of the available implementations based on some runtime environment. For example:
1import useColors from '@poppinss/colors' 2import supportsColor from 'supports-color' 3 4const isTestEnv = process.env.NODE_ENV === 'test' 5 6const colors = isTestEnv 7 ? useColors.raw() // use raw in test environment 8 : supportsColor.stdout 9 ? useColors.ansi() // use kleur when stdout has colors 10 : useColors.silent() // use silent mode 11 12export default colors
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 1/30 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
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
Score
Last Scanned on 2024-11-18
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