-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.d.ts
95 lines (78 loc) · 4.31 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/// <reference types="node" />
import { WriteFileOptions, WriteStream } from 'fs'
declare type OpenMode = 'w' | 'w+'
declare type OpenResult = { fd: number, path: string }
declare type OpenCallback = (err: NodeJS.ErrnoException | null, result: OpenResult | undefined) => void
declare type PathCallback = (err: NodeJS.ErrnoException | null, path: string | undefined) => void
declare type WriteStreamOptions = { flags?: string, encoding?: BufferEncoding, mode?: number, autoClose?: boolean, emitClose?: boolean, start?: number, highWaterMark?: number } | BufferEncoding | null
declare interface FSTemp {
/**
* Asynchronous open(2) - create a temporary file and open it.
* @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not supplied, defaults to `0o666`.
*/
open (flags: OpenMode, mode: number | string | undefined | null, callback: OpenCallback): void
/**
* Asynchronous open(2) - create a temporary file and open it, its mode will be `0o666`.
*/
open (flags: OpenMode, callback: OpenCallback): void
/**
* Synchronous open(2) - create a temporary file and open it, returning a file descriptor..
* @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not supplied, defaults to `0o666`.
*/
openSync (flags: OpenMode, mode?: number | string | null): OpenResult
/**
* Asynchronous mkdir(2) - create a temporary directory.
* @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not supplied, defaults to `0o666`.
*/
mkdir (mode: string | number | null | undefined, callback: PathCallback): void
/**
* Asynchronous mkdir(2) - create a temporary directory with a mode of `0o777`.
*/
mkdir (callback: PathCallback): void
/**
* Synchronous mkdir(2) - create a temporary directory.
* @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not supplied, defaults to `0o666`.
* @returns The path to the newly created directory.
*/
mkdirSync (mode?: string | number | null): string
/**
* Asynchronously writes data to a temporary file.
* @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
* @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
* If `encoding` is not supplied, the default of `'utf8'` is used.
* If `mode` is not supplied, the default of `0o666` is used.
* If `mode` is a string, it is parsed as an octal integer.
* If `flag` is not supplied, the default of `'w'` is used.
*/
writeFile (data: string | NodeJS.ArrayBufferView, options: WriteFileOptions, callback: PathCallback): void
/**
* Asynchronously writes data to a temporary file.
* @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
*/
writeFile (data: string | NodeJS.ArrayBufferView, callback: PathCallback): void
/**
* Synchronously writes data to a temporary file.
* @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
* @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
* If `encoding` is not supplied, the default of `'utf8'` is used.
* If `mode` is not supplied, the default of `0o666` is used.
* If `mode` is a string, it is parsed as an octal integer.
* If `flag` is not supplied, the default of `'w'` is used.
* @returns The path to the newly created file.
*/
writeFileSync (data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions): string
/**
* Returns a new `WriteStream` object.
*/
createWriteStream (options?: WriteStreamOptions): WriteStream
}
declare const _default: FSTemp & { template: (template: string) => FSTemp }
export const open: typeof _default['open']
export const openSync: typeof _default['openSync']
export const mkdir: typeof _default['mkdir']
export const mkdirSync: typeof _default['mkdirSync']
export const writeFile: typeof _default['writeFile']
export const writeFileSync: typeof _default['writeFileSync']
export const createWriteStream: typeof _default['createWriteStream']
export const template: typeof _default['template']
export default _default