Comparing version 0.1.10 to 0.2.0
{ | ||
"name": "rgb2hex", | ||
"main": "rgb2hex.js", | ||
"version": "0.1.10", | ||
"version": "0.2.0", | ||
"homepage": "https://github.com/christian-bromann/rgb2hex", | ||
@@ -6,0 +6,0 @@ "authors": [ |
@@ -31,3 +31,3 @@ /** | ||
*/ | ||
var digits = /(.*?)rgb(a)??\((\d{1,3}),(\d{1,3}),(\d{1,3})(,([01]|0??\.([0-9]{0,})))??\)/.exec(strippedColor); | ||
var digits = /(.*?)rgb(a)??\((\d{1,3}),(\d{1,3}),(\d{1,3})(,([01]|1.0*|0??\.([0-9]{0,})))??\)/.exec(strippedColor); | ||
@@ -57,2 +57,2 @@ if(!digits) { | ||
}; | ||
}; | ||
}; |
{ | ||
"name": "rgb2hex", | ||
"version": "0.1.10", | ||
"version": "0.2.0", | ||
"description": "lightweight rgb/rgba to hex parser", | ||
"author": "Christian Bromann <mail@christian-bromann.com>", | ||
"license": "MIT", | ||
"homepage": "https://github.com/christian-bromann/rgb2hex", | ||
"main": "index.js", | ||
"directories": { | ||
"test": "test" | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/christian-bromann/rgb2hex.git" | ||
}, | ||
"devDependencies": { | ||
"coveralls": "^3.0.1", | ||
"jest": "^25.0.0" | ||
"bugs": { | ||
"url": "https://github.com/christian-bromann/rgb2hex/issues" | ||
}, | ||
@@ -17,5 +20,5 @@ "scripts": { | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/christian-bromann/rgb2hex.git" | ||
"devDependencies": { | ||
"coveralls": "^3.1.0", | ||
"jest": "^26.0.1" | ||
}, | ||
@@ -30,8 +33,2 @@ "keywords": [ | ||
], | ||
"author": "Christian Bromann <mail@christian-bromann.com>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/christian-bromann/rgb2hex/issues" | ||
}, | ||
"homepage": "https://github.com/christian-bromann/rgb2hex", | ||
"jest": { | ||
@@ -38,0 +35,0 @@ "coverageThreshold": { |
@@ -24,3 +24,3 @@ ;(function(window) { | ||
*/ | ||
var digits = /(.*?)rgb(a)??\((\d{1,3}),(\d{1,3}),(\d{1,3})(,([01]|0??\.([0-9]{0,})))??\)/.exec(strippedColor); | ||
var digits = /(.*?)rgb(a)??\((\d{1,3}),(\d{1,3}),(\d{1,3})(,([01]|1.0*|0??\.([0-9]{0,})))??\)/.exec(strippedColor); | ||
@@ -66,2 +66,2 @@ if(!digits) { | ||
}(window)); | ||
}(window)); |
@@ -1,1 +0,1 @@ | ||
!function(r){var e=function(r){if("string"!=typeof r)throw new Error("color has to be type of `string`");if("#"===r.substr(0,1))return{hex:r,alpha:1};var e=r.replace(/\s+/g,""),t=/(.*?)rgb(a)??\((\d{1,3}),(\d{1,3}),(\d{1,3})(,([01]|0??\.([0-9]{0,})))??\)/.exec(e);if(!t)throw new Error("given color ("+r+") isn't a valid rgb or rgba color");var n=parseInt(t[3],10),o=parseInt(t[4],10),a=parseInt(t[5],10),i=t[6]?/([0-9\.]+)/.exec(t[6])[0]:"1",s=(a|o<<8|n<<16|1<<24).toString(16).slice(1);return"."===i.substr(0,1)&&(i=parseFloat("0"+i)),1<i&&(i=1),i=parseFloat(Math.round(100*i))/100,{hex:"#"+s.toString(16),alpha:i}};"function"==typeof define&&define.amd?define("rgb2hex",function(){return e}):r.rgb2hex=e}(window); | ||
!function(r){var e=function(r){if("string"!=typeof r)throw new Error("color has to be type of `string`");if("#"===r.substr(0,1))return{hex:r,alpha:1};var e=r.replace(/\s+/g,""),t=/(.*?)rgb(a)??\((\d{1,3}),(\d{1,3}),(\d{1,3})(,([01]|1.0*|0??\.([0-9]{0,})))??\)/.exec(e);if(!t)throw new Error("given color ("+r+") isn't a valid rgb or rgba color");var n=parseInt(t[3],10),o=parseInt(t[4],10),a=parseInt(t[5],10),i=t[6]?/([0-9\.]+)/.exec(t[6])[0]:"1",s=(a|o<<8|n<<16|1<<24).toString(16).slice(1);return"."===i.substr(0,1)&&(i=parseFloat("0"+i)),1<i&&(i=1),i=parseFloat(Math.round(100*i))/100,{hex:"#"+s.toString(16),alpha:i}};"function"==typeof define&&define.amd?define("rgb2hex",function(){return e}):r.rgb2hex=e}(window); |
@@ -107,2 +107,8 @@ const rgb2hex = require('../index') | ||
}) | ||
it('double digit alpha values', () => { | ||
const input = 'rgba(0, 0, 0, 1.00)' | ||
expect(rgb2hex(input).alpha).toBe(1) | ||
expect(rgb2hex(input).hex).toBe('#000000') | ||
}) | ||
}) | ||
@@ -109,0 +115,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
262
15782