colorformat
Advanced tools
Comparing version 1.1.1 to 1.2.1
@@ -38,3 +38,6 @@ (function (root, factory) { | ||
if(h.length != 6) throw new TypeError('Expected a 6 digit hex'); | ||
if(h.length === 3) h = h.replace(/(\w)/g, '$&$&'); | ||
if(h.length != 6) throw new TypeError('Expected a 3 or 6 digit hex'); | ||
if(options && options.styling) | ||
@@ -41,0 +44,0 @@ return 'rgb(' + decToHex(h[0]+h[1]) + ', ' + decToHex(h[2]+h[3]) + ', ' + decToHex(h[4]+h[5]) + ')'; |
{ | ||
"name": "colorformat", | ||
"version": "1.1.1", | ||
"version": "1.2.1", | ||
"description": "Convert color format from RGB to HEX and vice versa", | ||
@@ -13,3 +13,4 @@ "main": "index.js", | ||
"rgb", | ||
"hex" | ||
"hex", | ||
"convert" | ||
], | ||
@@ -16,0 +17,0 @@ "author": "Maria Kousta", |
# colorformat | ||
A JavaScript lib to convert color format from RGB to HEX and vice versa | ||
A simple JavaScript library to convert color format from RGB to HEX and vice versa | ||
## Installation | ||
@@ -14,3 +15,3 @@ | ||
``` | ||
```javascript | ||
cf = require('colorformat'); | ||
@@ -20,4 +21,3 @@ | ||
or | ||
// or with string input | ||
cf.rgbToHex('230', '241', '246'); // => '#e6f1f6' | ||
@@ -28,3 +28,3 @@ ``` | ||
``` | ||
```javascript | ||
cf = require('colorformat'); | ||
@@ -34,4 +34,3 @@ | ||
or // if you want a styling string format | ||
// or if you want a string for styling | ||
cf.hexToRgb('#e6f1f6', { styling: true }); //=> 'rgb(230, 241, 246)' | ||
@@ -41,2 +40,8 @@ | ||
Note: [UMD](https://github.com/umdjs/umd) is also supported for browser use. | ||
## The simplest browser use | ||
Load the script `node_modules/colorformat/index.js` and then simply: | ||
```javascript | ||
ColorFormat.rgbToHex(230, 241, 246); // => '#e6f1f6' | ||
``` | ||
**Note:** Supports [UMD](https://github.com/umdjs/umd) for easier browser use with the tools of your preference. |
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
2793
42
43