@miroyar/ccolor
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

cColor [pre-alpha(!)]


Utility for console text color. Based on 3-bit, 4-bit color chart from Wikipedia.

Description


Method: cColor
Type:

(text: string, initial: StringColorInitial | ObjectColorInitial) => string;

Type: StringColorInitial
Description: Has a value from the table of color full initials.

Type: ObjectColorInitial

{
  F?: ColorInitials;
  B?: ColorInitials;
}

Description: An object consisting of two keys F and B, denoting the position of the Foreground and Background colors and having a value from the color initials table.

Table: Colored initials that you can see here.

Color Foreground Background
F+ B+
Black D
Red R
Green G
Yellow Y
Blue B
Magenta M
Cyan C
White W
Bright Black (Gray) BD
Bright Red BR
Bright Green BG
Bright Yellow BY
Bright Blue BB
Bright Magenta BM
Bright Cyan BC
Bright White BW

Example:

import { CColor } from '@miroyar/ccolor';

const text = 'The SGR parameters 30–37 selected the foreground color, while 40–47 selected the background.';

const cColor = new CColor();

console.log(cColor.print(text, 'FB'));
console.log(cColor.print(text, 'BBG'));
console.log(cColor.print(text, { F: 'B', B: 'BG' }));

Readme

Keywords

Package Sidebar

Install

npm i @miroyar/ccolor

Weekly Downloads

0

Version

1.0.4

License

MIT

Unpacked Size

9.99 kB

Total Files

15

Last publish

Collaborators

  • miroyar