haus-colour-names 0.1.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/LICENSE +21 -0
- package/README.md +37 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/package.json +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 hipuku
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# haus-colour-names
|
|
2
|
+
|
|
3
|
+
31,900 named colours as data. No dependencies, no matching logic.
|
|
4
|
+
|
|
5
|
+
The dataset is [meodai/color-names](https://github.com/meodai/color-names). This package
|
|
6
|
+
carries it and normalises the hexes; the perceptual matching lives in
|
|
7
|
+
[`haus-colour-utils`](../colour-utils), so a project that wants CIEDE2000 or WCAG contrast
|
|
8
|
+
does not install 748KB of names to get them.
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install haus-colour-names haus-colour-utils
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { colourNameEntries } from 'haus-colour-names'
|
|
16
|
+
import { createNamedColourMatcher } from 'haus-colour-utils'
|
|
17
|
+
|
|
18
|
+
const nameColour = createNamedColourMatcher(colourNameEntries())
|
|
19
|
+
|
|
20
|
+
nameColour('#4f84ba', 3)
|
|
21
|
+
// [ { name: 'Blue Cola', hex: '#4a84c4', distance: 3.1 }, … ]
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
`haus-colour-utils` bundles 289 basic colour terms and uses them by default, so reach for
|
|
25
|
+
this package when you want the exhaustive set.
|
|
26
|
+
|
|
27
|
+
## API
|
|
28
|
+
|
|
29
|
+
| Export | Type | What it is |
|
|
30
|
+
|---|---|---|
|
|
31
|
+
| `colourNameEntries()` | `() => ColourNameEntry[]` | The dataset as `{ hex, name }`, hexes normalised to `#rrggbb`. Built on first call, then reused. |
|
|
32
|
+
| `colourNames` | `Record<string, string>` | The raw map. Keys are six hex digits with no `#`. |
|
|
33
|
+
| `COLOUR_NAME_COUNT` | `number` | 31,900. |
|
|
34
|
+
|
|
35
|
+
## Licence
|
|
36
|
+
|
|
37
|
+
MIT for the package. The dataset is MIT, from meodai/color-names.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Named colour data.
|
|
3
|
+
*
|
|
4
|
+
* The meodai colour-names dataset: 31,900 hex values with a human name each.
|
|
5
|
+
* Data only, no dependencies and no matching logic, so a project that wants ΔE
|
|
6
|
+
* from haus-colour-utils does not pay 748KB for names it never asks about.
|
|
7
|
+
*
|
|
8
|
+
* Pair it with `createNamedColourMatcher` from haus-colour-utils:
|
|
9
|
+
*
|
|
10
|
+
* import { colourNameEntries } from 'haus-colour-names'
|
|
11
|
+
* import { createNamedColourMatcher } from 'haus-colour-utils'
|
|
12
|
+
*
|
|
13
|
+
* const nameColour = createNamedColourMatcher(colourNameEntries())
|
|
14
|
+
* nameColour('#4f84ba') // [{ name: 'Blue Cola', hex: '#4a84c4', distance: 3.1 }, …]
|
|
15
|
+
*/
|
|
16
|
+
/** One dataset entry, with the hex normalised to `#rrggbb`. */
|
|
17
|
+
interface ColourNameEntry {
|
|
18
|
+
hex: string;
|
|
19
|
+
name: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The dataset as stored: keys are six hex digits with no leading `#`, and a
|
|
23
|
+
* value that starts with a zero keeps it (`"00ffff"`), so a key is always six
|
|
24
|
+
* characters. Exposed for a consumer that wants the raw map.
|
|
25
|
+
*/
|
|
26
|
+
declare const colourNames: Record<string, string>;
|
|
27
|
+
/** How many colours the dataset holds. */
|
|
28
|
+
declare const COLOUR_NAME_COUNT: number;
|
|
29
|
+
/**
|
|
30
|
+
* The dataset as `{ hex, name }` with hexes normalised to `#rrggbb`.
|
|
31
|
+
*
|
|
32
|
+
* Built on first call and then reused. Doing it at module load would cost every
|
|
33
|
+
* importer 31,900 string operations whether or not they name a colour.
|
|
34
|
+
*/
|
|
35
|
+
declare function colourNameEntries(): ColourNameEntry[];
|
|
36
|
+
|
|
37
|
+
export { COLOUR_NAME_COUNT, type ColourNameEntry, colourNameEntries, colourNames };
|