color-string 1.5.2 → 1.5.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.
Potentially problematic release.
This version of color-string might be problematic. Click here for more details.
- package/index.js +4 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -12,7 +12,8 @@ for (var name in colorNames) {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
var cs = module.exports = {
|
|
15
|
-
to: {}
|
|
15
|
+
to: {},
|
|
16
|
+
get: {}
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
cs.get = function (string) {
|
|
@@ -128,12 +129,12 @@ cs.get.hsl = function (string) {
|
|
|
128
129
|
return null;
|
|
129
130
|
}
|
|
130
131
|
|
|
131
|
-
var hsl = /^hsla?\(\s*([+-]
|
|
132
|
+
var hsl = /^hsla?\(\s*([+-]?(?:\d*\.)?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/;
|
|
132
133
|
var match = string.match(hsl);
|
|
133
134
|
|
|
134
135
|
if (match) {
|
|
135
136
|
var alpha = parseFloat(match[4]);
|
|
136
|
-
var h = (
|
|
137
|
+
var h = (parseFloat(match[1]) + 360) % 360;
|
|
137
138
|
var s = clamp(parseFloat(match[2]), 0, 100);
|
|
138
139
|
var l = clamp(parseFloat(match[3]), 0, 100);
|
|
139
140
|
var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
|