color-2-name 1.3.1 → 1.3.2

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.
Files changed (90) hide show
  1. package/CODE_OF_CONDUCT.md +45 -0
  2. package/CONTRIBUTING.md +92 -0
  3. package/biome.json +12 -0
  4. package/lib/@types/color-utils.d.ts +4 -1
  5. package/lib/@types/common.d.ts +3 -3
  6. package/lib/@types/hex-utils.d.ts +1 -1
  7. package/lib/@types/hsl-utils.d.ts +1 -1
  8. package/lib/@types/index.d.ts +13 -12
  9. package/lib/@types/rgb-utils.d.ts +1 -1
  10. package/lib/@types/types.d.ts +5 -0
  11. package/lib/browser/color-2-name.js +792 -500
  12. package/lib/browser/color-2-name.min.js +1 -2
  13. package/lib/cjs/index.js +1 -0
  14. package/lib/esm/color-utils.js +1 -0
  15. package/lib/esm/common.js +1 -0
  16. package/lib/esm/data/colorSet.js +1 -0
  17. package/lib/esm/hex-utils.js +1 -0
  18. package/lib/esm/hsl-utils.js +1 -0
  19. package/lib/esm/index.js +1 -0
  20. package/lib/esm/rgb-utils.js +1 -0
  21. package/package.json +63 -89
  22. package/readme.md +5 -5
  23. package/tests/colors_hex.test.ts +73 -64
  24. package/tests/colors_hsl.test.ts +66 -47
  25. package/tests/colors_rgb.test.ts +58 -35
  26. package/tests/core.test.ts +148 -131
  27. package/tsconfig.json +15 -31
  28. package/.eslintrc.json +0 -12
  29. package/babel.config.json +0 -6
  30. package/jest.config.json +0 -21
  31. package/lib/browser/color-2-name.js.map +0 -7
  32. package/lib/browser/color-2-name.min.js.map +0 -7
  33. package/lib/cjs/_virtual/_tslib.cjs +0 -35
  34. package/lib/cjs/_virtual/_tslib.cjs.map +0 -1
  35. package/lib/cjs/color-utils.cjs +0 -38
  36. package/lib/cjs/color-utils.cjs.map +0 -1
  37. package/lib/cjs/color-utils.d.ts +0 -18
  38. package/lib/cjs/common.cjs +0 -200
  39. package/lib/cjs/common.cjs.map +0 -1
  40. package/lib/cjs/common.d.ts +0 -93
  41. package/lib/cjs/data/colorSet.cjs +0 -148
  42. package/lib/cjs/data/colorSet.cjs.map +0 -1
  43. package/lib/cjs/data/colorSet.d.ts +0 -2
  44. package/lib/cjs/hex-utils.cjs +0 -105
  45. package/lib/cjs/hex-utils.cjs.map +0 -1
  46. package/lib/cjs/hex-utils.d.ts +0 -47
  47. package/lib/cjs/hsl-utils.cjs +0 -140
  48. package/lib/cjs/hsl-utils.cjs.map +0 -1
  49. package/lib/cjs/hsl-utils.d.ts +0 -47
  50. package/lib/cjs/index.cjs +0 -165
  51. package/lib/cjs/index.cjs.map +0 -1
  52. package/lib/cjs/index.d.ts +0 -87
  53. package/lib/cjs/rgb-utils.cjs +0 -58
  54. package/lib/cjs/rgb-utils.cjs.map +0 -1
  55. package/lib/cjs/rgb-utils.d.ts +0 -26
  56. package/lib/cjs/types.d.ts +0 -37
  57. package/lib/esm/_virtual/_tslib.mjs +0 -35
  58. package/lib/esm/_virtual/_tslib.mjs.map +0 -1
  59. package/lib/esm/color-utils.d.ts +0 -18
  60. package/lib/esm/color-utils.mjs +0 -35
  61. package/lib/esm/color-utils.mjs.map +0 -1
  62. package/lib/esm/common.d.ts +0 -93
  63. package/lib/esm/common.mjs +0 -184
  64. package/lib/esm/common.mjs.map +0 -1
  65. package/lib/esm/data/colorSet.d.ts +0 -2
  66. package/lib/esm/data/colorSet.mjs +0 -146
  67. package/lib/esm/data/colorSet.mjs.map +0 -1
  68. package/lib/esm/hex-utils.d.ts +0 -47
  69. package/lib/esm/hex-utils.mjs +0 -98
  70. package/lib/esm/hex-utils.mjs.map +0 -1
  71. package/lib/esm/hsl-utils.d.ts +0 -47
  72. package/lib/esm/hsl-utils.mjs +0 -133
  73. package/lib/esm/hsl-utils.mjs.map +0 -1
  74. package/lib/esm/index.d.ts +0 -87
  75. package/lib/esm/index.mjs +0 -156
  76. package/lib/esm/index.mjs.map +0 -1
  77. package/lib/esm/rgb-utils.d.ts +0 -26
  78. package/lib/esm/rgb-utils.mjs +0 -53
  79. package/lib/esm/rgb-utils.mjs.map +0 -1
  80. package/lib/esm/types.d.ts +0 -37
  81. package/lib/umd/color-2-name.js +0 -820
  82. package/lib/umd/color-2-name.min.js +0 -1
  83. package/lib/umd/color-utils.d.ts +0 -18
  84. package/lib/umd/common.d.ts +0 -93
  85. package/lib/umd/data/colorSet.d.ts +0 -2
  86. package/lib/umd/hex-utils.d.ts +0 -47
  87. package/lib/umd/hsl-utils.d.ts +0 -47
  88. package/lib/umd/index.d.ts +0 -87
  89. package/lib/umd/rgb-utils.d.ts +0 -26
  90. package/lib/umd/types.d.ts +0 -37
