1.0.4 • Published 1 year ago

spcolor v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Spcolor

Codecov NPM License

Detect whether a terminal supports color. Can run on Node, Browser, Deno.

Usage

Node.js

npm install spcolor
import { getColorSupport } from "spcolor";

console.log(getColorSupport());

Deno

import { getColorSupport } from "npm:spcolor@latest";

console.log(getColorSupport());

API

getColorSupport()

  • Return: ColorSupport
interface ColorSupport {
  level: ColorSupportLevel;
  has24bit: boolean;
  has8bit: boolean;
  has4bit: boolean;
}

const enum ColorSupportLevel {
  /** 16m color support */
  bit24 = 3,
  /** 256 color support */
  bit8 = 2,
  /** 16 color support */
  bit4 = 1,
  /** no color support */
  none = 0,
}