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

font-color-contrast

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

font-color-contrast - npm Package Compare versions

Comparing version 10.0.1 to 10.1.0

54

lib/index.js
"use strict";
exports.__esModule = true;
var hashRegEx = /#/;
var hexRegEx = /0x/i;
var isRGB;
var isArray;
var isHexString;
var isHexNumber;
Object.defineProperty(exports, "__esModule", { value: true });
const hashRegEx = /#/;
const hexRegEx = /0x/i;
let isRGB;
let isArray;
let isHexString;
let isHexNumber;
function fontColorContrast(hexColorOrRedOrArray, greenOrThreshold, blue, threshold) {
var _a, _b;
var red = 0;
var green = 0;
let red = 0;
let green = 0;
isRGB = !!(blue !== undefined);

@@ -18,7 +17,7 @@ isArray = Array.isArray(hexColorOrRedOrArray);

if (isHexString || isHexNumber) {
_a = hexColorToRGB(hexColorOrRedOrArray), red = _a[0], green = _a[1], blue = _a[2];
[red, green, blue] = hexColorToRGB(hexColorOrRedOrArray);
threshold = greenOrThreshold;
}
else if (isRGB || isArray) {
_b = arrayOrRgbToRGB(hexColorOrRedOrArray, greenOrThreshold, blue, threshold), red = _b[0], green = _b[1], blue = _b[2], threshold = _b[3];
[red, green, blue, threshold] = arrayOrRgbToRGB(hexColorOrRedOrArray, greenOrThreshold, blue, threshold);
}

@@ -31,3 +30,3 @@ else {

}
exports["default"] = fontColorContrast;
exports.default = fontColorContrast;
/**

@@ -39,3 +38,3 @@ * Converts a hexadecimal string to it's correspondent integer

function hexToDec(hexString) {
var decString = (hexString).replace(/[^a-f0-9]/gi, '');
const decString = (hexString).replace(/[^a-f0-9]/gi, '');
return parseInt(decString, 16);

@@ -56,6 +55,6 @@ }

function hexColorToRGB(hexColor) {
var red, green, blue;
var hasHash = hashRegEx.test(hexColor);
var hasHex = hexRegEx.test(hexColor);
var color = isHexNumber
let red, green, blue;
const hasHash = hashRegEx.test(hexColor);
const hasHex = hexRegEx.test(hexColor);
const color = isHexNumber
? hexColor.toString(16)

@@ -114,6 +113,6 @@ : hasHash

function arrayOrRgbToRGB(redOrArray, greenOrThreshold, blue, threshold) {
var r = 0;
var g = 0;
var b = 0;
var t = 0;
let r = 0;
let g = 0;
let b = 0;
let t = 0;
if (isArray) {

@@ -141,8 +140,7 @@ r = redOrArray[0];

*/
function contrastFromHSP(red, green, blue, threshold) {
if (threshold === void 0) { threshold = 0.5; }
var pRed = 0.299;
var pGreen = 0.587;
var pBlue = 0.114;
var contrast = Math.sqrt(pRed * Math.pow((red / 255), 2) +
function contrastFromHSP(red, green, blue, threshold = 0.5) {
const pRed = 0.299;
const pGreen = 0.587;
const pBlue = 0.114;
const contrast = Math.sqrt(pRed * Math.pow((red / 255), 2) +
pGreen * Math.pow((green / 255), 2) +

@@ -149,0 +147,0 @@ pBlue * Math.pow((blue / 255), 2));

{
"name": "font-color-contrast",
"version": "10.0.1",
"version": "10.1.0",
"description": "JavaScript module to use black or white font according to the given background color",
"main": "lib/index.js",
"directories": {
"lib": "lib"
},
"scripts": {
"build": "tsc",
"install": "tsc",
"prepare" : "npm run build",
"prepublishOnly" : "npm test",
"test": "jest"

@@ -30,2 +27,9 @@ },

],
"main": "lib/index.js",
"directories": {
"lib": "lib"
},
"files": [
"lib"
],
"devDependencies": {

@@ -32,0 +36,0 @@ "@types/jest": "^27.0.2",

Sorry, the diff of this file is not supported yet

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