New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

color-name-list

Package Overview
Dependencies
Maintainers
2
Versions
390
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

color-name-list - npm Package Compare versions

Comparing version 0.0.0-development to 0.0.0

.npmignore

6

package.json
{
"name": "color-name-list",
"version": "0.0.0-development",
"version": "0.0.0",
"description": "long list of color names",

@@ -33,3 +33,3 @@ "main": "dist/colornames.json",

"devDependencies": {
"closestvector": "^0.1.1",
"closestvector": "^0.2.0",
"commitizen": "^2.9.6",

@@ -55,2 +55,2 @@ "cz-conventional-changelog": "^2.0.0",

"dependencies": {}
}
}

@@ -6,3 +6,3 @@ const http = require('http');

const lib = require('./lib.js');
const nearestColor = require('../node_modules/nearest-color/nearestColor.js');
const ClosestVector = require('../node_modules/closestvector/index.umd.js');
const colors = JSON.parse(

@@ -27,8 +27,8 @@ fs.readFileSync(__dirname + '/../dist/colornames.json', 'utf8')

// object containing the name:hex pairs for nearestColor()
const colorsObj = {};
const rgbColorsArr = [];
colors.forEach((c) => {
const rgb = lib.hexToRgb(c.hex);
// populates object needed for nearestColor()
colorsObj[c.name] = c.hex;
// populates array needed for ClosestVector()
rgbColorsArr.push([rgb.r, rgb.g, rgb.b]);
// transform hex to RGB

@@ -40,3 +40,4 @@ c.rgb = rgb;

const nc = nearestColor.from(colorsObj);
const closest = new ClosestVector(rgbColorsArr);
/**

@@ -58,13 +59,15 @@ * validates a hex color

return colorArr.map((hex) => {
// get the closest named colors
const closestColor = nc(`#${hex}`);
// calculate RGB values for passed color
const rgb = lib.hexToRgb(hex);
// get the closest named colors
const closestColor = closest.get([rgb.r, rgb.g, rgb.b]);
const color = colors[closestColor.closestIndex];
return {
hex: closestColor.value,
name: closestColor.name,
rgb: closestColor.rgb,
hex: color.value,
name: color.name,
rgb: color.rgb,
requestedHex: `#${hex}`,
luminance: lib.luminance(closestColor.rgb),
distance: lib.distance(closestColor.rgb, rgb),
luminance: color.luminance,
distance: closestColor.distance,
};

@@ -71,0 +74,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