Skip to main content
Deno 2 is finally here πŸŽ‰οΈ
Learn more

πŸ–οΈ Crayon.js color support for πŸ¦• Deno


πŸ“š About

This module is extension for crayon.js however it can still be used by other modules.

This module is permission-safe module. It’ll still work without giving it permission by default, however you can force/ask for permissions by setting appropriate options.

However as for now Deno.osRelease is still unsafe you need to use --unsafe

Syntax

async function getColorSupport(options?: {
    requestPermissions?: boolean;
      forcePermissions?: boolean;
}): CrayonColorSupport;

function supportedColors(): CrayonColorSupport;

function getWindowsVersion(): number[];

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

Usage

import { getColorSupport, supportedColors, getWindowsVersion } from 'https://deno.land/x/crayon_color_support/mod.ts';

const support = await 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 'https://deno.land/x/crayon/mod.ts'; // it'll still work with modules that extend crayon instance as its config is global
import { getColorSupport } from 'https://deno.land/x/crayon_color_support/mod.ts';

crayon.config.colorSupport = await getColorSupport();

Wiki

To learn more about Crayon and its API look here

:handshake: Contributing

Feel free to add any commits, issues and pull requests

πŸ“ Licensing

This project is available under MIT License conditions.