Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
The 'colornames' npm package allows you to convert color names to their corresponding hexadecimal color codes. It is useful for developers who need to work with color names and require their hex values for web development, design, or other applications.
Convert color name to hex
This feature allows you to convert a color name (e.g., 'red') to its corresponding hexadecimal color code (e.g., '#ff0000').
const colornames = require('colornames');
const hexColor = colornames('red');
console.log(hexColor); // Output: '#ff0000'
Handle case-insensitive color names
The package can handle color names in a case-insensitive manner, making it flexible for user input.
const colornames = require('colornames');
const hexColor = colornames('Red');
console.log(hexColor); // Output: '#ff0000'
Return undefined for unknown color names
If an unknown color name is provided, the package returns 'undefined', allowing you to handle errors or invalid inputs gracefully.
const colornames = require('colornames');
const hexColor = colornames('unknownColor');
console.log(hexColor); // Output: undefined
The 'color-name' package provides a list of color names and their corresponding RGB values. Unlike 'colornames', which converts color names to hex codes, 'color-name' focuses on RGB values.
The 'color-convert' package allows for conversion between various color models, including RGB, HSL, and hex. It offers more comprehensive color conversion functionalities compared to 'colornames'.
The 'color' package provides a wide range of color manipulation and conversion utilities, including conversion between color models and color space manipulation. It is more feature-rich compared to 'colornames'.
Convert color names to HEX color values.
$ component install timoxley/colornames
$ npm install colornames
var toHex = require('colornames')
toHex('red') // => "#FF0000"
toHex('blue') // => "#0000FF"
toHex('lightsalmon') // => "#FFA07A"
toHex('mediumvioletred') // => "#C71585"
toHex.get('red')
// =>
{
name: "red",
css: true,
value: "#FF0000",
vga: true
}
toHex('Blue') // => "#0000FF"
toHex('BLUE') // => "#0000FF"
toHex('BlUe') // => "#0000FF"
Get HEX code for a color name, or undefined
if unknown.
All known data about color, including whether valid VGA or CSS color name.
HEX code for a color name, only if the color is a valid VGA color name.
HEX code for a color name, only if the color is a valid CSS color name.
###.all() Get all color names data.
MIT
FAQs
Map color names to HEX color values.
The npm package colornames receives a total of 578,848 weekly downloads. As such, colornames popularity was classified as popular.
We found that colornames 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
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.