-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.ts
51 lines (39 loc) · 1007 Bytes
/
test.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
import Kink from '@termsurf/kink'
import fs from 'fs'
import { format } from 'date-fns'
import { makeKinkText, makeBaseKinkText, TIME_FORM } from './node.js'
const host = '@termsurf/kink-text'
type Base = {
syntax_error: {}
}
type Name = keyof Base
Kink.base(host, 'syntax_error', () => ({
code: 1,
note: 'Syntax error',
}))
Kink.code(host, (code: number) => code.toString(16).padStart(4, '0'))
Kink.time(time => format(time, TIME_FORM))
export default function kink<N extends Name>(form: N, link?: Base[N]) {
return Kink.make(host, form, link)
}
console.log('')
console.log('')
console.log('')
// https://nodejs.org/api/errors.html
process.on('uncaughtException', err => {
if (err instanceof Kink) {
// Kink.saveFill(err, err.link)
console.log(makeKinkText(err))
} else {
console.log(makeBaseKinkText(err))
console.log('')
console.log('')
console.log('')
}
})
setTimeout(() => {
throw kink('syntax_error')
})
setTimeout(() => {
fs.readFileSync('.')
})