shelving
Version:
Toolkit for using data in JavaScript.
38 lines (37 loc) • 1.95 kB
TypeScript
import type { ImmutableArray } from "./array.js";
export declare const ANSI_DEFAULT: "\u001B[39m";
export declare const ANSI_BLACK: "\u001B[30m";
export declare const ANSI_RED: "\u001B[31m";
export declare const ANSI_GREEN: "\u001B[32m";
export declare const ANSI_YELLOW: "\u001B[33m";
export declare const ANSI_BLUE: "\u001B[34m";
export declare const ANSI_MAGENTA: "\u001B[35m";
export declare const ANSI_CYAN: "\u001B[36m";
export declare const ANSI_WHITE: "\u001B[37m";
export declare const ANSI_BOLD: "\u001B[1m";
export declare const ANSI_ITALIC: "\u001B[3m";
export declare const ANSI_UNDERLINE: "\u001B[4m";
export declare const ANSI_STRIKE: "\u001B[9m";
export declare const ANSI_INVERSE: "\u001B[7m";
export declare const ANSI_RESET = "\u001B[0m";
/**
* Wrap a string in the ANSI color/style codes (at the start), and `ANSI_RESET` at the end.
*
* - The `NO_COLOR` environment variable is read live on every call, so runtimes that populate `process.env` late (e.g. Cloudflare Workers, where `[vars]` bindings are only reliably available within the request scope) are honoured rather than baking in whatever `NO_COLOR` was at module-load time.
*/
export declare function ansiWrap(input: string, ...wrappers: ImmutableArray<string>): string;
/**
* A lazily-coloured icon that re-evaluates its ANSI colouring against the live `NO_COLOR` environment variable every time it is converted to a string.
*
* - Used directly inside template literals (`${ANSI_SUCCESS}`), where JavaScript invokes `toString()` automatically, so the icon is coloured at use-time, not at module-load time.
*/
export type AnsiIcon = {
toString(): string;
};
export declare const ANSI_WAITING: AnsiIcon;
export declare const ANSI_SUCCESS: AnsiIcon;
export declare const ANSI_FAILURE: AnsiIcon;
export declare const ANSI_UP: AnsiIcon;
export declare const ANSI_DOWN: AnsiIcon;
export declare const ANSI_RIGHT: AnsiIcon;
export declare const ANSI_LEFT: AnsiIcon;