generated from ehmicky/template-javascript
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.d.ts
80 lines (73 loc) · 1.84 KB
/
main.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
import type { Options as ColorsOptionOptions } from 'colors-option'
/**
* Options of `chalk-string`
*/
export interface Options {
/**
* Whether colors should be enabled/disabled, regardless of terminal
* support. Colors support is automatically detected, so this is only meant
* to override that default behavior.
*
* @default undefined
*/
readonly colors?: ColorsOptionOptions['colors']
/**
* Stream used to detect colors support.
* This should be the file or terminal where the colors are output.
*
* @default process.stdout
*/
readonly stream?: ColorsOptionOptions['stream']
}
type BasicStyle =
| 'bold'
| 'underline'
| 'inverse'
| 'reset'
| 'dim'
| 'italic'
| 'hidden'
| 'strikethrough'
| 'visible'
type BasicColors =
| 'black'
| 'red'
| 'green'
| 'yellow'
| 'blue'
| 'magenta'
| 'cyan'
| 'white'
| 'gray'
type Style =
| BasicStyle
| BasicColors
| `${BasicColors}Bright`
| `hex-${string}`
| `rgb-${number}-${number}-${number}`
| `bg${Capitalize<BasicColors>}`
| `bg${Capitalize<BasicColors>}Bright`
| `bgHex-${string}`
| `bgRgb-${number}-${number}-${number}`
/**
* Space-separated list of styles. Some styles require dash-separated arguments.
*/
export type Styles = Style | `${Style} ${Style}`
/**
* Add styles to terminal strings.
*
* @example
* ```js
* const addStyles = chalkString()
*
* addStyles('red', 'input') // Same as: chalk.red('input')
* addStyles('red bold', 'input') // Same as: chalk.red.bold('input')
* addStyles('hex-ffffff', 'input') // Same as: chalk.hex('ffffff')('input')
* addStyles('rgb-10-20-30', 'input') // Same as: chalk.rgb(10, 20, 30)('input')
*
* addStyles('invalidStyle', 'input') // Invalid styles throw an error
* ```
*/
export default function chalkString(
options?: Options,
): (styles: Styles, input: string) => string