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 3.8.1 to 3.8.2-development

6

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

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

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

@@ -39,3 +40,2 @@ "cz-conventional-changelog": "^2.0.0",

"ghooks": "^2.0.0",
"nearest-color": "^0.4.0",
"semantic-release": "^8.0.3"

@@ -56,2 +56,2 @@ },

"dependencies": {}
}
}

@@ -21,3 +21,3 @@ # __16706__ color-names

### Submit a color [via form 🌈](https://docs.google.com/forms/d/e/1FAIpQLSfbS5D6owA4dQupJJ-6qhRzuxkjX9r2AliPMg-VR2V3NpGkQg/viewform) / or [twitter 🐦](https://codepen.io/meodai/full/ZXQzLb/)
Make sure to read the [naming rules](CONTRIBUTING.md) before you contribute.
Make sure to read the [naming rules](CONTRIBUTING.md) before you contribute!

@@ -41,3 +41,3 @@ ### color count: __16706__ 🎉

### API (v1) 🃏
### API 🃏
```url

@@ -49,3 +49,3 @@ https://color-names.herokuapp.com/v1/{{hexvalue without the #}},{{more comma separated values}}

```json
```javascript
{

@@ -57,3 +57,4 @@ "colors": [{

"distance": 0, // its an exact match
"requestedHex": "#212121"
"luminance": 22.062320231562225,
"requestedHex": "#212121",
}]

@@ -60,0 +61,0 @@ }

@@ -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(

@@ -24,11 +24,12 @@ fs.readFileSync(__dirname + '/../dist/colornames.json', 'utf8')

'Content-Type': 'application/json; charset=utf-8',
}
};
// object containing the name:hex pairs for nearestColor()
const colorsObj = {};
const rgbColorsArr = [];
// prepare color array
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 +41,4 @@ c.rgb = rgb;

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

@@ -58,15 +60,19 @@ * 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.hex,
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,
};
})
});
// closest.clearCache()
};

@@ -73,0 +79,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