@crayon.js/color-support

Detect terminal color support

Usage no npm install needed!

<script type="module">
  import crayonJsColorSupport from 'https://cdn.skypack.dev/@crayon.js/color-support';
</script>

README

🖍️ Crayon.js color support


:books: About

This package is extension for crayon.js however it can still be used by other packages.

Installation

npm install @crayon.js/color-support #yarn add @crayon.js/color-support

Syntax

interface CrayonColorSupport {
    threeBitColor: boolean
    fourBitColor: boolean
    highColor: boolean
    trueColor: boolean
}

Usage

import { getColorSupport, supportedColors, getWindowsVersion } from '@crayon.js/color-support';

const support = getColorSupport(); // detect terminal color support
const cached = supportedColors(); // cached getColorSupport (it just returns cached object)
const windowsVersion = getWindowsVersion(); // Reusable function [version (7/8/10...), versionId (14931...)], empty if detected system is not Windows

Usage with crayon.js

import crayon from 'crayon.js'; // it'll still work with packages that extend crayon instance as its config is global
import { getColorSupport } from '@crayon.js/color-support';

crayon.config.colorSupport = getColorSupport();

:handshake: Contributing

Feel free to add any commits, issues and pull requests

:memo: Licensing

This project is available under MIT License conditions.