-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod.ts
27 lines (22 loc) · 768 Bytes
/
mod.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
const toString = (v: string | number | boolean) => v.toString()
export function h1(...words: (string | number | boolean)[]) {
console.log('#', ...words.map(toString))
}
export function h2(...words: (string | number | boolean)[]) {
console.log('##', ...words.map(toString))
}
export function h3(...words: (string | number | boolean)[]) {
console.log('###', ...words.map(toString))
}
export function tableHead(...heads: string[]) {
console.log('|' + heads.join('|') + '|')
const line = heads.map(() => '-')
console.log('|' + line.join('|') + '|')
}
export function tableRow(...values: unknown[]) {
values = values.map((v) => {
if (typeof v === 'number') v = v.toFixed(2)
return v
})
console.log('|' + values.join('|') + '|')
}