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

color-tf

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

color-tf - npm Package Compare versions

Comparing version 5.1.1 to 5.1.2

15

hexToRgb.js
'use strict';
var hexToRgb = (_hex => {
var hexToRgb = _hex => {
const hex = _hex[0] === '#' ? _hex.slice(1) : _hex;
const s = hex.length < 6 ? (hex[hex.length - 4] || '').repeat(2) + hex[hex.length - 3].repeat(2) + hex[hex.length - 2].repeat(2) + hex[hex.length - 1].repeat(2) : hex;
return [parseInt(s.slice(0, 2), 16), parseInt(s.slice(2, 4), 16), parseInt(s.slice(4, 6), 16), ...(s.length === 6 ? [] : [Math.round(parseInt(s.slice(6, 8), 16) / 0.255) / 1000])];
});
const s = hex.length < 6
? (hex[hex.length - 4] || '').repeat(2) + hex[hex.length - 3].repeat(2) + hex[hex.length - 2].repeat(2) + hex[hex.length - 1].repeat(2)
: hex;
return [
parseInt(s.slice(0, 2), 16),
parseInt(s.slice(2, 4), 16),
parseInt(s.slice(4, 6), 16),
...s.length === 6 ? [] : [Math.round(parseInt(s.slice(6, 8), 16) / 0.255) / 1000]
];
}
module.exports = hexToRgb;
'use strict';
var hsl2hsv = ((h, s, l) => {
var hsl2hsv = (h, s, l) => {
const t = s * (l < 0.5 ? l : 1 - l),
V = l + t,
S = l > 0 ? 2 * t / V : 0;
V = l + t,
S = l > 0 ? 2 * t / V : 0;
return [h, S, V];
});
};
module.exports = hsl2hsv;
'use strict';
var hsl2rgb = ((h, s, l) => {
var hsl2rgb = (h, s, l) => {
if (s === 0) return [l, l, l]; // achromatic

@@ -9,3 +9,3 @@

return [hue2rgb(p, q, h + 1 / 3), hue2rgb(p, q, h), hue2rgb(p, q, h - 1 / 3)];
});
};

