diff --git a/dist/color-2-name.js.map b/dist/color-2-name.js.map
index c621fe4..18462f0 100644
--- a/dist/color-2-name.js.map
+++ b/dist/color-2-name.js.map
@@ -1 +1 @@
-{"version":3,"file":"color-2-name.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,aAAc,GAAIH,GACC,iBAAZC,QACdA,QAAoB,WAAID,IAExBD,EAAiB,WAAIC,GACtB,CATD,CASGK,MAAM,I,mBCRT,IAAIC,EAAsB,CCA1BA,EAAwB,CAACL,EAASM,KACjC,IAAI,IAAIC,KAAOD,EACXD,EAAoBG,EAAEF,EAAYC,KAASF,EAAoBG,EAAER,EAASO,IAC5EE,OAAOC,eAAeV,EAASO,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDF,EAAwB,CAACQ,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFT,EAAyBL,IACH,oBAAXkB,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeV,EAASkB,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeV,EAAS,aAAc,CAAEoB,OAAO,GAAO,G,gJC40B9D,QAj1BiB,CACf,CACE,IACA,IACA,IACA,SAEF,CACE,EACA,EACA,EACA,SAEF,CACE,IACA,EACA,EACA,OAEF,CACE,EACA,IACA,EACA,SAEF,CACE,EACA,EACA,IACA,QAEF,CACE,IACA,IACA,EACA,UAEF,CACE,IACA,IACA,IACA,QAEF,CACE,IACA,IACA,EACA,UAEF,CACE,IACA,EACA,IACA,WAEF,CACE,IACA,IACA,GACA,eAEF,CACE,IACA,IACA,IACA,UAEF,CACE,EACA,IACA,EACA,QAEF,CACE,IACA,EACA,IACA,UAEF,CACE,IACA,GACA,GACA,UAEF,CACE,GACA,IACA,IACA,aAEF,CACE,IACA,IACA,GACA,SAEF,CACE,EACA,IACA,IACA,QAEF,CACE,IACA,IACA,IACA,eAEF,CACE,IACA,IACA,IACA,QAEF,CACE,GACA,IACA,GACA,eAEF,CACE,IACA,IACA,IACA,SAEF,CACE,IACA,EACA,IACA,WAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,IACA,EACA,QAEF,CACE,IACA,IACA,GACA,aAEF,CACE,IACA,IACA,GACA,eAEF,CACE,IACA,IACA,IACA,UAEF,CACE,IACA,IACA,IACA,SAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,EACA,EACA,WAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,GACA,GACA,aAEF,CACE,GACA,EACA,IACA,UAEF,CACE,IACA,IACA,IACA,gBAEF,CACE,EACA,IACA,IACA,QAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,IACA,IACA,SAEF,CACE,IACA,IACA,IACA,UAEF,CACE,IACA,IACA,IACA,kBAEF,CACE,IACA,GACA,IACA,cAEF,CACE,IACA,GACA,GACA,SAEF,CACE,IACA,IACA,IACA,aAEF,CACE,GACA,IACA,IACA,aAEF,CACE,IACA,IACA,EACA,cAEF,CACE,IACA,IACA,GACA,aAEF,CACE,IACA,IACA,IACA,kBAEF,CACE,IACA,IACA,IACA,YAEF,CACE,IACA,GACA,GACA,WAEF,CACE,EACA,EACA,IACA,YAEF,CACE,EACA,IACA,IACA,YAEF,CACE,IACA,IACA,GACA,iBAEF,CACE,IACA,IACA,IACA,YAEF,CACE,EACA,IACA,EACA,aAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,EACA,IACA,eAEF,CACE,GACA,IACA,GACA,kBAEF,CACE,IACA,IACA,EACA,cAEF,CACE,IACA,GACA,IACA,cAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,IACA,IACA,gBAEF,CACE,GACA,GACA,IACA,iBAEF,CACE,GACA,GACA,GACA,iBAEF,CACE,EACA,IACA,IACA,iBAEF,CACE,IACA,EACA,IACA,cAEF,CACE,IACA,GACA,IACA,YAEF,CACE,EACA,IACA,IACA,eAEF,CACE,IACA,IACA,IACA,WAEF,CACE,GACA,IACA,IACA,cAEF,CACE,IACA,GACA,GACA,aAEF,CACE,IACA,IACA,IACA,YAEF,CACE,IACA,IACA,IACA,WAEF,CACE,IACA,IACA,IACA,SAEF,CACE,IACA,IACA,IACA,SAEF,CACE,IACA,IACA,IACA,YAEF,CACE,IACA,IACA,IACA,iBAEF,CACE,IACA,IACA,EACA,aAEF,CACE,IACA,IACA,IACA,gBAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,wBAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,eAEF,CACE,GACA,IACA,IACA,iBAEF,CACE,IACA,IACA,IACA,gBAEF,CACE,IACA,IACA,IACA,kBAEF,CACE,IACA,IACA,IACA,kBAEF,CACE,IACA,IACA,IACA,eAEF,CACE,GACA,IACA,GACA,aAEF,CACE,IACA,IACA,IACA,SAEF,CACE,IACA,EACA,EACA,UAEF,CACE,IACA,IACA,IACA,oBAEF,CACE,EACA,EACA,IACA,cAEF,CACE,IACA,GACA,IACA,gBAEF,CACE,IACA,IACA,IACA,gBAEF,CACE,GACA,IACA,IACA,kBAEF,CACE,IACA,IACA,IACA,mBAEF,CACE,EACA,IACA,IACA,qBAEF,CACE,GACA,IACA,IACA,mBAEF,CACE,IACA,GACA,IACA,mBAEF,CACE,GACA,GACA,IACA,gBAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,YAEF,CACE,IACA,IACA,IACA,eAEF,CACE,EACA,EACA,IACA,QAEF,CACE,IACA,IACA,IACA,WAEF,CACE,IACA,IACA,EACA,SAEF,CACE,IACA,IACA,GACA,aAEF,CACE,IACA,GACA,EACA,aAEF,CACE,IACA,IACA,IACA,UAEF,CACE,IACA,IACA,IACA,iBAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,iBAEF,CACE,IACA,IACA,IACA,iBAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,GACA,QAEF,CACE,IACA,IACA,IACA,QAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,GACA,IACA,iBAEF,CACE,IACA,IACA,IACA,aAEF,CACE,GACA,IACA,IACA,aAEF,CACE,IACA,GACA,GACA,eAEF,CACE,IACA,IACA,IACA,UAEF,CACE,IACA,IACA,GACA,cAEF,CACE,GACA,IACA,GACA,YAEF,CACE,IACA,IACA,IACA,YAEF,CACE,IACA,GACA,GACA,UAEF,CACE,IACA,IACA,IACA,WAEF,CACE,IACA,GACA,IACA,aAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,QAEF,CACE,EACA,IACA,IACA,eAEF,CACE,GACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,OAEF,CACE,EACA,IACA,IACA,QAEF,CACE,IACA,IACA,IACA,YCzzBG,SAASC,EAAUD,GAExB,IAAME,EAA6C,MAAzBC,MAAMC,KAAKJ,GAAO,GAAcA,EAAMK,UAAU,GAAKL,EAM/E,GAAIE,EAASI,OAAS,EAAG,CACvB,GAAIJ,EAASI,OAAS,EACpB,OAtBC,SAA4BN,GAEjC,OAAOG,MAAMC,KAAKJ,GAAOO,KAAI,SAACC,GAAS,OAAMA,EAAIA,GAAGC,aAAa,GACnE,CAmBaC,CAAkBR,GAEzB,IAAMS,EAAMT,EAASU,MAAM,OAC3B,OAAe,MAAPD,EAAe,CAACA,EAAI,GAAGF,cAAeE,EAAI,GAAGF,cAAeE,EAAI,GAAGF,eAAiB,EAEhG,CAEA,MAAO,EACT,CA4BO,SAASI,EAAOC,GACrB,OAAOA,EAAKC,SAAS,IAAIC,SAAS,EAAG,IACvC,CASO,SA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2name/webpack/universalModuleDefinition","webpack://color2name/webpack/bootstrap","webpack://color2name/webpack/runtime/define property getters","webpack://color2name/webpack/runtime/hasOwnProperty shorthand","webpack://color2name/webpack/runtime/make namespace object","webpack://color2name/./src/data/colorSet.ts","webpack://color2name/./src/hex-utils.ts","webpack://color2name/./src/rgb-utils.ts","webpack://color2name/./src/hsl-utils.ts","webpack://color2name/./src/common.ts","webpack://color2name/./src/index.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"color2name\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"color2name\"] = factory();\n\telse\n\t\troot[\"color2name\"] = factory();\n})(this, () => {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const colorSet = [\n [\n 255,\n 255,\n 255,\n 'white'\n ],\n [\n 0,\n 0,\n 0,\n 'black'\n ],\n [\n 255,\n 0,\n 0,\n 'red'\n ],\n [\n 0,\n 128,\n 0,\n 'green'\n ],\n [\n 0,\n 0,\n 255,\n 'blue'\n ],\n [\n 255,\n 165,\n 0,\n 'orange'\n ],\n [\n 128,\n 128,\n 128,\n 'grey'\n ],\n [\n 255,\n 255,\n 0,\n 'yellow'\n ],\n [\n 255,\n 0,\n 255,\n 'magenta'\n ],\n [\n 154,\n 205,\n 50,\n 'yellowgreen'\n ],\n [\n 192,\n 192,\n 192,\n 'silver'\n ],\n [\n 0,\n 255,\n 0,\n 'lime'\n ],\n [\n 128,\n 0,\n 128,\n 'purple'\n ],\n [\n 255,\n 99,\n 71,\n 'tomato'\n ],\n [\n 64,\n 224,\n 208,\n 'turquoise'\n ],\n [\n 255,\n 127,\n 80,\n 'coral'\n ],\n [\n 0,\n 255,\n 255,\n 'cyan'\n ],\n [\n 255,\n 250,\n 240,\n 'floralwhite'\n ],\n [\n 255,\n 192,\n 203,\n 'pink'\n ],\n [\n 34,\n 139,\n 34,\n 'forestgreen'\n ],\n [\n 245,\n 245,\n 220,\n 'beige'\n ],\n [\n 255,\n 0,\n 255,\n 'fuchsia'\n ],\n [\n 220,\n 220,\n 220,\n 'gainsboro'\n ],\n [\n 248,\n 248,\n 255,\n 'ghostwhite'\n ],\n [\n 255,\n 215,\n 0,\n 'gold'\n ],\n [\n 218,\n 165,\n 32,\n 'goldenrod'\n ],\n [\n 173,\n 255,\n 47,\n 'greenyellow'\n ],\n [\n 238,\n 130,\n 238,\n 'violet'\n ],\n [\n 245,\n 222,\n 179,\n 'wheat'\n ],\n [\n 245,\n 245,\n 245,\n 'whitesmoke'\n ],\n [\n 139,\n 0,\n 0,\n 'darkred'\n ],\n [\n 240,\n 248,\n 255,\n 'aliceblue'\n ],\n [\n 205,\n 92,\n 92,\n 'indianred'\n ],\n [\n 75,\n 0,\n 130,\n 'indigo'\n ],\n [\n 250,\n 235,\n 215,\n 'antiquewhite'\n ],\n [\n 0,\n 255,\n 255,\n 'aqua'\n ],\n [\n 127,\n 255,\n 212,\n 'aquamarine'\n ],\n [\n 240,\n 255,\n 255,\n 'azure'\n ],\n [\n 255,\n 228,\n 196,\n 'bisque'\n ],\n [\n 255,\n 235,\n 205,\n 'blanchedalmond'\n ],\n [\n 138,\n 43,\n 226,\n 'blueviolet'\n ],\n [\n 165,\n 42,\n 42,\n 'brown'\n ],\n [\n 222,\n 184,\n 135,\n 'burlywood'\n ],\n [\n 95,\n 158,\n 160,\n 'cadetblue'\n ],\n [\n 127,\n 255,\n 0,\n 'chartreuse'\n ],\n [\n 210,\n 105,\n 30,\n 'chocolate'\n ],\n [\n 100,\n 149,\n 237,\n 'cornflowerblue'\n ],\n [\n 255,\n 248,\n 220,\n 'cornsilk'\n ],\n [\n 220,\n 20,\n 60,\n 'crimson'\n ],\n [\n 0,\n 0,\n 139,\n 'darkblue'\n ],\n [\n 0,\n 139,\n 139,\n 'darkcyan'\n ],\n [\n 184,\n 134,\n 11,\n 'darkgoldenrod'\n ],\n [\n 169,\n 169,\n 169,\n 'darkgrey'\n ],\n [\n 0,\n 100,\n 0,\n 'darkgreen'\n ],\n [\n 189,\n 183,\n 107,\n 'darkkhaki'\n ],\n [\n 139,\n 0,\n 139,\n 'darkmagenta'\n ],\n [\n 85,\n 107,\n 47,\n 'darkolivegreen'\n ],\n [\n 255,\n 140,\n 0,\n 'darkorange'\n ],\n [\n 153,\n 50,\n 204,\n 'darkorchid'\n ],\n [\n 233,\n 150,\n 122,\n 'darksalmon'\n ],\n [\n 143,\n 188,\n 143,\n 'darkseagreen'\n ],\n [\n 72,\n 61,\n 139,\n 'darkslateblue'\n ],\n [\n 47,\n 79,\n 79,\n 'darkslategrey'\n ],\n [\n 0,\n 206,\n 209,\n 'darkturquoise'\n ],\n [\n 148,\n 0,\n 211,\n 'darkviolet'\n ],\n [\n 255,\n 20,\n 147,\n 'deeppink'\n ],\n [\n 0,\n 191,\n 255,\n 'deepskyblue'\n ],\n [\n 105,\n 105,\n 105,\n 'dimgrey'\n ],\n [\n 30,\n 144,\n 255,\n 'dodgerblue'\n ],\n [\n 178,\n 34,\n 34,\n 'firebrick'\n ],\n [\n 240,\n 255,\n 240,\n 'honeydew'\n ],\n [\n 255,\n 105,\n 180,\n 'hotpink'\n ],\n [\n 255,\n 255,\n 240,\n 'ivory'\n ],\n [\n 240,\n 230,\n 140,\n 'khaki'\n ],\n [\n 230,\n 230,\n 250,\n 'lavender'\n ],\n [\n 255,\n 240,\n 245,\n 'lavenderblush'\n ],\n [\n 124,\n 252,\n 0,\n 'lawngreen'\n ],\n [\n 255,\n 250,\n 205,\n 'lemonchiffon'\n ],\n [\n 173,\n 216,\n 230,\n 'lightblue'\n ],\n [\n 240,\n 128,\n 128,\n 'lightcoral'\n ],\n [\n 224,\n 255,\n 255,\n 'lightcyan'\n ],\n [\n 250,\n 250,\n 210,\n 'lightgoldenrodyellow'\n ],\n [\n 144,\n 238,\n 144,\n 'lightgreen'\n ],\n [\n 211,\n 211,\n 211,\n 'lightgrey'\n ],\n [\n 255,\n 182,\n 193,\n 'lightpink'\n ],\n [\n 255,\n 160,\n 122,\n 'lightsalmon'\n ],\n [\n 32,\n 178,\n 170,\n 'lightseagreen'\n ],\n [\n 135,\n 206,\n 250,\n 'lightskyblue'\n ],\n [\n 119,\n 136,\n 153,\n 'lightslategrey'\n ],\n [\n 176,\n 196,\n 222,\n 'lightsteelblue'\n ],\n [\n 255,\n 255,\n 224,\n 'lightyellow'\n ],\n [\n 50,\n 205,\n 50,\n 'limegreen'\n ],\n [\n 250,\n 240,\n 230,\n 'linen'\n ],\n [\n 128,\n 0,\n 0,\n 'maroon'\n ],\n [\n 102,\n 205,\n 170,\n 'mediumaquamarine'\n ],\n [\n 0,\n 0,\n 205,\n 'mediumblue'\n ],\n [\n 186,\n 85,\n 211,\n 'mediumorchid'\n ],\n [\n 147,\n 112,\n 219,\n 'mediumpurple'\n ],\n [\n 60,\n 179,\n 113,\n 'mediumseagreen'\n ],\n [\n 123,\n 104,\n 238,\n 'mediumslateblue'\n ],\n [\n 0,\n 250,\n 154,\n 'mediumspringgreen'\n ],\n [\n 72,\n 209,\n 204,\n 'mediumturquoise'\n ],\n [\n 199,\n 21,\n 133,\n 'mediumvioletred'\n ],\n [\n 25,\n 25,\n 112,\n 'midnightblue'\n ],\n [\n 245,\n 255,\n 250,\n 'mintcream'\n ],\n [\n 255,\n 228,\n 225,\n 'mistyrose'\n ],\n [\n 255,\n 228,\n 181,\n 'moccasin'\n ],\n [\n 255,\n 222,\n 173,\n 'navajowhite'\n ],\n [\n 0,\n 0,\n 128,\n 'navy'\n ],\n [\n 253,\n 245,\n 230,\n 'oldlace'\n ],\n [\n 128,\n 128,\n 0,\n 'olive'\n ],\n [\n 107,\n 142,\n 35,\n 'olivedrab'\n ],\n [\n 255,\n 69,\n 0,\n 'orangered'\n ],\n [\n 218,\n 112,\n 214,\n 'orchid'\n ],\n [\n 238,\n 232,\n 170,\n 'palegoldenrod'\n ],\n [\n 152,\n 251,\n 152,\n 'palegreen'\n ],\n [\n 175,\n 238,\n 238,\n 'paleturquoise'\n ],\n [\n 219,\n 112,\n 147,\n 'palevioletred'\n ],\n [\n 255,\n 239,\n 213,\n 'papayawhip'\n ],\n [\n 255,\n 218,\n 185,\n 'peachpuff'\n ],\n [\n 205,\n 133,\n 63,\n 'peru'\n ],\n [\n 221,\n 160,\n 221,\n 'plum'\n ],\n [\n 176,\n 224,\n 230,\n 'powderblue'\n ],\n [\n 102,\n 51,\n 153,\n 'rebeccapurple'\n ],\n [\n 188,\n 143,\n 143,\n 'rosybrown'\n ],\n [\n 65,\n 105,\n 225,\n 'royalblue'\n ],\n [\n 139,\n 69,\n 19,\n 'saddlebrown'\n ],\n [\n 250,\n 128,\n 114,\n 'salmon'\n ],\n [\n 244,\n 164,\n 96,\n 'sandybrown'\n ],\n [\n 46,\n 139,\n 87,\n 'seagreen'\n ],\n [\n 255,\n 245,\n 238,\n 'seashell'\n ],\n [\n 160,\n 82,\n 45,\n 'sienna'\n ],\n [\n 135,\n 206,\n 235,\n 'skyblue'\n ],\n [\n 106,\n 90,\n 205,\n 'slateblue'\n ],\n [\n 112,\n 128,\n 144,\n 'slategrey'\n ],\n [\n 255,\n 250,\n 250,\n 'snow'\n ],\n [\n 0,\n 255,\n 127,\n 'springgreen'\n ],\n [\n 70,\n 130,\n 180,\n 'steelblue'\n ],\n [\n 210,\n 180,\n 140,\n 'tan'\n ],\n [\n 0,\n 128,\n 128,\n 'teal'\n ],\n [\n 216,\n 191,\n 216,\n 'thistle'\n ]\n]\n\nexport default colorSet\n","import { COLORSTRING, HEX, RGBVALUE } from './types'\n\n/**\n * It returns an object with the hex values of the 3 digit hex color\n *\n * @param {string} value 3 digit hex\n * @return {string[]} 6 digit hex\n */\nexport function shortHexToLongHex (value: string): string[] {\n // split the string in to an array of digits then return an array that contains that digit doubled for each item\n return Array.from(value).map((v: string) => (v + v).toUpperCase())\n}\n\n/**\n * Get the hex value of the color and convert it to an Object of R G And B values (still in hex format)\n *\n * @param value the string that contains the color in hex format\n *\n * @return {string[]} an array of 6 digit hex values in a triplet of R G and B (HEX format)\n */\nexport function parseHex (value: COLORSTRING): string[] {\n // remove # at the beginning of the hex color\n const hexColor: string = (Array.from(value)[0] === '#') ? value.substring(1) : value\n\n /**\n * then if the number of digits is greater than 2 (so it's something like 123 or abc456)\n * breakdown the string into an object that contains the r g and b values in hex\n */\n if (hexColor.length > 2) {\n if (hexColor.length < 6) { // >=6 is the long notation\n return shortHexToLongHex(hexColor)\n } else {\n const hex = hexColor.match(/../g)\n return (hex != null) ? [hex[0].toUpperCase(), hex[1].toUpperCase(), hex[2].toUpperCase()] : []\n }\n }\n\n return []\n}\n\n/**\n * Converts a Hex color to rgb\n *\n * @param {string} hex without the \"#\"\n *\n * @return {string} the rgb color values for the given hex color\n */\nexport function hexToRgb (hex: string[]): RGBVALUE | Error {\n // Extract the RGB values from the hex string\n if (hex.length >= 2) {\n return {\n r: parseInt(hex[0], 16),\n g: parseInt(hex[1], 16),\n b: parseInt(hex[2], 16)\n }\n }\n throw new Error(`Invalid Hex color: ${hex.join(', ')}`)\n}\n\n/**\n * Convert a INT8 value to HEX\n *\n * @param {number} int8 - the integer value to convert\n *\n * @return {string} the hex string\n */\nexport function toHex (int8: number): string {\n return int8.toString(16).padStart(2, '0')\n}\n\n/**\n* Convert rgb values to hex color\n*\n* @param {Object} rgb an object with the rgb values\n *\n * @return {string} the hex string\n*/\nexport function valuesToHex (rgb: RGBVALUE): HEX {\n // Extract the RGB values from the hex string\n if (\n typeof rgb?.r === 'number' &&\n typeof rgb?.g === 'number' &&\n typeof rgb?.b === 'number') {\n return `#${toHex(rgb?.r)}${toHex(rgb?.g)}${toHex(rgb?.b)}`\n }\n return '#errorr'\n}\n","import { convertToInt8, rgbRegex, splitValues } from './common'\nimport { RGBVALUE } from './types'\n\n/**\n * Get the values of the rgb string\n *\n * @param rgbAsString - the rgb color as string split into values\n *\n * @return {Array} the values of the rgb string as Array of strings that represent the rgb color\n */\nexport function parseRgb (rgbAsString: string): string[] {\n const rgbvalue = rgbAsString.match(rgbRegex)\n if (rgbvalue != null) {\n const rgb: string[] = splitValues(rgbvalue[1])\n\n if (rgb.length >= 2) {\n return [\n rgb[0],\n rgb[1],\n rgb[2]\n ]\n }\n }\n throw new Error(`Can't parse rgb color: ${rgbAsString}`)\n}\n\n/**\n * This function takes an array of strings and returns and object with the rgb values converted into INT8 (0-255)\n *\n * @param {Array} rgb - rgb color as Array of strings\n *\n * @return {Object} an object that contains the r, g and b values as INT8\n */\nexport function getRgbValues (rgb: string[]): RGBVALUE {\n if (rgb.length >= 2) {\n return {\n r: convertToInt8(rgb[0]),\n g: convertToInt8(rgb[1]),\n b: convertToInt8(rgb[2])\n }\n }\n throw new Error(`Invalid rgb color: ${rgb.join(', ')}`)\n}\n\n/**\n * returns a string representation of the rgb values\n *\n * @param {Object} rgb the rgb color object\n *\n * @return {string} a string representation of the rgb values\n */\nexport function valuesToRgb (rgb: RGBVALUE): string {\n return `rgb(${rgb.r},${rgb.g},${rgb.b})`\n}\n","import {hslRegex, normalizeDegree, RGBSET, splitValues} from './common'\nimport { HSLVALUE, RGBVALUE } from './types'\n\n/**\n * Get the values of the hsl string\n *\n * @param {string} hslAsString - the valid hsl color string\n * @return {string[]} the values of the hsl string\n */\nexport function parseHsl (hslAsString: string): string[] {\n const hslvalue = hslAsString.match(hslRegex)\n if (hslvalue != null) {\n const hsl: string[] = splitValues(hslvalue[1])\n\n if (hsl.length >= 2) {\n return [\n hsl[0],\n hsl[1],\n hsl[2]\n ]\n }\n }\n throw new Error(`Can't parse hsl color: ${hslAsString}`)\n}\n\n/**\n * This function takes an array of strings and returns and object with the hsl values converted into INT8 (0-255)\n *\n * @param {string[]} hsl - the hsl values to parse from string to int8 values\n *\n */\nexport function getHslValues (hsl: string[]): HSLVALUE {\n if (hsl.length >= 2) {\n return {\n h: normalizeDegree(hsl[0]),\n s: parseInt(hsl[1], 10),\n l: parseInt(hsl[2], 10)\n }\n }\n throw new Error(`Invalid hsl color: ${hsl.join(', ')}`)\n}\n\n/**\n * Given the HSL color it convert the color into RGB\n *\n * @param {string[]} hsl the HSL value to parse\n * @return {Object} rgb value\n */\nexport function hslToRgb (hsl: string[]): RGBVALUE {\n if (hsl === null || hsl.length < 2) {\n throw new Error(`Invalid hsl color: ${hsl.join(', ')}`)\n }\n\n let {\n h,\n s,\n l\n } = getHslValues(hsl)\n\n // Must be fractions of 1\n s /= 100\n l /= 100\n\n const c = (1 - Math.abs(2 * l - 1)) * s\n const x = c * (1 - Math.abs((h / 60) % 2 - 1))\n const m = l - c / 2\n let r = 0\n let g = 0\n let b = 0\n\n if (h >= 0 && h < 60) {\n r = c; g = x; b = 0\n } else if (h >= 60 && h < 120) {\n r = x; g = c; b = 0\n } else if (h >= 120 && h < 180) {\n r = 0; g = c; b = x\n } else if (h >= 180 && h < 240) {\n r = 0; g = x; b = c\n } else if (h >= 240 && h < 300) {\n r = x; g = 0; b = c\n } else if (h >= 300 && h < 360) {\n r = c; g = 0; b = x\n }\n r = Math.round((r + m) * 255)\n g = Math.round((g + m) * 255)\n b = Math.round((b + m) * 255)\n\n return { r, g, b }\n}\n\n/**\n * Given the RGB color it convert the color into HSL\n *\n * @param {number} r - red\n * @param {number} g - green\n * @param {number} b - blue\n *\n * @return {Object} hsl value\n */\nexport function valuesToHsl ({ r, g, b }: RGBVALUE): string {\n // Make r, g, and b fractions of 1\n r /= 255\n g /= 255\n b /= 255\n\n // Find greatest and smallest channel values\n const cmin = Math.min(r, g, b)\n const cmax = Math.max(r, g, b)\n const delta = cmax - cmin\n let h = 0\n let s = 0\n let l = 0\n\n // Calculate hue\n if (delta === 0) { // No difference\n h = 0\n } else if (cmax === r) { // Red is max\n h = ((g - b) / delta) % 6\n } else if (cmax === g) { // Green is max\n h = (b - r) / delta + 2\n } else { h = (r - g) / delta + 4 } // Blue is max\n\n h = Math.round(h * 60)\n\n // Make negative hues positive behind 360°\n if (h < 0) { h += 360 }\n\n // Calculate lightness\n l = (cmax + cmin) / 2\n\n // Calculate saturation\n s = delta === 0 ? 0 : delta / (1 - Math.abs(2 * l - 1))\n\n // Multiply l and s by 100\n s = +(s * 100).toFixed(1)\n l = +(l * 100).toFixed(1)\n\n return `hsl(${h},${s}%,${l}%)`\n}\n","// Regular expressions to match different color formats\nimport { COLORSTRING, HEX, HSL, RGB, RGBCOLORDEF, RGBVALUE } from './types'\nimport { hexToRgb, parseHex } from './hex-utils'\nimport { getRgbValues, parseRgb } from './rgb-utils'\nimport { hslToRgb, parseHsl } from './hsl-utils'\n\n/** The maximum distance possible between colors */\nexport const MAXDISTANCE = 441.6729559300637\n\n/** A regex to match hex colors */\nexport const hexRegex: RegExp = /^#([\\da-f]{6,}|[\\da-f]{3,})/i\n/** A regex to match rgb colors */\nexport const rgbRegex: RegExp = /^rgba?\\(([^)]+)\\)/i\n/** A regex to match hsl colors */\nexport const hslRegex: RegExp = /^hsla?\\(([^)]+)\\)/i\n/** A regex to match strings that are only int numbers */\nexport const isNumeric: RegExp = /^[0-9]*$/\n\n/**\n * This set is used in order to detect if the color is bright or dark\n *\n * @note the set has been corrected to get pure RGB values (eg. pure red, pure green) in the \"bright\" area\n */\nexport const BLACKANDWHITE: RGBCOLORDEF[] = [\n [255, 255, 255, 'white'],\n [1, 1, 1, 'black']\n]\n\n/**\n * This set is used in order to detect the nearest rgb color\n */\nexport const RGBSET: RGBCOLORDEF[] = [\n [255, 0, 0, 'red'],\n [0, 255, 0, 'green'],\n [0, 0, 255, 'blue']\n]\n\n/**\n * split the content of rgb and hsl colors depending on the parsed value of the css property\n *\n * https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb#syntax\n *\n * @param {string} rawValues - the value inside the rgb(.*) css color definition\n *\n * @return {Array} the array of rgb values finded inside the passed string\n */\nexport function splitValues (rawValues: string): string[] {\n if (rawValues.includes(',')) {\n return rawValues.split(/[,\\\\/]/).map(val => val.trim())\n }\n\n return rawValues.split(/[ \\\\/]/).map(val => val.trim()).filter(Boolean)\n}\n\n/**\n * If the value is an angle in degrees, convert it to the 0-360 range\n *\n * @param {string} value - the degrees to convert into a number\n * @param {number} multiplier - the number that represent the maximum - default is 100\n *\n * @return {number} the converted value\n */\nexport function normalizeDegree (value: string, multiplier: number = 360): number {\n let angle = parseFloat(value)\n while (angle < 0) {\n angle += 360\n }\n while (angle > 360) {\n angle -= 360\n }\n return (angle / 360) * multiplier\n}\n\n/**\n * 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\n *\n * @param {string} value - a valid value for the css color definition (like 255, \"100%\", \"324deg\", etc)\n * @param {string} value - a valid value for the css color definition (like 255, \"100%\", \"324deg\", etc)\n *\n * @example convertToInt8('100%'); // 255\n *\n * @return {string} the corresponding value in 8 bit format\n */\nexport function convertToInt8 (value: string, multiplier: number = 255): number {\n value = value.trim()\n if (isNumeric.test(value)) {\n // If the value is an int number return it as number\n return parseInt(value, 10)\n } else if (value.endsWith('%')) {\n // If the value is a percentage, divide it by 100 to get a value from 0 to 1\n // and then multiply it by 255 to get a value from 0 to 255\n return parseFloat(value) / 100 * multiplier\n } else if (value.endsWith('deg')) {\n return normalizeDegree(value, 255)\n } else {\n // If the value is not a percentage or an angle in degrees, it is invalid\n throw new Error(`Invalid value: ${value}`)\n }\n}\n\n/**\n * 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.\n * 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.\n * If the color string does not match any of the formats, the function throws an error.\n *\n * @param {string} colorString - the color string to test and convert to rgb values\n *\n * @return {Object|Error} the object with rgb values of that color\n */\nexport function parseColor (colorString: string): RGBVALUE | Error {\n // Check if the color string matches any of the regular expressions\n if (hexRegex.test(colorString)) {\n const hex = parseHex(colorString as HEX)\n if (hex.length > 0) {\n return hexToRgb(hex)\n }\n } else if (rgbRegex.test(colorString)) {\n const rgb = parseRgb(colorString as RGB)\n if (rgb.length > 0) {\n return getRgbValues(rgb)\n }\n } else if (hslRegex.test(colorString)) {\n const hsl = parseHsl(colorString as HSL)\n if (hsl.length > 0) {\n return hslToRgb(hsl)\n }\n }\n\n // If the color string does not match any of the regular expressions, return an error\n throw new Error(`Invalid color: ${colorString}`)\n}\n","import colorSet from './data/colorSet'\nimport { BLACKANDWHITE, parseColor, rgbRegex, RGBSET } from './common'\nimport { valuesToHex } from './hex-utils'\nimport { getRgbValues, parseRgb } from './rgb-utils'\nimport { valuesToHsl } from './hsl-utils'\nimport { COLORDEF, COLORSTRING, HEX, RGBCOLORDEF, RGBDEF, RGBVALUE } from './types'\n\n/**\n * Given a color string it returns the closest corresponding name of the color.\n * Uses the Euclidean distance formula to calculate the distance between colors in the RGB color space.\n *\n * @param {string} color - the color string you want to find the closest color name\n * @param {Object} set - the color set that will be used to find the closest color\n * @param {Object} args - Optionally you can pass some additional arguments\n * @param args.info - Set a non nullish value to return some additional information (like the distance between the colors, or the hex color value) about the closest color.\n *\n * @return {Object} the closest color name and rgb value\n *\n * @example // Returns the closest color name and rgb value given a css color string\n * closest('#f00'); // { name: 'red', color: 'rgb(255,0,0)' }\n *\n * closest('#f00', undefined, {info:true}); // { name: 'red', color: 'rgb(255,0,0)', hex: '#ff0000', hsl: 'hsl(0, 100%, 50%)', distance: 0 ) }\n */\nfunction closest (\n color: COLORSTRING,\n set: RGBCOLORDEF[] | undefined = colorSet as RGBCOLORDEF[],\n ...args: any[ string | number ]\n): COLORDEF {\n let closestGap = Number.MAX_SAFE_INTEGER\n const closestColor: COLORDEF = { name: 'error', color: '#F00' }\n\n if (set.length < 1) {\n return closestColor\n }\n\n const rgbColorValues = Object.values(parseColor(color))\n if (rgbColorValues.length > 2) {\n for (const tested of set) {\n const gap = distance(rgbColorValues as RGBDEF, tested, true)\n if (gap < closestGap) {\n closestGap = gap\n closestColor.name = tested[3]\n closestColor.color = `rgb(${String(tested[0])},${String(tested[1])},${String(tested[2])})`\n }\n\n // TODO: add a minimum acceptable value in order to speed up the calculation. for example #ff0001 should return red since is very very close to red\n if (gap === 0) {\n break\n }\n }\n }\n\n if (args?.length > 0) {\n if (args?.info !== null) {\n const rgbValue = parseColor(closestColor.color)\n const hexValue = valuesToHex(rgbValue as RGBVALUE)\n const hslValue = valuesToHsl(rgbValue as RGBVALUE)\n return {\n ...closestColor,\n hex: hexValue,\n hsl: hslValue,\n gap: Math.sqrt(closestGap)\n }\n }\n }\n\n return closestColor\n}\n\n/**\n * Given a color returns if the color is light (by light is meant more mathematically closer to white)\n *\n * @param {string} color - The color to check\n *\n * @returns {boolean} true when the color is light, false otherwise\n *\n * @example isLight('#ddd'); // true\n */\nfunction isLight (color: COLORSTRING): boolean {\n return closest(color, BLACKANDWHITE).name === 'white'\n}\n\n/**\n * Given a color returns if the color is dark (by dark is meant more mathematically closer to black)\n *\n * @param {string} color - The color to check\n *\n * @returns {boolean} true when the color is dark, false otherwise\n *\n * @example isDark('#333'); // true\n */\nfunction isDark (color: COLORSTRING): boolean {\n return closest(color, BLACKANDWHITE).name === 'black'\n}\n\n/**\n * Given a color returns if the color is light or dark (by dark is meant more mathematically closer to black)\n *\n * @param {string} color - The color to check\n *\n * @returns {string} light when the color is close to white, dark otherwise\n *\n * @example isLightOrDark('#fff'); // 'light'\n */\nfunction isLightOrDark (color: COLORSTRING): string {\n return isLight(color) ? 'light' : 'dark'\n}\n\n/**\n * Given a color returns if the color is closer to \"red\", \"green\" or \"blue\".\n *\n * @param {string} color - The color to check\n *\n * @returns {string} light when the color is close to white, dark otherwise\n *\n * @example closestRGB('#f00'); // 'red'\n */\nfunction closestRGB (color: COLORSTRING): string {\n return closest(color, RGBSET).name\n}\n\n/**\n * Compute the distance between the two RGB values\n * There are two modes:\n * fast = true -> the distance is calculated without using the Euclidean formula completely, it is reliable but its result is exponential\n * fast = false -> the distance is calculated with the Euclidean formula, its result is linear\n *\n * @param rgb1 - The RGB value of the first color to compare\n * @param rgb2 - The RGB value of the second color to compare\n * @param fast - If you want to calculate the distance without calculating the square root, the result will be exponential otherwise is linear\n *\n * @return {number} the distance between the two RGB values\n *\n * @example distance([10, 20, 30], [120, 120, 120]); // 173.78147196982766\n */\nfunction distance (rgb1: RGBDEF, rgb2: RGBCOLORDEF | number[], fast: boolean = false): number {\n const r = Math.pow(rgb2[0] - rgb1[0], 2) +\n Math.pow(rgb2[1] - rgb1[1], 2) +\n Math.pow(rgb2[2] - rgb1[2], 2)\n return fast ? r : Math.sqrt(r)\n}\n\n/**\n * Given a color string it returns the hex representation\n *\n * @param rgbString - the rgb color string to convert to hex\n *\n * @return {string} the corresponding color hex\n *\n * @example rgbToHex(\"rgba(100% 0 0 / .5)\"); // #FF0000\n */\nfunction rgbToHex (rgbString: string): HEX | Error {\n // if is a rgb string\n if (rgbRegex.test(rgbString)) {\n const rgb = parseRgb(rgbString)\n if (rgb.length > 0) {\n const RgbValues = getRgbValues(rgb)\n return valuesToHex(RgbValues)\n }\n }\n throw new Error(`Invalid color: ${rgbString}`)\n}\n\nexport {\n colorSet,\n closest,\n rgbToHex,\n distance,\n isLight,\n isDark,\n isLightOrDark,\n closestRGB\n}\n"],"names":["root","factory","exports","module","define","amd","this","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","parseHex","hexColor","Array","from","substring","length","map","v","toUpperCase","shortHexToLongHex","hex","match","toHex","int8","toString","padStart","valuesToHex","rgb","r","g","b","parseRgb","rgbAsString","rgbvalue","rgbRegex","splitValues","Error","getRgbValues","convertToInt8","join","hslToRgb","hsl","h","normalizeDegree","s","parseInt","l","getHslValues","c","Math","abs","x","m","round","valuesToHsl","cmin","min","cmax","max","delta","toFixed","hexRegex","hslRegex","isNumeric","BLACKANDWHITE","RGBSET","rawValues","includes","split","val","trim","filter","Boolean","multiplier","angle","parseFloat","test","endsWith","parseColor","colorString","hexToRgb","hslAsString","hslvalue","parseHsl","closest","color","set","colorSet","closestGap","Number","MAX_SAFE_INTEGER","closestColor","name","rgbColorValues","values","tested","gap","distance","String","args","info","rgbValue","hexValue","hslValue","sqrt","isLight","isDark","isLightOrDark","closestRGB","rgb1","rgb2","fast","pow","rgbToHex","rgbString"],"sourceRoot":""}
\ No newline at end of file
+{"version":3,"file":"color-2-name.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,aAAc,GAAIH,GACC,iBAAZC,QACdA,QAAoB,WAAID,IAExBD,EAAiB,WAAIC,GACtB,CATD,CASGK,MAAM,I,mBCRT,IAAIC,EAAsB,CCA1BA,EAAwB,CAACL,EAASM,KACjC,IAAI,IAAIC,KAAOD,EACXD,EAAoBG,EAAEF,EAAYC,KAASF,EAAoBG,EAAER,EAASO,IAC5EE,OAAOC,eAAeV,EAASO,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDF,EAAwB,CAACQ,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFT,EAAyBL,IACH,oBAAXkB,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeV,EAASkB,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeV,EAAS,aAAc,CAAEoB,OAAO,GAAO,G,gJC40B9D,QAj1BiB,CACf,CACE,IACA,IACA,IACA,SAEF,CACE,EACA,EACA,EACA,SAEF,CACE,IACA,EACA,EACA,OAEF,CACE,EACA,IACA,EACA,SAEF,CACE,EACA,EACA,IACA,QAEF,CACE,IACA,IACA,EACA,UAEF,CACE,IACA,IACA,IACA,QAEF,CACE,IACA,IACA,EACA,UAEF,CACE,IACA,EACA,IACA,WAEF,CACE,IACA,IACA,GACA,eAEF,CACE,IACA,IACA,IACA,UAEF,CACE,EACA,IACA,EACA,QAEF,CACE,IACA,EACA,IACA,UAEF,CACE,IACA,GACA,GACA,UAEF,CACE,GACA,IACA,IACA,aAEF,CACE,IACA,IACA,GACA,SAEF,CACE,EACA,IACA,IACA,QAEF,CACE,IACA,IACA,IACA,eAEF,CACE,IACA,IACA,IACA,QAEF,CACE,GACA,IACA,GACA,eAEF,CACE,IACA,IACA,IACA,SAEF,CACE,IACA,EACA,IACA,WAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,IACA,EACA,QAEF,CACE,IACA,IACA,GACA,aAEF,CACE,IACA,IACA,GACA,eAEF,CACE,IACA,IACA,IACA,UAEF,CACE,IACA,IACA,IACA,SAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,EACA,EACA,WAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,GACA,GACA,aAEF,CACE,GACA,EACA,IACA,UAEF,CACE,IACA,IACA,IACA,gBAEF,CACE,EACA,IACA,IACA,QAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,IACA,IACA,SAEF,CACE,IACA,IACA,IACA,UAEF,CACE,IACA,IACA,IACA,kBAEF,CACE,IACA,GACA,IACA,cAEF,CACE,IACA,GACA,GACA,SAEF,CACE,IACA,IACA,IACA,aAEF,CACE,GACA,IACA,IACA,aAEF,CACE,IACA,IACA,EACA,cAEF,CACE,IACA,IACA,GACA,aAEF,CACE,IACA,IACA,IACA,kBAEF,CACE,IACA,IACA,IACA,YAEF,CACE,IACA,GACA,GACA,WAEF,CACE,EACA,EACA,IACA,YAEF,CACE,EACA,IACA,IACA,YAEF,CACE,IACA,IACA,GACA,iBAEF,CACE,IACA,IACA,IACA,YAEF,CACE,EACA,IACA,EACA,aAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,EACA,IACA,eAEF,CACE,GACA,IACA,GACA,kBAEF,CACE,IACA,IACA,EACA,cAEF,CACE,IACA,GACA,IACA,cAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,IACA,IACA,gBAEF,CACE,GACA,GACA,IACA,iBAEF,CACE,GACA,GACA,GACA,iBAEF,CACE,EACA,IACA,IACA,iBAEF,CACE,IACA,EACA,IACA,cAEF,CACE,IACA,GACA,IACA,YAEF,CACE,EACA,IACA,IACA,eAEF,CACE,IACA,IACA,IACA,WAEF,CACE,GACA,IACA,IACA,cAEF,CACE,IACA,GACA,GACA,aAEF,CACE,IACA,IACA,IACA,YAEF,CACE,IACA,IACA,IACA,WAEF,CACE,IACA,IACA,IACA,SAEF,CACE,IACA,IACA,IACA,SAEF,CACE,IACA,IACA,IACA,YAEF,CACE,IACA,IACA,IACA,iBAEF,CACE,IACA,IACA,EACA,aAEF,CACE,IACA,IACA,IACA,gBAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,wBAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,eAEF,CACE,GACA,IACA,IACA,iBAEF,CACE,IACA,IACA,IACA,gBAEF,CACE,IACA,IACA,IACA,kBAEF,CACE,IACA,IACA,IACA,kBAEF,CACE,IACA,IACA,IACA,eAEF,CACE,GACA,IACA,GACA,aAEF,CACE,IACA,IACA,IACA,SAEF,CACE,IACA,EACA,EACA,UAEF,CACE,IACA,IACA,IACA,oBAEF,CACE,EACA,EACA,IACA,cAEF,CACE,IACA,GACA,IACA,gBAEF,CACE,IACA,IACA,IACA,gBAEF,CACE,GACA,IACA,IACA,kBAEF,CACE,IACA,IACA,IACA,mBAEF,CACE,EACA,IACA,IACA,qBAEF,CACE,GACA,IACA,IACA,mBAEF,CACE,IACA,GACA,IACA,mBAEF,CACE,GACA,GACA,IACA,gBAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,YAEF,CACE,IACA,IACA,IACA,eAEF,CACE,EACA,EACA,IACA,QAEF,CACE,IACA,IACA,IACA,WAEF,CACE,IACA,IACA,EACA,SAEF,CACE,IACA,IACA,GACA,aAEF,CACE,IACA,GACA,EACA,aAEF,CACE,IACA,IACA,IACA,UAEF,CACE,IACA,IACA,IACA,iBAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,iBAEF,CACE,IACA,IACA,IACA,iBAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,GACA,QAEF,CACE,IACA,IACA,IACA,QAEF,CACE,IACA,IACA,IACA,cAEF,CACE,IACA,GACA,IACA,iBAEF,CACE,IACA,IACA,IACA,aAEF,CACE,GACA,IACA,IACA,aAEF,CACE,IACA,GACA,GACA,eAEF,CACE,IACA,IACA,IACA,UAEF,CACE,IACA,IACA,GACA,cAEF,CACE,GACA,IACA,GACA,YAEF,CACE,IACA,IACA,IACA,YAEF,CACE,IACA,GACA,GACA,UAEF,CACE,IACA,IACA,IACA,WAEF,CACE,IACA,GACA,IACA,aAEF,CACE,IACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,QAEF,CACE,EACA,IACA,IACA,eAEF,CACE,GACA,IACA,IACA,aAEF,CACE,IACA,IACA,IACA,OAEF,CACE,EACA,IACA,IACA,QAEF,CACE,IACA,IACA,IACA,YCzzBG,SAASC,EAAUD,GAExB,IAAME,EAA6C,MAAzBC,MAAMC,KAAKJ,GAAO,GAAcA,EAAMK,UAAU,GAAKL,EAM/E,GAAIE,EAASI,OAAS,EAAG,CACvB,GAAI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AK,GAAI,GACtC5D,KAAK+D,IAAIF,EAAK,GAAKD,EAAK,GAAI,GAC5B5D,KAAK+D,IAAIF,EAAK,GAAKD,EAAK,GAAI,GAC5B,OAAOE,EAAOnF,EAAIqB,KAAKuD,KAAK5E,EAC9B,CAWA,SAASqF,EAAUC,GAEjB,GAAIhF,EAAS0C,KAAKsC,GAAY,CAC5B,IAAMvF,EAAMI,EAASmF,GACrB,GAAIvF,EAAIZ,OAAS,EAEf,OAAOW,EADWW,EAAaV,GAGnC,CACA,MAAM,IAAIS,MAAM,kBAAD,OAAmB8E,GACpC,C","sources":["webpack://color2name/webpack/universalModuleDefinition","webpack://color2name/webpack/bootstrap","webpack://color2name/webpack/runtime/define property getters","webpack://color2name/webpack/runtime/hasOwnProperty shorthand","webpack://color2name/webpack/runtime/make namespace object","webpack://color2name/./src/data/colorSet.ts","webpack://color2name/./src/hex-utils.ts","webpack://color2name/./src/rgb-utils.ts","webpack://color2name/./src/hsl-utils.ts","webpack://color2name/./src/common.ts","webpack://color2name/./src/index.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"color2name\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"color2name\"] = factory();\n\telse\n\t\troot[\"color2name\"] = factory();\n})(this, () => {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const colorSet = [\n [\n 255,\n 255,\n 255,\n 'white'\n ],\n [\n 0,\n 0,\n 0,\n 'black'\n ],\n [\n 255,\n 0,\n 0,\n 'red'\n ],\n [\n 0,\n 128,\n 0,\n 'green'\n ],\n [\n 0,\n 0,\n 255,\n 'blue'\n ],\n [\n 255,\n 165,\n 0,\n 'orange'\n ],\n [\n 128,\n 128,\n 128,\n 'grey'\n ],\n [\n 255,\n 255,\n 0,\n 'yellow'\n ],\n [\n 255,\n 0,\n 255,\n 'magenta'\n ],\n [\n 154,\n 205,\n 50,\n 'yellowgreen'\n ],\n [\n 192,\n 192,\n 192,\n 'silver'\n ],\n [\n 0,\n 255,\n 0,\n 'lime'\n ],\n [\n 128,\n 0,\n 128,\n 'purple'\n ],\n [\n 255,\n 99,\n 71,\n 'tomato'\n ],\n [\n 64,\n 224,\n 208,\n 'turquoise'\n ],\n [\n 255,\n 127,\n 80,\n 'coral'\n ],\n [\n 0,\n 255,\n 255,\n 'cyan'\n ],\n [\n 255,\n 250,\n 240,\n 'floralwhite'\n ],\n [\n 255,\n 192,\n 203,\n 'pink'\n ],\n [\n 34,\n 139,\n 34,\n 'forestgreen'\n ],\n [\n 245,\n 245,\n 220,\n 'beige'\n ],\n [\n 255,\n 0,\n 255,\n 'fuchsia'\n ],\n [\n 220,\n 220,\n 220,\n 'gainsboro'\n ],\n [\n 248,\n 248,\n 255,\n 'ghostwhite'\n ],\n [\n 255,\n 215,\n 0,\n 'gold'\n ],\n [\n 218,\n 165,\n 32,\n 'goldenrod'\n ],\n [\n 173,\n 255,\n 47,\n 'greenyellow'\n ],\n [\n 238,\n 130,\n 238,\n 'violet'\n ],\n [\n 245,\n 222,\n 179,\n 'wheat'\n ],\n [\n 245,\n 245,\n 245,\n 'whitesmoke'\n ],\n [\n 139,\n 0,\n 0,\n 'darkred'\n ],\n [\n 240,\n 248,\n 255,\n 'aliceblue'\n ],\n [\n 205,\n 92,\n 92,\n 'indianred'\n ],\n [\n 75,\n 0,\n 130,\n 'indigo'\n ],\n [\n 250,\n 235,\n 215,\n 'antiquewhite'\n ],\n [\n 0,\n 255,\n 255,\n 'aqua'\n ],\n [\n 127,\n 255,\n 212,\n 'aquamarine'\n ],\n [\n 240,\n 255,\n 255,\n 'azure'\n ],\n [\n 255,\n 228,\n 196,\n 'bisque'\n ],\n [\n 255,\n 235,\n 205,\n 'blanchedalmond'\n ],\n [\n 138,\n 43,\n 226,\n 'blueviolet'\n ],\n [\n 165,\n 42,\n 42,\n 'brown'\n ],\n [\n 222,\n 184,\n 135,\n 'burlywood'\n ],\n [\n 95,\n 158,\n 160,\n 'cadetblue'\n ],\n [\n 127,\n 255,\n 0,\n 'chartreuse'\n ],\n [\n 210,\n 105,\n 30,\n 'chocolate'\n ],\n [\n 100,\n 149,\n 237,\n 'cornflowerblue'\n ],\n [\n 255,\n 248,\n 220,\n 'cornsilk'\n ],\n [\n 220,\n 20,\n 60,\n 'crimson'\n ],\n [\n 0,\n 0,\n 139,\n 'darkblue'\n ],\n [\n 0,\n 139,\n 139,\n 'darkcyan'\n ],\n [\n 184,\n 134,\n 11,\n 'darkgoldenrod'\n ],\n [\n 169,\n 169,\n 169,\n 'darkgrey'\n ],\n [\n 0,\n 100,\n 0,\n 'darkgreen'\n ],\n [\n 189,\n 183,\n 107,\n 'darkkhaki'\n ],\n [\n 139,\n 0,\n 139,\n 'darkmagenta'\n ],\n [\n 85,\n 107,\n 47,\n 'darkolivegreen'\n ],\n [\n 255,\n 140,\n 0,\n 'darkorange'\n ],\n [\n 153,\n 50,\n 204,\n 'darkorchid'\n ],\n [\n 233,\n 150,\n 122,\n 'darksalmon'\n ],\n [\n 143,\n 188,\n 143,\n 'darkseagreen'\n ],\n [\n 72,\n 61,\n 139,\n 'darkslateblue'\n ],\n [\n 47,\n 79,\n 79,\n 'darkslategrey'\n ],\n [\n 0,\n 206,\n 209,\n 'darkturquoise'\n ],\n [\n 148,\n 0,\n 211,\n 'darkviolet'\n ],\n [\n 255,\n 20,\n 147,\n 'deeppink'\n ],\n [\n 0,\n 191,\n 255,\n 'deepskyblue'\n ],\n [\n 105,\n 105,\n 105,\n 'dimgrey'\n ],\n [\n 30,\n 144,\n 255,\n 'dodgerblue'\n ],\n [\n 178,\n 34,\n 34,\n 'firebrick'\n ],\n [\n 240,\n 255,\n 240,\n 'honeydew'\n ],\n [\n 255,\n 105,\n 180,\n 'hotpink'\n ],\n [\n 255,\n 255,\n 240,\n 'ivory'\n ],\n [\n 240,\n 230,\n 140,\n 'khaki'\n ],\n [\n 230,\n 230,\n 250,\n 'lavender'\n ],\n [\n 255,\n 240,\n 245,\n 'lavenderblush'\n ],\n [\n 124,\n 252,\n 0,\n 'lawngreen'\n ],\n [\n 255,\n 250,\n 205,\n 'lemonchiffon'\n ],\n [\n 173,\n 216,\n 230,\n 'lightblue'\n ],\n [\n 240,\n 128,\n 128,\n 'lightcoral'\n ],\n [\n 224,\n 255,\n 255,\n 'lightcyan'\n ],\n [\n 250,\n 250,\n 210,\n 'lightgoldenrodyellow'\n ],\n [\n 144,\n 238,\n 144,\n 'lightgreen'\n ],\n [\n 211,\n 211,\n 211,\n 'lightgrey'\n ],\n [\n 255,\n 182,\n 193,\n 'lightpink'\n ],\n [\n 255,\n 160,\n 122,\n 'lightsalmon'\n ],\n [\n 32,\n 178,\n 170,\n 'lightseagreen'\n ],\n [\n 135,\n 206,\n 250,\n 'lightskyblue'\n ],\n [\n 119,\n 136,\n 153,\n 'lightslategrey'\n ],\n [\n 176,\n 196,\n 222,\n 'lightsteelblue'\n ],\n [\n 255,\n 255,\n 224,\n 'lightyellow'\n ],\n [\n 50,\n 205,\n 50,\n 'limegreen'\n ],\n [\n 250,\n 240,\n 230,\n 'linen'\n ],\n [\n 128,\n 0,\n 0,\n 'maroon'\n ],\n [\n 102,\n 205,\n 170,\n 'mediumaquamarine'\n ],\n [\n 0,\n 0,\n 205,\n 'mediumblue'\n ],\n [\n 186,\n 85,\n 211,\n 'mediumorchid'\n ],\n [\n 147,\n 112,\n 219,\n 'mediumpurple'\n ],\n [\n 60,\n 179,\n 113,\n 'mediumseagreen'\n ],\n [\n 123,\n 104,\n 238,\n 'mediumslateblue'\n ],\n [\n 0,\n 250,\n 154,\n 'mediumspringgreen'\n ],\n [\n 72,\n 209,\n 204,\n 'mediumturquoise'\n ],\n [\n 199,\n 21,\n 133,\n 'mediumvioletred'\n ],\n [\n 25,\n 25,\n 112,\n 'midnightblue'\n ],\n [\n 245,\n 255,\n 250,\n 'mintcream'\n ],\n [\n 255,\n 228,\n 225,\n 'mistyrose'\n ],\n [\n 255,\n 228,\n 181,\n 'moccasin'\n ],\n [\n 255,\n 222,\n 173,\n 'navajowhite'\n ],\n [\n 0,\n 0,\n 128,\n 'navy'\n ],\n [\n 253,\n 245,\n 230,\n 'oldlace'\n ],\n [\n 128,\n 128,\n 0,\n 'olive'\n ],\n [\n 107,\n 142,\n 35,\n 'olivedrab'\n ],\n [\n 255,\n 69,\n 0,\n 'orangered'\n ],\n [\n 218,\n 112,\n 214,\n 'orchid'\n ],\n [\n 238,\n 232,\n 170,\n 'palegoldenrod'\n ],\n [\n 152,\n 251,\n 152,\n 'palegreen'\n ],\n [\n 175,\n 238,\n 238,\n 'paleturquoise'\n ],\n [\n 219,\n 112,\n 147,\n 'palevioletred'\n ],\n [\n 255,\n 239,\n 213,\n 'papayawhip'\n ],\n [\n 255,\n 218,\n 185,\n 'peachpuff'\n ],\n [\n 205,\n 133,\n 63,\n 'peru'\n ],\n [\n 221,\n 160,\n 221,\n 'plum'\n ],\n [\n 176,\n 224,\n 230,\n 'powderblue'\n ],\n [\n 102,\n 51,\n 153,\n 'rebeccapurple'\n ],\n [\n 188,\n 143,\n 143,\n 'rosybrown'\n ],\n [\n 65,\n 105,\n 225,\n 'royalblue'\n ],\n [\n 139,\n 69,\n 19,\n 'saddlebrown'\n ],\n [\n 250,\n 128,\n 114,\n 'salmon'\n ],\n [\n 244,\n 164,\n 96,\n 'sandybrown'\n ],\n [\n 46,\n 139,\n 87,\n 'seagreen'\n ],\n [\n 255,\n 245,\n 238,\n 'seashell'\n ],\n [\n 160,\n 82,\n 45,\n 'sienna'\n ],\n [\n 135,\n 206,\n 235,\n 'skyblue'\n ],\n [\n 106,\n 90,\n 205,\n 'slateblue'\n ],\n [\n 112,\n 128,\n 144,\n 'slategrey'\n ],\n [\n 255,\n 250,\n 250,\n 'snow'\n ],\n [\n 0,\n 255,\n 127,\n 'springgreen'\n ],\n [\n 70,\n 130,\n 180,\n 'steelblue'\n ],\n [\n 210,\n 180,\n 140,\n 'tan'\n ],\n [\n 0,\n 128,\n 128,\n 'teal'\n ],\n [\n 216,\n 191,\n 216,\n 'thistle'\n ]\n]\n\nexport default colorSet\n","import { COLORSTRING, HEX, RGBVALUE } from './types'\n\n/**\n * It returns an object with the hex values of the 3 digit hex color\n *\n * @param {string} value 3 digit hex\n * @return {string[]} 6 digit hex\n */\nexport function shortHexToLongHex (value: string): string[] {\n // split the string in to an array of digits then return an array that contains that digit doubled for each item\n return Array.from(value).map((v: string) => (v + v).toUpperCase())\n}\n\n/**\n * Get the hex value of the color and convert it to an Object of R G And B values (still in hex format)\n *\n * @param value the string that contains the color in hex format\n *\n * @return {string[]} an array of 6 digit hex values in a triplet of R G and B (HEX format)\n */\nexport function parseHex (value: COLORSTRING): string[] {\n // remove # at the beginning of the hex color\n const hexColor: string = (Array.from(value)[0] === '#') ? value.substring(1) : value\n\n /**\n * then if the number of digits is greater than 2 (so it's something like 123 or abc456)\n * breakdown the string into an object that contains the r g and b values in hex\n */\n if (hexColor.length > 2) {\n if (hexColor.length < 6) { // >=6 is the long notation\n return shortHexToLongHex(hexColor)\n } else {\n const hex = hexColor.match(/../g)\n return (hex != null) ? [hex[0].toUpperCase(), hex[1].toUpperCase(), hex[2].toUpperCase()] : []\n }\n }\n\n return []\n}\n\n/**\n * Converts a Hex color to rgb\n *\n * @param {string} hex without the \"#\"\n *\n * @return {string} the rgb color values for the given hex color\n */\nexport function hexToRgb (hex: string[]): RGBVALUE | Error {\n // Extract the RGB values from the hex string\n if (hex.length >= 2) {\n return {\n r: parseInt(hex[0], 16),\n g: parseInt(hex[1], 16),\n b: parseInt(hex[2], 16)\n }\n }\n throw new Error(`Invalid Hex color: ${hex.join(', ')}`)\n}\n\n/**\n * Convert a INT8 value to HEX\n *\n * @param {number} int8 - the integer value to convert\n *\n * @return {string} the hex string\n */\nexport function toHex (int8: number): string {\n return int8.toString(16).padStart(2, '0')\n}\n\n/**\n* Convert rgb values to hex color\n*\n* @param {Object} rgb an object with the rgb values\n *\n * @return {string} the hex string\n*/\nexport function valuesToHex (rgb: RGBVALUE): HEX {\n // Extract the RGB values from the hex string\n if (\n typeof rgb?.r === 'number' &&\n typeof rgb?.g === 'number' &&\n typeof rgb?.b === 'number') {\n return `#${toHex(rgb?.r)}${toHex(rgb?.g)}${toHex(rgb?.b)}`\n }\n return '#errorr'\n}\n","import { convertToInt8, rgbRegex, splitValues } from './common'\nimport { RGBVALUE } from './types'\n\n/**\n * Get the values of the rgb string\n *\n * @param rgbAsString - the rgb color as string split into values\n *\n * @return {Array} the values of the rgb string as Array of strings that represent the rgb color\n */\nexport function parseRgb (rgbAsString: string): string[] {\n const rgbvalue = rgbAsString.match(rgbRegex)\n if (rgbvalue != null) {\n const rgb: string[] = splitValues(rgbvalue[1])\n\n if (rgb.length >= 2) {\n return [\n rgb[0],\n rgb[1],\n rgb[2]\n ]\n }\n }\n throw new Error(`Can't parse rgb color: ${rgbAsString}`)\n}\n\n/**\n * This function takes an array of strings and returns and object with the rgb values converted into INT8 (0-255)\n *\n * @param {Array} rgb - rgb color as Array of strings\n *\n * @return {Object} an object that contains the r, g and b values as INT8\n */\nexport function getRgbValues (rgb: string[]): RGBVALUE {\n if (rgb.length >= 2) {\n return {\n r: convertToInt8(rgb[0]),\n g: convertToInt8(rgb[1]),\n b: convertToInt8(rgb[2])\n }\n }\n throw new Error(`Invalid rgb color: ${rgb.join(', ')}`)\n}\n\n/**\n * returns a string representation of the rgb values\n *\n * @param {Object} rgb the rgb color object\n *\n * @return {string} a string representation of the rgb values\n */\nexport function valuesToRgb (rgb: RGBVALUE): string {\n return `rgb(${rgb.r},${rgb.g},${rgb.b})`\n}\n","import { hslRegex, normalizeDegree, splitValues } from './common'\nimport { HSLVALUE, RGBVALUE } from './types'\n\n/**\n * Get the values of the hsl string\n *\n * @param {string} hslAsString - the valid hsl color string\n * @return {string[]} the values of the hsl string\n */\nexport function parseHsl (hslAsString: string): string[] {\n const hslvalue = hslAsString.match(hslRegex)\n if (hslvalue != null) {\n const hsl: string[] = splitValues(hslvalue[1])\n\n if (hsl.length >= 2) {\n return [\n hsl[0],\n hsl[1],\n hsl[2]\n ]\n }\n }\n throw new Error(`Can't parse hsl color: ${hslAsString}`)\n}\n\n/**\n * This function takes an array of strings and returns and object with the hsl values converted into INT8 (0-255)\n *\n * @param {string[]} hsl - the hsl values to parse from string to int8 values\n *\n */\nexport function getHslValues (hsl: string[]): HSLVALUE {\n if (hsl.length >= 2) {\n return {\n h: normalizeDegree(hsl[0]),\n s: parseInt(hsl[1], 10),\n l: parseInt(hsl[2], 10)\n }\n }\n throw new Error(`Invalid hsl color: ${hsl.join(', ')}`)\n}\n\n/**\n * Given the HSL color it convert the color into RGB\n *\n * @param {string[]} hsl the HSL value to parse\n * @return {Object} rgb value\n */\nexport function hslToRgb (hsl: string[]): RGBVALUE {\n if (hsl === null || hsl.length < 2) {\n throw new Error(`Invalid hsl color: ${hsl.join(', ')}`)\n }\n\n let {\n h,\n s,\n l\n } = getHslValues(hsl)\n\n // Must be fractions of 1\n s /= 100\n l /= 100\n\n const c = (1 - Math.abs(2 * l - 1)) * s\n const x = c * (1 - Math.abs((h / 60) % 2 - 1))\n const m = l - c / 2\n let r = 0\n let g = 0\n let b = 0\n\n if (h >= 0 && h < 60) {\n r = c; g = x; b = 0\n } else if (h >= 60 && h < 120) {\n r = x; g = c; b = 0\n } else if (h >= 120 && h < 180) {\n r = 0; g = c; b = x\n } else if (h >= 180 && h < 240) {\n r = 0; g = x; b = c\n } else if (h >= 240 && h < 300) {\n r = x; g = 0; b = c\n } else if (h >= 300 && h < 360) {\n r = c; g = 0; b = x\n }\n r = Math.round((r + m) * 255)\n g = Math.round((g + m) * 255)\n b = Math.round((b + m) * 255)\n\n return { r, g, b }\n}\n\n/**\n * Given the RGB color it convert the color into HSL\n *\n * @param {number} r - red\n * @param {number} g - green\n * @param {number} b - blue\n *\n * @return {Object} hsl value\n */\nexport function valuesToHsl ({ r, g, b }: RGBVALUE): string {\n // Make r, g, and b fractions of 1\n r /= 255\n g /= 255\n b /= 255\n\n // Find greatest and smallest channel values\n const cmin = Math.min(r, g, b)\n const cmax = Math.max(r, g, b)\n const delta = cmax - cmin\n let h = 0\n let s = 0\n let l = 0\n\n // Calculate hue\n if (delta === 0) { // No difference\n h = 0\n } else if (cmax === r) { // Red is max\n h = ((g - b) / delta) % 6\n } else if (cmax === g) { // Green is max\n h = (b - r) / delta + 2\n } else { h = (r - g) / delta + 4 } // Blue is max\n\n h = Math.round(h * 60)\n\n // Make negative hues positive behind 360°\n if (h < 0) { h += 360 }\n\n // Calculate lightness\n l = (cmax + cmin) / 2\n\n // Calculate saturation\n s = delta === 0 ? 0 : delta / (1 - Math.abs(2 * l - 1))\n\n // Multiply l and s by 100\n s = +(s * 100).toFixed(1)\n l = +(l * 100).toFixed(1)\n\n return `hsl(${h},${s}%,${l}%)`\n}\n","// Regular expressions to match different color formats\nimport { COLORSTRING, HEX, HSL, RGB, RGBCOLORDEF, RGBVALUE } from './types'\nimport { hexToRgb, parseHex } from './hex-utils'\nimport { getRgbValues, parseRgb } from './rgb-utils'\nimport { hslToRgb, parseHsl } from './hsl-utils'\n\n/** The maximum distance possible between colors */\nexport const MAXDISTANCE = 441.6729559300637\n\n/** A regex to match hex colors */\nexport const hexRegex: RegExp = /^#([\\da-f]{6,}|[\\da-f]{3,})/i\n/** A regex to match rgb colors */\nexport const rgbRegex: RegExp = /^rgba?\\(([^)]+)\\)/i\n/** A regex to match hsl colors */\nexport const hslRegex: RegExp = /^hsla?\\(([^)]+)\\)/i\n/** A regex to match strings that are only int numbers */\nexport const isNumeric: RegExp = /^[0-9]*$/\n\n/**\n * This set is used in order to detect if the color is bright or dark\n *\n * @note the set has been corrected to get pure RGB values (eg. pure red, pure green) in the \"bright\" area\n */\nexport const BLACKANDWHITE: RGBCOLORDEF[] = [\n [255, 255, 255, 'white'],\n [1, 1, 1, 'black']\n]\n\n/**\n * This set is used in order to detect the nearest rgb color\n */\nexport const RGBSET: RGBCOLORDEF[] = [\n [255, 0, 0, 'red'],\n [0, 255, 0, 'green'],\n [0, 0, 255, 'blue']\n]\n\n/**\n * split the content of rgb and hsl colors depending on the parsed value of the css property\n *\n * https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb#syntax\n *\n * @param {string} rawValues - the value inside the rgb(.*) css color definition\n *\n * @return {Array} the array of rgb values finded inside the passed string\n */\nexport function splitValues (rawValues: string): string[] {\n if (rawValues.includes(',')) {\n return rawValues.split(/[,\\\\/]/).map(val => val.trim())\n }\n\n return rawValues.split(/[ \\\\/]/).map(val => val.trim()).filter(Boolean)\n}\n\n/**\n * If the value is an angle in degrees, convert it to the 0-360 range\n *\n * @param {string} value - the degrees to convert into a number\n * @param {number} multiplier - the number that represent the maximum - default is 100\n *\n * @return {number} the converted value\n */\nexport function normalizeDegree (value: string, multiplier: number = 360): number {\n let angle = parseFloat(value)\n while (angle < 0) {\n angle += 360\n }\n while (angle > 360) {\n angle -= 360\n }\n return (angle / 360) * multiplier\n}\n\n/**\n * 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\n *\n * @param {string} value - a valid value for the css color definition (like 255, \"100%\", \"324deg\", etc)\n * @param {string} value - a valid value for the css color definition (like 255, \"100%\", \"324deg\", etc)\n *\n * @example convertToInt8('100%'); // 255\n *\n * @return {string} the corresponding value in 8 bit format\n */\nexport function convertToInt8 (value: string, multiplier: number = 255): number {\n value = value.trim()\n if (isNumeric.test(value)) {\n // If the value is an int number return it as number\n return parseInt(value, 10)\n } else if (value.endsWith('%')) {\n // If the value is a percentage, divide it by 100 to get a value from 0 to 1\n // and then multiply it by 255 to get a value from 0 to 255\n return parseFloat(value) / 100 * multiplier\n } else if (value.endsWith('deg')) {\n return normalizeDegree(value, 255)\n } else {\n // If the value is not a percentage or an angle in degrees, it is invalid\n throw new Error(`Invalid value: ${value}`)\n }\n}\n\n/**\n * 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.\n * 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.\n * If the color string does not match any of the formats, the function throws an error.\n *\n * @param {string} colorString - the color string to test and convert to rgb values\n *\n * @return {Object|Error} the object with rgb values of that color\n */\nexport function parseColor (colorString: string): RGBVALUE | Error {\n // Check if the color string matches any of the regular expressions\n if (hexRegex.test(colorString)) {\n const hex = parseHex(colorString as HEX)\n if (hex.length > 0) {\n return hexToRgb(hex)\n }\n } else if (rgbRegex.test(colorString)) {\n const rgb = parseRgb(colorString as RGB)\n if (rgb.length > 0) {\n return getRgbValues(rgb)\n }\n } else if (hslRegex.test(colorString)) {\n const hsl = parseHsl(colorString as HSL)\n if (hsl.length > 0) {\n return hslToRgb(hsl)\n }\n }\n\n // If the color string does not match any of the regular expressions, return an error\n throw new Error(`Invalid color: ${colorString}`)\n}\n","import colorSet from './data/colorSet'\nimport { BLACKANDWHITE, parseColor, rgbRegex, RGBSET } from './common'\nimport { valuesToHex } from './hex-utils'\nimport { getRgbValues, parseRgb } from './rgb-utils'\nimport { valuesToHsl } from './hsl-utils'\nimport { COLORDEF, HEX, RGBCOLORDEF, RGBDEF, RGBVALUE } from './types'\n\n/**\n * Given a color string it returns the closest corresponding name of the color.\n * Uses the Euclidean distance formula to calculate the distance between colors in the RGB color space.\n *\n * @param {string} color - the color string you want to find the closest color name\n * @param {Object} set - the color set that will be used to find the closest color\n * @param {Object} args - Optionally you can pass some additional arguments\n * @param args.info - Set a non nullish value to return some additional information (like the distance between the colors, or the hex color value) about the closest color.\n *\n * @return {Object} the closest color name and rgb value\n *\n * @example // Returns the closest color name and rgb value given a css color string\n * closest('#f00'); // { name: 'red', color: 'rgb(255,0,0)' }\n *\n * closest('#f00', undefined, {info:true}); // { name: 'red', color: 'rgb(255,0,0)', hex: '#ff0000', hsl: 'hsl(0, 100%, 50%)', distance: 0 ) }\n */\nfunction closest (\n color: string,\n set: Array<[number, number, number, string]> | undefined = colorSet as RGBCOLORDEF[],\n ...args: any[ string | number ]\n): COLORDEF {\n let closestGap = Number.MAX_SAFE_INTEGER\n const closestColor: COLORDEF = { name: 'error', color: '#F00' }\n\n if (set.length < 1) {\n return closestColor\n }\n\n const rgbColorValues = Object.values(parseColor(color))\n if (rgbColorValues.length > 2) {\n for (const tested of set) {\n const gap = distance(rgbColorValues as RGBDEF, tested, true)\n if (gap < closestGap) {\n closestGap = gap\n closestColor.name = tested[3]\n closestColor.color = `rgb(${String(tested[0])},${String(tested[1])},${String(tested[2])})`\n }\n\n // TODO: add a minimum acceptable value in order to speed up the calculation. for example #ff0001 should return red since is very very close to red\n if (gap === 0) {\n break\n }\n }\n }\n\n if (args?.length > 0) {\n if (args?.info !== null) {\n const rgbValue = parseColor(closestColor.color)\n const hexValue = valuesToHex(rgbValue as RGBVALUE)\n const hslValue = valuesToHsl(rgbValue as RGBVALUE)\n return {\n ...closestColor,\n hex: hexValue,\n hsl: hslValue,\n gap: Math.sqrt(closestGap)\n }\n }\n }\n\n return closestColor\n}\n\n/**\n * Given a color returns if the color is light (by light is meant more mathematically closer to white)\n *\n * @param {string} color - The color to check\n *\n * @returns {boolean} true when the color is light, false otherwise\n *\n * @example isLight('#ddd'); // true\n */\nfunction isLight (color: string): boolean {\n return closest(color, BLACKANDWHITE).name === 'white'\n}\n\n/**\n * Given a color returns if the color is dark (by dark is meant more mathematically closer to black)\n *\n * @param {string} color - The color to check\n *\n * @returns {boolean} true when the color is dark, false otherwise\n *\n * @example isDark('#333'); // true\n */\nfunction isDark (color: string): boolean {\n return closest(color, BLACKANDWHITE).name === 'black'\n}\n\n/**\n * Given a color returns if the color is light or dark (by dark is meant more mathematically closer to black)\n *\n * @param {string} color - The color to check\n *\n * @returns {string} light when the color is close to white, dark otherwise\n *\n * @example isLightOrDark('#fff'); // 'light'\n */\nfunction isLightOrDark (color: string): string {\n return isLight(color) ? 'light' : 'dark'\n}\n\n/**\n * Given a color returns if the color is closer to \"red\", \"green\" or \"blue\".\n *\n * @param {string} color - The color to check\n *\n * @returns {string} light when the color is close to white, dark otherwise\n *\n * @example closestRGB('#f00'); // 'red'\n */\nfunction closestRGB (color: string): string {\n return closest(color, RGBSET).name\n}\n\n/**\n * Compute the distance between the two RGB values\n * There are two modes:\n * fast = true -> the distance is calculated without using the Euclidean formula completely, it is reliable but its result is exponential\n * fast = false -> the distance is calculated with the Euclidean formula, its result is linear\n *\n * @param rgb1 - The RGB value of the first color to compare\n * @param rgb2 - The RGB value of the second color to compare\n * @param fast - If you want to calculate the distance without calculating the square root, the result will be exponential otherwise is linear\n *\n * @return {number} the distance between the two RGB values\n *\n * @example distance([10, 20, 30], [120, 120, 120]); // 173.78147196982766\n */\nfunction distance (rgb1: [number, number, number], rgb2: [number, number, number, string] | number[], fast: boolean = false): number {\n const r = Math.pow(rgb2[0] - rgb1[0], 2) +\n Math.pow(rgb2[1] - rgb1[1], 2) +\n Math.pow(rgb2[2] - rgb1[2], 2)\n return fast ? r : Math.sqrt(r)\n}\n\n/**\n * Given a color string it returns the hex representation\n *\n * @param rgbString - the rgb color string to convert to hex\n *\n * @return {string} the corresponding color hex\n *\n * @example rgbToHex(\"rgba(100% 0 0 / .5)\"); // #FF0000\n */\nfunction rgbToHex (rgbString: string): HEX | Error {\n // if is a rgb string\n if (rgbRegex.test(rgbString)) {\n const rgb = parseRgb(rgbString)\n if (rgb.length > 0) {\n const RgbValues = getRgbValues(rgb)\n return valuesToHex(RgbValues)\n }\n }\n throw new Error(`Invalid color: ${rgbString}`)\n}\n\nexport {\n colorSet,\n closest,\n rgbToHex,\n distance,\n isLight,\n isDark,\n isLightOrDark,\n closestRGB\n}\n"],"names":["root","factory","exports","module","define","amd","this","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","parseHex","hexColor","Array","from","substring","length","map","v","toUpperCase","shortHexToLongHex","hex","match","toHex","int8","toString","padStart","valuesToHex","rgb","r","g","b","parseRgb","rgbAsString","rgbvalue","rgbRegex","splitValues","Error","getRgbValues","convertToInt8","join","hslToRgb","hsl","h","normalizeDegree","s","parseInt","l","getHslValues","c","Math","abs","x","m","round","valuesToHsl","cmin","min","cmax","max","delta","toFixed","hexRegex","hslRegex","isNumeric","BLACKANDWHITE","RGBSET","rawValues","includes","split","val","trim","filter","Boolean","multiplier","angle","parseFloat","test","endsWith","parseColor","colorString","hexToRgb","hslAsString","hslvalue","parseHsl","closest","color","set","colorSet","closestGap","Number","MAX_SAFE_INTEGER","closestColor","name","rgbColorValues","values","tested","gap","distance","String","args","info","rgbValue","hexValue","hslValue","sqrt","isLight","isDark","isLightOrDark","closestRGB","rgb1","rgb2","fast","pow","rgbToHex","rgbString"],"sourceRoot":""}
\ No newline at end of file
diff --git a/dist/types/index.d.ts b/dist/types/index.d.ts
index fb90191..0467a2a 100644
--- a/dist/types/index.d.ts
+++ b/dist/types/index.d.ts
@@ -1,5 +1,5 @@
import colorSet from './data/colorSet';
-import { COLORDEF, COLORSTRING, HEX, RGBCOLORDEF, RGBDEF } from './types';
+import { COLORDEF, HEX } from './types';
/**
* Given a color string it returns the closest corresponding name of the color.
* Uses the Euclidean distance formula to calculate the distance between colors in the RGB color space.
@@ -16,7 +16,7 @@ import { COLORDEF, COLORSTRING, HEX, RGBCOLORDEF, RGBDEF } from './types';
*
* closest('#f00', undefined, {info:true}); // { name: 'red', color: 'rgb(255,0,0)', hex: '#ff0000', hsl: 'hsl(0, 100%, 50%)', distance: 0 ) }
*/
-declare function closest(color: COLORSTRING, set?: RGBCOLORDEF[] | undefined, ...args: any[string | number]): COLORDEF;
+declare function closest(color: string, set?: Array<[number, number, number, string]> | undefined, ...args: any[string | number]): COLORDEF;
/**
* Given a color returns if the color is light (by light is meant more mathematically closer to white)
*
@@ -26,7 +26,7 @@ declare function closest(color: COLORSTRING, set?: RGBCOLORDEF[] | undefined, ..
*
* @example isLight('#ddd'); // true
*/
-declare function isLight(color: COLORSTRING): boolean;
+declare function isLight(color: string): boolean;
/**
* Given a color returns if the color is dark (by dark is meant more mathematically closer to black)
*
@@ -36,7 +36,7 @@ declare function isLight(color: COLORSTRING): boolean;
*
* @example isDark('#333'); // true
*/
-declare function isDark(color: COLORSTRING): boolean;
+declare function isDark(color: string): boolean;
/**
* Given a color returns if the color is light or dark (by dark is meant more mathematically closer to black)
*
@@ -46,7 +46,7 @@ declare function isDark(color: COLORSTRING): boolean;
*
* @example isLightOrDark('#fff'); // 'light'
*/
-declare function isLightOrDark(color: COLORSTRING): string;
+declare function isLightOrDark(color: string): string;
/**
* Given a color returns if the color is closer to "red", "green" or "blue".
*
@@ -56,7 +56,7 @@ declare function isLightOrDark(color: COLORSTRING): string;
*
* @example closestRGB('#f00'); // 'red'
*/
-declare function closestRGB(color: COLORSTRING): string;
+declare function closestRGB(color: string): string;
/**
* Compute the distance between the two RGB values
* There are two modes:
@@ -71,7 +71,7 @@ declare function closestRGB(color: COLORSTRING): string;
*
* @example distance([10, 20, 30], [120, 120, 120]); // 173.78147196982766
*/
-declare function distance(rgb1: RGBDEF, rgb2: RGBCOLORDEF | number[], fast?: boolean): number;
+declare function distance(rgb1: [number, number, number], rgb2: [number, number, number, string] | number[], fast?: boolean): number;
/**
* Given a color string it returns the hex representation
*
diff --git a/dist/types/index.d.ts.map b/dist/types/index.d.ts.map
index c98bda4..2c6f366 100644
--- a/dist/types/index.d.ts.map
+++ b/dist/types/index.d.ts.map
@@ -1 +1 @@
-{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,iBAAiB,CAAA;AAKtC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAY,MAAM,SAAS,CAAA;AAEnF;;;;;;;;;;;;;;;GAeG;AACH,iBAAS,OAAO,CACd,KAAK,EAAE,WAAW,EAClB,GAAG,GAAE,WAAW,EAAE,GAAG,SAAqC,EAC1D,GAAG,IAAI,EAAE,GAAG,CAAE,MAAM,GAAG,MAAM,CAAE,GAC9B,QAAQ,CAwCV;AAED;;;;;;;;GAQG;AACH,iBAAS,OAAO,CAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAE7C;AAED;;;;;;;;GAQG;AACH,iBAAS,MAAM,CAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAE5C;AAED;;;;;;;;GAQG;AACH,iBAAS,aAAa,CAAE,KAAK,EAAE,WAAW,GAAG,MAAM,CAElD;AAED;;;;;;;;GAQG;AACH,iBAAS,UAAU,CAAE,KAAK,EAAE,WAAW,GAAG,MAAM,CAE/C;AAED;;;;;;;;;;;;;GAaG;AACH,iBAAS,QAAQ,CAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,MAAM,EAAE,EAAE,IAAI,GAAE,OAAe,GAAG,MAAM,CAK5F;AAED;;;;;;;;GAQG;AACH,iBAAS,QAAQ,CAAE,SAAS,EAAE,MAAM,GAAG,GAAG,GAAG,KAAK,CAUjD;AAED,OAAO,EACL,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,MAAM,EACN,aAAa,EACb,UAAU,EACX,CAAA"}
\ No newline at end of file
+{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,iBAAiB,CAAA;AAKtC,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAiC,MAAM,SAAS,CAAA;AAEtE;;;;;;;;;;;;;;;GAeG;AACH,iBAAS,OAAO,CACd,KAAK,EAAE,MAAM,EACb,GAAG,GAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,SAAqC,EACpF,GAAG,IAAI,EAAE,GAAG,CAAE,MAAM,GAAG,MAAM,CAAE,GAC9B,QAAQ,CAwCV;AAED;;;;;;;;GAQG;AACH,iBAAS,OAAO,CAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAExC;AAED;;;;;;;;GAQG;AACH,iBAAS,MAAM,CAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAEvC;AAED;;;;;;;;GAQG;AACH,iBAAS,aAAa,CAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;;;;;;;GAQG;AACH,iBAAS,UAAU,CAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAE1C;AAED;;;;;;;;;;;;;GAaG;AACH,iBAAS,QAAQ,CAAE,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,EAAE,EAAE,IAAI,GAAE,OAAe,GAAG,MAAM,CAKnI;AAED;;;;;;;;GAQG;AACH,iBAAS,QAAQ,CAAE,SAAS,EAAE,MAAM,GAAG,GAAG,GAAG,KAAK,CAUjD;AAED,OAAO,EACL,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,MAAM,EACN,aAAa,EACb,UAAU,EACX,CAAA"}
\ No newline at end of file
diff --git a/docs/color-utils.ts.html b/docs/color-utils.ts.html
index d72b221..5193542 100644
--- a/docs/color-utils.ts.html
+++ b/docs/color-utils.ts.html
@@ -67,6 +67,20 @@
color-2-name.js!
Example
+
+ GitHub Project
+
+
+
+ Playground
+
+
diff --git a/docs/common.ts.html b/docs/common.ts.html
index 13ad3e0..e7e3448 100644
--- a/docs/common.ts.html
+++ b/docs/common.ts.html
@@ -67,6 +67,20 @@ color-2-name.js!
Example
+
+ GitHub Project
+
+
+
+ Playground
+
+
diff --git a/docs/global.html b/docs/global.html
index f7a8906..f380157 100644
--- a/docs/global.html
+++ b/docs/global.html
@@ -65,6 +65,20 @@ color-2-name.js!
Example
+
+ GitHub Project
+
+
+
+ Playground
+
+
diff --git a/docs/hex-utils.ts.html b/docs/hex-utils.ts.html
index cd2779f..5345455 100644
--- a/docs/hex-utils.ts.html
+++ b/docs/hex-utils.ts.html
@@ -67,6 +67,20 @@ color-2-name.js!
Example
+
+ GitHub Project
+
+
+
+ Playground
+
+
diff --git a/docs/hsl-utils.ts.html b/docs/hsl-utils.ts.html
index 74aeb12..9559408 100644
--- a/docs/hsl-utils.ts.html
+++ b/docs/hsl-utils.ts.html
@@ -67,6 +67,20 @@ color-2-name.js!
Example
+
+ GitHub Project
+
+
+
+ Playground
+
+
@@ -98,7 +112,7 @@ hsl-utils.ts
- import {hslRegex, normalizeDegree, RGBSET, splitValues} from './common'
+ import { hslRegex, normalizeDegree, splitValues } from './common'
import { HSLVALUE, RGBVALUE } from './types'
/**
diff --git a/docs/index.html b/docs/index.html
index 387a01e..259e49f 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -65,6 +65,20 @@ color-2-name.js!
Example
+
+ GitHub Project
+
+
+
+ Playground
+
+
@@ -161,13 +175,11 @@ As a Node module
As script (browser)
To load color-2-name add the script tag like below in your head/footer:
-<script src="color-2-name.js"></script>
+<script src="https://cdn.jsdelivr.net/npm/color-2-name/dist/color-2-name.js"></script>
<script>
// Then the color-2-name module will be available using the following command:
// You will find the packed script loaded into window.color2name
- color2name.closest('#123456') // color name
- color2name.rgbToHex('rgb(18 52 86)') // #123456
- color2name.distance([0, 0, 0], [255, 255, 255]) // 431.12
+ color2name.closest('#123456') // returns -> {name: "midnightblue" , color: "rgb(25,25,112)" }
</script>
diff --git a/docs/index.ts.html b/docs/index.ts.html
index 2fef9e4..600a9dc 100644
--- a/docs/index.ts.html
+++ b/docs/index.ts.html
@@ -67,6 +67,20 @@ color-2-name.js!
Example
+
+ GitHub Project
+
+
+
+ Playground
+
+
@@ -103,7 +117,7 @@ index.ts
import { valuesToHex } from './hex-utils'
import { getRgbValues, parseRgb } from './rgb-utils'
import { valuesToHsl } from './hsl-utils'
-import { COLORDEF, COLORSTRING, HEX, RGBCOLORDEF, RGBDEF, RGBVALUE } from './types'
+import { COLORDEF, HEX, RGBCOLORDEF, RGBDEF, RGBVALUE } from './types'
/**
* Given a color string it returns the closest corresponding name of the color.
@@ -122,8 +136,8 @@ index.ts
* closest('#f00', undefined, {info:true}); // { name: 'red', color: 'rgb(255,0,0)', hex: '#ff0000', hsl: 'hsl(0, 100%, 50%)', distance: 0 ) }
*/
function closest (
- color: COLORSTRING,
- set: RGBCOLORDEF[] | undefined = colorSet as RGBCOLORDEF[],
+ color: string,
+ set: Array<[number, number, number, string]> | undefined = colorSet as RGBCOLORDEF[],
...args: any[ string | number ]
): COLORDEF {
let closestGap = Number.MAX_SAFE_INTEGER
@@ -176,7 +190,7 @@ index.ts
*
* @example isLight('#ddd'); // true
*/
-function isLight (color: COLORSTRING): boolean {
+function isLight (color: string): boolean {
return closest(color, BLACKANDWHITE).name === 'white'
}
@@ -189,7 +203,7 @@ index.ts
*
* @example isDark('#333'); // true
*/
-function isDark (color: COLORSTRING): boolean {
+function isDark (color: string): boolean {
return closest(color, BLACKANDWHITE).name === 'black'
}
@@ -202,7 +216,7 @@ index.ts
*
* @example isLightOrDark('#fff'); // 'light'
*/
-function isLightOrDark (color: COLORSTRING): string {
+function isLightOrDark (color: string): string {
return isLight(color) ? 'light' : 'dark'
}
@@ -215,7 +229,7 @@ index.ts
*
* @example closestRGB('#f00'); // 'red'
*/
-function closestRGB (color: COLORSTRING): string {
+function closestRGB (color: string): string {
return closest(color, RGBSET).name
}
@@ -233,7 +247,7 @@ index.ts
*
* @example distance([10, 20, 30], [120, 120, 120]); // 173.78147196982766
*/
-function distance (rgb1: RGBDEF, rgb2: RGBCOLORDEF | number[], fast: boolean = false): number {
+function distance (rgb1: [number, number, number], rgb2: [number, number, number, string] | number[], fast: boolean = false): number {
const r = Math.pow(rgb2[0] - rgb1[0], 2) +
Math.pow(rgb2[1] - rgb1[1], 2) +
Math.pow(rgb2[2] - rgb1[2], 2)
diff --git a/docs/rgb-utils.ts.html b/docs/rgb-utils.ts.html
index 624dcda..8fddf4c 100644
--- a/docs/rgb-utils.ts.html
+++ b/docs/rgb-utils.ts.html
@@ -67,6 +67,20 @@ color-2-name.js!
Example
+
+ GitHub Project
+
+
+
+ Playground
+
+
diff --git a/jsdoc.json b/jsdoc.json
index 737200e..aa410f2 100644
--- a/jsdoc.json
+++ b/jsdoc.json
@@ -34,6 +34,14 @@
{
"label": "Example",
"href": "example.html"
+ },
+ {
+ "label": "GitHub Project",
+ "href": "https://github.com/erikyo/color-2-name"
+ },
+ {
+ "label": "Playground",
+ "href": "https://codesandbox.io/s/color-2-name-js-playground-b5f9gj"
}
]
}
diff --git a/package-lock.json b/package-lock.json
index e5e5234..0c9ceb4 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,29 +1,29 @@
{
"name": "color-2-name",
- "version": "1.0.3",
+ "version": "1.1.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "color-2-name",
- "version": "1.0.3",
+ "version": "1.1.1",
"license": "ISC",
"devDependencies": {
- "@babel/core": "^7.20.7",
+ "@babel/core": "^7.20.12",
"@babel/preset-env": "^7.20.2",
"@babel/preset-typescript": "^7.18.6",
"@jest/globals": "^29.3.1",
- "@types/jest": "^29.2.4",
+ "@types/jest": "^29.2.6",
"@types/node": "^18.11.18",
"@types/webpack": "^5.28.0",
"@typescript-eslint/eslint-plugin": "^5.47.0",
- "babel-loader": "^9.1.0",
+ "babel-loader": "^9.1.2",
"better-docs": "^2.7.2",
"clean-webpack-plugin": "^4.0.0",
- "eslint": "^8.30.0",
- "eslint-config-standard-with-typescript": "^24.0.0",
- "eslint-plugin-import": "^2.26.0",
- "eslint-plugin-n": "^15.6.0",
+ "eslint": "^8.32.0",
+ "eslint-config-standard-with-typescript": "^30.0.0",
+ "eslint-plugin-import": "^2.27.5",
+ "eslint-plugin-n": "^15.6.1",
"eslint-plugin-promise": "^6.1.1",
"jest": "^29.3.1",
"jsdoc": "^3.6.11",
@@ -70,25 +70,25 @@
}
},
"node_modules/@babel/core": {
- "version": "7.20.7",
- "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.20.7.tgz",
- "integrity": "sha512-t1ZjCluspe5DW24bn2Rr1CDb2v9rn/hROtg9a2tmd0+QYf4bsloYfLQzjG4qHPNMhWtKdGC33R5AxGR2Af2cBw==",
+ "version": "7.20.12",
+ "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.20.12.tgz",
+ "integrity": "sha512-XsMfHovsUYHFMdrIHkZphTN/2Hzzi78R08NuHfDBehym2VsPDL6Zn/JAD/JQdnRvbSsbQc4mVaU1m6JgtTEElg==",
"dev": true,
"dependencies": {
"@ampproject/remapping": "^2.1.0",
"@babel/code-frame": "^7.18.6",
"@babel/generator": "^7.20.7",
"@babel/helper-compilation-targets": "^7.20.7",
- "@babel/helper-module-transforms": "^7.20.7",
+ "@babel/helper-module-transforms": "^7.20.11",
"@babel/helpers": "^7.20.7",
"@babel/parser": "^7.20.7",
"@babel/template": "^7.20.7",
- "@babel/traverse": "^7.20.7",
+ "@babel/traverse": "^7.20.12",
"@babel/types": "^7.20.7",
"convert-source-map": "^1.7.0",
"debug": "^4.1.0",
"gensync": "^1.0.0-beta.2",
- "json5": "^2.2.1",
+ "json5": "^2.2.2",
"semver": "^6.3.0"
},
"engines": {
@@ -1688,9 +1688,9 @@
}
},
"node_modules/@babel/traverse": {
- "version": "7.20.10",
- "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.20.10.tgz",
- "integrity": "sha512-oSf1juCgymrSez8NI4A2sr4+uB/mFd9MXplYGPEBnfAuWmmyeVcHa6xLPiaRBcXkcb/28bgxmQLTVwFKE1yfsg==",
+ "version": "7.20.12",
+ "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.20.12.tgz",
+ "integrity": "sha512-MsIbFN0u+raeja38qboyF8TIT7K0BFzz/Yd/77ta4MsUsmP2RAnidIlwq7d5HFQrH/OZJecGV6B71C4zAgpoSQ==",
"dev": true,
"dependencies": {
"@babel/code-frame": "^7.18.6",
@@ -2940,9 +2940,9 @@
}
},
"node_modules/@types/jest": {
- "version": "29.2.5",
- "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.2.5.tgz",
- "integrity": "sha512-H2cSxkKgVmqNHXP7TC2L/WUorrZu8ZigyRywfVzv6EyBlxj39n4C00hjXYQWsbwqgElaj/CiAeSRmk5GoaKTgw==",
+ "version": "29.2.6",
+ "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.2.6.tgz",
+ "integrity": "sha512-XEUC/Tgw3uMh6Ho8GkUtQ2lPhY5Fmgyp3TdlkTJs1W9VgNxs+Ow/x3Elh8lHQKqCbZL0AubQuqWjHVT033Hhrw==",
"dev": true,
"dependencies": {
"expect": "^29.0.0",
@@ -3891,6 +3891,24 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/array.prototype.flatmap": {
+ "version": "1.3.1",
+ "resolved": "https://registry.npmjs.org/array.prototype.flatmap/-/array.prototype.flatmap-1.3.1.tgz",
+ "integrity": "sha512-8UGn9O1FDVvMNB0UlLv4voxRMze7+FpHyF5mSMRjWHUMlpoDViniy05870VlxhfgTnLbpuwTzvD76MTtWxB/mQ==",
+ "dev": true,
+ "dependencies": {
+ "call-bind": "^1.0.2",
+ "define-properties": "^1.1.4",
+ "es-abstract": "^1.20.4",
+ "es-shim-unscopables": "^1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
"node_modules/asap": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz",
@@ -4001,9 +4019,9 @@
}
},
"node_modules/babel-loader": {
- "version": "9.1.0",
- "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-9.1.0.tgz",
- "integrity": "sha512-Antt61KJPinUMwHwIIz9T5zfMgevnfZkEVWYDWlG888fgdvRRGD0JTuf/fFozQnfT+uq64sk1bmdHDy/mOEWnA==",
+ "version": "9.1.2",
+ "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-9.1.2.tgz",
+ "integrity": "sha512-mN14niXW43tddohGl8HPu5yfQq70iUThvFL/4QzESA7GcZoC0eVOhvWdQ8+3UlSjaDE9MVtsW9mxDY07W7VpVA==",
"dev": true,
"dependencies": {
"find-cache-dir": "^3.3.2",
@@ -5341,9 +5359,9 @@
}
},
"node_modules/eslint": {
- "version": "8.31.0",
- "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.31.0.tgz",
- "integrity": "sha512-0tQQEVdmPZ1UtUKXjX7EMm9BlgJ08G90IhWh0PKDCb3ZLsgAOHI8fYSIzYVZej92zsgq+ft0FGsxhJ3xo2tbuA==",
+ "version": "8.32.0",
+ "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.32.0.tgz",
+ "integrity": "sha512-nETVXpnthqKPFyuY2FNjz/bEd6nbosRgKbkgS/y1C7LJop96gYHWpiguLecMHQ2XCPxn77DS0P+68WzG6vkZSQ==",
"dev": true,
"dependencies": {
"@eslint/eslintrc": "^1.4.1",
@@ -5423,9 +5441,9 @@
}
},
"node_modules/eslint-config-standard-with-typescript": {
- "version": "24.0.0",
- "resolved": "https://registry.npmjs.org/eslint-config-standard-with-typescript/-/eslint-config-standard-with-typescript-24.0.0.tgz",
- "integrity": "sha512-vEnGXZ5aiR1enl9652iIP4nTpY3GPcNEwuhrsPbKO3Ce3D6T3yCqZdkUPk8nJetfdL/yO0DLsHg2d/l9iECIdg==",
+ "version": "30.0.0",
+ "resolved": "https://registry.npmjs.org/eslint-config-standard-with-typescript/-/eslint-config-standard-with-typescript-30.0.0.tgz",
+ "integrity": "sha512-/Ltst1BCZCWrGmqprLHBkTwuAbcoQrR8uMeSzZAv1vHKIVg+2nFje+DULA30SW01yCNhnx0a8yhZBkR0ZZPp+w==",
"dev": true,
"dependencies": {
"@typescript-eslint/parser": "^5.0.0",
@@ -5441,13 +5459,14 @@
}
},
"node_modules/eslint-import-resolver-node": {
- "version": "0.3.6",
- "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.6.tgz",
- "integrity": "sha512-0En0w03NRVMn9Uiyn8YRPDKvWjxCWkslUEhGNTdGx15RvPJYQ+lbOlqrlNI2vEAs4pDYK4f/HN2TbDmk5TP0iw==",
+ "version": "0.3.7",
+ "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.7.tgz",
+ "integrity": "sha512-gozW2blMLJCeFpBwugLTGyvVjNoeo1knonXAcatC6bjPBZitotxdWf7Gimr25N4c0AAOo4eOUfaG82IJPDpqCA==",
"dev": true,
"dependencies": {
"debug": "^3.2.7",
- "resolve": "^1.20.0"
+ "is-core-module": "^2.11.0",
+ "resolve": "^1.22.1"
}
},
"node_modules/eslint-import-resolver-node/node_modules/debug": {
@@ -5529,23 +5548,25 @@
}
},
"node_modules/eslint-plugin-import": {
- "version": "2.26.0",
- "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz",
- "integrity": "sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA==",
+ "version": "2.27.5",
+ "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.27.5.tgz",
+ "integrity": "sha512-LmEt3GVofgiGuiE+ORpnvP+kAm3h6MLZJ4Q5HCyHADofsb4VzXFsRiWj3c0OFiV+3DWFh0qg3v9gcPlfc3zRow==",
"dev": true,
"dependencies": {
- "array-includes": "^3.1.4",
- "array.prototype.flat": "^1.2.5",
- "debug": "^2.6.9",
+ "array-includes": "^3.1.6",
+ "array.prototype.flat": "^1.3.1",
+ "array.prototype.flatmap": "^1.3.1",
+ "debug": "^3.2.7",
"doctrine": "^2.1.0",
- "eslint-import-resolver-node": "^0.3.6",
- "eslint-module-utils": "^2.7.3",
+ "eslint-import-resolver-node": "^0.3.7",
+ "eslint-module-utils": "^2.7.4",
"has": "^1.0.3",
- "is-core-module": "^2.8.1",
+ "is-core-module": "^2.11.0",
"is-glob": "^4.0.3",
"minimatch": "^3.1.2",
- "object.values": "^1.1.5",
- "resolve": "^1.22.0",
+ "object.values": "^1.1.6",
+ "resolve": "^1.22.1",
+ "semver": "^6.3.0",
"tsconfig-paths": "^3.14.1"
},
"engines": {
@@ -5556,12 +5577,12 @@
}
},
"node_modules/eslint-plugin-import/node_modules/debug": {
- "version": "2.6.9",
- "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
- "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
+ "version": "3.2.7",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
+ "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
"dev": true,
"dependencies": {
- "ms": "2.0.0"
+ "ms": "^2.1.1"
}
},
"node_modules/eslint-plugin-import/node_modules/doctrine": {
@@ -5576,16 +5597,10 @@
"node": ">=0.10.0"
}
},
- "node_modules/eslint-plugin-import/node_modules/ms": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
- "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
- "dev": true
- },
"node_modules/eslint-plugin-n": {
- "version": "15.6.0",
- "resolved": "https://registry.npmjs.org/eslint-plugin-n/-/eslint-plugin-n-15.6.0.tgz",
- "integrity": "sha512-Hd/F7wz4Mj44Jp0H6Jtty13NcE69GNTY0rVlgTIj1XBnGGVI6UTdDrpE6vqu3AHo07bygq/N+7OH/lgz1emUJw==",
+ "version": "15.6.1",
+ "resolved": "https://registry.npmjs.org/eslint-plugin-n/-/eslint-plugin-n-15.6.1.tgz",
+ "integrity": "sha512-R9xw9OtCRxxaxaszTQmQAlPgM+RdGjaL1akWuY/Fv9fRAi8Wj4CUKc6iYVG8QNRjRuo8/BqVYIpfqberJUEacA==",
"dev": true,
"dependencies": {
"builtins": "^5.0.1",
@@ -12571,25 +12586,25 @@
"dev": true
},
"@babel/core": {
- "version": "7.20.7",
- "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.20.7.tgz",
- "integrity": "sha512-t1ZjCluspe5DW24bn2Rr1CDb2v9rn/hROtg9a2tmd0+QYf4bsloYfLQzjG4qHPNMhWtKdGC33R5AxGR2Af2cBw==",
+ "version": "7.20.12",
+ "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.20.12.tgz",
+ "integrity": "sha512-XsMfHovsUYHFMdrIHkZphTN/2Hzzi78R08NuHfDBehym2VsPDL6Zn/JAD/JQdnRvbSsbQc4mVaU1m6JgtTEElg==",
"dev": true,
"requires": {
"@ampproject/remapping": "^2.1.0",
"@babel/code-frame": "^7.18.6",
"@babel/generator": "^7.20.7",
"@babel/helper-compilation-targets": "^7.20.7",
- "@babel/helper-module-transforms": "^7.20.7",
+ "@babel/helper-module-transforms": "^7.20.11",
"@babel/helpers": "^7.20.7",
"@babel/parser": "^7.20.7",
"@babel/template": "^7.20.7",
- "@babel/traverse": "^7.20.7",
+ "@babel/traverse": "^7.20.12",
"@babel/types": "^7.20.7",
"convert-source-map": "^1.7.0",
"debug": "^4.1.0",
"gensync": "^1.0.0-beta.2",
- "json5": "^2.2.1",
+ "json5": "^2.2.2",
"semver": "^6.3.0"
}
},
@@ -13686,9 +13701,9 @@
}
},
"@babel/traverse": {
- "version": "7.20.10",
- "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.20.10.tgz",
- "integrity": "sha512-oSf1juCgymrSez8NI4A2sr4+uB/mFd9MXplYGPEBnfAuWmmyeVcHa6xLPiaRBcXkcb/28bgxmQLTVwFKE1yfsg==",
+ "version": "7.20.12",
+ "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.20.12.tgz",
+ "integrity": "sha512-MsIbFN0u+raeja38qboyF8TIT7K0BFzz/Yd/77ta4MsUsmP2RAnidIlwq7d5HFQrH/OZJecGV6B71C4zAgpoSQ==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.18.6",
@@ -14705,9 +14720,9 @@
}
},
"@types/jest": {
- "version": "29.2.5",
- "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.2.5.tgz",
- "integrity": "sha512-H2cSxkKgVmqNHXP7TC2L/WUorrZu8ZigyRywfVzv6EyBlxj39n4C00hjXYQWsbwqgElaj/CiAeSRmk5GoaKTgw==",
+ "version": "29.2.6",
+ "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.2.6.tgz",
+ "integrity": "sha512-XEUC/Tgw3uMh6Ho8GkUtQ2lPhY5Fmgyp3TdlkTJs1W9VgNxs+Ow/x3Elh8lHQKqCbZL0AubQuqWjHVT033Hhrw==",
"dev": true,
"requires": {
"expect": "^29.0.0",
@@ -15444,6 +15459,18 @@
"es-shim-unscopables": "^1.0.0"
}
},
+ "array.prototype.flatmap": {
+ "version": "1.3.1",
+ "resolved": "https://registry.npmjs.org/array.prototype.flatmap/-/array.prototype.flatmap-1.3.1.tgz",
+ "integrity": "sha512-8UGn9O1FDVvMNB0UlLv4voxRMze7+FpHyF5mSMRjWHUMlpoDViniy05870VlxhfgTnLbpuwTzvD76MTtWxB/mQ==",
+ "dev": true,
+ "requires": {
+ "call-bind": "^1.0.2",
+ "define-properties": "^1.1.4",
+ "es-abstract": "^1.20.4",
+ "es-shim-unscopables": "^1.0.0"
+ }
+ },
"asap": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz",
@@ -15526,9 +15553,9 @@
}
},
"babel-loader": {
- "version": "9.1.0",
- "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-9.1.0.tgz",
- "integrity": "sha512-Antt61KJPinUMwHwIIz9T5zfMgevnfZkEVWYDWlG888fgdvRRGD0JTuf/fFozQnfT+uq64sk1bmdHDy/mOEWnA==",
+ "version": "9.1.2",
+ "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-9.1.2.tgz",
+ "integrity": "sha512-mN14niXW43tddohGl8HPu5yfQq70iUThvFL/4QzESA7GcZoC0eVOhvWdQ8+3UlSjaDE9MVtsW9mxDY07W7VpVA==",
"dev": true,
"requires": {
"find-cache-dir": "^3.3.2",
@@ -16585,9 +16612,9 @@
"dev": true
},
"eslint": {
- "version": "8.31.0",
- "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.31.0.tgz",
- "integrity": "sha512-0tQQEVdmPZ1UtUKXjX7EMm9BlgJ08G90IhWh0PKDCb3ZLsgAOHI8fYSIzYVZej92zsgq+ft0FGsxhJ3xo2tbuA==",
+ "version": "8.32.0",
+ "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.32.0.tgz",
+ "integrity": "sha512-nETVXpnthqKPFyuY2FNjz/bEd6nbosRgKbkgS/y1C7LJop96gYHWpiguLecMHQ2XCPxn77DS0P+68WzG6vkZSQ==",
"dev": true,
"requires": {
"@eslint/eslintrc": "^1.4.1",
@@ -16727,9 +16754,9 @@
"requires": {}
},
"eslint-config-standard-with-typescript": {
- "version": "24.0.0",
- "resolved": "https://registry.npmjs.org/eslint-config-standard-with-typescript/-/eslint-config-standard-with-typescript-24.0.0.tgz",
- "integrity": "sha512-vEnGXZ5aiR1enl9652iIP4nTpY3GPcNEwuhrsPbKO3Ce3D6T3yCqZdkUPk8nJetfdL/yO0DLsHg2d/l9iECIdg==",
+ "version": "30.0.0",
+ "resolved": "https://registry.npmjs.org/eslint-config-standard-with-typescript/-/eslint-config-standard-with-typescript-30.0.0.tgz",
+ "integrity": "sha512-/Ltst1BCZCWrGmqprLHBkTwuAbcoQrR8uMeSzZAv1vHKIVg+2nFje+DULA30SW01yCNhnx0a8yhZBkR0ZZPp+w==",
"dev": true,
"requires": {
"@typescript-eslint/parser": "^5.0.0",
@@ -16737,13 +16764,14 @@
}
},
"eslint-import-resolver-node": {
- "version": "0.3.6",
- "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.6.tgz",
- "integrity": "sha512-0En0w03NRVMn9Uiyn8YRPDKvWjxCWkslUEhGNTdGx15RvPJYQ+lbOlqrlNI2vEAs4pDYK4f/HN2TbDmk5TP0iw==",
+ "version": "0.3.7",
+ "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.7.tgz",
+ "integrity": "sha512-gozW2blMLJCeFpBwugLTGyvVjNoeo1knonXAcatC6bjPBZitotxdWf7Gimr25N4c0AAOo4eOUfaG82IJPDpqCA==",
"dev": true,
"requires": {
"debug": "^3.2.7",
- "resolve": "^1.20.0"
+ "is-core-module": "^2.11.0",
+ "resolve": "^1.22.1"
},
"dependencies": {
"debug": {
@@ -16805,33 +16833,35 @@
}
},
"eslint-plugin-import": {
- "version": "2.26.0",
- "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz",
- "integrity": "sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA==",
+ "version": "2.27.5",
+ "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.27.5.tgz",
+ "integrity": "sha512-LmEt3GVofgiGuiE+ORpnvP+kAm3h6MLZJ4Q5HCyHADofsb4VzXFsRiWj3c0OFiV+3DWFh0qg3v9gcPlfc3zRow==",
"dev": true,
"requires": {
- "array-includes": "^3.1.4",
- "array.prototype.flat": "^1.2.5",
- "debug": "^2.6.9",
+ "array-includes": "^3.1.6",
+ "array.prototype.flat": "^1.3.1",
+ "array.prototype.flatmap": "^1.3.1",
+ "debug": "^3.2.7",
"doctrine": "^2.1.0",
- "eslint-import-resolver-node": "^0.3.6",
- "eslint-module-utils": "^2.7.3",
+ "eslint-import-resolver-node": "^0.3.7",
+ "eslint-module-utils": "^2.7.4",
"has": "^1.0.3",
- "is-core-module": "^2.8.1",
+ "is-core-module": "^2.11.0",
"is-glob": "^4.0.3",
"minimatch": "^3.1.2",
- "object.values": "^1.1.5",
- "resolve": "^1.22.0",
+ "object.values": "^1.1.6",
+ "resolve": "^1.22.1",
+ "semver": "^6.3.0",
"tsconfig-paths": "^3.14.1"
},
"dependencies": {
"debug": {
- "version": "2.6.9",
- "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
- "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
+ "version": "3.2.7",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
+ "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
"dev": true,
"requires": {
- "ms": "2.0.0"
+ "ms": "^2.1.1"
}
},
"doctrine": {
@@ -16842,19 +16872,13 @@
"requires": {
"esutils": "^2.0.2"
}
- },
- "ms": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
- "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
- "dev": true
}
}
},
"eslint-plugin-n": {
- "version": "15.6.0",
- "resolved": "https://registry.npmjs.org/eslint-plugin-n/-/eslint-plugin-n-15.6.0.tgz",
- "integrity": "sha512-Hd/F7wz4Mj44Jp0H6Jtty13NcE69GNTY0rVlgTIj1XBnGGVI6UTdDrpE6vqu3AHo07bygq/N+7OH/lgz1emUJw==",
+ "version": "15.6.1",
+ "resolved": "https://registry.npmjs.org/eslint-plugin-n/-/eslint-plugin-n-15.6.1.tgz",
+ "integrity": "sha512-R9xw9OtCRxxaxaszTQmQAlPgM+RdGjaL1akWuY/Fv9fRAi8Wj4CUKc6iYVG8QNRjRuo8/BqVYIpfqberJUEacA==",
"dev": true,
"requires": {
"builtins": "^5.0.1",
diff --git a/package.json b/package.json
index 56af134..6bb0af8 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "color-2-name",
- "version": "1.1.0",
+ "version": "1.1.1",
"author": "Erik ",
"license": "ISC",
"description": "Finds the closest color name to a given hex, rgb and hsl color (with and without alpha). It uses the Euclidean distance formula to calculate the distance between colors in the RGB color space",
@@ -47,24 +47,24 @@
"color picker"
],
"devDependencies": {
- "@babel/core": "^7.20.7",
+ "@babel/core": "^7.20.12",
"@babel/preset-env": "^7.20.2",
"@babel/preset-typescript": "^7.18.6",
"@jest/globals": "^29.3.1",
- "@types/jest": "^29.2.4",
+ "@types/jest": "^29.2.6",
"@types/node": "^18.11.18",
"@types/webpack": "^5.28.0",
"@typescript-eslint/eslint-plugin": "^5.47.0",
- "babel-loader": "^9.1.0",
- "jsdoc": "^3.6.11",
+ "babel-loader": "^9.1.2",
"better-docs": "^2.7.2",
"clean-webpack-plugin": "^4.0.0",
- "eslint": "^8.30.0",
- "eslint-config-standard-with-typescript": "^24.0.0",
- "eslint-plugin-import": "^2.26.0",
- "eslint-plugin-n": "^15.6.0",
+ "eslint": "^8.32.0",
+ "eslint-config-standard-with-typescript": "^30.0.0",
+ "eslint-plugin-import": "^2.27.5",
+ "eslint-plugin-n": "^15.6.1",
"eslint-plugin-promise": "^6.1.1",
"jest": "^29.3.1",
+ "jsdoc": "^3.6.11",
"terser-webpack-plugin": "^5.3.6",
"ts-node": "^10.9.1",
"typescript": "^4.9.4",
diff --git a/readme.md b/readme.md
index e9dd8eb..78c2066 100644
--- a/readme.md
+++ b/readme.md
@@ -61,26 +61,24 @@ color2Name.closest('#abcdef')
To load color-2-name add the script tag like below in your head/footer:
```js
-
+
```
---
This Package includes the following functions:
-- [closest()](#closest--)
-- [distance()](#distance--)
+- [closest()](#closest)
+- [distance()](#distance)
- [rgbToHex()](#rgbToHex)
-- [isLight()](#isLight--)
-- [isDark()](#isDark--)
-- [isLightOrDark()](#isLightOrDark--)
-- [closestRGB()](#closestRGB--)
+- [isLight()](#isLight)
+- [isDark()](#isDark)
+- [isLightOrDark()](#isLightOrDark)
+- [closestRGB()](#closestRGB)
### 💡closest()
diff --git a/src/hsl-utils.ts b/src/hsl-utils.ts
index 9b29b33..3bcb20d 100644
--- a/src/hsl-utils.ts
+++ b/src/hsl-utils.ts
@@ -1,4 +1,4 @@
-import {hslRegex, normalizeDegree, RGBSET, splitValues} from './common'
+import { hslRegex, normalizeDegree, splitValues } from './common'
import { HSLVALUE, RGBVALUE } from './types'
/**