Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
parse-color
Advanced tools
The parse-color npm package is a utility for parsing color values from various formats (like hex, RGB, HSL, etc.) into a consistent format. It helps in converting and manipulating color values in JavaScript applications.
Parsing Hex Color
This feature allows you to parse a hex color string into an object containing different representations of the color, such as RGB, HSL, and HSV.
const parse = require('parse-color');
const color = parse('#ff0000');
console.log(color);
Parsing RGB Color
This feature allows you to parse an RGB color string into an object containing different representations of the color, such as hex, HSL, and HSV.
const parse = require('parse-color');
const color = parse('rgb(255, 0, 0)');
console.log(color);
Parsing HSL Color
This feature allows you to parse an HSL color string into an object containing different representations of the color, such as hex, RGB, and HSV.
const parse = require('parse-color');
const color = parse('hsl(0, 100%, 50%)');
console.log(color);
The 'color' package is a comprehensive library for color conversion and manipulation. It supports a wide range of color models and provides methods for color transformations. Compared to parse-color, it offers more extensive functionality for color manipulation.
The 'tinycolor2' package is a small, fast library for color manipulation and conversion. It supports various color formats and provides methods for color operations like lightening, darkening, and mixing. It is similar to parse-color but focuses more on lightweight and performance.
The 'chroma-js' package is a powerful library for color conversions and color scales. It supports a wide range of color spaces and provides advanced features for color manipulation and visualization. Compared to parse-color, it offers more advanced features for working with color scales and gradients.
parse a css color string
plus hsv()
and cmyk()
strings
var parse = require('parse-color');
console.log(parse(process.argv[2]));
output:
$ node example/parse.js '#ffa500'
{ rgb: [ 255, 165, 0 ],
hsl: [ 39, 100, 50 ],
hsv: [ 39, 100, 100 ],
cmyk: [ 0, 35, 100, 0 ],
keyword: 'orange',
hex: '#ffa500',
rgba: [ 255, 165, 0, 1 ],
hsla: [ 39, 100, 50, 1 ],
hsva: [ 39, 100, 100, 1 ],
cmyka: [ 0, 35, 100, 0, 1 ] }
$ node example/parse.js lime
{ rgb: [ 0, 255, 0 ],
hsl: [ 120, 100, 50 ],
hsv: [ 120, 100, 100 ],
cmyk: [ 100, 0, 100, 0 ],
keyword: 'lime',
hex: '#00ff00',
rgba: [ 0, 255, 0, 1 ],
hsla: [ 120, 100, 50, 1 ],
hsva: [ 120, 100, 100, 1 ],
cmyka: [ 100, 0, 100, 0, 1 ] }
$ node example/parse.js 'hsl(210,50,50)'
{ rgb: [ 64, 127, 191 ],
hsl: [ 210, 50, 50 ],
hsv: [ 210, 67, 75 ],
cmyk: [ 67, 33, 0, 25 ],
keyword: undefined,
hex: '#407fbf',
rgba: [ 64, 127, 191, 1 ],
hsla: [ 210, 50, 50, 1 ],
hsva: [ 210, 67, 75, 1 ],
cmyka: [ 67, 33, 0, 25, 1 ] }
$ node example/parse.js 'rgba(153,50,204,60%)'
{ rgb: [ 153, 50, 204 ],
hsl: [ 280, 61, 50 ],
hsv: [ 280, 75, 80 ],
cmyk: [ 25, 75, 0, 20 ],
keyword: 'darkorchid',
hex: '#9932cc',
rgba: [ 153, 50, 204, 0.6 ],
hsla: [ 280, 61, 50, 0.6 ],
hsva: [ 280, 75, 80, 0.6 ],
cmyka: [ 25, 75, 0, 20, 0.6 ] }
var parse = require('parse-color')
Return a color
object from the
css colorString.
color
has these attributes:
[ red, green, blue ]
[ hue, saturation, luminosity ]
[ hue, saturation, value ]
[ cyan, magenta, yellow, blac(k) ]
#rrggbb
When a color can't be parsed or is unknown, the attributes will be undefined:
$ node example/parse.js 'x'
{ rgb: undefined,
hsl: undefined,
hsv: undefined,
cmyk: undefined,
keyword: 'x',
hex: undefined }
With npm do:
npm install parse-color
MIT
FAQs
parse a css color string (plus hsv and cmyk) into an object
The npm package parse-color receives a total of 171,498 weekly downloads. As such, parse-color popularity was classified as popular.
We found that parse-color 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.