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.
Files changed (2) hide show
  1. package/index.js +4 -3
  2. 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*([+-]?[\d.]+)(%?)\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.parseInt(match[i + 1], 10);
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
- rgb = colorNames[match[1]];
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;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "color-string",
3
3
  "description": "Parser and generator for CSS color strings",
4
- "version": "2.1.2",
4
+ "version": "2.1.3",
5
5
  "author": "Josh Junon (https://github.com/qix-)",
6
6
  "contributors": [
7
7
  "Maxime Thirouin",