color-name-list 10.28.1 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.husky/pre-commit +1 -0
- package/README.md +5 -5
- package/dist/colornames.bestof.esm.js +1 -1
- package/dist/colornames.bestof.esm.mjs +1 -1
- package/dist/colornames.esm.js +1 -1
- package/dist/colornames.esm.mjs +1 -1
- package/dist/colornames.short.esm.js +1 -1
- package/dist/colornames.short.esm.mjs +1 -1
- package/dist/history.json +1 -1
- package/package.json +21 -7
- package/scripts/build.js +6 -7
- package/scripts/esm.js.tpl +1 -1
- package/scripts/lib.js +82 -77
- package/scripts/tools/history.js +2 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npm test && npm run build
|
package/README.md
CHANGED
|
@@ -135,12 +135,12 @@ consider using the [public rest API](#api-)
|
|
|
135
135
|
#### Exact Color
|
|
136
136
|
|
|
137
137
|
```javascript
|
|
138
|
-
import {
|
|
138
|
+
import { colornames } from 'color-name-list';
|
|
139
139
|
|
|
140
|
-
let someColor =
|
|
140
|
+
let someColor = colornames.find(color => color.hex === '#ffffff');
|
|
141
141
|
console.log(someColor.name); // => white
|
|
142
142
|
|
|
143
|
-
let someNamedColor =
|
|
143
|
+
let someNamedColor = colornames.find(color => color.name === 'Eigengrau')
|
|
144
144
|
console.log(someColor.hex); // => #16161d
|
|
145
145
|
```
|
|
146
146
|
|
|
@@ -151,10 +151,10 @@ Since there are 16777216 possible RGB colors, you might use a library such as
|
|
|
151
151
|
|
|
152
152
|
```js
|
|
153
153
|
import nearestColor from 'nearest-color';
|
|
154
|
-
import {
|
|
154
|
+
import { colornames } from 'color-name-list';
|
|
155
155
|
|
|
156
156
|
// nearestColor need objects {name => hex} as input
|
|
157
|
-
const colors =
|
|
157
|
+
const colors = colornames.reduce((o, { name, hex }) => Object.assign(o, { [name]: hex }), {});
|
|
158
158
|
|
|
159
159
|
const nearest = nearestColor.from(colors);
|
|
160
160
|
|