@@ -12,0 +12,0 @@ function hue2rgb(p, q, t) {

'use strict';
var hsv2hsl = ((h, s, v) => {
var hsv2hsl = (h, s, v) => {
const L = (2 - s) * v / 2,
S = s * v / (L < 0.5 ? L * 2 : 2 - L * 2);
S = s * v / (L < 0.5 ? L * 2 : 2 - L * 2);
return [h, S || 0, L];
});
};
module.exports = hsv2hsl;
'use strict';
var hsv2hwb = ((h, s, v) => [h, (1 - s) * v, 1 - v]);
var hsv2hwb = (h, s, v) => [h, (1 - s) * v, 1 - v];
module.exports = hsv2hwb;
'use strict';
var hsv2rgb = ((h, s, v) => {
var hsv2rgb = (h, s, v) => {
const i = Math.floor(h * 6);

@@ -14,20 +14,15 @@ const f = h * 6 - i;

return [v, t, p];
case 1:
return [q, v, p];
case 2:
return [p, v, t];
case 3:
return [p, q, v];
case 4:
return [t, p, v];
case 5:
return [v, p, q];
}
});
};
module.exports = hsv2rgb;
'use strict';
var hwb2hsv = ((h, w, b) => [h, b === 1 ? 0 : Math.max(0, 1 - w / (1 - b)), 1 - b]);
var hwb2hsv = (h, w, b) => [h, b === 1 ? 0 : Math.max(0, 1 - w / (1 - b)), 1 - b];
module.exports = hwb2hsv;
'use strict';
var hwb2rgb = ((h, w, b) => {
var hwb2rgb = (h, w, b) => {
// could throw or warn, or normalize if w+b>=1 ?

@@ -8,3 +8,2 @@ const v = 1 - b;

const f = i & 1 ? 1 + i - h * 6 : h * 6 - i; // if i is odd
const n = w + f * (v - w); // linear interpolation

@@ -16,20 +15,15 @@

return [v, n, w];
case 1:
return [n, v, w];
case 2:
return [w, v, n];
case 3:
return [w, n, v];
case 4:
return [n, w, v];
case 5:
return [v, w, n];
}
});
};
module.exports = hwb2rgb;
{
"name": "color-tf",
"version": "5.1.1",
"version": "5.1.2",
"description": "RGB, HSL, HSV, HWB and more color models convertors",

@@ -9,3 +9,3 @@ "main": "proxy",

"scripts": {
"test": "npm run build && babel-node --presets @babel/env test/index.spec",
"test": "npm run build && nyc babel-node --presets @babel/env test/index.spec",
"coverage": "nyc report --reporter=lcov > coverage.lcov && codecov",

@@ -36,8 +36,8 @@ "rollup": "rm -rf dist && NODE_ENV=rollup rollup -c",

"devDependencies": {
"@babel/cli": "^7.0.0-beta.46",
"@babel/core": "^7.0.0-beta.46",
"@babel/node": "^7.0.0-beta.46",
"@babel/preset-env": "^7.0.0-beta.46",
"@babel/cli": "^7.0.0-beta.47",
"@babel/core": "^7.0.0-beta.47",
"@babel/node": "^7.0.0-beta.47",
"@babel/preset-env": "^7.0.0-beta.47",
"codecov": "^3.0.2",
"nyc": "^11.7.3",
"nyc": "^11.8.0",
"rollup": "github:rollup/rollup",

@@ -44,0 +44,0 @@ "rollup-plugin-babel": "^4.0.0-beta.4",

@@ -19,12 +19,12 @@ 'use strict';

var lib = /*#__PURE__*/Object.freeze({
hsl2hsv: hsl2hsv.default,
hsl2rgb: hsl2rgb.default,
hsv2hsl: hsv2hsl.default,
hsv2hwb: hsv2hwb.default,
hsv2rgb: hsv2rgb.default,
hwb2hsv: hwb2hsv.default,
hwb2rgb: hwb2rgb.default,
rgb2hsl: rgb2hsl.default,
rgb2hsv: rgb2hsv.default,
rgb2hwb: rgb2hwb.default
hsl2hsv: hsl2hsv,
hsl2rgb: hsl2rgb,
hsv2hsl: hsv2hsl,
hsv2hwb: hsv2hwb,
hsv2rgb: hsv2rgb,
hwb2hsv: hwb2hsv,
hwb2rgb: hwb2rgb,
rgb2hsl: rgb2hsl,
rgb2hsv: rgb2hsv,
rgb2hwb: rgb2hwb
});

@@ -35,6 +35,5 @@

*/
var getFnPath = ((lib, fromKey, toKey) => {
var getFnPath = (lib, fromKey, toKey) => {
let nodes = [fromKey];
const visited = new Map(); // map node key => parent key
while (nodes.length) {

@@ -48,21 +47,22 @@ // search breadth-first

const fns = [`${k}2${toKey}`];
for (let key = k; visited.has(key) && key !== fromKey; key = visited.get(key)) {
fns.push(`${visited.get(key)}2${key}`);
}
return fns;
}
Object.keys(lib).filter(s => s.slice(0, 3) === k).map(s => s.slice(4)).filter(key => !visited.has(key)).forEach(key => {
visited.set(key, k);
newNodes.push(key);
});
Object.keys(lib)
.filter(s => s.slice(0, 3) === k)
.map(s => s.slice(4))
.filter(key => !visited.has(key))
.forEach(key => {
visited.set(key, k);
newNodes.push(key);
});
}
nodes = newNodes;
}
});
};
const roundH = ([h, s, l]) => [Math.round(360 * h) % 360, Math.round(100 * s), Math.round(100 * l)];
/**

@@ -73,28 +73,35 @@ * all functions available from a Proxy (to generate missing ones dynamically)

*/
var proxy = new Proxy(
new Map([...Object.entries(lib), ['rgbToHex', rgbToHex], ['hexToRgb', hexToRgb]]),
{
get: (map, key) => {
if (typeof key !== 'string') return map;
if (map.has(key)) return map.get(key);
var proxy = new Proxy(new Map([...Object.entries(lib), ['rgbToHex', rgbToHex.default], ['hexToRgb', hexToRgb.default]]), {
get: (map, key) => {
if (typeof key !== 'string') return map;
if (map.has(key)) return map.get(key);
const fromKey = key.slice(0, 3);
const toKey = key.slice(-3).toLowerCase();
const k = fromKey + '2' + toKey;
let fn = lib[k];
const fromKey = key.slice(0, 3);
const toKey = key.slice(-3).toLowerCase();
if (!fn) {
// todo check fromKey, toKey are in available keys, else getPath might be in infinite loop
const fns = getFnPath(lib, fromKey, toKey).map(n => lib[n]);
fn = fns.reduceRight((f, g) => (...a) => g(...f(...a)));
map.set(k, fn);
const k = fromKey + '2' + toKey;
let fn = lib[k];
if (!fn) {
// todo check fromKey, toKey are in available keys, else getPath might be in infinite loop
const fns = getFnPath(lib, fromKey, toKey).map(n => lib[n]);
fn = fns.reduceRight((f, g) => (...a) => g(...f(...a)));
map.set(k, fn);
}
if (key[3] === '2') return fn;
const K = fromKey + 'To' + toKey[0].toUpperCase() + toKey.slice(1);
const FN = fromKey === 'rgb'
? (r, g, b) => roundH(fn(r / 255, g / 255, b / 255))
: toKey === 'rgb'
? (h, x, y) => fn(h / 360, x / 100, y / 100).map(v => Math.round(v * 255))
: (h, x, y) => roundH(fn(h / 360, x / 100, y / 100));
map.set(K, FN);
return FN;
}
if (key[3] === '2') return fn;
const K = fromKey + 'To' + toKey[0].toUpperCase() + toKey.slice(1);
const FN = fromKey === 'rgb' ? (r, g, b) => roundH(fn(r / 255, g / 255, b / 255)) : toKey === 'rgb' ? (h, x, y) => fn(h / 360, x / 100, y / 100).map(v => Math.round(v * 255)) : (h, x, y) => roundH(fn(h / 360, x / 100, y / 100));
map.set(K, FN);
return FN;
}
});
);
module.exports = proxy;
'use strict';
var rgb2hsl = ((r, g, b) => {
var rgb2hsl = (r, g, b) => {
const max = Math.max(r, g, b),
min = Math.min(r, g, b);
min = Math.min(r, g, b);
const l = (max + min) / 2,
d = max - min;
d = max - min;
if (d <= 0) return [0, 0, l]; // achromatic

@@ -13,4 +14,4 @@

return [h / 6, s, l];
});
};
module.exports = rgb2hsl;
'use strict';
var rgb2hsv = ((r, g, b) => {
var rgb2hsv = (r, g, b) => {
const max = Math.max(r, g, b),
min = Math.min(r, g, b);
min = Math.min(r, g, b);
const v = max,
d = max - min,
s = max === 0 ? 0 : d / max;
d = max - min,
s = max === 0 ? 0 : d / max;
if (d <= 0) return [0, s, v]; // achromatic

@@ -13,4 +14,4 @@

return [h / 6, s, v];
});
};
module.exports = rgb2hsv;
'use strict';
var rgb2hwb = ((R, G, B) => {
var rgb2hwb = (R, G, B) => {
const max = Math.max(R, G, B),
min = Math.min(R, G, B);
min = Math.min(R, G, B);
const b = 1 - max,
d = max - min;
d = max - min;
if (d <= 0) return [0, min, b]; // achromatic
const hue = min === R ? 3 - (G - B) / d : min === G ? 5 - (B - R) / d : 1 - (R - G) / d; // const [f, i] = min === R ? [G - B, 3 / 6] : min === G ? [B - R, 5 / 6] : [R - G, 1 / 6];
const hue = min === R ? 3 - (G - B) / d : min === G ? 5 - (B - R) / d : 1 - (R - G) / d;
// const [f, i] = min === R ? [G - B, 3 / 6] : min === G ? [B - R, 5 / 6] : [R - G, 1 / 6];
return [hue / 6, min, b];
});
};
module.exports = rgb2hwb;
'use strict';
var rgbToHex = ((R, G, B, A, forceLongVersion) => {
var rgbToHex = (R, G, B, A, forceLongVersion) => {
if (A < 1) {
const alpha = Math.floor(A * 256);
return !forceLongVersion && alpha % 17 === 0 && R % 17 === 0 && G % 17 === 0 && B % 17 === 0 // short version
? R.toString(16)[0] + G.toString(16)[0] + B.toString(16)[0] + alpha.toString(16)[0] : R.toString(16).padStart(2, 0) + G.toString(16).padStart(2, 0) + B.toString(16).padStart(2, 0) + alpha.toString(16).padStart(2, 0);
return !forceLongVersion && alpha % 17 === 0 && R % 17 === 0 && G % 17 === 0 && B % 17 === 0// short version
? R.toString(16)[0] + G.toString(16)[0] + B.toString(16)[0] + alpha.toString(16)[0]
: R.toString(16).padStart(2, 0) + G.toString(16).padStart(2, 0) + B.toString(16).padStart(2, 0) + alpha.toString(16).padStart(2, 0);
}
return !forceLongVersion && R % 17 === 0 && G % 17 === 0 && B % 17 === 0// short version
? R.toString(16)[0] + G.toString(16)[0] + B.toString(16)[0]
: R.toString(16).padStart(2, 0) + G.toString(16).padStart(2, 0) + B.toString(16).padStart(2, 0);
}
return !forceLongVersion && R % 17 === 0 && G % 17 === 0 && B % 17 === 0 // short version
? R.toString(16)[0] + G.toString(16)[0] + B.toString(16)[0] : R.toString(16).padStart(2, 0) + G.toString(16).padStart(2, 0) + B.toString(16).padStart(2, 0);
});
module.exports = rgbToHex;

@@ -1,7 +0,14 @@

var hexToRgb = (_hex => {
var hexToRgb = _hex => {
const hex = _hex[0] === '#' ? _hex.slice(1) : _hex;
const s = hex.length < 6 ? (hex[hex.length - 4] || '').repeat(2) + hex[hex.length - 3].repeat(2) + hex[hex.length - 2].repeat(2) + hex[hex.length - 1].repeat(2) : hex;
return [parseInt(s.slice(0, 2), 16), parseInt(s.slice(2, 4), 16), parseInt(s.slice(4, 6), 16), ...(s.length === 6 ? [] : [Math.round(parseInt(s.slice(6, 8), 16) / 0.255) / 1000])];
});
const s = hex.length < 6
? (hex[hex.length - 4] || '').repeat(2) + hex[hex.length - 3].repeat(2) + hex[hex.length - 2].repeat(2) + hex[hex.length - 1].repeat(2)
: hex;
return [
parseInt(s.slice(0, 2), 16),
parseInt(s.slice(2, 4), 16),
parseInt(s.slice(4, 6), 16),
...s.length === 6 ? [] : [Math.round(parseInt(s.slice(6, 8), 16) / 0.255) / 1000]
];
}
export default hexToRgb;

@@ -1,8 +0,8 @@

var hsl2hsv = ((h, s, l) => {
var hsl2hsv = (h, s, l) => {
const t = s * (l < 0.5 ? l : 1 - l),
V = l + t,
S = l > 0 ? 2 * t / V : 0;
V = l + t,
S = l > 0 ? 2 * t / V : 0;
return [h, S, V];
});
};
export default hsl2hsv;

@@ -1,2 +0,2 @@

var hsl2rgb = ((h, s, l) => {
var hsl2rgb = (h, s, l) => {
if (s === 0) return [l, l, l]; // achromatic

@@ -7,3 +7,3 @@

return [hue2rgb(p, q, h + 1 / 3), hue2rgb(p, q, h), hue2rgb(p, q, h - 1 / 3)];
});
};

@@ -10,0 +10,0 @@ function hue2rgb(p, q, t) {

@@ -1,7 +0,8 @@

var hsv2hsl = ((h, s, v) => {
var hsv2hsl = (h, s, v) => {
const L = (2 - s) * v / 2,
S = s * v / (L < 0.5 ? L * 2 : 2 - L * 2);
S = s * v / (L < 0.5 ? L * 2 : 2 - L * 2);
return [h, S || 0, L];
});
};
export default hsv2hsl;

@@ -1,3 +0,3 @@

var hsv2hwb = ((h, s, v) => [h, (1 - s) * v, 1 - v]);
var hsv2hwb = (h, s, v) => [h, (1 - s) * v, 1 - v];
export default hsv2hwb;

@@ -1,2 +0,2 @@

var hsv2rgb = ((h, s, v) => {
var hsv2rgb = (h, s, v) => {
const i = Math.floor(h * 6);

@@ -12,20 +12,15 @@ const f = h * 6 - i;

return [v, t, p];
case 1:
return [q, v, p];
case 2:
return [p, v, t];
case 3:
return [p, q, v];
case 4:
return [t, p, v];
case 5:
return [v, p, q];
}
});
};
export default hsv2rgb;

@@ -1,3 +0,3 @@

var hwb2hsv = ((h, w, b) => [h, b === 1 ? 0 : Math.max(0, 1 - w / (1 - b)), 1 - b]);
var hwb2hsv = (h, w, b) => [h, b === 1 ? 0 : Math.max(0, 1 - w / (1 - b)), 1 - b];
export default hwb2hsv;

@@ -1,2 +0,2 @@

var hwb2rgb = ((h, w, b) => {
var hwb2rgb = (h, w, b) => {
// could throw or warn, or normalize if w+b>=1 ?

@@ -6,3 +6,2 @@ const v = 1 - b;

const f = i & 1 ? 1 + i - h * 6 : h * 6 - i; // if i is odd
const n = w + f * (v - w); // linear interpolation

@@ -14,20 +13,15 @@

return [v, n, w];
case 1:
return [n, v, w];
case 2:
return [w, v, n];
case 3:
return [w, n, v];
case 4:
return [n, w, v];
case 5:
return [v, w, n];
}
});
};
export default hwb2rgb;

@@ -32,6 +32,5 @@ import hsl2hsv from './hsl2hsv.js';

*/
var getFnPath = ((lib, fromKey, toKey) => {
var getFnPath = (lib, fromKey, toKey) => {
let nodes = [fromKey];
const visited = new Map(); // map node key => parent key
while (nodes.length) {

@@ -45,21 +44,22 @@ // search breadth-first

const fns = [`${k}2${toKey}`];
for (let key = k; visited.has(key) && key !== fromKey; key = visited.get(key)) {
fns.push(`${visited.get(key)}2${key}`);
}
return fns;
}
Object.keys(lib).filter(s => s.slice(0, 3) === k).map(s => s.slice(4)).filter(key => !visited.has(key)).forEach(key => {
visited.set(key, k);
newNodes.push(key);
});
Object.keys(lib)
.filter(s => s.slice(0, 3) === k)
.map(s => s.slice(4))
.filter(key => !visited.has(key))
.forEach(key => {
visited.set(key, k);
newNodes.push(key);
});
}
nodes = newNodes;
}
});
};
const roundH = ([h, s, l]) => [Math.round(360 * h) % 360, Math.round(100 * s), Math.round(100 * l)];
/**

@@ -70,28 +70,35 @@ * all functions available from a Proxy (to generate missing ones dynamically)

*/
var proxy = new Proxy(
new Map([...Object.entries(lib), ['rgbToHex', rgbToHex], ['hexToRgb', hexToRgb]]),
{
get: (map, key) => {
if (typeof key !== 'string') return map;
if (map.has(key)) return map.get(key);
var proxy = new Proxy(new Map([...Object.entries(lib), ['rgbToHex', rgbToHex], ['hexToRgb', hexToRgb]]), {
get: (map, key) => {
if (typeof key !== 'string') return map;
if (map.has(key)) return map.get(key);
const fromKey = key.slice(0, 3);
const toKey = key.slice(-3).toLowerCase();
const k = fromKey + '2' + toKey;
let fn = lib[k];
const fromKey = key.slice(0, 3);
const toKey = key.slice(-3).toLowerCase();
if (!fn) {
// todo check fromKey, toKey are in available keys, else getPath might be in infinite loop
const fns = getFnPath(lib, fromKey, toKey).map(n => lib[n]);
fn = fns.reduceRight((f, g) => (...a) => g(...f(...a)));
map.set(k, fn);
const k = fromKey + '2' + toKey;
let fn = lib[k];
if (!fn) {
// todo check fromKey, toKey are in available keys, else getPath might be in infinite loop
const fns = getFnPath(lib, fromKey, toKey).map(n => lib[n]);
fn = fns.reduceRight((f, g) => (...a) => g(...f(...a)));
map.set(k, fn);
}
if (key[3] === '2') return fn;
const K = fromKey + 'To' + toKey[0].toUpperCase() + toKey.slice(1);
const FN = fromKey === 'rgb'
? (r, g, b) => roundH(fn(r / 255, g / 255, b / 255))
: toKey === 'rgb'
? (h, x, y) => fn(h / 360, x / 100, y / 100).map(v => Math.round(v * 255))
: (h, x, y) => roundH(fn(h / 360, x / 100, y / 100));
map.set(K, FN);
return FN;
}
if (key[3] === '2') return fn;
const K = fromKey + 'To' + toKey[0].toUpperCase() + toKey.slice(1);
const FN = fromKey === 'rgb' ? (r, g, b) => roundH(fn(r / 255, g / 255, b / 255)) : toKey === 'rgb' ? (h, x, y) => fn(h / 360, x / 100, y / 100).map(v => Math.round(v * 255)) : (h, x, y) => roundH(fn(h / 360, x / 100, y / 100));
map.set(K, FN);
return FN;
}
});
);
export default proxy;

@@ -1,6 +0,7 @@

var rgb2hsl = ((r, g, b) => {
var rgb2hsl = (r, g, b) => {
const max = Math.max(r, g, b),
min = Math.min(r, g, b);
min = Math.min(r, g, b);
const l = (max + min) / 2,
d = max - min;
d = max - min;
if (d <= 0) return [0, 0, l]; // achromatic

@@ -11,4 +12,4 @@

return [h / 6, s, l];
});
};
export default rgb2hsl;

@@ -1,7 +0,8 @@

var rgb2hsv = ((r, g, b) => {
var rgb2hsv = (r, g, b) => {
const max = Math.max(r, g, b),
min = Math.min(r, g, b);
min = Math.min(r, g, b);
const v = max,
d = max - min,
s = max === 0 ? 0 : d / max;
d = max - min,
s = max === 0 ? 0 : d / max;
if (d <= 0) return [0, s, v]; // achromatic

@@ -11,4 +12,4 @@

return [h / 6, s, v];
});
};
export default rgb2hsv;

@@ -1,13 +0,16 @@

var rgb2hwb = ((R, G, B) => {
var rgb2hwb = (R, G, B) => {
const max = Math.max(R, G, B),
min = Math.min(R, G, B);
min = Math.min(R, G, B);
const b = 1 - max,
d = max - min;
d = max - min;
if (d <= 0) return [0, min, b]; // achromatic
const hue = min === R ? 3 - (G - B) / d : min === G ? 5 - (B - R) / d : 1 - (R - G) / d; // const [f, i] = min === R ? [G - B, 3 / 6] : min === G ? [B - R, 5 / 6] : [R - G, 1 / 6];
const hue = min === R ? 3 - (G - B) / d : min === G ? 5 - (B - R) / d : 1 - (R - G) / d;
// const [f, i] = min === R ? [G - B, 3 / 6] : min === G ? [B - R, 5 / 6] : [R - G, 1 / 6];
return [hue / 6, min, b];
});
};
export default rgb2hwb;

@@ -1,12 +0,13 @@

var rgbToHex = ((R, G, B, A, forceLongVersion) => {
var rgbToHex = (R, G, B, A, forceLongVersion) => {
if (A < 1) {
const alpha = Math.floor(A * 256);
return !forceLongVersion && alpha % 17 === 0 && R % 17 === 0 && G % 17 === 0 && B % 17 === 0 // short version
? R.toString(16)[0] + G.toString(16)[0] + B.toString(16)[0] + alpha.toString(16)[0] : R.toString(16).padStart(2, 0) + G.toString(16).padStart(2, 0) + B.toString(16).padStart(2, 0) + alpha.toString(16).padStart(2, 0);
return !forceLongVersion && alpha % 17 === 0 && R % 17 === 0 && G % 17 === 0 && B % 17 === 0// short version
? R.toString(16)[0] + G.toString(16)[0] + B.toString(16)[0] + alpha.toString(16)[0]
: R.toString(16).padStart(2, 0) + G.toString(16).padStart(2, 0) + B.toString(16).padStart(2, 0) + alpha.toString(16).padStart(2, 0);
}
return !forceLongVersion && R % 17 === 0 && G % 17 === 0 && B % 17 === 0// short version
? R.toString(16)[0] + G.toString(16)[0] + B.toString(16)[0]
: R.toString(16).padStart(2, 0) + G.toString(16).padStart(2, 0) + B.toString(16).padStart(2, 0);
}
return !forceLongVersion && R % 17 === 0 && G % 17 === 0 && B % 17 === 0 // short version
? R.toString(16)[0] + G.toString(16)[0] + B.toString(16)[0] : R.toString(16).padStart(2, 0) + G.toString(16).padStart(2, 0) + B.toString(16).padStart(2, 0);
});
export default rgbToHex;
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