Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Color.isValid = function (value) {
if (types.isNullOrUndefined(value) || value instanceof Color) {
return true;
}
if (!types.isString(value)) {
return false;
}
if (knownColors.isKnownName(value)) {
return true;
}
return HEX_REGEX.test(value) || isRgbOrRgba(value);
};
Color.prototype._buildHex = function () {
Color.isValid = function (value) {
if (types.isNullOrUndefined(value) || value instanceof Color) {
return true;
}
if (!types.isString(value)) {
return false;
}
if (knownColors.isKnownName(value)) {
return true;
}
return HEX_REGEX.test(value) || isRgbOrRgba(value);
};
Color.prototype._buildHex = function () {
Color.isValid = function (value) {
if (types.isNullOrUndefined(value) || value instanceof Color) {
return true;
}
if (!types.isString(value)) {
return false;
}
if (knownColors.isKnownName(value)) {
return true;
}
return HEX_REGEX.test(value) || isRgbOrRgba(value);
};
Color.prototype._buildHex = function () {
function Color() {
if (arguments.length === 1) {
var arg = arguments[0];
if (types.isString(arg)) {
if (knownColors.isKnownName(arg)) {
this._hex = knownColors.getKnownColor(arg);
this._name = arg;
}
else {
this._hex = this._normalizeHex(arg);
}
this._argb = this._argbFromString(this._hex);
}
else if (types.isNumber(arg)) {
this._argb = arg;
}
else {
throw new Error("Expected 1 or 4 constructor parameters.");
}
this._parseComponents();
if (!this._hex) {
function Color() {
if (arguments.length === 1) {
var arg = arguments[0];
if (types.isString(arg)) {
if (isRgbOrRgba(arg)) {
this._argb = argbFromRgbOrRgba(arg);
}
else if (knownColors.isKnownName(arg)) {
this._hex = knownColors.getKnownColor(arg);
this._name = arg;
this._argb = this._argbFromString(this._hex);
}
else {
this._hex = this._normalizeHex(arg);
this._argb = this._argbFromString(this._hex);
}
}
else if (types.isNumber(arg)) {
this._argb = arg;
}
else {
throw new Error("Expected 1 or 4 constructor parameters.");
}
this._parseComponents();
function Color() {
if (arguments.length === 1) {
var arg = arguments[0];
if (types.isString(arg)) {
if (isRgbOrRgba(arg)) {
this._argb = argbFromRgbOrRgba(arg);
}
else if (knownColors.isKnownName(arg)) {
this._hex = knownColors.getKnownColor(arg);
this._name = arg;
this._argb = this._argbFromString(this._hex);
}
else {
this._hex = this._normalizeHex(arg);
this._argb = this._argbFromString(this._hex);
}
}
else if (types.isNumber(arg)) {
this._argb = arg;
}
else {
throw new Error("Expected 1 or 4 constructor parameters.");
}
this._parseComponents();
function Color() {
if (arguments.length === 1) {
var arg = arguments[0];
if (types.isString(arg)) {
if (isRgbOrRgba(arg)) {
this._argb = argbFromRgbOrRgba(arg);
}
else if (knownColors.isKnownName(arg)) {
this._hex = knownColors.getKnownColor(arg);
this._name = arg;
this._argb = this._argbFromString(this._hex);
}
else {
this._hex = this._normalizeHex(arg);
this._argb = this._argbFromString(this._hex);
}
}
else if (types.isNumber(arg)) {
this._argb = arg;
}
else {
throw new Error("Expected 1 or 4 constructor parameters.");
}
this._parseComponents();