@@ -0,0 +1,45 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ ## Our Standards
8
+
9
+ Examples of behavior that contributes to creating a positive environment include:
10
+
11
+ * Using welcoming and inclusive language
12
+ * Being respectful of differing viewpoints and experiences
13
+ * Gracefully accepting constructive criticism
14
+ * Focusing on what is best for the community
15
+ * Showing empathy towards other community members
16
+
17
+ Examples of unacceptable behavior by participants include:
18
+
19
+ * The use of sexualized language or imagery and unwelcome sexual attention or advances
20
+ * Trolling, insulting/derogatory comments, and personal or political attacks
21
+ * Public or private harassment
22
+ * Publishing others' private information, such as a physical or electronic address, without explicit permission
23
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
24
+
25
+ ## Our Responsibilities
26
+
27
+ Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28
+
29
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30
+
31
+ ## Scope
32
+
33
+ This Code of Conduct applies within all project spaces, and it also applies when an individual is representing the project or its community in public spaces. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34
+
35
+ ## Enforcement
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project maintainer using any of the [private contact addresses](https://github.com/dec0dOS/amazing-github-template#support). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38
+
39
+ Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40
+
41
+ ## Attribution
42
+
43
+ This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 1.4, available at <https://www.contributor-covenant.org/version/1/4/code-of-conduct.html>
44
+
45
+ For answers to common questions about this code of conduct, see <https://www.contributor-covenant.org/faq>
@@ -0,0 +1,92 @@
1
+ # Contributing
2
+
3
+ When contributing to this repository, please first discuss the change you wish to make via issue,
4
+ email, or any other method with the owners of this repository before making a change.
5
+
6
+ Please note we have a code of conduct, please follow it in all your interactions with the project.
7
+
8
+ ## Pull Request Process
9
+
10
+ 1. Ensure any install or build dependencies are removed before the end of the layer when doing a
11
+ build.
12
+ 2. Update the README.md with details of changes to the interface, this includes new environment
13
+ variables, exposed ports, useful file locations and container parameters.
14
+ 3. Increase the version numbers in any examples files and the README.md to the new version that this
15
+ Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
16
+ 4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you
17
+ do not have permission to do that, you may request the second reviewer to merge it for you.
18
+
19
+ ## Code of Conduct
20
+
21
+ ### Our Pledge
22
+
23
+ In the interest of fostering an open and welcoming environment, we as
24
+ contributors and maintainers pledge to making participation in our project and
25
+ our community a harassment-free experience for everyone, regardless of age, body
26
+ size, disability, ethnicity, gender identity and expression, level of experience,
27
+ nationality, personal appearance, race, religion, or sexual identity and
28
+ orientation.
29
+
30
+ ### Our Standards
31
+
32
+ Examples of behavior that contributes to creating a positive environment
33
+ include:
34
+
35
+ * Using welcoming and inclusive language
36
+ * Being respectful of differing viewpoints and experiences
37
+ * Gracefully accepting constructive criticism
38
+ * Focusing on what is best for the community
39
+ * Showing empathy towards other community members
40
+
41
+ Examples of unacceptable behavior by participants include:
42
+
43
+ * The use of sexualized language or imagery and unwelcome sexual attention or
44
+ advances
45
+ * Trolling, insulting/derogatory comments, and personal or political attacks
46
+ * Public or private harassment
47
+ * Publishing others' private information, such as a physical or electronic
48
+ address, without explicit permission
49
+ * Other conduct which could reasonably be considered inappropriate in a
50
+ professional setting
51
+
52
+ ### Our Responsibilities
53
+
54
+ Project maintainers are responsible for clarifying the standards of acceptable
55
+ behavior and are expected to take appropriate and fair corrective action in
56
+ response to any instances of unacceptable behavior.
57
+
58
+ Project maintainers have the right and responsibility to remove, edit, or
59
+ reject comments, commits, code, wiki edits, issues, and other contributions
60
+ that are not aligned to this Code of Conduct, or to ban temporarily or
61
+ permanently any contributor for other behaviors that they deem inappropriate,
62
+ threatening, offensive, or harmful.
63
+
64
+ ### Scope
65
+
66
+ This Code of Conduct applies both within project spaces and in public spaces
67
+ when an individual is representing the project or its community. Examples of
68
+ representing a project or community include using an official project e-mail
69
+ address, posting via an official social media account, or acting as an appointed
70
+ representative at an online or offline event. Representation of a project may be
71
+ further defined and clarified by project maintainers.
72
+
73
+ ### Enforcement
74
+
75
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
76
+ reported by contacting the project team. All
77
+ complaints will be reviewed and investigated and will result in a response that
78
+ is deemed necessary and appropriate to the circumstances. The project team is
79
+ obligated to maintain confidentiality with regard to the reporter of an incident.
80
+ Further details of specific enforcement policies may be posted separately.
81
+
82
+ Project maintainers who do not follow or enforce the Code of Conduct in good
83
+ faith may face temporary or permanent repercussions as determined by other
84
+ members of the project's leadership.
85
+
86
+ ### Attribution
87
+
88
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
89
+ available at [http://contributor-covenant.org/version/1/4][version]
90
+
91
+ [homepage]: http://contributor-covenant.org
92
+ [version]: http://contributor-covenant.org/version/1/4/
package/biome.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "$schema": "https://biomejs.dev/schemas/1.7.0/schema.json",
3
+ "organizeImports": {
4
+ "enabled": true
5
+ },
6
+ "linter": {
7
+ "enabled": true,
8
+ "rules": {
9
+ "recommended": true
10
+ }
11
+ }
12
+ }
@@ -1,4 +1,4 @@
1
- import { RGBCOLORDEF } from "./types";
1
+ import type { RGBCOLORDEF } from "./types";
2
2
  /**
3
3
  * This function was the opposite of the name of the repo and returns the color of the colorSet given the name
4
4
  *
@@ -10,6 +10,9 @@ export declare function getColor(searchedColor: string, set?: RGBCOLORDEF[] | un
10
10
  rgb: string;
11
11
  hsl: string;
12
12
  };
13
+ /**
14
+ * Get all the colors from the colorSet
15
+ */
13
16
  export declare function getColors(): {
14
17
  hex: string;
15
18
  rgb: string;
@@ -1,4 +1,4 @@
1
- import { RGBCOLORDEF } from "./types";
1
+ import type { RGBCOLORDEF } from "./types";
2
2
  /** The maximum distance possible between colors */
3
3
  export declare const MAXDISTANCE = 441.6729559300637;
4
4
  /** A regex to match hex colors */
@@ -83,11 +83,11 @@ export declare function colorValueFallbacks(value: string, err?: string): number
83
83
  /**
84
84
  * Takes a string with a css value that could be a number or percentage or an angle in degrees and returns the corresponding 8bit value
85
85
  *
86
- * @param {string} value - a valid value for the css color definition (like 255, "100%", "324deg", etc.) *
86
+ * @param value - a valid value for the css color definition (like 255, "100%", "324deg", etc.) *
87
87
  * @param multiplier - the number that represent the maximum - default is 255 decimal - 100 hex
88
88
  *
89
89
  * @example convertToInt8('100%'); // 255
90
90
  *
91
91
  * @return {string} the corresponding value in 8-bit format
92
92
  */
93
- export declare function convertToInt8(value: string, multiplier?: number): number;
93
+ export declare function convertToInt8(value: string | unknown, multiplier?: number): number;
@@ -1,4 +1,4 @@
1
- import { COLORSTRING, HEX, RGBVALUE } from "./types";
1
+ import type { COLORSTRING, HEX, RGBVALUE } from "./types";
2
2
  /**
3
3
  * It returns an object with the hex values of the 3 digit hex color
4
4
  *
@@ -1,4 +1,4 @@
1
- import { HSLVALUE, RGBVALUE } from "./types";
1
+ import type { HSLVALUE, RGBVALUE } from "./types";
2
2
  export declare function fallbackHSL(hsl: string[], err?: string): string[];
3
3
  /**
4
4
  * Get the values of the hsl string
@@ -1,5 +1,6 @@
1
- import type { COLORDEF, COLORSTRING, HEX, RGBCOLORDEF, RGBVALUE } from "./types";
2
1
  import { getColor, getColors } from "./color-utils";
2
+ import type { COLORDEF, COLORSTRING, ColorParsers, HEX, RGBCOLORDEF, RGBVALUE } from "./types";
3
+ export declare const colorParsers: ColorParsers[];
3
4
  /**
4
5
  * Given a color string, it returns the closest corresponding name of the color.
5
6
  * Uses the Euclidean distance formula to calculate the distance between colors in the RGB color space.
@@ -19,6 +20,16 @@ import { getColor, getColors } from "./color-utils";
19
20
  declare function closest(color: string | COLORSTRING, set?: RGBCOLORDEF[] | undefined, args?: {
20
21
  info?: boolean;
21
22
  }): COLORDEF;
23
+ /**
24
+ * This function takes a string representing a color (color) and uses regular expressions to check if it matches any of the following formats: hex, hex+alpha, RGB, RGBA, HSL, or HSLA.
25
+ * If the color string matches one of these formats, the function returns an object with the type of color and the value of the color.
26
+ * If the color string does not match any of the formats, the function throws an error.
27
+ *
28
+ * @param {string} colorString - the color string to test and convert to rgb values
29
+ *
30
+ * @return {Object|Error} the object with rgb values of that color
31
+ */
32
+ export declare function parseColor(colorString: string): RGBVALUE;
22
33
  /**
23
34
  * Given a color returns if the color is light (by light is meant more mathematically closer to white)
24
35
  *
@@ -74,14 +85,4 @@ declare function distance(rgb1: [number, number, number], rgb2: [number, number,
74
85
  * @example rgbToHex("rgba(100% 0 0 / .5)"); // #FF0000
75
86
  */
76
87
  declare function rgbToHex(rgbString: string): HEX | Error;
77
- /**
78
- * This function takes a string representing a color (color) and uses regular expressions to check if it matches any of the following formats: hex, hex+alpha, RGB, RGBA, HSL, or HSLA.
79
- * If the color string matches one of these formats, the function returns an object with the type of color and the value of the color.
80
- * If the color string does not match any of the formats, the function throws an error.
81
- *
82
- * @param {string} colorString - the color string to test and convert to rgb values
83
- *
84
- * @return {Object|Error} the object with rgb values of that color
85
- */
86
- export declare function parseColor(colorString: string): RGBVALUE;
87
- export { closest, rgbToHex, distance, isLight, isDark, closestRGB, getColor, getColors };
88
+ export { closest, rgbToHex, distance, isLight, isDark, closestRGB, getColor, getColors, };
@@ -1,4 +1,4 @@
1
- import { RGBVALUE } from "./types";
1
+ import type { RGBVALUE } from "./types";
2
2
  export declare function fallbackRGB(rgb: string[], err?: string): string[];
3
3
  /**
4
4
  * Get the values of the rgb string
@@ -31,6 +31,11 @@ export interface COLORDEF {
31
31
  hsl?: string;
32
32
  gap?: number;
33
33
  }
34
+ export interface ColorParsers {
35
+ regex: RegExp;
36
+ parser: (color: string) => string[];
37
+ converter: (colorSet: string[]) => RGBVALUE;
38
+ }
34
39
  export type colorListHEX = Array<{
35
40
  name: string;
36
41
  color: string;