forked from mcollina/close-with-grace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
70 lines (66 loc) · 1.73 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
declare namespace closeWithGrace {
interface Options {
/**
* The numbers of milliseconds before abruptly close the process
* @default 10000
*/
delay: number
}
type Signals = "SIGTERM" | "SIGINT"
interface CloseWithGraceCallback {
(
options: { err?: Error, signal?: Signals, manual?: boolean },
cb: (error?: Error) => void
): void
}
interface CloseWithGraceAsyncCallback {
(options: {
err?: Error
signal?: Signals
manual?: boolean
}): Promise<void>
}
}
declare interface CloseWithGraceReturn {
/**
* Close the process, the manual argument will be set to true.
*/
close: () => void
/**
* Remove all global listeners
*/
uninstall: () => void
}
/**
@example
import * as closeWithGrace from 'close-with-grace'
// delay is the number of milliseconds for the graceful close to
// finish.
closeWithGrace({ delay: 500 }, async function ({ signal, err, manual }) {
if (err) {
console.error(err)
}
await closeYourServer()
})
*/
declare function closeWithGrace (
fn: closeWithGrace.CloseWithGraceAsyncCallback
): CloseWithGraceReturn
declare function closeWithGrace (
fn: closeWithGrace.CloseWithGraceCallback
): CloseWithGraceReturn
declare function closeWithGrace (
opts: closeWithGrace.Options,
fn: closeWithGrace.CloseWithGraceAsyncCallback
): CloseWithGraceReturn
declare function closeWithGrace (
opts: closeWithGrace.Options,
fn: closeWithGrace.CloseWithGraceCallback
): CloseWithGraceReturn
declare function closeWithGrace (
fn: closeWithGrace.CloseWithGraceAsyncCallback
): CloseWithGraceReturn
declare function closeWithGrace (
fn: closeWithGrace.CloseWithGraceCallback
): CloseWithGraceReturn
export = closeWithGrace