Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

color-rgba

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

color-rgba - npm Package Compare versions

Comparing version 2.3.0 to 2.4.0

test.cjs

33

index.js

@@ -6,4 +6,2 @@ /** @module color-rgba */

var parse = require('color-parse')
var rgb = require('color-space/rgb')
var hsl = require('color-space/hsl')

@@ -21,4 +19,3 @@ module.exports = function rgba (color) {

var min = parsed.space[0] === 'h' ? hsl.min : rgb.min
var max = parsed.space[0] === 'h' ? hsl.max : rgb.max
var min = [0,0,0], max = parsed.space[0] === 'h' ? [360,100,100] : [255,255,255]

@@ -30,5 +27,3 @@ values = Array(3)

if (parsed.space[0] === 'h') {
values = hsl.rgb(values)
}
if (parsed.space[0] === 'h') values = hsl2rgb(values)

@@ -39,1 +34,25 @@ values.push(Math.min(Math.max(parsed.alpha, 0), 1))

}
// excerpt from color-space/hsl
function hsl2rgb(hsl) {
var h = hsl[0]/360, s = hsl[1]/100, l = hsl[2]/100, t1, t2, t3, rgb, val, i=0;
if (s === 0) return val = l * 255, [val, val, val];
t2 = l < 0.5 ? l * (1 + s) : l + s - l * s;
t1 = 2 * l - t2;
rgb = [0, 0, 0];
for (;i<3;) {
t3 = h + 1 / 3 * - (i - 1);
t3 < 0 ? t3++ : t3 > 1 && t3--;
val = 6 * t3 < 1 ? t1 + (t2 - t1) * 6 * t3 :
2 * t3 < 1 ? t2 :
3 * t3 < 2 ? t1 + (t2 - t1) * (2 / 3 - t3) * 6 :
t1;
rgb[i++] = val * 255;
}
return rgb;
}
{
"name": "color-rgba",
"version": "2.3.0",
"version": "2.4.0",
"description": "Convert color string (or parseable argument) to RGBA array",

@@ -9,3 +9,3 @@ "main": "index.js",

"scripts": {
"test": "node test.mjs"
"test": "node test.mjs && node test.cjs"
},

@@ -35,5 +35,5 @@ "exports": {

"dependencies": {
"color-parse": "^1.4.1",
"color-space": "^1.14.6"
"color-parse": "^1.4.2",
"color-space": "^2.0.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc