Socket
Socket
Sign inDemoInstall

onecolor

Package Overview
Dependencies
0
Maintainers
2
Versions
36
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.7 to 2.1.0

lib/one/color-namedColors.js

6

lib/one/color.js

@@ -50,2 +50,8 @@ /*global one*/

} else if (obj.charCodeAt) {
if (ONECOLOR.namedColors) {
var lowerCased = obj.toLowerCase();
if (ONECOLOR.namedColors[lowerCased]) {
obj = ONECOLOR.namedColors[lowerCased];
}
}
// Test for CSS rgb(....) string

@@ -52,0 +58,0 @@ var matchCssSyntax = obj.match(cssColorRegExp);

5

lib/one/color/_all.js
// This file is purely for the build system
one.include('lib:one/color/HSV.js');
one.include('lib:one/color/HSL.js');
//one.include('lib:one/color/CMYK.js');
one.include('lib:one/color/CMYK.js');
one.include('lib:one/color-namedColors.js');
if (typeof module !== 'undefined') {
module.exports = one.color;
module.exports = one.color;
}

@@ -62,2 +62,8 @@ /*global one*/

} else if (obj.charCodeAt) {
if (ONECOLOR.namedColors) {
var lowerCased = obj.toLowerCase();
if (ONECOLOR.namedColors[lowerCased]) {
obj = ONECOLOR.namedColors[lowerCased];
}
}
// Test for CSS rgb(....) string

@@ -761,6 +767,6 @@ var matchCssSyntax = obj.match(cssColorRegExp);

// This file is purely for the build system
//
if (typeof module !== 'undefined') {
module.exports = one.color;
module.exports = one.color;
}

2

one-color.js

@@ -1,1 +0,1 @@

typeof one=="undefined"&&(one={include:function(){}}),function(){var a=Function,b=parseInt,c=parseFloat,d=Math.round,e=[],f=/\s*(\.\d+|\d+(?:\.\d+)?)(%)?\s*/,g=/\s*(\.\d+|\d+(?:\.\d+)?)\s*/,h=new RegExp("^(rgb|hsl|hsv)a?\\("+f.source+","+f.source+","+f.source+"(?:,"+g.source+")?"+"\\)$","i"),i=one.color=function(a){if(Object.prototype.toString.apply(a)==="[object Array]")return a[0].length===4?new i.RGB(a[0]/255,a[1]/255,a[2]/255,a[3]/255):new i[a[0]](a.slice(1,a.length));if(a.charCodeAt){var d=a.match(h);if(d){var e=d[1].toUpperCase(),f=typeof d[8]=="undefined"?d[8]:c(d[8]),g=e[0]==="H",j=d[3]?100:g?360:255,k=d[5]||g?100:255,l=d[7]||g?100:255;if(typeof i[e]=="undefined")throw new Error("one.color."+e+" is not installed.");return new i[e](c(d[2])/j,c(d[4])/k,c(d[6])/l,f)}a.length<6&&(a=a.replace(/^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i,"$1$1$2$2$3$3"));var m=a.match(/^#?([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])$/i);if(m)return new i.RGB(b(m[1],16)/255,b(m[2],16)/255,b(m[3],16)/255)}else{if(typeof a=="object"&&a.isColor)return a;if(!isNaN(a))return new i.RGB((a&255)/255,((a&65280)>>8)/255,((a&16711680)>>16)/255)}return!1};i.installColorSpace=function(b,c,d){function j(b,c){var d={};d[c.toLowerCase()]=new a("return this.rgb()."+c.toLowerCase()+"();"),i[c].propertyNames.forEach(function(b,e){d[b]=new a("value","isDelta","return this."+c.toLowerCase()+"()."+b+"(value, isDelta);")});for(var e in d)d.hasOwnProperty(e)&&i[b].prototype[e]===undefined&&(i[b].prototype[e]=d[e])}i[b]=new a(c.join(","),"if (Object.prototype.toString.apply("+c[0]+") === '[object Array]') {"+c.map(function(a,b){return a+"="+c[0]+"["+b+"];"}).reverse().join("")+"}"+"if ("+c.filter(function(a){return a!=="alpha"}).map(function(a){return"isNaN("+a+")"}).join("||")+"){"+'throw new Error("[one.color.'+b+']: Invalid color: ("+'+c.join('+","+')+'+")");}'+c.map(function(a){return a==="hue"?"this._hue=hue<0?hue-Math.floor(hue):hue%1":a==="alpha"?"this._alpha=(isNaN(alpha)||alpha>1)?1:(alpha<0?0:alpha);":"this._"+a+"="+a+"<0?0:("+a+">1?1:"+a+")"}).join(";")+";"),i[b].propertyNames=c;var f=i[b].prototype;["valueOf","hex","css","cssa"].forEach(function(c){f[c]=f[c]||(b==="RGB"?f.hex:new a("return this.rgb()."+c+"();"))}),f.isColor=!0,f.equals=function(a,d){typeof d=="undefined"&&(d=1e-10),a=a[b.toLowerCase()]();for(var e=0;e<c.length;e+=1)if(Math.abs(this["_"+c[e]]-a["_"+c[e]])>d)return!1;return!0},f.toJSON=new a("return ['"+b+"', "+c.map(function(a){return"this._"+a},this).join(", ")+"];");for(var g in d)if(d.hasOwnProperty(g)){var h=g.match(/^from(.*)$/);h?i[h[1].toUpperCase()].prototype[b.toLowerCase()]=d[g]:f[g]=d[g]}f[b.toLowerCase()]=function(){return this},f.toString=new a('return "[one.color.'+b+':"+'+c.map(function(a,b){return'" '+c[b]+'="+this._'+a}).join("+")+'+"]";'),c.forEach(function(b,d){f[b]=new a("value","isDelta","if (typeof value === 'undefined') {return this._"+b+";"+"}"+"if (isDelta) {"+"return new this.constructor("+c.map(function(a,c){return"this._"+a+(b===a?"+value":"")}).join(", ")+");"+"}"+"return new this.constructor("+c.map(function(a,c){return b===a?"value":"this._"+a}).join(", ")+");")}),e.forEach(function(a){j(b,a),j(a,b)}),e.push(b)},i.installColorSpace("RGB",["red","green","blue","alpha"],{hex:function(){var a=(d(255*this._red)*65536+d(255*this._green)*256+d(255*this._blue)).toString(16);return"#"+"00000".substr(0,6-a.length)+a},css:function(){return"rgb("+d(255*this._red)+","+d(255*this._green)+","+d(255*this._blue)+")"},cssa:function(){return"rgba("+d(255*this._red)+","+d(255*this._green)+","+d(255*this._blue)+","+this._alpha+")"}})}(),function(){var a=Math,b=one.color;b.installColorSpace("HSV",["hue","saturation","value","alpha"],{rgb:function(){var c=this._hue,d=this._saturation,e=this._value,f=a.min(5,a.floor(c*6)),g=c*6-f,h=e*(1-d),i=e*(1-g*d),j=e*(1-(1-g)*d),k,l,m;switch(f){case 0:k=e,l=j,m=h;break;case 1:k=i,l=e,m=h;break;case 2:k=h,l=e,m=j;break;case 3:k=h,l=i,m=e;break;case 4:k=j,l=h,m=e;break;case 5:k=e,l=h,m=i}return new b.RGB(k,l,m,this._alpha)},hsl:function(){var a=(2-this._saturation)*this._value,c=this._saturation*this._value,d=a<=1?a:2-a,e;return d<1e-9?e=0:e=c/d,new b.HSL(this._hue,e,a/2,this._alpha)},fromRgb:function(){var c=this._red,d=this._green,e=this._blue,f=a.max(c,d,e),g=a.min(c,d,e),h=f-g,i,j=f===0?0:h/f,k=f;if(h===0)i=0;else switch(f){case c:i=(d-e)/h/6+(d<e?1:0);break;case d:i=(e-c)/h/6+1/3;break;case e:i=(c-d)/h/6+2/3}return new b.HSV(i,j,k,this._alpha)}})}(),one.color.installColorSpace("HSL",["hue","saturation","lightness","alpha"],{hsv:function(){var a=this._lightness*2,b=this._saturation*(a<=1?a:2-a),c;return a+b<1e-9?c=0:c=2*b/(a+b),new one.color.HSV(this._hue,c,(a+b)/2,this._alpha)},rgb:function(){return this.hsv().rgb()},fromRgb:function(){return this.hsv().hsl()}}),typeof module!="undefined"&&(module.exports=one.color);
typeof one=="undefined"&&(one={include:function(){}}),function(){var a=Function,b=parseInt,c=parseFloat,d=Math.round,e=[],f=/\s*(\.\d+|\d+(?:\.\d+)?)(%)?\s*/,g=/\s*(\.\d+|\d+(?:\.\d+)?)\s*/,h=new RegExp("^(rgb|hsl|hsv)a?\\("+f.source+","+f.source+","+f.source+"(?:,"+g.source+")?"+"\\)$","i"),i=one.color=function(a){if(Object.prototype.toString.apply(a)==="[object Array]")return a[0].length===4?new i.RGB(a[0]/255,a[1]/255,a[2]/255,a[3]/255):new i[a[0]](a.slice(1,a.length));if(a.charCodeAt){if(i.namedColors){var d=a.toLowerCase();i.namedColors[d]&&(a=i.namedColors[d])}var e=a.match(h);if(e){var f=e[1].toUpperCase(),g=typeof e[8]=="undefined"?e[8]:c(e[8]),j=f[0]==="H",k=e[3]?100:j?360:255,l=e[5]||j?100:255,m=e[7]||j?100:255;if(typeof i[f]=="undefined")throw new Error("one.color."+f+" is not installed.");return new i[f](c(e[2])/k,c(e[4])/l,c(e[6])/m,g)}a.length<6&&(a=a.replace(/^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i,"$1$1$2$2$3$3"));var n=a.match(/^#?([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])$/i);if(n)return new i.RGB(b(n[1],16)/255,b(n[2],16)/255,b(n[3],16)/255)}else{if(typeof a=="object"&&a.isColor)return a;if(!isNaN(a))return new i.RGB((a&255)/255,((a&65280)>>8)/255,((a&16711680)>>16)/255)}return!1};i.installColorSpace=function(b,c,d){function j(b,c){var d={};d[c.toLowerCase()]=new a("return this.rgb()."+c.toLowerCase()+"();"),i[c].propertyNames.forEach(function(b,e){d[b]=new a("value","isDelta","return this."+c.toLowerCase()+"()."+b+"(value, isDelta);")});for(var e in d)d.hasOwnProperty(e)&&i[b].prototype[e]===undefined&&(i[b].prototype[e]=d[e])}i[b]=new a(c.join(","),"if (Object.prototype.toString.apply("+c[0]+") === '[object Array]') {"+c.map(function(a,b){return a+"="+c[0]+"["+b+"];"}).reverse().join("")+"}"+"if ("+c.filter(function(a){return a!=="alpha"}).map(function(a){return"isNaN("+a+")"}).join("||")+"){"+'throw new Error("[one.color.'+b+']: Invalid color: ("+'+c.join('+","+')+'+")");}'+c.map(function(a){return a==="hue"?"this._hue=hue<0?hue-Math.floor(hue):hue%1":a==="alpha"?"this._alpha=(isNaN(alpha)||alpha>1)?1:(alpha<0?0:alpha);":"this._"+a+"="+a+"<0?0:("+a+">1?1:"+a+")"}).join(";")+";"),i[b].propertyNames=c;var f=i[b].prototype;["valueOf","hex","css","cssa"].forEach(function(c){f[c]=f[c]||(b==="RGB"?f.hex:new a("return this.rgb()."+c+"();"))}),f.isColor=!0,f.equals=function(a,d){typeof d=="undefined"&&(d=1e-10),a=a[b.toLowerCase()]();for(var e=0;e<c.length;e+=1)if(Math.abs(this["_"+c[e]]-a["_"+c[e]])>d)return!1;return!0},f.toJSON=new a("return ['"+b+"', "+c.map(function(a){return"this._"+a},this).join(", ")+"];");for(var g in d)if(d.hasOwnProperty(g)){var h=g.match(/^from(.*)$/);h?i[h[1].toUpperCase()].prototype[b.toLowerCase()]=d[g]:f[g]=d[g]}f[b.toLowerCase()]=function(){return this},f.toString=new a('return "[one.color.'+b+':"+'+c.map(function(a,b){return'" '+c[b]+'="+this._'+a}).join("+")+'+"]";'),c.forEach(function(b,d){f[b]=new a("value","isDelta","if (typeof value === 'undefined') {return this._"+b+";"+"}"+"if (isDelta) {"+"return new this.constructor("+c.map(function(a,c){return"this._"+a+(b===a?"+value":"")}).join(", ")+");"+"}"+"return new this.constructor("+c.map(function(a,c){return b===a?"value":"this._"+a}).join(", ")+");")}),e.forEach(function(a){j(b,a),j(a,b)}),e.push(b)},i.installColorSpace("RGB",["red","green","blue","alpha"],{hex:function(){var a=(d(255*this._red)*65536+d(255*this._green)*256+d(255*this._blue)).toString(16);return"#"+"00000".substr(0,6-a.length)+a},css:function(){return"rgb("+d(255*this._red)+","+d(255*this._green)+","+d(255*this._blue)+")"},cssa:function(){return"rgba("+d(255*this._red)+","+d(255*this._green)+","+d(255*this._blue)+","+this._alpha+")"}})}(),function(){var a=Math,b=one.color;b.installColorSpace("HSV",["hue","saturation","value","alpha"],{rgb:function(){var c=this._hue,d=this._saturation,e=this._value,f=a.min(5,a.floor(c*6)),g=c*6-f,h=e*(1-d),i=e*(1-g*d),j=e*(1-(1-g)*d),k,l,m;switch(f){case 0:k=e,l=j,m=h;break;case 1:k=i,l=e,m=h;break;case 2:k=h,l=e,m=j;break;case 3:k=h,l=i,m=e;break;case 4:k=j,l=h,m=e;break;case 5:k=e,l=h,m=i}return new b.RGB(k,l,m,this._alpha)},hsl:function(){var a=(2-this._saturation)*this._value,c=this._saturation*this._value,d=a>1?2-a:a,e;return d<1e-9?e=0:e=c/d,new b.HSL(this._hue,e,a/2,this._alpha)},fromRgb:function(){var c=this._red,d=this._green,e=this._blue,f=a.max(c,d,e),g=a.min(c,d,e),h=f-g,i,j=f===0?0:h/f,k=f;if(h===0)i=0;else switch(f){case c:i=(d-e)/h/6+(d<e?1:0);break;case d:i=(e-c)/h/6+1/3;break;case e:i=(c-d)/h/6+2/3}return new b.HSV(i,j,k,this._alpha)}})}(),one.color.installColorSpace("HSL",["hue","saturation","lightness","alpha"],{hsv:function(){var a=this._lightness*2,b=this._saturation*(a>1?2-a:a),c;return a+b<1e-9?c=0:c=2*b/(a+b),new one.color.HSV(this._hue,c,(a+b)/2,this._alpha)},rgb:function(){return this.hsv().rgb()},fromRgb:function(){return this.hsv().hsl()}}),typeof module!="undefined"&&(module.exports=one.color)

@@ -5,3 +5,3 @@ {

"repository": "git@github.com:One-com/one-color.git",
"version": "2.0.7",
"version": "2.1.0",
"keywords": ["ender", "color", "colour"],

@@ -32,7 +32,7 @@ "maintainers": [

},
"main": "one-color-debug.js",
"main": "one-color-all-debug.js",
"ender": "lib/ender.js",
"scripts": {
"prepublish": "make; vows"
"prepublish": "make && vows"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc