color-string 2.1.2 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +4 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -52,7 +52,7 @@ cs.get.rgb = function (string) {
|
|
|
52
52
|
|
|
53
53
|
const abbr = /^#([a-f\d]{3,4})$/i;
|
|
54
54
|
const hex = /^#([a-f\d]{6})([a-f\d]{2})?$/i;
|
|
55
|
-
const rgba = /^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[\s,|/]\s*([+-]?
|
|
55
|
+
const rgba = /^rgba?\(\s*([+-]?(?:\d*\.)?\d+(?:e\d+)?)(?=[\s,])\s*(?:,\s*)?([+-]?(?:\d*\.)?\d+(?:e\d+)?)(?=[\s,])\s*(?:,\s*)?([+-]?(?:\d*\.)?\d+(?:e\d+)?)\s*(?:[\s,|/]\s*([+-]?(?:\d*\.)?\d+(?:e\d+)?)(%?)\s*)?\)$/i;
|
|
56
56
|
const per = /^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/;
|
|
57
57
|
const keyword = /^(\w+)$/;
|
|
58
58
|
|
|
@@ -87,7 +87,7 @@ cs.get.rgb = function (string) {
|
|
|
87
87
|
}
|
|
88
88
|
} else if (match = string.match(rgba)) {
|
|
89
89
|
for (i = 0; i < 3; i++) {
|
|
90
|
-
rgb[i] = Number.
|
|
90
|
+
rgb[i] = Number.parseFloat(match[i + 1]);
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
if (match[4]) {
|
|
@@ -110,7 +110,8 @@ cs.get.rgb = function (string) {
|
|
|
110
110
|
return null;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
// eslint-disable-next-line unicorn/prefer-spread
|
|
114
|
+
rgb = colorNames[match[1]].slice();
|
|
114
115
|
rgb[3] = 1;
|
|
115
116
|
|
|
116
117
|
return rgb;
|