Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

polychrome

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

polychrome - npm Package Compare versions

Comparing version 4.1.0 to 4.1.1

2

dist/polychrome.es.js

@@ -234,3 +234,3 @@ var patterns = {

var contrastColor = baseColor.isDark() ? lightColor : darkColor;
var contrastColor = baseColor.luma < 128 ? lightColor : darkColor;

@@ -237,0 +237,0 @@ /**

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

!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):n.polychrome=r()}(this,function(){"use strict";var n={hex:/^#(?:[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,rgb:/^rgba?\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),?\s*(\d?\.?\d+)?\)$/,hsl:/^hsla?\((\d{1,3}),\s*(\d{1,3})%,\s*(\d{1,3})%,?\s*(\d?\.?\d+)?\)$/},r=Object.assign({},n,{asList:Object.keys(n).map(function(r){return{name:r,regex:n[r]}})}),t=function(n,r,t){return[n,r,t].map(function(n){return parseInt(n,16)})},e=function(n,r,t){return[n,r,t].map(function(n){return("0"+parseInt(n,10).toString(16)).toUpperCase().slice(-2)})},u=function(n,r,t,e){void 0===e&&(e=1);var u=[n,r,t].map(function(n){return n/255}),i=u[0],o=u[1],a=u[2],f=Math.max(i,o,a),c=Math.min(i,o,a),s=f-c,l=(f+c)/2;if(f===c)return[0,0,Math.round(100*l),e];var p=l<.5?s/(f+c):s/(2-f-c),d=[i,o,a].map(function(n){return((f-n)/6+s/2)/s}),v=d[0],h=d[1],m=d[2],g=0;switch(f){case i:g=m-h;break;case o:g=1/3+v-m;break;case a:g=2/3+h-v}return g<0&&(g+=1),g>1&&(g-=1),[360*g,100*p,100*l,e].map(function(n){return Math.round(n)})},i=function(n,r,t,e){void 0===e&&(e=1);var u=[n/360,r/100,t/100],i=u[0],o=u[1],a=u[2];if(0==o)return[a,a,a].map(function(n){return Math.round(255*n)}).concat(e);var f=function(n,r,t){return t<0&&(t+=1),t>1&&(t-=1),6*t<1?n+6*(r-n)*t:2*t<1?r:3*t<2?n+(r-n)*(2/3-t)*6:n},c=a<.5?a*(1+o):a+o-a*o,s=2*a-c;return[f(s,c,i+1/3),f(s,c,i),f(s,c,i-1/3)].map(function(n){return Math.round(255*n)}).concat(e)},o=function(n,r){var t=r/100;return n?n*t:t},a=function(n,r){return n?n*(r/100):r},f=function(n,r){if(void 0===r&&(r=null),null===r)return n;var t=n.h,e=n.s,u=n.a,i=r>100?100:r<0?0:r;return w.fromHsl(t,e,i,u)},c=function(n,r){void 0===r&&(r=10);var t=n.l;return f(n,t+a(t,r))},s=function(n,r){void 0===r&&(r=10);var t=n.l;return f(n,t-a(t,r))},l=function(n,r){if(void 0===r&&(r=null),null===r)return n;var t=n.h,e=n.s,u=n.l,i=r>100?1:r<0?0:r/100;return w.fromHsl(t,e,u,i)},p=function(n,r){void 0===r&&(r=50);var t=n.a;return l(n,100*(t+o(t,r)))},d=function(n,r){void 0===r&&(r=50);var t=n.a;return l(n,100*(t-o(t,r)))},v=function(n,r){if(void 0===r&&(r=null),null===r)return n;var t=n.h,e=n.l,u=n.a,i=r>100?100:r<0?0:r;return w.fromHsl(t,i,e,u)},h=function(n,r){void 0===r&&(r=10);var t=n.s;return v(n,t+a(t,r))},m=function(n,r){void 0===r&&(r=10);var t=n.s;return v(n,t-a(t,r))},g=function(n){return v(n,0)},b=function(n,r){if(null===r)return n;var t=n.s,e=n.l,u=n.a;return w.fromHsl(r,t,e,u)},x=function(n,r){return void 0===r&&(r=0),b(n,(n.h+r+360)%360)},H=function(n){return x(n,180)},y=function(n,r){var t="string"==typeof r?L(r):r,e=n.r,u=n.g,i=n.b,o=n.a;return w.fromRgb.apply(w,Object.keys({r:e,g:u,b:i,a:o}).map(function(r){return(n[r]+t[r])/2}))},M=function(n){return y(n,"#FFF")},F=function(n){return y(n,"#000")},I=function(n){var r=[n.r,n.g,n.b].map(function(n){var r=n/255;return r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)});return.2126*r[0]+.7152*r[1]+.0722*r[2]},k=function(n,r,t){void 0===r&&(r=L("#000")),void 0===t&&(t=L("#FFF"));var e=L(n),u="string"==typeof r?L(r):r,i="string"==typeof t?L(t):t,o=e.isDark()?i:u,a=[I(e),I(o)];return(Math.max.apply(Math,a)+.05)/(Math.min.apply(Math,a)+.05)>=4.5?o:k(e,u.darken(1),i.lighten(1))},j=function(n,r,t){return(299*n+587*r+114*t)/1e3},O=function(n){var r=n.rHex,t=n.gHex,e=n.bHex,u=n.r,i=n.g,o=n.b,a=n.h,I=n.s,O=n.l,w=n.a;void 0===w&&(w=1);var A=Object.assign({},n,{hex:function(){return"#"+r+t+e},rgb:function(){return w<1?"rgba("+u+","+i+","+o+","+w+")":"rgb("+u+","+i+","+o+")"},hsl:function(){return w<1?"hsla("+a+","+I+"%,"+O+"%,"+w+")":"hsl("+a+","+I+"%,"+O+"%)"},luma:j(u,i,o)});return Object.assign({},A,{isDark:function(){return A.luma<128},isLight:function(){return A.luma>=128},setHue:function(n){return b(A,n)},spin:function(n){return x(A,n)},complimentary:function(){return H(A)},setLightness:function(n){return f(A,n)},darken:function(n){return s(A,n)},lighten:function(n){return c(A,n)},setAlpha:function(n){return l(A,n)},fadeIn:function(n){return p(A,n)},fadeOut:function(n){return d(A,n)},contrast:function(n,r){return k(A,n,r)},setSaturation:function(n){return v(A,n)},saturate:function(n){return h(A,n)},desaturate:function(n){return m(A,n)},grayscale:function(){return g(A)},mix:function(n){return y(A,n)},shade:function(){return F(A)},tint:function(){return M(A)}})},w={fromHex:function(n,r,e){var i=t(n,r,e),o=i[0],a=i[1],f=i[2],c=u(o,a,f);return O({rHex:n,gHex:r,bHex:e,r:o,g:a,b:f,h:c[0],s:c[1],l:c[2],a:c[3]})},fromRgb:function(n,r,t,i){void 0===i&&(i=1);var o=e(n,r,t),a=o[0],f=o[1],c=o[2],s=u(n,r,t);return O({rHex:a,gHex:f,bHex:c,r:n,g:r,b:t,h:s[0],s:s[1],l:s[2],a:i})},fromHsl:function(n,r,t,u){void 0===u&&(u=1);var o=i(n,r,t),a=o[0],f=o[1],c=o[2],s=e(a,f,c);return O({rHex:s[0],gHex:s[1],bHex:s[2],r:a,g:f,b:c,h:n,s:r,l:t,a:u})}},A={hex:function n(r){var n=r.replace("#","");return n.length<6&&(n=n.split("").map(function(n){return n.concat(n)}).join("")),[n.slice(0,2),n.slice(2,4),n.slice(4,6)]},rgb:function(n){var t=n.match(r.rgb).slice(1),e=t[0],u=t[1],i=t[2],o=t[3];return void 0===o&&(o=1),[parseInt(e),parseInt(u),parseInt(i),parseFloat(o)]},hsl:function(n){var t=n.match(r.hsl).slice(1),e=t[0],u=t[1],i=t[2],o=t[3];return void 0===o&&(o=1),[parseInt(e),parseInt(u),parseInt(i),parseFloat(o)]}},L=function(n){if(!n)return w.fromRgb(0,0,0);if("string"!=typeof n)return n;var t=r.asList.filter(function(r){return n.match(r.regex)});if(!t.length)throw new Error("No matching color patterns found for "+n);return t.reduce(function(r,t){var e=t.name;return w["from"+e.charAt(0).toUpperCase()+e.slice(1)].apply(w,A[e](n))},{})};return L});
!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):n.polychrome=r()}(this,function(){"use strict";var n={hex:/^#(?:[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,rgb:/^rgba?\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),?\s*(\d?\.?\d+)?\)$/,hsl:/^hsla?\((\d{1,3}),\s*(\d{1,3})%,\s*(\d{1,3})%,?\s*(\d?\.?\d+)?\)$/},r=Object.assign({},n,{asList:Object.keys(n).map(function(r){return{name:r,regex:n[r]}})}),t=function(n,r,t){return[n,r,t].map(function(n){return parseInt(n,16)})},e=function(n,r,t){return[n,r,t].map(function(n){return("0"+parseInt(n,10).toString(16)).toUpperCase().slice(-2)})},u=function(n,r,t,e){void 0===e&&(e=1);var u=[n,r,t].map(function(n){return n/255}),i=u[0],o=u[1],a=u[2],f=Math.max(i,o,a),c=Math.min(i,o,a),s=f-c,l=(f+c)/2;if(f===c)return[0,0,Math.round(100*l),e];var p=l<.5?s/(f+c):s/(2-f-c),d=[i,o,a].map(function(n){return((f-n)/6+s/2)/s}),v=d[0],h=d[1],m=d[2],g=0;switch(f){case i:g=m-h;break;case o:g=1/3+v-m;break;case a:g=2/3+h-v}return g<0&&(g+=1),g>1&&(g-=1),[360*g,100*p,100*l,e].map(function(n){return Math.round(n)})},i=function(n,r,t,e){void 0===e&&(e=1);var u=[n/360,r/100,t/100],i=u[0],o=u[1],a=u[2];if(0==o)return[a,a,a].map(function(n){return Math.round(255*n)}).concat(e);var f=function(n,r,t){return t<0&&(t+=1),t>1&&(t-=1),6*t<1?n+6*(r-n)*t:2*t<1?r:3*t<2?n+(r-n)*(2/3-t)*6:n},c=a<.5?a*(1+o):a+o-a*o,s=2*a-c;return[f(s,c,i+1/3),f(s,c,i),f(s,c,i-1/3)].map(function(n){return Math.round(255*n)}).concat(e)},o=function(n,r){var t=r/100;return n?n*t:t},a=function(n,r){return n?n*(r/100):r},f=function(n,r){if(void 0===r&&(r=null),null===r)return n;var t=n.h,e=n.s,u=n.a,i=r>100?100:r<0?0:r;return w.fromHsl(t,e,i,u)},c=function(n,r){void 0===r&&(r=10);var t=n.l;return f(n,t+a(t,r))},s=function(n,r){void 0===r&&(r=10);var t=n.l;return f(n,t-a(t,r))},l=function(n,r){if(void 0===r&&(r=null),null===r)return n;var t=n.h,e=n.s,u=n.l,i=r>100?1:r<0?0:r/100;return w.fromHsl(t,e,u,i)},p=function(n,r){void 0===r&&(r=50);var t=n.a;return l(n,100*(t+o(t,r)))},d=function(n,r){void 0===r&&(r=50);var t=n.a;return l(n,100*(t-o(t,r)))},v=function(n,r){if(void 0===r&&(r=null),null===r)return n;var t=n.h,e=n.l,u=n.a,i=r>100?100:r<0?0:r;return w.fromHsl(t,i,e,u)},h=function(n,r){void 0===r&&(r=10);var t=n.s;return v(n,t+a(t,r))},m=function(n,r){void 0===r&&(r=10);var t=n.s;return v(n,t-a(t,r))},g=function(n){return v(n,0)},b=function(n,r){if(null===r)return n;var t=n.s,e=n.l,u=n.a;return w.fromHsl(r,t,e,u)},x=function(n,r){return void 0===r&&(r=0),b(n,(n.h+r+360)%360)},H=function(n){return x(n,180)},y=function(n,r){var t="string"==typeof r?L(r):r,e=n.r,u=n.g,i=n.b,o=n.a;return w.fromRgb.apply(w,Object.keys({r:e,g:u,b:i,a:o}).map(function(r){return(n[r]+t[r])/2}))},M=function(n){return y(n,"#FFF")},F=function(n){return y(n,"#000")},I=function(n){var r=[n.r,n.g,n.b].map(function(n){var r=n/255;return r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)});return.2126*r[0]+.7152*r[1]+.0722*r[2]},j=function(n,r,t){void 0===r&&(r=L("#000")),void 0===t&&(t=L("#FFF"));var e=L(n),u="string"==typeof r?L(r):r,i="string"==typeof t?L(t):t,o=e.luma<128?i:u,a=[I(e),I(o)];return(Math.max.apply(Math,a)+.05)/(Math.min.apply(Math,a)+.05)>=4.5?o:j(e,u.darken(1),i.lighten(1))},k=function(n,r,t){return(299*n+587*r+114*t)/1e3},O=function(n){var r=n.rHex,t=n.gHex,e=n.bHex,u=n.r,i=n.g,o=n.b,a=n.h,I=n.s,O=n.l,w=n.a;void 0===w&&(w=1);var A=Object.assign({},n,{hex:function(){return"#"+r+t+e},rgb:function(){return w<1?"rgba("+u+","+i+","+o+","+w+")":"rgb("+u+","+i+","+o+")"},hsl:function(){return w<1?"hsla("+a+","+I+"%,"+O+"%,"+w+")":"hsl("+a+","+I+"%,"+O+"%)"},luma:k(u,i,o)});return Object.assign({},A,{isDark:function(){return A.luma<128},isLight:function(){return A.luma>=128},setHue:function(n){return b(A,n)},spin:function(n){return x(A,n)},complimentary:function(){return H(A)},setLightness:function(n){return f(A,n)},darken:function(n){return s(A,n)},lighten:function(n){return c(A,n)},setAlpha:function(n){return l(A,n)},fadeIn:function(n){return p(A,n)},fadeOut:function(n){return d(A,n)},contrast:function(n,r){return j(A,n,r)},setSaturation:function(n){return v(A,n)},saturate:function(n){return h(A,n)},desaturate:function(n){return m(A,n)},grayscale:function(){return g(A)},mix:function(n){return y(A,n)},shade:function(){return F(A)},tint:function(){return M(A)}})},w={fromHex:function(n,r,e){var i=t(n,r,e),o=i[0],a=i[1],f=i[2],c=u(o,a,f);return O({rHex:n,gHex:r,bHex:e,r:o,g:a,b:f,h:c[0],s:c[1],l:c[2],a:c[3]})},fromRgb:function(n,r,t,i){void 0===i&&(i=1);var o=e(n,r,t),a=o[0],f=o[1],c=o[2],s=u(n,r,t);return O({rHex:a,gHex:f,bHex:c,r:n,g:r,b:t,h:s[0],s:s[1],l:s[2],a:i})},fromHsl:function(n,r,t,u){void 0===u&&(u=1);var o=i(n,r,t),a=o[0],f=o[1],c=o[2],s=e(a,f,c);return O({rHex:s[0],gHex:s[1],bHex:s[2],r:a,g:f,b:c,h:n,s:r,l:t,a:u})}},A={hex:function n(r){var n=r.replace("#","");return n.length<6&&(n=n.split("").map(function(n){return n.concat(n)}).join("")),[n.slice(0,2),n.slice(2,4),n.slice(4,6)]},rgb:function(n){var t=n.match(r.rgb).slice(1),e=t[0],u=t[1],i=t[2],o=t[3];return void 0===o&&(o=1),[parseInt(e),parseInt(u),parseInt(i),parseFloat(o)]},hsl:function(n){var t=n.match(r.hsl).slice(1),e=t[0],u=t[1],i=t[2],o=t[3];return void 0===o&&(o=1),[parseInt(e),parseInt(u),parseInt(i),parseFloat(o)]}},L=function(n){if(!n)return w.fromRgb(0,0,0);if("string"!=typeof n)return n;var t=r.asList.filter(function(r){return n.match(r.regex)});if(!t.length)throw new Error("No matching color patterns found for "+n);return t.reduce(function(r,t){var e=t.name;return w["from"+e.charAt(0).toUpperCase()+e.slice(1)].apply(w,A[e](n))},{})};return L});
//# sourceMappingURL=polychrome.js.map
{
"name": "polychrome",
"version": "4.1.0",
"version": "4.1.1",
"author": "Chad Donohue <chad.donohue@gmail.com>",

@@ -5,0 +5,0 @@ "description": "A small library for parsing and manipulating colors",

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc