Skip to content

Commit a774c3f

Browse files
Copilotstreamich
andcommitted
feat: update Node.js interfaces to use property syntax instead of method declarations
Co-authored-by: streamich <[email protected]>
1 parent a60abb5 commit a774c3f

File tree

3 files changed

+280
-220
lines changed

3 files changed

+280
-220
lines changed

src/node/types/FsCallbackApi.ts

Lines changed: 173 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -2,142 +2,192 @@ import type * as misc from './misc';
22
import type * as opts from './options';
33

44
export interface FsCallbackApi {
5-
access(path: misc.PathLike, callback: misc.TCallback<void>);
6-
access(path: misc.PathLike, mode: number, callback: misc.TCallback<void>);
7-
appendFile(id: misc.TFileId, data: misc.TData, callback: misc.TCallback<void>);
8-
appendFile(
9-
id: misc.TFileId,
10-
data: misc.TData,
11-
options: opts.IAppendFileOptions | string,
12-
callback: misc.TCallback<void>,
13-
);
14-
chmod(path: misc.PathLike, mode: misc.TMode, callback: misc.TCallback<void>): void;
15-
chown(path: misc.PathLike, uid: number, gid: number, callback: misc.TCallback<void>): void;
16-
close(fd: number, callback: misc.TCallback<void>): void;
17-
copyFile(src: misc.PathLike, dest: misc.PathLike, callback: misc.TCallback<void>);
18-
copyFile(src: misc.PathLike, dest: misc.PathLike, flags: misc.TFlagsCopy, callback: misc.TCallback<void>);
19-
cp(src: string | URL, dest: string | URL, callback: misc.TCallback<void>);
20-
cp(src: string | URL, dest: string | URL, options: opts.ICpOptions, callback: misc.TCallback<void>);
21-
createReadStream(path: misc.PathLike, options?: opts.IReadStreamOptions | string): misc.IReadStream;
22-
createWriteStream(path: misc.PathLike, options?: opts.IWriteStreamOptions | string): misc.IWriteStream;
23-
exists(path: misc.PathLike, callback: (exists: boolean) => void): void;
24-
fchmod(fd: number, mode: misc.TMode, callback: misc.TCallback<void>): void;
25-
fchown(fd: number, uid: number, gid: number, callback: misc.TCallback<void>): void;
26-
fdatasync(fd: number, callback: misc.TCallback<void>): void;
27-
fsync(fd: number, callback: misc.TCallback<void>): void;
28-
fstat(fd: number, callback: misc.TCallback<misc.IStats>): void;
29-
fstat(fd: number, options: opts.IFStatOptions, callback: misc.TCallback<misc.IStats>): void;
30-
ftruncate(fd: number, callback: misc.TCallback<void>);
31-
ftruncate(fd: number, len: number, callback: misc.TCallback<void>);
32-
futimes(fd: number, atime: misc.TTime, mtime: misc.TTime, callback: misc.TCallback<void>): void;
33-
lchmod(path: misc.PathLike, mode: misc.TMode, callback: misc.TCallback<void>): void;
34-
lchown(path: misc.PathLike, uid: number, gid: number, callback: misc.TCallback<void>): void;
35-
lutimes(
5+
access: {
6+
(path: misc.PathLike, callback: misc.TCallback<void>): void;
7+
(path: misc.PathLike, mode: number, callback: misc.TCallback<void>): void;
8+
};
9+
appendFile: {
10+
(id: misc.TFileId, data: misc.TData, callback: misc.TCallback<void>): void;
11+
(
12+
id: misc.TFileId,
13+
data: misc.TData,
14+
options: opts.IAppendFileOptions | string,
15+
callback: misc.TCallback<void>,
16+
): void;
17+
};
18+
chmod: (path: misc.PathLike, mode: misc.TMode, callback: misc.TCallback<void>) => void;
19+
chown: (path: misc.PathLike, uid: number, gid: number, callback: misc.TCallback<void>) => void;
20+
close: (fd: number, callback: misc.TCallback<void>) => void;
21+
copyFile: {
22+
(src: misc.PathLike, dest: misc.PathLike, callback: misc.TCallback<void>): void;
23+
(src: misc.PathLike, dest: misc.PathLike, flags: misc.TFlagsCopy, callback: misc.TCallback<void>): void;
24+
};
25+
cp: {
26+
(src: string | URL, dest: string | URL, callback: misc.TCallback<void>): void;
27+
(src: string | URL, dest: string | URL, options: opts.ICpOptions, callback: misc.TCallback<void>): void;
28+
};
29+
createReadStream: (path: misc.PathLike, options?: opts.IReadStreamOptions | string) => misc.IReadStream;
30+
createWriteStream: (path: misc.PathLike, options?: opts.IWriteStreamOptions | string) => misc.IWriteStream;
31+
exists: (path: misc.PathLike, callback: (exists: boolean) => void) => void;
32+
fchmod: (fd: number, mode: misc.TMode, callback: misc.TCallback<void>) => void;
33+
fchown: (fd: number, uid: number, gid: number, callback: misc.TCallback<void>) => void;
34+
fdatasync: (fd: number, callback: misc.TCallback<void>) => void;
35+
fsync: (fd: number, callback: misc.TCallback<void>) => void;
36+
fstat: {
37+
(fd: number, callback: misc.TCallback<misc.IStats>): void;
38+
(fd: number, options: opts.IFStatOptions, callback: misc.TCallback<misc.IStats>): void;
39+
};
40+
ftruncate: {
41+
(fd: number, callback: misc.TCallback<void>): void;
42+
(fd: number, len: number, callback: misc.TCallback<void>): void;
43+
};
44+
futimes: (fd: number, atime: misc.TTime, mtime: misc.TTime, callback: misc.TCallback<void>) => void;
45+
lchmod: (path: misc.PathLike, mode: misc.TMode, callback: misc.TCallback<void>) => void;
46+
lchown: (path: misc.PathLike, uid: number, gid: number, callback: misc.TCallback<void>) => void;
47+
lutimes: (
3648
path: misc.PathLike,
3749
atime: number | string | Date,
3850
mtime: number | string | Date,
3951
callback: misc.TCallback<void>,
40-
): void;
41-
link(existingPath: misc.PathLike, newPath: misc.PathLike, callback: misc.TCallback<void>): void;
42-
lstat(path: misc.PathLike, callback: misc.TCallback<misc.IStats>): void;
43-
lstat(path: misc.PathLike, options: opts.IStatOptions, callback: misc.TCallback<misc.IStats>): void;
44-
mkdir(path: misc.PathLike, callback: misc.TCallback<void>);
45-
mkdir(
46-
path: misc.PathLike,
47-
mode: misc.TMode | (opts.IMkdirOptions & { recursive?: false }),
48-
callback: misc.TCallback<void>,
49-
);
50-
mkdir(path: misc.PathLike, mode: opts.IMkdirOptions & { recursive: true }, callback: misc.TCallback<string>);
51-
mkdir(path: misc.PathLike, mode: misc.TMode | opts.IMkdirOptions, callback: misc.TCallback<string>);
52-
mkdtemp(prefix: string, callback: misc.TCallback<string>): void;
53-
mkdtemp(prefix: string, options: opts.IOptions, callback: misc.TCallback<string>);
54-
open(path: misc.PathLike, flags: misc.TFlags, callback: misc.TCallback<number>);
55-
open(path: misc.PathLike, flags: misc.TFlags, mode: misc.TMode, callback: misc.TCallback<number>);
56-
openAsBlob(path: misc.PathLike, options?: opts.IOpenAsBlobOptions): Promise<Blob>;
57-
opendir(path: misc.PathLike, options: opts.IOpendirOptions, callback: misc.TCallback<misc.IDir>): void;
58-
read(
52+
) => void;
53+
link: (existingPath: misc.PathLike, newPath: misc.PathLike, callback: misc.TCallback<void>) => void;
54+
lstat: {
55+
(path: misc.PathLike, callback: misc.TCallback<misc.IStats>): void;
56+
(path: misc.PathLike, options: opts.IStatOptions, callback: misc.TCallback<misc.IStats>): void;
57+
};
58+
mkdir: {
59+
(path: misc.PathLike, callback: misc.TCallback<void>): void;
60+
(
61+
path: misc.PathLike,
62+
mode: misc.TMode | (opts.IMkdirOptions & { recursive?: false }),
63+
callback: misc.TCallback<void>,
64+
): void;
65+
(path: misc.PathLike, mode: opts.IMkdirOptions & { recursive: true }, callback: misc.TCallback<string>): void;
66+
(path: misc.PathLike, mode: misc.TMode | opts.IMkdirOptions, callback: misc.TCallback<string>): void;
67+
};
68+
mkdtemp: {
69+
(prefix: string, callback: misc.TCallback<string>): void;
70+
(prefix: string, options: opts.IOptions, callback: misc.TCallback<string>): void;
71+
};
72+
open: {
73+
(path: misc.PathLike, flags: misc.TFlags, callback: misc.TCallback<number>): void;
74+
(path: misc.PathLike, flags: misc.TFlags, mode: misc.TMode, callback: misc.TCallback<number>): void;
75+
};
76+
openAsBlob: (path: misc.PathLike, options?: opts.IOpenAsBlobOptions) => Promise<Blob>;
77+
opendir: (path: misc.PathLike, options: opts.IOpendirOptions, callback: misc.TCallback<misc.IDir>) => void;
78+
read: (
5979
fd: number,
6080
buffer: Buffer | ArrayBufferView | DataView,
6181
offset: number,
6282
length: number,
6383
position: number,
6484
callback: (err?: Error | null, bytesRead?: number, buffer?: Buffer | ArrayBufferView | DataView) => void,
65-
): void;
66-
readdir(path: misc.PathLike, callback: misc.TCallback<misc.TDataOut[] | misc.IDirent[]>);
67-
readdir(
68-
path: misc.PathLike,
69-
options: opts.IReaddirOptions | string,
70-
callback: misc.TCallback<misc.TDataOut[] | misc.IDirent[]>,
71-
);
72-
readFile(id: misc.TFileId, callback: misc.TCallback<misc.TDataOut>);
73-
readFile(id: misc.TFileId, options: opts.IReadFileOptions | string, callback: misc.TCallback<misc.TDataOut>);
74-
readlink(path: misc.PathLike, callback: misc.TCallback<misc.TDataOut>);
75-
readlink(path: misc.PathLike, options: opts.IOptions, callback: misc.TCallback<misc.TDataOut>);
76-
readv(fd: number, buffers: ArrayBufferView[], callback: misc.TCallback2<number, ArrayBufferView[]>): void;
77-
readv(
78-
fd: number,
79-
buffers: ArrayBufferView[],
80-
position: number | null,
81-
callback: misc.TCallback2<number, ArrayBufferView[]>,
82-
): void;
83-
realpath(path: misc.PathLike, callback: misc.TCallback<misc.TDataOut>);
84-
realpath(path: misc.PathLike, options: opts.IRealpathOptions | string, callback: misc.TCallback<misc.TDataOut>);
85-
rename(oldPath: misc.PathLike, newPath: misc.PathLike, callback: misc.TCallback<void>): void;
86-
rmdir(path: misc.PathLike, callback: misc.TCallback<void>);
87-
rmdir(path: misc.PathLike, options: opts.IRmdirOptions, callback: misc.TCallback<void>);
88-
rm(path: misc.PathLike, callback: misc.TCallback<void>): void;
89-
rm(path: misc.PathLike, options: opts.IRmOptions, callback: misc.TCallback<void>): void;
90-
stat(path: misc.PathLike, callback: misc.TCallback<misc.IStats>): void;
91-
stat(path: misc.PathLike, options: opts.IStatOptions, callback: misc.TCallback<misc.IStats>): void;
92-
statfs(path: misc.PathLike, callback: misc.TCallback<misc.IStatFs>): void;
93-
statfs(path: misc.PathLike, options: opts.IStatOptions, callback: misc.TCallback<misc.IStatFs>): void;
94-
symlink(target: misc.PathLike, path: misc.PathLike, callback: misc.TCallback<void>);
95-
symlink(target: misc.PathLike, path: misc.PathLike, type: misc.symlink.Type, callback: misc.TCallback<void>);
96-
truncate(id: misc.PathLike, callback: misc.TCallback<void>);
97-
truncate(id: misc.PathLike, len: number, callback: misc.TCallback<void>);
98-
unlink(path: misc.PathLike, callback: misc.TCallback<void>): void;
99-
unwatchFile(path: misc.PathLike, listener?: (curr: misc.IStats, prev: misc.IStats) => void): void;
100-
utimes(path: misc.PathLike, atime: misc.TTime, mtime: misc.TTime, callback: misc.TCallback<void>): void;
101-
watch(
85+
) => void;
86+
readdir: {
87+
(path: misc.PathLike, callback: misc.TCallback<misc.TDataOut[] | misc.IDirent[]>): void;
88+
(
89+
path: misc.PathLike,
90+
options: opts.IReaddirOptions | string,
91+
callback: misc.TCallback<misc.TDataOut[] | misc.IDirent[]>,
92+
): void;
93+
};
94+
readFile: {
95+
(id: misc.TFileId, callback: misc.TCallback<misc.TDataOut>): void;
96+
(id: misc.TFileId, options: opts.IReadFileOptions | string, callback: misc.TCallback<misc.TDataOut>): void;
97+
};
98+
readlink: {
99+
(path: misc.PathLike, callback: misc.TCallback<misc.TDataOut>): void;
100+
(path: misc.PathLike, options: opts.IOptions, callback: misc.TCallback<misc.TDataOut>): void;
101+
};
102+
readv: {
103+
(fd: number, buffers: ArrayBufferView[], callback: misc.TCallback2<number, ArrayBufferView[]>): void;
104+
(
105+
fd: number,
106+
buffers: ArrayBufferView[],
107+
position: number | null,
108+
callback: misc.TCallback2<number, ArrayBufferView[]>,
109+
): void;
110+
};
111+
realpath: {
112+
(path: misc.PathLike, callback: misc.TCallback<misc.TDataOut>): void;
113+
(path: misc.PathLike, options: opts.IRealpathOptions | string, callback: misc.TCallback<misc.TDataOut>): void;
114+
};
115+
rename: (oldPath: misc.PathLike, newPath: misc.PathLike, callback: misc.TCallback<void>) => void;
116+
rmdir: {
117+
(path: misc.PathLike, callback: misc.TCallback<void>): void;
118+
(path: misc.PathLike, options: opts.IRmdirOptions, callback: misc.TCallback<void>): void;
119+
};
120+
rm: {
121+
(path: misc.PathLike, callback: misc.TCallback<void>): void;
122+
(path: misc.PathLike, options: opts.IRmOptions, callback: misc.TCallback<void>): void;
123+
};
124+
stat: {
125+
(path: misc.PathLike, callback: misc.TCallback<misc.IStats>): void;
126+
(path: misc.PathLike, options: opts.IStatOptions, callback: misc.TCallback<misc.IStats>): void;
127+
};
128+
statfs: {
129+
(path: misc.PathLike, callback: misc.TCallback<misc.IStatFs>): void;
130+
(path: misc.PathLike, options: opts.IStatOptions, callback: misc.TCallback<misc.IStatFs>): void;
131+
};
132+
symlink: {
133+
(target: misc.PathLike, path: misc.PathLike, callback: misc.TCallback<void>): void;
134+
(target: misc.PathLike, path: misc.PathLike, type: misc.symlink.Type, callback: misc.TCallback<void>): void;
135+
};
136+
truncate: {
137+
(id: misc.PathLike, callback: misc.TCallback<void>): void;
138+
(id: misc.PathLike, len: number, callback: misc.TCallback<void>): void;
139+
};
140+
unlink: (path: misc.PathLike, callback: misc.TCallback<void>) => void;
141+
unwatchFile: (path: misc.PathLike, listener?: (curr: misc.IStats, prev: misc.IStats) => void) => void;
142+
utimes: (path: misc.PathLike, atime: misc.TTime, mtime: misc.TTime, callback: misc.TCallback<void>) => void;
143+
watch: (
102144
path: misc.PathLike,
103145
options?: opts.IWatchOptions | string,
104146
listener?: (eventType: string, filename: string) => void,
105-
): misc.IFSWatcher;
106-
watchFile(path: misc.PathLike, listener: (curr: misc.IStats, prev: misc.IStats) => void): misc.IStatWatcher;
107-
watchFile(
108-
path: misc.PathLike,
109-
options: opts.IWatchFileOptions,
110-
listener: (curr: misc.IStats, prev: misc.IStats) => void,
111-
): misc.IStatWatcher;
112-
write(fd: number, buffer: Buffer | ArrayBufferView | DataView, callback: (...args) => void);
113-
write(fd: number, buffer: Buffer | ArrayBufferView | DataView, offset: number, callback: (...args) => void);
114-
write(
115-
fd: number,
116-
buffer: Buffer | ArrayBufferView | DataView,
117-
offset: number,
118-
length: number,
119-
callback: (...args) => void,
120-
);
121-
write(
122-
fd: number,
123-
buffer: Buffer | ArrayBufferView | DataView,
124-
offset: number,
125-
length: number,
126-
position: number,
127-
callback: (...args) => void,
128-
);
129-
write(fd: number, str: string, callback: (...args) => void);
130-
write(fd: number, str: string, position: number, callback: (...args) => void);
131-
write(fd: number, str: string, position: number, encoding: BufferEncoding, callback: (...args) => void);
132-
writeFile(id: misc.TFileId, data: misc.TData, callback: misc.TCallback<void>);
133-
writeFile(
134-
id: misc.TFileId,
135-
data: misc.TData,
136-
options: opts.IWriteFileOptions | string,
137-
callback: misc.TCallback<void>,
138-
);
139-
writev(fd: number, buffers: ArrayBufferView[], callback: WritevCallback): void;
140-
writev(fd: number, buffers: ArrayBufferView[], position: number | null, callback: WritevCallback): void;
147+
) => misc.IFSWatcher;
148+
watchFile: {
149+
(path: misc.PathLike, listener: (curr: misc.IStats, prev: misc.IStats) => void): misc.IStatWatcher;
150+
(
151+
path: misc.PathLike,
152+
options: opts.IWatchFileOptions,
153+
listener: (curr: misc.IStats, prev: misc.IStats) => void,
154+
): misc.IStatWatcher;
155+
};
156+
write: {
157+
(fd: number, buffer: Buffer | ArrayBufferView | DataView, callback: (...args) => void): void;
158+
(fd: number, buffer: Buffer | ArrayBufferView | DataView, offset: number, callback: (...args) => void): void;
159+
(
160+
fd: number,
161+
buffer: Buffer | ArrayBufferView | DataView,
162+
offset: number,
163+
length: number,
164+
callback: (...args) => void,
165+
): void;
166+
(
167+
fd: number,
168+
buffer: Buffer | ArrayBufferView | DataView,
169+
offset: number,
170+
length: number,
171+
position: number,
172+
callback: (...args) => void,
173+
): void;
174+
(fd: number, str: string, callback: (...args) => void): void;
175+
(fd: number, str: string, position: number, callback: (...args) => void): void;
176+
(fd: number, str: string, position: number, encoding: BufferEncoding, callback: (...args) => void): void;
177+
};
178+
writeFile: {
179+
(id: misc.TFileId, data: misc.TData, callback: misc.TCallback<void>): void;
180+
(
181+
id: misc.TFileId,
182+
data: misc.TData,
183+
options: opts.IWriteFileOptions | string,
184+
callback: misc.TCallback<void>,
185+
): void;
186+
};
187+
writev: {
188+
(fd: number, buffers: ArrayBufferView[], callback: WritevCallback): void;
189+
(fd: number, buffers: ArrayBufferView[], position: number | null, callback: WritevCallback): void;
190+
};
141191
}
142192

143193
export type WritevCallback = (err: Error | null, bytesWritten?: number, buffers?: ArrayBufferView[]) => void;

0 commit comments

Comments
 (0)