-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.d.ts
117 lines (87 loc) · 3.22 KB
/
index.d.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import type {ChalkInstance} from 'chalk';
/**
Terminal string styling with [tagged template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates)
@example
```
import chalkTemplate from 'chalk-template';
console.log(chalkTemplate`
CPU: {red ${cpu.totalPercent}%}
RAM: {green ${ram.used / ram.total * 100}%}
DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
`);
```
@example
```
import chalkTemplate from 'chalk-template';
import chalk from 'chalk';
console.log(chalk.red.bgBlack(chalkTemplate`2 + 3 = {bold ${2 + 3}}`));
```
*/
export default function chalkTemplate(text: TemplateStringsArray, ...placeholders: unknown[]): string;
/**
Terminal string styling with [tagged template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates),
configured for standard error instead of standard output
@example
```
import {chalkTemplateStderr as chalkTemplate} from 'chalk-template';
console.log(chalkTemplate`
CPU: {red ${cpu.totalPercent}%}
RAM: {green ${ram.used / ram.total * 100}%}
DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
`);
```
@example
```
import {chalkTemplateStderr as chalkTemplate} from 'chalk-template';
import {chalkStderr as chalk} from 'chalk';
console.log(chalk.red.bgBlack(chalkTemplate`2 + 3 = {bold ${2 + 3}}`));
```
*/
export function chalkTemplateStderr(text: TemplateStringsArray, ...placeholders: unknown[]): string;
/**
Terminal string styling.
This function can be useful if you need to wrap the template function. However, prefer the default export whenever possible.
__Note:__ It's up to you to properly escape the input.
@example
```
import {template} from 'chalk-template';
console.log(template('Today is {red hot}'));
```
*/
export function template(text: string): string;
/**
Terminal string styling, configured for stderr.
This function can be useful if you need to wrap the template function. However, prefer the `chalkTemplateStderr` export whenever possible.
__Note:__ It's up to you to properly escape the input.
@example
```
import {templateStderr as template} from 'chalk-template';
console.log(template('Today is {red hot}'));
```
*/
export function templateStderr(text: string): string;
/**
Terminal string styling, using a custom Chalk instance.
This function can be useful if you need to create a template function using your own Chalk instance.
__Note:__ It's up to you to properly escape the input.
@example
```
import {Chalk} from 'chalk'
import {makeTemplate} from 'chalk-template';
const template = makeTemplate(new Chalk());
console.log(template('Today is {red hot}''));
```
*/
export function makeTemplate(chalk: ChalkInstance): (text: string) => string;
/**
Terminal string styling with [tagged template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates),
configured using a custom Chalk instance.
@example
```
import {Chalk} from 'chalk'
import {makeTaggedTemplate} from 'chalk-template';
const chalkTemplate = makeTaggedTemplate(new Chalk());
console.log(chalkTemplate`Today is {red hot}`);
```
*/
export function makeTaggedTemplate(chalk: ChalkInstance): (text: TemplateStringsArray, ...placeholders: unknown[]) => string;