1.0.1 • Published 1 year ago

colors-list v1.0.1

Weekly downloads
-
License
CODER AB
Repository
github
Last release
1 year ago

colors-list

A comprehensive list of color names with their corresponding RGB values.

Installation

To install the package, use npm:

npm install colors-list

Usage

This package provides an easy-to-use interface for accessing color names and their RGB values.

Example

Code

import assert from 'node:assert';
import colorNameList from './index.js';

// Function to get RGB value by color name
function getColorByName(colorName) {
    return colorNameList[colorName.toLowerCase()] || null;
}


// Example usage
console.log(getColorByName('blue')); // [0, 0, 255]
console.log(getColorByName('red')); // [255, 0, 0]
console.log(getColorByName('unknownColor')); // null

ES Module

import colorNameList from 'colors-list';

// Access RGB values using color names
console.log(colorNameList.red); // [255, 0, 0]
console.log(colorNameList.aliceblue); // [240, 248, 255]

Example Code

import colors from 'colors-list';
colors.red //[255,0,0]

CommonJS Module

If you need to use this package in a CommonJS environment, you can dynamically import the module:

(async () => {
  const colorNameList = await import('colors-list');

  // Access RGB values using color names
  console.log(colorNameList.default.red); // [255, 0, 0]
  console.log(colorNameList.default.aliceblue); // [240, 248, 255]);
})();

Contributing

Feel free to contribute by opening issues or submitting pull requests.

Contact

For any issues or questions, please visit the GitHub Issues page.

Author

Aditya Bhavar