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-detector

v1.0.3

Published

Easy access to all the color formats on the web.

Downloads

32

Readme

color-detector

color-detector is an Javascript library to get all the HTML colors (256 colors) in standard formats. (hex, rgb, hsl and simple name).

This library helps you to filter through any type of standard color format and find you all other details of it.

npm install color-detector --save

Usage

// import the library
const {
    accessFromId,
    accessFromName,
    accessFromHexString,
    accessColorFromRGB,
    accessColorFromHSL
} = require('color-detector');

(async () => {
    try {

    // get color from name
    const resultFromName = await accessFromName('Green');
    console.log('result from name :', resultFromName);

    // get color from hex
    const resultFromHex = await accessFromHexString('#000000');
    console.log('result from Hex :', resultFromHex);

    // get color from RGB
    const resultFromRGB = await accessColorFromRGB({
        r: 128,
        g: 0,
        b: 128,
    });
    console.log('result from RGB :', resultFromRGB);

    // get color from HSL
    const resultFromHSL = await accessColorFromHSL({
        h: 0,
        s: 0,
        l: 75,
    });
    console.log('result from HSL :', resultFromHSL);

    // get color from ID
    const resultFromId = await accessFromId(10);
    console.log('result from Id :', resultFromId);

} catch (error) {
    console.log(error);
}
})();

Result :-

result from name : {
  colorId: 2,
  hexString: '#008000',
  rgb: { r: 0, g: 128, b: 0 },
  hsl: { h: 120, s: 100, l: 25 },
  name: 'Green'
}
result from Hex : {
  colorId: 0,
  hexString: '#000000',
  rgb: { r: 0, g: 0, b: 0 },
  hsl: { h: 0, s: 0, l: 0 },
  name: 'Black'
}
result from RGB : {
  colorId: 5,
  hexString: '#800080',
  rgb: { r: 128, g: 0, b: 128 },
  hsl: { h: 300, s: 100, l: 25 },
  name: 'Purple'
}
result from HSL : {
  colorId: 7,
  hexString: '#c0c0c0',
  rgb: { r: 192, g: 192, b: 192 },
  hsl: { h: 0, s: 0, l: 75 },
  name: 'Silver'
}
result from Id : {
  colorId: 10,
  hexString: '#00ff00',
  rgb: { r: 0, g: 255, b: 0 },
  hsl: { h: 120, s: 100, l: 50 },
  name: 'Lime'
}

Reference

The colors which are avaible in the library is refered from jonasjacek.github.io/colors

Licence

(The MIT License) Copyright (c) 2021 [email protected]