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

fuzzy-color

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fuzzy-color - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

4

index.js

@@ -25,2 +25,3 @@ module.exports = parse;

.replace(/rgb?\(/, '')
.replace(/;/g, '')
.replace(')', '')

@@ -56,2 +57,3 @@ .split(',')

.replace(/rgba?\(/, '')
.replace(/;/g, '')
.replace(')', '')

@@ -115,3 +117,3 @@ .split(',')

function hex(str) {
var hex = str.trim().replace('#', '');
var hex = str.trim().replace('#', '').replace(/;/g, '');

@@ -118,0 +120,0 @@ if ((hex.length === 3 || hex.length === 6) && hex.match(/[a-zA-Z0-9]/g).length === hex.length) {

{
"name": "fuzzy-color",
"version": "0.0.3",
"version": "0.0.4",
"description": "Fuzzy color is a utility that takes a string and does its absolute best to parse a meaningful color value from it.",

@@ -5,0 +5,0 @@ "repository": "https://github.com/jonnyscholes/fuzzy-color",

@@ -18,2 +18,6 @@ fuzzy-color

There is also an 'assume' mode. When the assume parameter is passed we can parse values like ``` 0 0 0 ``` and assume they
are a certain color format. Some examples would be ``` rgb ```, ``` hsl ```, ``` hsv ```. If there are 4 numbers
(``` 0 0 0 0.5 ```) it will always assume it is ``` rgba ```.
Install

@@ -29,5 +33,10 @@ -------

var fuzzycolor = require('fuzzy-color');
var rgb = fuzzycolor('rgb(34,210,222)');
console.log(rgb);
var color1 = fuzzycolor('rgb(34,210,222)');
console.log(color1);
// { string: 'rgb(34,210,222)', raw: [ 34, 210, 222 ], type: 'rgb' }
var color2 = fuzzycolor('34, 210, 222', 'hsv');
console.log(color2);
// { string: 'hsv(34,210,222)', raw: [ 34, 210, 222 ], type: 'hsv' }
```

@@ -34,0 +43,0 @@

@@ -18,3 +18,13 @@ var test = require('tape');

test('RGB test - w/ ;', function (t) {
t.plan(1);
var rgb = fuzzyColor('rgb(34,210,222);');
t.deepEqual(rgb, {
string: 'rgb(34,210,222)',
raw: [34,210,222],
type: 'rgb'
});
});
test('RGB test - w/ number over 255', function (t) {

@@ -134,3 +144,13 @@ t.plan(1);

test('6 char HEX test - w/ ;', function (t) {
t.plan(1);
var rgb = fuzzyColor('#000000;');
t.deepEqual(rgb, {
string: '#000000',
raw: [0, 0, 0],
type: 'hex'
});
});
test('Adobe format #1 test eg R:252 G:252 B:252', function (t) {

@@ -137,0 +157,0 @@ t.plan(1);

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