-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.ts
96 lines (83 loc) · 2.88 KB
/
example.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// 👉 `bun examples\example.ts`
import {
re,
colorize,
getColor,
setColorLevel,
rgb,
colorSupport,
} from "~/main.js";
// Print color support information
console.log("Color Support Info:");
console.log(re.cyan(`Terminal: ${colorSupport.terminalName}`));
console.log(
re.green(`Colors Supported: ${String(colorSupport.isColorSupported)}`),
);
console.log(re.yellow(`Colors Forced: ${String(colorSupport.isForced)}`));
console.log(re.red(`Colors Disabled: ${String(colorSupport.isDisabled)}`));
console.log();
// Basic color examples
console.log("Basic Colors:");
console.log(re.red("This is red text"));
console.log(re.blue("This is blue text"));
console.log(re.green("This is green text"));
console.log(re.yellow("This is yellow text"));
console.log();
// Style examples
console.log("Text Styles:");
console.log(re.bold("This is bold text"));
console.log(re.dim("This is dim text"));
console.log(re.italic("This is italic text"));
console.log(re.underline("This is underlined text"));
console.log();
// Nested colors and styles
console.log("Nested Styles:");
console.log(re.red(re.bold("Bold red text")));
console.log(re.blue(re.underline("Underlined blue text")));
console.log(re.green(re.italic("Italic green text")));
console.log();
// Background colors
console.log("Background Colors:");
console.log(re.bgRed("Text with red background"));
console.log(re.bgBlue("Text with blue background"));
console.log(re.bgGreen("Text with green background"));
console.log();
// Bright colors
console.log("Bright Colors:");
console.log(re.redBright("Bright red text"));
console.log(re.blueBright("Bright blue text"));
console.log(re.greenBright("Bright green text"));
console.log();
// Using colorize function
console.log("Using colorize():");
console.log(colorize("magenta", "This is magenta using colorize()"));
console.log(colorize("cyan", "This is cyan using colorize()"));
console.log();
// Using getColor function
console.log("Using getColor():");
const redColor = getColor("red");
const blueColor = getColor("blue");
console.log(redColor("This is red using getColor()"));
console.log(blueColor("This is blue using getColor()"));
console.log();
// Custom RGB colors (requires level 3 support)
console.log("Custom RGB Colors (requires level 3 support):");
setColorLevel(3);
const salmon = rgb(250, 128, 114);
const turquoise = rgb(64, 224, 208);
const gold = rgb(255, 215, 0);
console.log(salmon("This is salmon colored text"));
console.log(turquoise("This is turquoise colored text"));
console.log(gold("This is gold colored text"));
console.log();
// Demonstrate color levels
console.log("Color Level Examples:");
console.log("Level 3 (True Color):");
setColorLevel(3);
console.log(re.red("This should be colored"));
console.log("\nLevel 0 (No Color):");
setColorLevel(0);
console.log(re.red("This should NOT be colored"));
console.log("\nBack to Level 3:");
setColorLevel(3);
console.log(re.red("Colors working again!"));