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

color-string

Package Overview
Dependencies
Maintainers
3
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

color-string - npm Package Compare versions

Comparing version 1.5.1 to 1.5.2

22

index.js

@@ -49,3 +49,3 @@ /* MIT license */

var abbr = /^#([a-f0-9]{3})([a-f0-9]{1})?$/i;
var abbr = /^#([a-f0-9]{3,4})$/i;
var hex = /^#([a-f0-9]{6})([a-f0-9]{2})?$/i;

@@ -61,3 +61,3 @@ var rgba = /^rgba?\(\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/;

if (match = string.match(abbr)) {
if (match = string.match(hex)) {
hexAlpha = match[2];

@@ -67,20 +67,20 @@ match = match[1];

for (i = 0; i < 3; i++) {
rgb[i] = parseInt(match[i] + match[i], 16);
// https://jsperf.com/slice-vs-substr-vs-substring-methods-long-string/19
var i2 = i * 2;
rgb[i] = parseInt(match.slice(i2, i2 + 2), 16);
}
if (hexAlpha) {
rgb[3] = Math.round((parseInt(hexAlpha + hexAlpha, 16) / 255) * 100) / 100;
rgb[3] = Math.round((parseInt(hexAlpha, 16) / 255) * 100) / 100;
}
} else if (match = string.match(hex)) {
hexAlpha = match[2];
} else if (match = string.match(abbr)) {
match = match[1];
hexAlpha = match[3];
for (i = 0; i < 3; i++) {
// https://jsperf.com/slice-vs-substr-vs-substring-methods-long-string/19
var i2 = i * 2;
rgb[i] = parseInt(match.slice(i2, i2 + 2), 16);
rgb[i] = parseInt(match[i] + match[i], 16);
}
if (hexAlpha) {
rgb[3] = Math.round((parseInt(hexAlpha, 16) / 255) * 100) / 100;
rgb[3] = Math.round((parseInt(hexAlpha + hexAlpha, 16) / 255) * 100) / 100;
}

@@ -121,3 +121,3 @@ } else if (match = string.match(rgba)) {

for (i = 0; i < rgb.length; i++) {
for (i = 0; i < 3; i++) {
rgb[i] = clamp(rgb[i], 0, 255);

@@ -124,0 +124,0 @@ }

{
"name": "color-string",
"description": "Parser and generator for CSS color strings",
"version": "1.5.1",
"version": "1.5.2",
"author": "Heather Arthur <fayearthur@gmail.com>",

@@ -6,0 +6,0 @@ "contributors": [

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