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

color-octree

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

color-octree - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

5

dist/cjs.js

@@ -160,3 +160,4 @@ 'use strict';

const nodes = [];
const n = r.length;
const n = r.length,
N = 2 ** n;

@@ -170,3 +171,3 @@ for (let dr = dir[0] - 1; dr <= dir[0]; dr++) {

if (R >= 0 && R < 2 ** n && G >= 0 && G < 2 ** n && B >= 0 && B < 2 ** n) {
if (R >= 0 && R < N && G >= 0 && G < N && B >= 0 && B < N) {
nodes.push([R.toString(2).padStart(n, 0), G.toString(2).padStart(n, 0), B.toString(2).padStart(n, 0)]);

@@ -173,0 +174,0 @@ }

@@ -158,3 +158,4 @@ function _defineProperty(obj, key, value) {

const nodes = [];
const n = r.length;
const n = r.length,
N = 2 ** n;

@@ -168,3 +169,3 @@ for (let dr = dir[0] - 1; dr <= dir[0]; dr++) {

if (R >= 0 && R < 2 ** n && G >= 0 && G < 2 ** n && B >= 0 && B < 2 ** n) {
if (R >= 0 && R < N && G >= 0 && G < N && B >= 0 && B < N) {
nodes.push([R.toString(2).padStart(n, 0), G.toString(2).padStart(n, 0), B.toString(2).padStart(n, 0)]);

@@ -171,0 +172,0 @@ }

@@ -162,3 +162,4 @@ (function (global, factory) {

const nodes = [];
const n = r.length;
const n = r.length,
N = 2 ** n;

@@ -172,3 +173,3 @@ for (let dr = dir[0] - 1; dr <= dir[0]; dr++) {

if (R >= 0 && R < 2 ** n && G >= 0 && G < 2 ** n && B >= 0 && B < 2 ** n) {
if (R >= 0 && R < N && G >= 0 && G < N && B >= 0 && B < N) {
nodes.push([R.toString(2).padStart(n, 0), G.toString(2).padStart(n, 0), B.toString(2).padStart(n, 0)]);

@@ -175,0 +176,0 @@ }

30

index.js

@@ -24,13 +24,13 @@ export const parseHex = hex =>

: {
n,
colors: [],
'000': buildOctree(depth, n + 1),
'001': buildOctree(depth, n + 1),
'010': buildOctree(depth, n + 1),
'011': buildOctree(depth, n + 1),
'100': buildOctree(depth, n + 1),
'101': buildOctree(depth, n + 1),
'110': buildOctree(depth, n + 1),
'111': buildOctree(depth, n + 1),
};
n,
colors: [],
'000': buildOctree(depth, n + 1),
'001': buildOctree(depth, n + 1),
'010': buildOctree(depth, n + 1),
'011': buildOctree(depth, n + 1),
'100': buildOctree(depth, n + 1),
'101': buildOctree(depth, n + 1),
'110': buildOctree(depth, n + 1),
'111': buildOctree(depth, n + 1),
};

@@ -47,3 +47,3 @@ export let __root;

__root = {};
__root = {...buildOctree(depth), depth, colors: undefined}; // colors are not stored at top-level
__root = { ...buildOctree(depth), depth, colors: undefined }; // colors are not stored at top-level
};

@@ -77,3 +77,3 @@

if (idx >= 0) {
node.colors = [...node.colors.slice(0,idx), ...node.colors.slice(idx+1)]; // don't like splice
node.colors = [...node.colors.slice(0, idx), ...node.colors.slice(idx + 1)]; // don't like splice
}

@@ -92,3 +92,3 @@ }

const nodes = [];
const n = r.length;
const n = r.length, N = 2 ** n;
for (let dr = dir[0] - 1; dr <= dir[0]; dr++) {

@@ -100,3 +100,3 @@ for (let dg = dir[1] - 1; dg <= dir[1]; dg++) {

B = bDec + db;
if (R >= 0 && R < 2 ** n && G >= 0 && G < 2 ** n && B >= 0 && B < 2 ** n) {
if (R >= 0 && R < N && G >= 0 && G < N && B >= 0 && B < N) {
nodes.push([

@@ -103,0 +103,0 @@ R.toString(2).padStart(n, 0),

@@ -14,3 +14,3 @@ import assert from 'assert';

console.time('add');
add([{name: 'Test', hex: '557'}, {name: 'Test_', hex: '656'}]);
add([{ name: 'Test', hex: '557' }, { name: 'Test_', hex: '656' }]);
console.timeEnd('add');

@@ -25,5 +25,5 @@

// # color-names (148 colors)
// # color-names (148 colors)
const colors = Object.entries(colorNames).map(([hex, name]) => ({hex, name}));
const colors = Object.entries(colorNames).map(([hex, name]) => ({ hex, name }));

@@ -42,3 +42,3 @@ console.time('add2');

// # color-name-list (17k colors)
// # color-name-list (17k colors)

@@ -64,3 +64,3 @@ console.time('add3');

assert.deepEqual(col31, { name: 'Inky Storm', hex: '#535266', d: 3.605551275463989 });
assert.deepEqual(col31, { name: 'Inky Storm', hex: '#535266', d: 3.605551275463989 });

@@ -67,0 +67,0 @@ console.time('remove32');

{
"name": "color-octree",
"version": "2.1.0",
"version": "2.1.1",
"description": "Get closest hex color",

@@ -40,2 +40,2 @@ "main": "dist/cjs.js",

"dependencies": {}
}
}
## Find efficiently the closest hex color
[![npm version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
### API

@@ -8,3 +11,3 @@

- `init(depth: Int = 7)`: Init the tree at a given depth (default 7), accepted range: [0, 7]
- `remove(hex)`: Remove a a color object by its hex property
- `remove(hex)`: Remove a color object by its hex property

@@ -27,2 +30,7 @@ ```js

It uses `String.prototype.padStart`, it exist on node 8.11 and recent browsers, but you might still want to polyfill it (see polyfill.io or es-shims)
It uses `String.prototype.padStart`, it exists on node 8.11 and recent browsers, but you might still want to polyfill it (see polyfill.io or es-shims)
[npm-image]: https://img.shields.io/npm/v/color-octree.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/color-octree
[travis-image]: https://img.shields.io/travis/caub/color-octree.svg?style=flat-square
[travis-url]: https://travis-ci.org/caub/color-octree
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