@ant-design/fast-color
Advanced tools
Comparing version 1.2.3 to 1.2.4
@@ -13,3 +13,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
function splitColorStr(str, parseNum) { | ||
const match = str.match(/\d*\.?\d+%?/g) || []; | ||
const match = str | ||
// Remove str before `(` | ||
.replace(/^[^(]*\((.*)/, '$1') | ||
// Remove str after `)` | ||
.replace(/\).*/, '').match(/\d*\.?\d+%?/g) || []; | ||
const numList = match.map(item => parseFloat(item)); | ||
@@ -29,2 +33,5 @@ for (let i = 0; i < 3; i += 1) { | ||
} | ||
function inRange(val, max = 255, min = 0) { | ||
return typeof val === 'number' && val >= min && val <= max; | ||
} | ||
const parseHSVorHSL = (num, _, index) => index === 0 ? num : num / 100; | ||
@@ -111,3 +118,3 @@ export class FastColor { | ||
get isValid() { | ||
return typeof this.r === 'number' && this.r >= 0 && this.r <= 255 && typeof this.g === 'number' && this.g >= 0 && this.g <= 255 && typeof this.b === 'number' && this.b >= 0 && this.b <= 255 && typeof this.a === 'number' && this.a >= 0 && this.a <= 1; | ||
return inRange(this.r) && inRange(this.g) && inRange(this.b) && inRange(this.a, 1); | ||
} | ||
@@ -114,0 +121,0 @@ clone() { |
@@ -20,3 +20,7 @@ "use strict"; | ||
function splitColorStr(str, parseNum) { | ||
const match = str.match(/\d*\.?\d+%?/g) || []; | ||
const match = str | ||
// Remove str before `(` | ||
.replace(/^[^(]*\((.*)/, '$1') | ||
// Remove str after `)` | ||
.replace(/\).*/, '').match(/\d*\.?\d+%?/g) || []; | ||
const numList = match.map(item => parseFloat(item)); | ||
@@ -36,2 +40,5 @@ for (let i = 0; i < 3; i += 1) { | ||
} | ||
function inRange(val, max = 255, min = 0) { | ||
return typeof val === 'number' && val >= min && val <= max; | ||
} | ||
const parseHSVorHSL = (num, _, index) => index === 0 ? num : num / 100; | ||
@@ -118,3 +125,3 @@ class FastColor { | ||
get isValid() { | ||
return typeof this.r === 'number' && this.r >= 0 && this.r <= 255 && typeof this.g === 'number' && this.g >= 0 && this.g <= 255 && typeof this.b === 'number' && this.b >= 0 && this.b <= 255 && typeof this.a === 'number' && this.a >= 0 && this.a <= 1; | ||
return inRange(this.r) && inRange(this.g) && inRange(this.b) && inRange(this.a, 1); | ||
} | ||
@@ -121,0 +128,0 @@ clone() { |
{ | ||
"name": "@ant-design/fast-color", | ||
"version": "1.2.3", | ||
"version": "1.2.4", | ||
"description": "fast and small color class", | ||
@@ -5,0 +5,0 @@ "engines": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40909
1236