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

emphasizer

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

emphasizer - npm Package Compare versions

Comparing version 1.1.4 to 1.1.5

2

dist/index.js

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jolor=require("jolor");function emphasizeNumberBase(e,t,i,r,n){var s=e<=t,o=Math.min(e,t),a=Math.max(e,t),u=a-o,h=i<=r,p=Math.min(i,r),m=u/(Math.max(i,r)-p)*(n-p);return m=Math.round(100*m)/100,keepRange(e,t,s==h?o+m:a-m)}function keepRange(e,t,i){var r=Math.max(e,t),n=Math.min(e,t);return i<n?n:r<i?r:i}function emphasizeNumber(e,t,i,r,n){return"number"==typeof r&&"number"==typeof n?emphasizeNumberBase(e,t,i,r,n):emphasizeNumberBase(e,t,0,1,i)}var SizePatterns={length:/\d+[a-z%]*/gi,number:/\d+/gi,dimension:/[a-z%]+/gi,lenght1:/^\s*(\s*\d+[a-z%]*\s*){1}\s*(;)?\s*$/gi,lenght2:/^\s*(\s*\d+[a-z%]*\s*){2}\s*(;)?\s*$/gi,lenght3:/^\s*(\s*\d+[a-z%]*\s*){3}\s*(;)?\s*$/gi,lenght4:/^\s*(\s*\d+[a-z%]*\s*){4}\s*(;)?\s*$/gi},SizeValue=function(){function i(e){if(this.units=[],"string"==typeof e)i.isSize(e)&&(this.units=this.parseUnits(e),(t=this.units.find(function(e){return e.dimension}))&&(this.dimension=t.dimension));else if(Array.isArray(e)){var t;this.units=e,(t=this.units.find(function(e){return e.dimension}))&&(this.dimension=t.dimension)}}return i.isSize=function(e){return i.isSingle(e)||i.isDouble(e)||i.isTriple(e)||i.isQuadro(e)},i.isSingle=function(e){return i.isMatched(SizePatterns.lenght1,e)},i.isDouble=function(e){return i.isMatched(SizePatterns.lenght2,e)},i.isTriple=function(e){return i.isMatched(SizePatterns.lenght3,e)},i.isQuadro=function(e){return i.isMatched(SizePatterns.lenght4,e)},i.isMatched=function(e,t){return"string"==typeof t&&null!==t.match(e)},i.prototype.toString=function(){for(var e="",t=0,i=this.units;t<i.length;t++){e+=""+i[t].value+this.dimension+" "}return e.replace(/\s*$/g,"")},i.prototype.isMatched=function(e){return this.units.length===e.units.length&&this.dimension===e.dimension},i.prototype.parseUnits=function(e){var t=[],i=e.match(SizePatterns.length);if(i)for(var r=0,n=i;r<n.length;r++){var s=n[r],o={value:parseFloat(this.firstMatch(SizePatterns.number,s)||"0"),dimension:this.firstMatch(SizePatterns.dimension,s)};t.push(o)}return t},i.prototype.firstMatch=function(e,t){var i,r=t.match(e);return r&&(i=r[0]),i},i}();function emphasizeColorBase(e,t,i,r,n){var s=new jolor.Color(e),o=new jolor.Color(t),a=Math.round(emphasizeNumber(s.rgbObject.r,o.rgbObject.r,i,r,n)),u=Math.round(emphasizeNumber(s.rgbObject.g,o.rgbObject.g,i,r,n)),h=Math.round(emphasizeNumber(s.rgbObject.b,o.rgbObject.b,i,r,n)),p=Math.round(emphasizeNumber(s.opacity,o.opacity,i,r,n));return jolor.toHex(a,u,h,p)||e}function emphasizeColor(e,t,i,r,n){return"number"==typeof r&&"number"==typeof n?emphasizeColorBase(e,t,i,r,n):emphasizeColorBase(e,t,0,1,i)}function splitColor(e,t,i){for(var r=[],n=1;n<=i;n++)r.push(emphasizeColorBase(e,t,1,i,n));return r}function sizeValue(e,t,i,r,n){if(e.isMatched(t)){for(var s=e.dimension,o=[],a=0;a<e.units.length;a++){var u=e.units[a],h=t.units[a];o.push({dimension:s,value:emphasizeNumber(u.value,h.value,i,r,n)})}return new SizeValue(o).toString()}}function emphasizeStylePropertyBase(e,t,i,r,n){if("number"==typeof e&&"number"==typeof t)return emphasizeNumber(e,t,i,r,n);if("string"==typeof e&&"string"==typeof t){if(jolor.Color.isColor(e))return emphasizeColor(e,t,i,r,n);if(SizeValue.isSize(e))return sizeValue(new SizeValue(e),new SizeValue(t),i,r,n)}return void 0===e?t:e}function emphasizeStyleProperty(e,t,i,r,n){return"number"==typeof r&&"number"==typeof n?emphasizeStylePropertyBase(e,t,i,r,n):emphasizeStylePropertyBase(e,t,0,1,i)}function emphasizeStyleBase(e,t,i,r,n){var s={};for(var o in e)e.hasOwnProperty(o)&&t.hasOwnProperty(o)&&(s[o]=emphasizeStyleProperty(e[o],t[o],i,r,n));return s}function emphasizeStyle(e,t,i,r,n){return"number"==typeof r&&"number"==typeof n?emphasizeStyleBase(e,t,i,r,n):emphasizeStyleBase(e,t,0,1,i)}exports.SizeValue=SizeValue,exports.emphasizeColor=emphasizeColor,exports.emphasizeNumber=emphasizeNumber,exports.emphasizeStyle=emphasizeStyle,exports.emphasizeStyleProperty=emphasizeStyleProperty,exports.splitColor=splitColor;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jolor=require("jolor");function emphasizeNumberBase(e,t,r,i,n){var s=e<=t,o=Math.min(e,t),a=Math.max(e,t),u=a-o,h=r<=i,p=Math.min(r,i),l=u/(Math.max(r,i)-p)*(n-p);return l=Math.round(100*l)/100,keepRange(e,t,s==h?o+l:a-l)}function keepRange(e,t,r){var i=Math.max(e,t),n=Math.min(e,t);return r<n?n:i<r?i:r}function emphasizeNumber(e,t,r,i,n){return"number"==typeof i&&"number"==typeof n?emphasizeNumberBase(e,t,r,i,n):emphasizeNumberBase(e,t,0,1,r)}var SizePatterns={length:/\d+[a-z%]*/gi,number:/\d+/gi,dimension:/[a-z%]+/gi,lenght1:/^\s*(\s*\d+[a-z%]*\s*){1}\s*(;)?\s*$/gi,lenght2:/^\s*(\s*\d+[a-z%]*\s*){2}\s*(;)?\s*$/gi,lenght3:/^\s*(\s*\d+[a-z%]*\s*){3}\s*(;)?\s*$/gi,lenght4:/^\s*(\s*\d+[a-z%]*\s*){4}\s*(;)?\s*$/gi},SizeValue=function(){function r(e){if(this.units=[],"string"==typeof e)r.isSize(e)&&(this.units=this.parseUnits(e),(t=this.units.find(function(e){return e.dimension}))&&(this.dimension=t.dimension));else if(Array.isArray(e)){var t;this.units=e,(t=this.units.find(function(e){return e.dimension}))&&(this.dimension=t.dimension)}}return r.isSize=function(e){return r.isSingle(e)||r.isDouble(e)||r.isTriple(e)||r.isQuadro(e)},r.isSingle=function(e){return r.isMatched(SizePatterns.lenght1,e)},r.isDouble=function(e){return r.isMatched(SizePatterns.lenght2,e)},r.isTriple=function(e){return r.isMatched(SizePatterns.lenght3,e)},r.isQuadro=function(e){return r.isMatched(SizePatterns.lenght4,e)},r.isMatched=function(e,t){return"string"==typeof t&&null!==t.match(e)},r.prototype.toString=function(){for(var e="",t=0,r=this.units;t<r.length;t++){e+=""+r[t].value+this.dimension+" "}return e.replace(/\s*$/g,"")},r.prototype.isMatched=function(e){return this.units.length===e.units.length&&this.dimension===e.dimension},r.prototype.parseUnits=function(e){var t=[],r=e.match(SizePatterns.length);if(r)for(var i=0,n=r;i<n.length;i++){var s=n[i],o={value:parseFloat(this.firstMatch(SizePatterns.number,s)||"0"),dimension:this.firstMatch(SizePatterns.dimension,s)};t.push(o)}return t},r.prototype.firstMatch=function(e,t){var r,i=t.match(e);return i&&(r=i[0]),r},r}();function emphasizeColorBase(e,t,r,i,n){var s=new jolor.Color(e),o=new jolor.Color(t),a=Math.round(emphasizeNumber(s.rgbObject.r,o.rgbObject.r,r,i,n)),u=Math.round(emphasizeNumber(s.rgbObject.g,o.rgbObject.g,r,i,n)),h=Math.round(emphasizeNumber(s.rgbObject.b,o.rgbObject.b,r,i,n)),p=Math.round(emphasizeNumber(s.opacity,o.opacity,r,i,n));return jolor.toHex(a,u,h,p)||e}function emphasizeColor(e,t,r,i,n){return"number"==typeof i&&"number"==typeof n?emphasizeColorBase(e,t,r,i,n):emphasizeColorBase(e,t,0,1,r)}function splitColor(e,t,r){for(var i=[],n=1;n<=r;n++)i.push(emphasizeColorBase(e,t,1,r,n));return i}function sizeValue(e,t,r,i,n){if(e.isMatched(t)){for(var s=e.dimension,o=[],a=0;a<e.units.length;a++){var u=e.units[a],h=t.units[a];o.push({dimension:s,value:emphasizeNumber(u.value,h.value,r,i,n)})}return new SizeValue(o).toString()}}function emphasizeStylePropertyBase(e,t,r,i,n){if("number"==typeof e&&"number"==typeof t)return emphasizeNumber(e,t,r,i,n);if("string"==typeof e&&"string"==typeof t){if(jolor.Color.isColor(e))return emphasizeColor(e,t,r,i,n);if(SizeValue.isSize(e))return sizeValue(new SizeValue(e),new SizeValue(t),r,i,n)}return void 0===e?t:e}function emphasizeStyleProperty(e,t,r,i,n){return"number"==typeof i&&"number"==typeof n?emphasizeStylePropertyBase(e,t,r,i,n):emphasizeStylePropertyBase(e,t,0,1,r)}function emphasizeStyleBase(e,t,r,i,n){for(var s={},o=0,a=Object.keys(e).concat(Object.keys(t));o<a.length;o++){var u=a[o];(e.hasOwnProperty(u)||t.hasOwnProperty(u))&&(s[u]=emphasizeStyleProperty(e[u],t[u],r,i,n))}return s}function emphasizeStyle(e,t,r,i,n){return"number"==typeof i&&"number"==typeof n?emphasizeStyleBase(e,t,r,i,n):emphasizeStyleBase(e,t,0,1,r)}exports.SizeValue=SizeValue,exports.emphasizeColor=emphasizeColor,exports.emphasizeNumber=emphasizeNumber,exports.emphasizeStyle=emphasizeStyle,exports.emphasizeStyleProperty=emphasizeStyleProperty,exports.splitColor=splitColor;
{
"name": "emphasizer",
"version": "1.1.4",
"version": "1.1.5",
"description": "React style emphasizer",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

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