UNPKG

2.13 kBTypeScriptView Raw
1// Type definitions for tmp 0.2
2// Project: http://github.com/raszi/node-tmp
3// Definitions by: Jared Klopper <https://github.com/optical>
4// Gyusun Yeom <https://github.com/Perlmint>
5// Alan Plum <https://github.com/pluma>
6// Carsten Klein <https://github.com/silkentrance>
7// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
8
9export interface TmpNameOptions {
10 dir?: string | undefined;
11 name?: string | undefined;
12 postfix?: string | undefined;
13 prefix?: string | undefined;
14 template?: string | undefined;
15 tmpdir?: string | undefined;
16 tries?: number | undefined;
17}
18
19export interface FileOptions extends TmpNameOptions {
20 detachDescriptor?: boolean | undefined;
21 discardDescriptor?: boolean | undefined;
22 keep?: boolean | undefined;
23 mode?: number | undefined;
24}
25
26export interface DirOptions extends TmpNameOptions {
27 keep?: boolean | undefined;
28 mode?: number | undefined;
29 unsafeCleanup?: boolean | undefined;
30}
31
32export interface FileResult {
33 name: string;
34 fd: number;
35 removeCallback: () => void;
36}
37
38export interface DirResult {
39 name: string;
40 removeCallback: () => void;
41}
42
43export type FileCallback = (
44 err: Error|null,
45 name: string,
46 fd: number,
47 removeCallback: () => void
48) => void;
49
50export type DirCallback = (
51 err: Error|null,
52 name: string,
53 removeCallback: () => void
54) => void;
55
56export type TmpNameCallback = (err: Error|null, name: string) => void;
57
58export const tmpdir: string;
59
60export function file(options: FileOptions, cb: FileCallback): void;
61export function file(cb: FileCallback): void;
62
63export function fileSync(options?: FileOptions): FileResult;
64
65export function dir(options: DirOptions, cb: DirCallback): void;
66export function dir(cb: DirCallback): void;
67
68export function dirSync(options?: DirOptions): DirResult;
69
70export function tmpName(options: TmpNameOptions, cb: TmpNameCallback): void;
71export function tmpName(cb: TmpNameCallback): void;
72
73export function tmpNameSync(options?: TmpNameOptions): string;
74
75export function setGracefulCleanup(): void;