color-string 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +1 -0
  2. package/index.js +3 -3
  3. package/package.json +4 -3
package/README.md CHANGED
@@ -33,6 +33,7 @@ colorString.get.hsl('hsl(360 100% 50%)') // [0, 100, 50, 1]
33
33
  colorString.get.hsl('hsla(360, 60%, 50%, 0.4)') // [0, 60, 50, 0.4]
34
34
  colorString.get.hsl('hsl(360 60% 50% / 0.4)') // [0, 60, 50, 0.4]
35
35
 
36
+ colorString.get.hwb('hwb(60 3% 60%)') // [60, 3, 60, 1]
36
37
  colorString.get.hwb('hwb(60, 3%, 60%)') // [60, 3, 60, 1]
37
38
  colorString.get.hwb('hwb(60, 3%, 60%, 0.6)') // [60, 3, 60, 0.6]
38
39
 
package/index.js CHANGED
@@ -52,8 +52,8 @@ 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*([+-]?[\d.]+)(%?)\s*)?\)$/;
56
- const per = /^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/;
55
+ const rgba = /^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/;
56
+ const per = /^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/;
57
57
  const keyword = /^(\w+)$/;
58
58
 
59
59
  let rgb = [0, 0, 0, 1];
@@ -153,7 +153,7 @@ cs.get.hwb = function (string) {
153
153
  return null;
154
154
  }
155
155
 
156
- const hwb = /^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/;
156
+ const hwb = /^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*[\s,]\s*([+-]?[\d.]+)%\s*[\s,]\s*([+-]?[\d.]+)%\s*(?:[\s,]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/;
157
157
  const match = string.match(hwb);
158
158
 
159
159
  if (match) {
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "color-string",
3
3
  "description": "Parser and generator for CSS color strings",
4
- "version": "2.0.1",
5
- "author": "Heather Arthur <fayearthur@gmail.com>",
4
+ "version": "2.1.0",
5
+ "author": "Josh Junon (https://github.com/qix-)",
6
6
  "contributors": [
7
7
  "Maxime Thirouin",
8
8
  "Dyma Ywanov <dfcreative@gmail.com>",
9
- "Josh Junon"
9
+ "Heather Arthur <fayearthur@gmail.com>",
10
+ "LitoMore (https://github.com/LitoMore)"
10
11
  ],
11
12
  "repository": "Qix-/color-string",
12
13
  "type": "module",