UNPKG

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