Skip to content

crayon-js/color-support

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

34 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽจ Color support

Terminal color support detection package.
Supports NO_COLOR and FORCE_COLOR.

Made primarily for use with Crayon

๐ŸŒˆ Usage

import { ColorSupport, getColorSupport } from "@crayon/color-support";

const colors = await getColorSupport();
console.log(colors); // Prints amount of colors supported by current terminal

switch (colors) {
  case ColorSupport.TrueColor:
    console.log("over 16mil colors!");
    break;
  case ColorSupport.HighColor:
    console.log("255 colors");
    break;
  case ColorSupport.FourBit:
    console.log("16 colors..");
    break;
  case ColorSupport.ThreeBit:
    console.log("8 colors :/");
    break;
  default:
    console.log("No colors :(");
    break;
}

๐Ÿค Contributing

Crayon is open for any contributions.
If you feel like you can enhance this project - please open an issue and/or pull request.
Code should be well document and easy to follow what's going on.

Crayon 4.x follows conventional commits.
If your pull request's code could introduce understandability trouble, please add comments to it.

๐Ÿ“ Licensing

This project is available under MIT License conditions.