UNPKG

1.3 kBTypeScriptView Raw
1/// <reference types="node" />
2
3import * as fs from "fs";
4
5declare namespace temp {
6 interface OpenFile {
7 path: string;
8 fd: number;
9 }
10
11 interface Stats {
12 files: number;
13 dirs: number;
14 }
15
16 interface AffixOptions {
17 prefix?: string | undefined;
18 suffix?: string | undefined;
19 dir?: string | undefined;
20 }
21
22 let dir: string;
23
24 function track(value?: boolean): typeof temp;
25
26 function mkdir(affixes: string | AffixOptions | undefined, callback: (err: any, dirPath: string) => void): void;
27 function mkdir(affixes?: string | AffixOptions): Promise<string>;
28
29 function mkdirSync(affixes?: string | AffixOptions): string;
30
31 function open(affixes: string | AffixOptions | undefined, callback: (err: any, result: OpenFile) => void): void;
32 function open(affixes?: string | AffixOptions): Promise<OpenFile>;
33
34 function openSync(affixes?: string | AffixOptions): OpenFile;
35
36 function path(affixes?: string | AffixOptions, defaultPrefix?: string): string;
37
38 function cleanup(callback: (err: any, result: Stats) => void): void;
39 function cleanup(): Promise<Stats>;
40
41 function cleanupSync(): boolean | Stats;
42
43 function createWriteStream(affixes?: string | AffixOptions): fs.WriteStream;
44}
45
46export = temp;