New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

colornamify

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

colornamify

Gives names to colors.

  • 1.1.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

colornamify

Gives names to colors

npm install colornamify
Also available as a Visual Studio Code Extension!

Short Description

There are only two real problems in computer science: Naming things, cache invalidation, and off-by-one errors. colornamify aims to partially solve problems[0] by giving names to to RGB colors.

Usage

colornamify expects an object containing r, g and b attributes, ranging from 0 to 255. It will return a string with an all lowercase color name.

const colornamify = require('colornamify')
let color = {
  r: 65,
  g: 45,
  b:  0,
}
let name = colornamify(color)
// name now contains 'zanzibar'

Notes

  • We are currently at 6691 unique color names, yay!
  • Invalid input will return null and not throw an error.
  • Lookups will be cached for performance.
  • Library uses a naive searching algorithm.
  • Self-contained, needs no dependencies.
  • Conversion between or accepting different color formats is not in the scope - various solutions already exist for this.
  • Color names are taken from many sources, check the comments in colors.js
  • With the exception of the default CSS named colors, the value of a color is not guaranteed to match the source from which the name is taken. This means do not use this library to precisely identify colors.

Todo

  • Check if we can use a more performant algorithm for lookup.

Shoutout

Big "Thank You!" goes out to Chirag Mehta whose work gave me some great ideas on my search for color naming solutions.

License

MIT

Keywords

FAQs

Package last updated on 08 May 2021

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

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