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

stringman

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stringman - npm Package Compare versions

Comparing version 0.9.0 to 0.10.0

2

lib/source/colors.d.ts

@@ -7,2 +7,3 @@ import { IHsl } from '../models/colors.model';

declare function hexToHsl(str: string): IHsl | null;
declare function rgbToHsl(r: number, g: number, b: number): IHsl | null;
declare const colors: {

@@ -14,3 +15,4 @@ hexToHsl: typeof hexToHsl;

rgbToHex: typeof rgbToHex;
rgbToHsl: typeof rgbToHsl;
};
export { colors };

79

lib/source/colors.js

@@ -69,37 +69,6 @@ "use strict";

if (result && result.length) {
let r = parseInt(result[1], 16);
let g = parseInt(result[2], 16);
let b = parseInt(result[3], 16);
r /= 255;
g /= 255;
b /= 255;
const max = Math.max(r, g, b);
const min = Math.min(r, g, b);
let h;
let s;
const l = (max + min) / 2;
if (max === min) {
h = s = 0;
}
else {
const d = max - min;
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
switch (max) {
case r:
h = (g - b) / d + (g < b ? 6 : 0);
break;
case g:
h = (b - r) / d + 2;
break;
case b:
h = (r - g) / d + 4;
break;
}
h = h ? h / 6 : 0;
}
return {
h: parseFloat((h * 360).toFixed(1)),
l: parseFloat((l * 100).toFixed(1)),
s: parseFloat((s * 100).toFixed(1))
};
const r = parseInt(result[1], 16);
const g = parseInt(result[2], 16);
const b = parseInt(result[3], 16);
return rgbToHsl(r, g, b);
}

@@ -114,2 +83,39 @@ else {

}
function rgbToHsl(r, g, b) {
if (typeof r !== 'number' || typeof g !== 'number' || typeof b !== 'number') {
return null;
}
r /= 255;
g /= 255;
b /= 255;
const max = Math.max(r, g, b);
const min = Math.min(r, g, b);
let h;
let s;
const l = (max + min) / 2;
if (max === min) {
h = s = 0;
}
else {
const d = max - min;
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
switch (max) {
case r:
h = (g - b) / d + (g < b ? 6 : 0);
break;
case g:
h = (b - r) / d + 2;
break;
case b:
h = (r - g) / d + 4;
break;
}
h = h ? h / 6 : 0;
}
return {
h: parseFloat((h * 360).toFixed(1)),
l: parseFloat((l * 100).toFixed(1)),
s: parseFloat((s * 100).toFixed(1))
};
}
const colors = {

@@ -120,4 +126,5 @@ hexToHsl,

luminance,
rgbToHex
rgbToHex,
rgbToHsl
};
exports.colors = colors;
{
"name": "stringman",
"version": "0.9.0",
"version": "0.10.0",
"description": "Stringman does string manipulation. Do anything from lightening color codes to swapping email address in a string!",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -53,2 +53,4 @@ # Stringman

- luminance => Takes a hex color value and a percentage and returns a hex color string that is the result of lightening or darkening the original color by the percentage. Does not work on black or white (yet)!
- hexToHsl => Takes a string representing a hex color code and returns the hsl equivalent in an object with keys for h, s, and l
- rgbToHsl => Takes each of the 3 rgb number values as individual arguments and returns the hsl equivalent in an object with keys for h, s, and l

@@ -55,0 +57,0 @@ #### email module

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