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

rgb-hex

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rgb-hex - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

license

19

index.js
'use strict';
module.exports = function (red, green, blue) {
if ((typeof red !== 'number' || typeof green !== 'number' || typeof blue !== 'number') &&
(red > 255 || green > 255 || blue > 255)) {
/* eslint-disable no-mixed-operators */
module.exports = (red, green, blue) => {
if (typeof red === 'string') {
const res = red.match(/\b\d{1,3}\b/g).map(Number);
// TODO: use destructuring when targeting Node.js 6
red = res[0];
green = res[1];
blue = res[2];
}
if (typeof red !== 'number' ||
typeof green !== 'number' ||
typeof blue !== 'number' ||
red > 255 ||
green > 255 ||
blue > 255) {
throw new TypeError('Expected three numbers below 256');

@@ -6,0 +19,0 @@ }

14

package.json
{
"name": "rgb-hex",
"version": "1.0.0",
"version": "2.0.0",
"description": "Convert RGB color to HEX",

@@ -10,9 +10,9 @@ "license": "MIT",

"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
"url": "sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
"node": ">=4"
},
"scripts": {
"test": "node test.js"
"test": "xo && ava"
},

@@ -32,4 +32,8 @@ "files": [

"devDependencies": {
"ava": "0.0.3"
"ava": "*",
"xo": "*"
},
"xo": {
"esnext": true
}
}

@@ -8,3 +8,3 @@ # rgb-hex [![Build Status](https://travis-ci.org/sindresorhus/rgb-hex.svg?branch=master)](https://travis-ci.org/sindresorhus/rgb-hex)

```sh
```
$ npm install --save rgb-hex

@@ -17,6 +17,9 @@ ```

```js
var rgbHex = require('rgb-hex');
const rgbHex = require('rgb-hex');
rgbHex(65, 131, 196);
//=> 4183c4
//=> '4183c4'
rgbHex('rgb(40, 42, 54)');
//=> '282a36'
```

@@ -27,3 +30,4 @@

See [hex-rgb](https://github.com/sindresorhus/hex-rgb) for the inverse.
- [rgb-hex-cli](https://github.com/sindresorhus/rgb-hex-cli) - CLI for this module
- [hex-rgb](https://github.com/sindresorhus/hex-rgb) - Convert HEX color to RGB

@@ -33,2 +37,2 @@

MIT © [Sindre Sorhus](http://sindresorhus.com)
MIT © [Sindre Sorhus](https://sindresorhus.com)
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