npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

color-to-name

v1.1.0

Published

A command line tool which helps to map a hex color code to a color name, based on Zeplin's color palette dataset

Downloads

2,572

Readme

Color To Name

Build Status NPM version

A command line tool which helps to map a hex color code to a color name, based on Zeplin's color palette dataset

Please note that the color preview may not be as accurate as the real color. It depends if your terminal supports 24-bit true color. Please refer to: https://github.com/chalk/chalk#256-and-truecolor-color-support

For mac OS, iTerm 3.0+ supports true color by default

Installation

As command line:

npm install -g color-to-name

As project dependency:

npm install color-to-name

Usage

Command line

$ color-to-name --help

  Usage: color-to-name [options]


  Options:

    -V, --version        output the version number
    -a, --all            Print all Zeplin palette colors
    -c, --color [color]  The hex color code
    -h, --help           output usage information
$ 
$ color-to-name -c '#EE4055'
Input Color          -> HEX: #ee4055, RGB: { 238,  64,  85 }, Preview:
Closest Color        -> HEX: #fd4659, RGB: { 253,  70,  89 }, Preview:
Color Name           -> watermelon
$
$ color-to-name -c '#3BAA33'
Input Color          -> HEX: #3baa33, RGB: {  59, 170,  51 }, Preview:
Closest Color        -> HEX: #39ad48, RGB: {  57, 173,  72 }, Preview:
Color Name           -> medium green
$
$ color-to-name -c '#FDB82A'
Input Color          -> HEX: #fdb82a, RGB: { 253, 184,  42 }, Preview:
Closest Color        -> HEX: #ffa62b, RGB: { 255, 166,  43 }, Preview:
Color Name           -> mango

API

You can import the library as your project dependency

const ColorHelper = require('color-to-name');

isValidHexCode(color)

Check if a color hex code is valid

ColorHelper.isValidHexCode('#000000');
// return true

ColorHelper.isValidHexCode('#qwerty');
// return false

hexToRGB(color)

Convert a color hex code to RGB values

ColorHelper.hexToRGB('#123456');
// return { r: 18, g: 52, b: 86 }

getAllColors()

Return the full Zeplin color palette

ColorHelper.getAllColors();
// return {
//   "#000000": "black",
//   "#000133": "very dark blue",
//   .
//   .
//   .
// }

findClosestColor(color)

find the closest color to the input color hex code based on Zeplin's color palette dataset

ColorHelper.findClosestColor('#123456');
// return { color: '#1f3b4d', name: 'dark blue grey' }

To do

  • support more parameters like darken, lighten, hsl, etc