Socket
Book a DemoInstallSign in
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

Fuzzy color is a utility that takes a string and does its absolute best to parse a meaningful color value from it.

latest
Source
npmnpm
Version
0.0.5
Version published
Maintainers
1
Created
Source

fuzzy-color

Fuzzy color is a utility that takes a string and does its absolute best to parse a meaningful color value from it. It takes all the everyday color formats plus a few rarer ones that are (unfortunately) out there.

Supported formats

  • RGB - rgb(0, 0, 0)
  • RGBA - rgba(0, 0, 0, 0)
  • HEX 3 Char - #000
  • HEX 6 Char - #000000
  • HEX 6 Char - #000000
  • Adobe #1 - R:0 G:0 B:0
  • Adobe #2 - (R0 / G0 / B0)

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

npm install fuzzy-color

Usage

var fuzzycolor = require('fuzzy-color');

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' }

License

MIT

FAQs

Package last updated on 02 Dec 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts