Installations
npm install hex-rgb
Score
99.4
Supply Chain
94.4
Quality
75.5
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Developer
sindresorhus
Developer Guide
Module System
ESM
Min. Node Version
>=12
Typescript Support
No
Node Version
16.0.0
NPM Version
7.10.0
Statistics
131 Stars
24 Commits
23 Forks
6 Watching
1 Branches
7 Contributors
Updated on 05 Jul 2024
Bundle Size
943.00 B
Minified
563.00 B
Minified + Gzipped
Languages
JavaScript (91.44%)
TypeScript (8.56%)
Total Downloads
Cumulative downloads
Total Downloads
43,277,794
Last day
-3.3%
60,215
Compared to previous day
Last week
2%
330,373
Compared to previous week
Last month
6.9%
1,422,426
Compared to previous month
Last year
50.9%
16,521,274
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
hex-rgb
Convert HEX color to RGBA
Install
$ npm install hex-rgb
Usage
1import hexRgb from 'hex-rgb'; 2 3hexRgb('4183c4'); 4//=> {red: 65, green: 131, blue: 196, alpha: 1} 5 6hexRgb('#4183c4'); 7//=> {red: 65, green: 131, blue: 196, alpha: 1} 8 9hexRgb('#fff'); 10//=> {red: 255, green: 255, blue: 255, alpha: 1} 11 12hexRgb('#22222299'); 13//=> {red: 34, green: 34, blue: 34, alpha: 0.6} 14 15hexRgb('#0006'); 16//=> {red: 0, green: 0, blue: 0, alpha: 0.4} 17 18hexRgb('#cd2222cc'); 19//=> {red: 205, green: 34, blue: 34, alpha: 0.8} 20 21hexRgb('#cd2222cc', {format: 'array'}); 22//=> [205, 34, 34, 0.8] 23 24hexRgb('#cd2222cc', {format: 'css'}); 25//=> 'rgb(205 34 34 / 80%)' 26 27hexRgb('#000', {format: 'css'}); 28//=> 'rgb(0 0 0)' 29 30hexRgb('#22222299', {alpha: 1}); 31//=> {red: 34, green: 34, blue: 34, alpha: 1} 32 33hexRgb('#fff', {alpha: 0.5}); 34//=> {red: 255, green: 255, blue: 255, alpha: 0.5}
API
hexRgb(hex, options?)
hex
Type: string
The color in HEX format. Leading #
is optional.
options
Type: object
format
Type: string
Values: 'object' | 'array' | 'css'
Defaults: 'object'
The RGB output format.
Note that when using the css
format, the value of the alpha channel is rounded to two decimal places.
alpha
Type: number
Set the alpha of the color.
This overrides any existing alpha component in the Hex color string. For example, the 99
in #22222299
.
The number must be in the range 0 to 1.
Related
See rgb-hex for the inverse.
No vulnerabilities found.
Reason
security policy file detected
Details
- Info: security policy file detected: .github/security.md:1
- Info: Found linked content: .github/security.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: .github/security.md:1
- Info: Found text in security policy: .github/security.md:1
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: license:0
- Info: FSF or OSI recognized license: MIT License: license:0
Reason
Found 7/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
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/sindresorhus/hex-rgb/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/sindresorhus/hex-rgb/main.yml/main?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/main.yml:22
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 npmCommand dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/main.yml:1
- Info: no jobLevel write permissions found
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 7 are checked with a SAST tool
Score
4.2
/10
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 MoreOther packages similar to hex-rgb
colors-named-hex
A array with color name -> Hex rgb.
validate-color
Validate HTML colors by 'name', 'special name', 'hex', 'rgb', 'rgba', 'hsl', 'hsla', 'hwb', 'lab' or 'lch' values
@ricardo-jrm/color-converter
Convert colors: HEX -> RGB / RGB -> HEX
easton
Use ANSI styles and HEX/RGB in CLI