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.0.2 to 5.0.3

src/hsl2hwb.js

4

package.json
{
"name": "color-tf",
"version": "5.0.2",
"version": "5.0.3",
"description": "RGB, HSL, HSV, HWB and more color models convertor",

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

"rollup": "rm -rf dist && NODE_ENV=rollup rollup -c",
"build": "rm -rf dist && npm run rollup && cp package.json dist/ && cp README.md dist/",
"build": "rm -rf dist && npm run rollup && babel-node --presets @babel/env generateFns && cp package.json dist/ && cp README.md dist/",
"pub": "npm run build && npm publish dist"

@@ -14,0 +14,0 @@ },

@@ -40,8 +40,6 @@ 'use strict';

const libKeys = Object.keys(lib);
/**
* @return the shortest (inverted) path fn between 2 keys in lib object
* @return fns to compose between 2 keys in lib object e.g. fns.reduceRight((fn, f) => (...a) => f(...fn(...a)))
*/
const getPath = (fromKey, toKey) => {
var getFnPath = ((lib, fromKey, toKey) => {
let nodes = [fromKey];

@@ -57,14 +55,12 @@ const visited = new Map(); // map node key => parent key

// done, we can stop
const arr = [toKey, k];
let fn = lib[k + '2' + toKey];
const fns = [`${k}2${toKey}`];
for (let key = k; visited.has(key) && key !== fromKey; key = visited.get(key)) {
// compose functions while there's a parent
arr.push(visited.get(key));
fns.push(`${visited.get(key)}2${key}`);
}
return arr;
return fns;
}
libKeys.filter(s => s.slice(0, 3) === k).map(s => s.slice(4)).filter(key => !visited.has(key)).forEach(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);

@@ -77,3 +73,3 @@ newNodes.push(key);

}
};
});

@@ -99,7 +95,4 @@ const roundH = ([h, s, l]) => [Math.round(360 * h) % 360, Math.round(100 * s), Math.round(100 * l)];

// todo check fromKey, toKey are in available keys, else getPath might be in infinite loop
const path = getPath(fromKey, toKey);
const funcs = Array.from({
length: path.length - 1
}, (_, i) => lib[`${path[i + 1]}2${path[i]}`]);
fn = funcs.reduceRight((func, f) => (...a) => f(...func(...a)));
const fns = getFnPath(lib, fromKey, toKey);
fn = fns.reduceRight((fn, f) => (...a) => f(...fn(...a)));
map.set(k, fn);

@@ -106,0 +99,0 @@ }

@@ -38,8 +38,6 @@ import hsl2hsv from './hsl2hsv.js';

const libKeys = Object.keys(lib);
/**
* @return the shortest (inverted) path fn between 2 keys in lib object
* @return fns to compose between 2 keys in lib object e.g. fns.reduceRight((fn, f) => (...a) => f(...fn(...a)))
*/
const getPath = (fromKey, toKey) => {
var getFnPath = ((lib, fromKey, toKey) => {
let nodes = [fromKey];

@@ -55,14 +53,12 @@ const visited = new Map(); // map node key => parent key

// done, we can stop
const arr = [toKey, k];
let fn = lib[k + '2' + toKey];
const fns = [`${k}2${toKey}`];
for (let key = k; visited.has(key) && key !== fromKey; key = visited.get(key)) {
// compose functions while there's a parent
arr.push(visited.get(key));
fns.push(`${visited.get(key)}2${key}`);
}
return arr;
return fns;
}
libKeys.filter(s => s.slice(0, 3) === k).map(s => s.slice(4)).filter(key => !visited.has(key)).forEach(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);

@@ -75,3 +71,3 @@ newNodes.push(key);

}
};
});

@@ -97,7 +93,4 @@ const roundH = ([h, s, l]) => [Math.round(360 * h) % 360, Math.round(100 * s), Math.round(100 * l)];

// todo check fromKey, toKey are in available keys, else getPath might be in infinite loop
const path = getPath(fromKey, toKey);
const funcs = Array.from({
length: path.length - 1
}, (_, i) => lib[`${path[i + 1]}2${path[i]}`]);
fn = funcs.reduceRight((func, f) => (...a) => f(...func(...a)));
const fns = getFnPath(lib, fromKey, toKey);
fn = fns.reduceRight((fn, f) => (...a) => f(...fn(...a)));
map.set(k, fn);

@@ -104,0 +97,0 @@ }

@@ -163,8 +163,6 @@ (function (global, factory) {

const libKeys = Object.keys(lib);
/**
* @return the shortest (inverted) path fn between 2 keys in lib object
* @return fns to compose between 2 keys in lib object e.g. fns.reduceRight((fn, f) => (...a) => f(...fn(...a)))
*/
const getPath = (fromKey, toKey) => {
var getFnPath = ((lib, fromKey, toKey) => {
let nodes = [fromKey];

@@ -180,14 +178,12 @@ const visited = new Map(); // map node key => parent key

// done, we can stop
const arr = [toKey, k];
let fn = lib[k + '2' + toKey];
const fns = [`${k}2${toKey}`];
for (let key = k; visited.has(key) && key !== fromKey; key = visited.get(key)) {
// compose functions while there's a parent
arr.push(visited.get(key));
fns.push(`${visited.get(key)}2${key}`);
}
return arr;
return fns;
}
libKeys.filter(s => s.slice(0, 3) === k).map(s => s.slice(4)).filter(key => !visited.has(key)).forEach(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);

@@ -200,3 +196,3 @@ newNodes.push(key);

}
};
});

@@ -222,7 +218,4 @@ const roundH = ([h, s, l]) => [Math.round(360 * h) % 360, Math.round(100 * s), Math.round(100 * l)];

// todo check fromKey, toKey are in available keys, else getPath might be in infinite loop
const path = getPath(fromKey, toKey);
const funcs = Array.from({
length: path.length - 1
}, (_, i) => lib[`${path[i + 1]}2${path[i]}`]);
fn = funcs.reduceRight((func, f) => (...a) => f(...func(...a)));
const fns = getFnPath(lib, fromKey, toKey);
fn = fns.reduceRight((fn, f) => (...a) => f(...fn(...a)));
map.set(k, fn);

@@ -229,0 +222,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