Socket
Socket
Sign inDemoInstall

colord

Package Overview
Dependencies
0
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.3.0 to 1.3.1

4

CHANGELOG.md

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

### 1.3.1
- Support modern CSS notations of RGB, HSL and LCH color functions
### 1.3.0

@@ -2,0 +6,0 @@

2

index.js

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

Object.defineProperty(exports,"__esModule",{value:!0});var r=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},t=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=Math.pow(10,t)),Math.round(n*r)/n},n=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),r>n?n:r>t?r:t},e=function(r){return{r:n(r.r,0,255),g:n(r.g,0,255),b:n(r.b,0,255),a:n(r.a)}},u=function(r){return{r:t(r.r),g:t(r.g),b:t(r.b),a:t(r.a,2)}},o=/^\s*#?([0-9a-f]{3,8})\s*$/i,a=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},i=function(r){var t=r.r,n=r.g,e=r.b,u=r.a,o=Math.max(t,n,e),a=o-Math.min(t,n,e),i=a?o===t?(n-e)/a:o===n?2+(e-t)/a:4+(t-n)/a:0;return{h:60*(i<0?i+6:i),s:o?a/o*100:0,v:o/255*100,a:u}},s=function(r){var t=r.h,n=r.s,e=r.v,u=r.a;t=t/360*6,n/=100,e/=100;var o=Math.floor(t),a=e*(1-n),i=e*(1-(t-o)*n),s=e*(1-(1-t+o)*n),b=o%6;return{r:255*[e,i,a,a,s,e][b],g:255*[s,e,e,i,a,a][b],b:255*[a,a,s,e,e,i][b],a:u}},b=function(r){return{h:n(r.h,0,360),s:n(r.s,0,100),l:n(r.l,0,100),a:n(r.a)}},h=function(r){return{h:t(r.h),s:t(r.s),l:t(r.l),a:t(r.a,2)}},f=function(r){return s((n=(t=r).s,{h:t.h,s:(n*=((e=t.l)<50?e:100-e)/100)>0?2*n/(e+n)*100:0,v:e+n,a:t.a}));var t,n,e},g=function(r){return{h:(t=i(r)).h,s:(u=(200-(n=t.s))*(e=t.v)/100)>0&&u<200?n*e/100/(u<=100?u:200-u)*100:0,l:u/2,a:t.a};var t,n,e,u},l=/hsla?\(?\s*(-?\d+\.?\d*),?\s*(-?\d+\.?\d*)%?,?\s*(-?\d+\.?\d*)%?,?\s*(-?\d*\.?\d+)?\s*\)?/i,p=/rgba?\(?\s*(-?\d+),?\s*(-?\d+),?\s*(-?\d+),?\s*(-?\d*\.?\d+)?\s*\)?/i,c={string:[function(r){var t=o.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:4===r.length?parseInt(r[3]+r[3],16)/255:1}:6===r.length||8===r.length?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:8===r.length?parseInt(r.substr(6,2),16)/255:1}:null:null},function(r){var t=p.exec(r);return t?e({r:Number(t[1]),g:Number(t[2]),b:Number(t[3]),a:void 0===t[4]?1:Number(t[4])}):null},function(r){var t=l.exec(r);if(!t)return null;var n=b({h:Number(t[1]),s:Number(t[2]),l:Number(t[3]),a:void 0===t[4]?1:Number(t[4])});return f(n)}],object:[function(t){var n=t.r,u=t.g,o=t.b,a=t.a,i=void 0===a?1:a;return r(n)&&r(u)&&r(o)?e({r:Number(n),g:Number(u),b:Number(o),a:Number(i)}):null},function(t){var n=t.h,e=t.s,u=t.l,o=t.a,a=void 0===o?1:o;if(!r(n)||!r(e)||!r(u))return null;var i=b({h:Number(n),s:Number(e),l:Number(u),a:Number(a)});return f(i)},function(t){var e=t.h,u=t.s,o=t.v,a=t.a,i=void 0===a?1:a;if(!r(e)||!r(u)||!r(o))return null;var b=function(r){return{h:n(r.h,0,360),s:n(r.s,0,100),v:n(r.v,0,100),a:n(r.a)}}({h:Number(e),s:Number(u),v:Number(o),a:Number(i)});return s(b)}]},v=function(r,t){for(var n=0;n<t.length;n++){var e=t[n](r);if(e)return e}return null},d=function(r,t){var e=g(r);return{h:e.h,s:n(e.s+100*t,0,100),l:e.l,a:e.a}},m=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},y=function(r,t){var e=g(r);return{h:e.h,s:e.s,l:n(e.l+100*t,0,100),a:e.a}},N=function(){function r(r){this.parsed=function(r){return"string"==typeof r?v(r,c.string):"object"==typeof r&&null!==r?v(r,c.object):null}(r),this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return null!==this.parsed},r.prototype.brightness=function(){return t(m(this.rgba),2)},r.prototype.isDark=function(){return m(this.rgba)<.5},r.prototype.isLight=function(){return m(this.rgba)>=.5},r.prototype.toHex=function(){return r=u(this.rgba),n=r.r,e=r.g,o=r.b,s=(i=r.a)<1?a(t(255*i)):"","#"+a(n)+a(e)+a(o)+s;var r,n,e,o,i,s},r.prototype.toRgb=function(){return u(this.rgba)},r.prototype.toRgbString=function(){return r=u(this.rgba),t=r.r,n=r.g,e=r.b,(o=r.a)<1?"rgba("+t+", "+n+", "+e+", "+o+")":"rgb("+t+", "+n+", "+e+")";var r,t,n,e,o},r.prototype.toHsl=function(){return h(g(this.rgba))},r.prototype.toHslString=function(){return r=h(g(this.rgba)),t=r.h,n=r.s,e=r.l,(u=r.a)<1?"hsla("+t+", "+n+"%, "+e+"%, "+u+")":"hsl("+t+", "+n+"%, "+e+"%)";var r,t,n,e,u},r.prototype.toHsv=function(){return r=i(this.rgba),{h:t(r.h),s:t(r.s),v:t(r.v),a:t(r.a,2)};var r},r.prototype.invert=function(){return x({r:255-(r=this.rgba).r,g:255-r.g,b:255-r.b,a:r.a});var r},r.prototype.saturate=function(r){return void 0===r&&(r=.1),x(d(this.rgba,r))},r.prototype.desaturate=function(r){return void 0===r&&(r=.1),x(d(this.rgba,-r))},r.prototype.grayscale=function(){return x(d(this.rgba,-1))},r.prototype.lighten=function(r){return void 0===r&&(r=.1),x(y(this.rgba,r))},r.prototype.darken=function(r){return void 0===r&&(r=.1),x(y(this.rgba,-r))},r.prototype.alpha=function(r){return"number"==typeof r?x({r:(n=this.rgba).r,g:n.g,b:n.b,a:r}):t(this.rgba.a,2);var n},r}(),x=function(r){return r instanceof N?r:new N(r)},I=[];exports.Colord=N,exports.colord=x,exports.extend=function(r){r.forEach(function(r){I.indexOf(r)<0&&(r(N,c),I.push(r))})};
Object.defineProperty(exports,"__esModule",{value:!0});var r=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},t=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=Math.pow(10,t)),Math.round(n*r)/n},n=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),r>n?n:r>t?r:t},e=function(r){return{r:n(r.r,0,255),g:n(r.g,0,255),b:n(r.b,0,255),a:n(r.a)}},u=function(r){return{r:t(r.r),g:t(r.g),b:t(r.b),a:t(r.a,2)}},o=/^\s*#?([0-9a-f]{3,8})\s*$/i,a=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},i=function(r){var t=r.r,n=r.g,e=r.b,u=r.a,o=Math.max(t,n,e),a=o-Math.min(t,n,e),i=a?o===t?(n-e)/a:o===n?2+(e-t)/a:4+(t-n)/a:0;return{h:60*(i<0?i+6:i),s:o?a/o*100:0,v:o/255*100,a:u}},s=function(r){var t=r.h,n=r.s,e=r.v,u=r.a;t=t/360*6,n/=100,e/=100;var o=Math.floor(t),a=e*(1-n),i=e*(1-(t-o)*n),s=e*(1-(1-t+o)*n),b=o%6;return{r:255*[e,i,a,a,s,e][b],g:255*[s,e,e,i,a,a][b],b:255*[a,a,s,e,e,i][b],a:u}},b=function(r){return{h:n(r.h,0,360),s:n(r.s,0,100),l:n(r.l,0,100),a:n(r.a)}},h=function(r){return{h:t(r.h),s:t(r.s),l:t(r.l),a:t(r.a,2)}},f=function(r){return s((n=(t=r).s,{h:t.h,s:(n*=((e=t.l)<50?e:100-e)/100)>0?2*n/(e+n)*100:0,v:e+n,a:t.a}));var t,n,e},g=function(r){return{h:(t=i(r)).h,s:(u=(200-(n=t.s))*(e=t.v)/100)>0&&u<200?n*e/100/(u<=100?u:200-u)*100:0,l:u/2,a:t.a};var t,n,e,u},l=/hsla?\(?\s*(-?\d+\.?\d*)(deg)?[,\s]+(-?\d+\.?\d*)%?[,\s]+(-?\d+\.?\d*)%?,?\s*[/\s]*(-?\d*\.?\d+)?(%)?\s*\)?/i,p=/rgba?\(?\s*(-?\d+\.?\d*)(%)?[,\s]+(-?\d+\.?\d*)(%)?[,\s]+(-?\d+\.?\d*)(%)?,?\s*[/\s]*(-?\d*\.?\d+)?(%)?\s*\)?/i,c={string:[function(r){var t=o.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:4===r.length?parseInt(r[3]+r[3],16)/255:1}:6===r.length||8===r.length?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:8===r.length?parseInt(r.substr(6,2),16)/255:1}:null:null},function(r){var t=p.exec(r);return t?e({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:void 0===t[7]?1:Number(t[7])/(t[8]?100:1)}):null},function(r){var t=l.exec(r);if(!t)return null;var n=b({h:Number(t[1]),s:Number(t[3]),l:Number(t[4]),a:void 0===t[5]?1:Number(t[5])/(t[6]?100:1)});return f(n)}],object:[function(t){var n=t.r,u=t.g,o=t.b,a=t.a,i=void 0===a?1:a;return r(n)&&r(u)&&r(o)?e({r:Number(n),g:Number(u),b:Number(o),a:Number(i)}):null},function(t){var n=t.h,e=t.s,u=t.l,o=t.a,a=void 0===o?1:o;if(!r(n)||!r(e)||!r(u))return null;var i=b({h:Number(n),s:Number(e),l:Number(u),a:Number(a)});return f(i)},function(t){var e=t.h,u=t.s,o=t.v,a=t.a,i=void 0===a?1:a;if(!r(e)||!r(u)||!r(o))return null;var b=function(r){return{h:n(r.h,0,360),s:n(r.s,0,100),v:n(r.v,0,100),a:n(r.a)}}({h:Number(e),s:Number(u),v:Number(o),a:Number(i)});return s(b)}]},v=function(r,t){for(var n=0;n<t.length;n++){var e=t[n](r);if(e)return e}return null},d=function(r,t){var e=g(r);return{h:e.h,s:n(e.s+100*t,0,100),l:e.l,a:e.a}},m=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},y=function(r,t){var e=g(r);return{h:e.h,s:e.s,l:n(e.l+100*t,0,100),a:e.a}},N=function(){function r(r){this.parsed=function(r){return"string"==typeof r?v(r,c.string):"object"==typeof r&&null!==r?v(r,c.object):null}(r),this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return null!==this.parsed},r.prototype.brightness=function(){return t(m(this.rgba),2)},r.prototype.isDark=function(){return m(this.rgba)<.5},r.prototype.isLight=function(){return m(this.rgba)>=.5},r.prototype.toHex=function(){return r=u(this.rgba),n=r.r,e=r.g,o=r.b,s=(i=r.a)<1?a(t(255*i)):"","#"+a(n)+a(e)+a(o)+s;var r,n,e,o,i,s},r.prototype.toRgb=function(){return u(this.rgba)},r.prototype.toRgbString=function(){return r=u(this.rgba),t=r.r,n=r.g,e=r.b,(o=r.a)<1?"rgba("+t+", "+n+", "+e+", "+o+")":"rgb("+t+", "+n+", "+e+")";var r,t,n,e,o},r.prototype.toHsl=function(){return h(g(this.rgba))},r.prototype.toHslString=function(){return r=h(g(this.rgba)),t=r.h,n=r.s,e=r.l,(u=r.a)<1?"hsla("+t+", "+n+"%, "+e+"%, "+u+")":"hsl("+t+", "+n+"%, "+e+"%)";var r,t,n,e,u},r.prototype.toHsv=function(){return r=i(this.rgba),{h:t(r.h),s:t(r.s),v:t(r.v),a:t(r.a,2)};var r},r.prototype.invert=function(){return x({r:255-(r=this.rgba).r,g:255-r.g,b:255-r.b,a:r.a});var r},r.prototype.saturate=function(r){return void 0===r&&(r=.1),x(d(this.rgba,r))},r.prototype.desaturate=function(r){return void 0===r&&(r=.1),x(d(this.rgba,-r))},r.prototype.grayscale=function(){return x(d(this.rgba,-1))},r.prototype.lighten=function(r){return void 0===r&&(r=.1),x(y(this.rgba,r))},r.prototype.darken=function(r){return void 0===r&&(r=.1),x(y(this.rgba,-r))},r.prototype.alpha=function(r){return"number"==typeof r?x({r:(n=this.rgba).r,g:n.g,b:n.b,a:r}):t(this.rgba.a,2);var n},r}(),x=function(r){return r instanceof N?r:new N(r)},I=[];exports.Colord=N,exports.colord=x,exports.extend=function(r){r.forEach(function(r){I.indexOf(r)<0&&(r(N,c),I.push(r))})};
{
"name": "colord",
"version": "1.3.0",
"version": "1.3.1",
"description": "👑 A tiny yet powerful tool for high-performance color manipulations and conversions",

@@ -5,0 +5,0 @@ "keywords": [

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

var t=function(t){return"string"==typeof t?t.length>0:"number"==typeof t},r=function(t,r,a){return void 0===r&&(r=0),void 0===a&&(a=Math.pow(10,r)),Math.round(a*t)/a},a=function(t,r,a){return void 0===r&&(r=0),void 0===a&&(a=1),t>a?a:t>r?t:r},n=function(t){var r=t/255;return r<.04045?r/12.92:Math.pow((r+.055)/1.055,2.4)},u=function(t){return 255*(t>.0031308?1.055*Math.pow(t,1/2.4)-.055:12.92*t)},h=function(t){var r,n=t.x/100,h=t.y/100,o=t.z/100;return r={r:u(3.2404542*n-1.5371385*h-.4985314*o),g:u(-.969266*n+1.8760108*h+.041556*o),b:u(.0556434*n-.2040259*h+1.0572252*o),a:t.a},{r:a(r.r,0,255),g:a(r.g,0,255),b:a(r.b,0,255),a:a(r.a)}},o=function(t){var r,u=n(t.r),h=n(t.g),o=n(t.b);return{x:a((r={x:100*(.4124564*u+.3575761*h+.1804375*o),y:100*(.2126729*u+.7151522*h+.072175*o),z:100*(.0193339*u+.119192*h+.9503041*o),a:t.a}).x,0,95.047),y:a(r.y,0,100),z:a(r.z,0,108.883),a:a(r.a)}},c=.0088564517,e=7.787037037,i=function(t){return{l:a(t.l,0,100),c:t.c,h:a(t.h,0,360),a:t.a}},l=function(t){return{l:r(t.l,2),c:r(t.c,2),h:r(t.h,2),a:r(t.a,2)}},b=function(r){var a=r.l,n=r.c,u=r.h,h=r.a,o=void 0===h?1:h;if(!t(a)||!t(n)||!t(u))return null;var c=i({l:Number(a),c:Number(n),h:Number(u),a:Number(o)});return f(c)},p=function(t){var r=function(t){var r=o(t),a=r.x/95.047,n=r.y/100,u=r.z/108.883;return a=a>c?Math.cbrt(a):e*a+16/116,{l:116*(n=n>c?Math.cbrt(n):e*n+16/116)-16,a:500*(a-n),b:200*(n-(u=u>c?Math.cbrt(u):e*u+16/116)),alpha:r.a}}(t),a=180*Math.atan2(r.b,r.a)/Math.PI;return{l:r.l,c:Math.sqrt(r.a*r.a+r.b*r.b),h:a<0?a+360:a,a:r.alpha}},f=function(t){return r={l:t.l,a:t.c*Math.cos(t.h*Math.PI/180),b:t.c*Math.sin(t.h*Math.PI/180),alpha:t.a},n=r.a/500+(a=(r.l+16)/116),u=a-r.b/200,h({x:95.047*(Math.pow(n,3)>c?Math.pow(n,3):(n-16/116)/e),y:100*(Math.pow(a,3)>c?Math.pow(a,3):(a-16/116)/e),z:108.883*(Math.pow(u,3)>c?Math.pow(u,3):(u-16/116)/e),a:r.alpha});var r,a,n,u},M=/lcha?\(?\s*(-?\d+\.?\d*)%?,?\s*(-?\d+\.?\d*),?\s*(-?\d+\.?\d*),?\s*\/?\s*(-?\d*\.?\d+)?\s*\)?/i,v=function(t){var r=M.exec(t);if(!r)return null;var a=i({l:Number(r[1]),c:Number(r[2]),h:Number(r[3]),a:void 0===r[4]?1:Number(r[4])});return f(a)};module.exports=function(t,r){t.prototype.toLch=function(){return l(p(this.rgba))},t.prototype.toLchString=function(){return t=l(p(this.rgba)),r=t.l,a=t.c,n=t.h,(u=t.a)<1?"lch("+r+"% "+a+" "+n+" / "+u+")":"lch("+r+"% "+a+" "+n+")";var t,r,a,n,u},r.string.push(v),r.object.push(b)};
var t=function(t){return"string"==typeof t?t.length>0:"number"==typeof t},r=function(t,r,a){return void 0===r&&(r=0),void 0===a&&(a=Math.pow(10,r)),Math.round(a*t)/a},a=function(t,r,a){return void 0===r&&(r=0),void 0===a&&(a=1),t>a?a:t>r?t:r},n=function(t){var r=t/255;return r<.04045?r/12.92:Math.pow((r+.055)/1.055,2.4)},u=function(t){return 255*(t>.0031308?1.055*Math.pow(t,1/2.4)-.055:12.92*t)},h=function(t){var r,n=t.x/100,h=t.y/100,o=t.z/100;return r={r:u(3.2404542*n-1.5371385*h-.4985314*o),g:u(-.969266*n+1.8760108*h+.041556*o),b:u(.0556434*n-.2040259*h+1.0572252*o),a:t.a},{r:a(r.r,0,255),g:a(r.g,0,255),b:a(r.b,0,255),a:a(r.a)}},o=function(t){var r,u=n(t.r),h=n(t.g),o=n(t.b);return{x:a((r={x:100*(.4124564*u+.3575761*h+.1804375*o),y:100*(.2126729*u+.7151522*h+.072175*o),z:100*(.0193339*u+.119192*h+.9503041*o),a:t.a}).x,0,95.047),y:a(r.y,0,100),z:a(r.z,0,108.883),a:a(r.a)}},c=.0088564517,e=7.787037037,i=function(t){return{l:a(t.l,0,100),c:t.c,h:a(t.h,0,360),a:t.a}},l=function(t){return{l:r(t.l,2),c:r(t.c,2),h:r(t.h,2),a:r(t.a,2)}},b=function(r){var a=r.l,n=r.c,u=r.h,h=r.a,o=void 0===h?1:h;if(!t(a)||!t(n)||!t(u))return null;var c=i({l:Number(a),c:Number(n),h:Number(u),a:Number(o)});return f(c)},p=function(t){var r=function(t){var r=o(t),a=r.x/95.047,n=r.y/100,u=r.z/108.883;return a=a>c?Math.cbrt(a):e*a+16/116,{l:116*(n=n>c?Math.cbrt(n):e*n+16/116)-16,a:500*(a-n),b:200*(n-(u=u>c?Math.cbrt(u):e*u+16/116)),alpha:r.a}}(t),a=180*Math.atan2(r.b,r.a)/Math.PI;return{l:r.l,c:Math.sqrt(r.a*r.a+r.b*r.b),h:a<0?a+360:a,a:r.alpha}},f=function(t){return r={l:t.l,a:t.c*Math.cos(t.h*Math.PI/180),b:t.c*Math.sin(t.h*Math.PI/180),alpha:t.a},n=r.a/500+(a=(r.l+16)/116),u=a-r.b/200,h({x:95.047*(Math.pow(n,3)>c?Math.pow(n,3):(n-16/116)/e),y:100*(Math.pow(a,3)>c?Math.pow(a,3):(a-16/116)/e),z:108.883*(Math.pow(u,3)>c?Math.pow(u,3):(u-16/116)/e),a:r.alpha});var r,a,n,u},M=/lcha?\(?\s*(-?\d+\.?\d*)%?[,\s]+(-?\d+\.?\d*)[,\s]+(-?\d+\.?\d*),?\s*[/\s]*(-?\d*\.?\d+)?(%)?\s*\)?/i,v=function(t){var r=M.exec(t);if(!r)return null;var a=i({l:Number(r[1]),c:Number(r[2]),h:Number(r[3]),a:void 0===r[4]?1:Number(r[4])/(r[5]?100:1)});return f(a)};module.exports=function(t,r){t.prototype.toLch=function(){return l(p(this.rgba))},t.prototype.toLchString=function(){return t=l(p(this.rgba)),r=t.l,a=t.c,n=t.h,(u=t.a)<1?"lch("+r+"% "+a+" "+n+" / "+u+")":"lch("+r+"% "+a+" "+n+")";var t,r,a,n,u},r.string.push(v),r.object.push(b)};

@@ -115,3 +115,3 @@ <div align="center">

colord(" aBc ").toHex(); // "#aabbcc"
colord("__rGbA 10 20, 999...").toRgbString(); // "rgb(10, 20, 255)"
colord("__rGbA 10 20,, 999...").toRgbString(); // "rgb(10, 20, 255)"
colord(" hsL( 10, 200% 30 .5!!!").toHslString(); // "hsla(10, 100%, 30%, 0.5)"

@@ -118,0 +118,0 @@ colord({ r: NaN, g: -Infinity, b: +Infinity, a: 100500 }).toRgb(); // { r: 0, g: 0, b: 255, a: 1 }

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc