Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
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.
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.