|
| 1 | +declare namespace InternalFSBinding { |
| 2 | + class FSReqCallback<ResultType = unknown> { |
| 3 | + constructor(bigint?: boolean); |
| 4 | + oncomplete: ((error: Error) => void) | ((error: null, result: ResultType) => void); |
| 5 | + context: any; |
| 6 | + } |
| 7 | + |
| 8 | + interface FSSyncContext { |
| 9 | + fd?: number; |
| 10 | + path?: string; |
| 11 | + dest?: string; |
| 12 | + errno?: string; |
| 13 | + message?: string; |
| 14 | + syscall?: string; |
| 15 | + error?: Error; |
| 16 | + } |
| 17 | + |
| 18 | + type Buffer = Uint8Array; |
| 19 | + type StringOrBuffer = string | Buffer; |
| 20 | + |
| 21 | + const kUsePromises: symbol; |
| 22 | + |
| 23 | + class FileHandle { |
| 24 | + constructor(fd: number, offset: number, length: number); |
| 25 | + fd: number; |
| 26 | + getAsyncId(): number; |
| 27 | + close(): Promise<void>; |
| 28 | + onread: () => void; |
| 29 | + stream: unknown; |
| 30 | + } |
| 31 | + |
| 32 | + class StatWatcher { |
| 33 | + constructor(useBigint: boolean); |
| 34 | + initialized: boolean; |
| 35 | + start(path: string, interval: number): number; |
| 36 | + getAsyncId(): number; |
| 37 | + close(): void; |
| 38 | + ref(): void; |
| 39 | + unref(): void; |
| 40 | + onchange: (status: number, eventType: string, filename: string | Buffer) => void; |
| 41 | + } |
| 42 | + |
| 43 | + function access(path: StringOrBuffer, mode: number, req: FSReqCallback): void; |
| 44 | + function access(path: StringOrBuffer, mode: number, req: undefined, ctx: FSSyncContext): void; |
| 45 | + function access(path: StringOrBuffer, mode: number, usePromises: typeof kUsePromises): Promise<void>; |
| 46 | + |
| 47 | + function chmod(path: string, mode: number, req: FSReqCallback): void; |
| 48 | + function chmod(path: string, mode: number, req: undefined, ctx: FSSyncContext): void; |
| 49 | + function chmod(path: string, mode: number, usePromises: typeof kUsePromises): Promise<void>; |
| 50 | + |
| 51 | + function chown(path: string, uid: number, gid: number, req: FSReqCallback): void; |
| 52 | + function chown(path: string, uid: number, gid: number, req: undefined, ctx: FSSyncContext): void; |
| 53 | + function chown(path: string, uid: number, gid: number, usePromises: typeof kUsePromises): Promise<void>; |
| 54 | + |
| 55 | + function close(fd: number, req: FSReqCallback): void; |
| 56 | + function close(fd: number, req: undefined, ctx: FSSyncContext): void; |
| 57 | + |
| 58 | + function copyFile(src: StringOrBuffer, dest: StringOrBuffer, mode: number, req: FSReqCallback): void; |
| 59 | + function copyFile(src: StringOrBuffer, dest: StringOrBuffer, mode: number, req: undefined, ctx: FSSyncContext): void; |
| 60 | + function copyFile(src: StringOrBuffer, dest: StringOrBuffer, mode: number, usePromises: typeof kUsePromises): Promise<void>; |
| 61 | + |
| 62 | + function fchmod(fd: number, mode: number, req: FSReqCallback): void; |
| 63 | + function fchmod(fd: number, mode: number, req: undefined, ctx: FSSyncContext): void; |
| 64 | + function fchmod(fd: number, mode: number, usePromises: typeof kUsePromises): Promise<void>; |
| 65 | + |
| 66 | + function fchown(fd: number, uid: number, gid: number, req: FSReqCallback): void; |
| 67 | + function fchown(fd: number, uid: number, gid: number, req: undefined, ctx: FSSyncContext): void; |
| 68 | + function fchown(fd: number, uid: number, gid: number, usePromises: typeof kUsePromises): Promise<void>; |
| 69 | + |
| 70 | + function fdatasync(fd: number, req: FSReqCallback): void; |
| 71 | + function fdatasync(fd: number, req: undefined, ctx: FSSyncContext): void; |
| 72 | + function fdatasync(fd: number, usePromises: typeof kUsePromises): Promise<void>; |
| 73 | + |
| 74 | + function fstat(fd: number, useBigint: boolean, req: FSReqCallback<Float64Array | BigUint64Array>): void; |
| 75 | + function fstat(fd: number, useBigint: true, req: FSReqCallback<BigUint64Array>): void; |
| 76 | + function fstat(fd: number, useBigint: false, req: FSReqCallback<Float64Array>): void; |
| 77 | + function fstat(fd: number, useBigint: boolean, req: undefined, ctx: FSSyncContext): Float64Array | BigUint64Array; |
| 78 | + function fstat(fd: number, useBigint: true, req: undefined, ctx: FSSyncContext): BigUint64Array; |
| 79 | + function fstat(fd: number, useBigint: false, req: undefined, ctx: FSSyncContext): Float64Array; |
| 80 | + function fstat(fd: number, useBigint: boolean, usePromises: typeof kUsePromises): Promise<Float64Array | BigUint64Array>; |
| 81 | + function fstat(fd: number, useBigint: true, usePromises: typeof kUsePromises): Promise<BigUint64Array>; |
| 82 | + function fstat(fd: number, useBigint: false, usePromises: typeof kUsePromises): Promise<Float64Array>; |
| 83 | + |
| 84 | + function fsync(fd: number, req: FSReqCallback): void; |
| 85 | + function fsync(fd: number, req: undefined, ctx: FSSyncContext): void; |
| 86 | + function fsync(fd: number, usePromises: typeof kUsePromises): Promise<void>; |
| 87 | + |
| 88 | + function ftruncate(fd: number, len: number, req: FSReqCallback): void; |
| 89 | + function ftruncate(fd: number, len: number, req: undefined, ctx: FSSyncContext): void; |
| 90 | + function ftruncate(fd: number, len: number, usePromises: typeof kUsePromises): Promise<void>; |
| 91 | + |
| 92 | + function futimes(fd: number, atime: number, mtime: number, req: FSReqCallback): void; |
| 93 | + function futimes(fd: number, atime: number, mtime: number, req: undefined, ctx: FSSyncContext): void; |
| 94 | + function futimes(fd: number, atime: number, mtime: number, usePromises: typeof kUsePromises): Promise<void>; |
| 95 | + |
| 96 | + function internalModuleReadJSON(path: string): [] | [string, boolean]; |
| 97 | + function internalModuleStat(path: string): number; |
| 98 | + |
| 99 | + function lchown(path: string, uid: number, gid: number, req: FSReqCallback): void; |
| 100 | + function lchown(path: string, uid: number, gid: number, req: undefined, ctx: FSSyncContext): void; |
| 101 | + function lchown(path: string, uid: number, gid: number, usePromises: typeof kUsePromises): Promise<void>; |
| 102 | + |
| 103 | + function link(existingPath: string, newPath: string, req: FSReqCallback): void; |
| 104 | + function link(existingPath: string, newPath: string, req: undefined, ctx: FSSyncContext): void; |
| 105 | + function link(existingPath: string, newPath: string, usePromises: typeof kUsePromises): Promise<void>; |
| 106 | + |
| 107 | + function lstat(path: StringOrBuffer, useBigint: boolean, req: FSReqCallback<Float64Array | BigUint64Array>): void; |
| 108 | + function lstat(path: StringOrBuffer, useBigint: true, req: FSReqCallback<BigUint64Array>): void; |
| 109 | + function lstat(path: StringOrBuffer, useBigint: false, req: FSReqCallback<Float64Array>): void; |
| 110 | + function lstat(path: StringOrBuffer, useBigint: boolean, req: undefined, ctx: FSSyncContext): Float64Array | BigUint64Array; |
| 111 | + function lstat(path: StringOrBuffer, useBigint: true, req: undefined, ctx: FSSyncContext): BigUint64Array; |
| 112 | + function lstat(path: StringOrBuffer, useBigint: false, req: undefined, ctx: FSSyncContext): Float64Array; |
| 113 | + function lstat(path: StringOrBuffer, useBigint: boolean, usePromises: typeof kUsePromises): Promise<Float64Array | BigUint64Array>; |
| 114 | + function lstat(path: StringOrBuffer, useBigint: true, usePromises: typeof kUsePromises): Promise<BigUint64Array>; |
| 115 | + function lstat(path: StringOrBuffer, useBigint: false, usePromises: typeof kUsePromises): Promise<Float64Array>; |
| 116 | + |
| 117 | + function lutimes(path: string, atime: number, mtime: number, req: FSReqCallback): void; |
| 118 | + function lutimes(path: string, atime: number, mtime: number, req: undefined, ctx: FSSyncContext): void; |
| 119 | + function lutimes(path: string, atime: number, mtime: number, usePromises: typeof kUsePromises): Promise<void>; |
| 120 | + |
| 121 | + function mkdtemp(prefix: string, encoding: unknown, req: FSReqCallback<string>): void; |
| 122 | + function mkdtemp(prefix: string, encoding: unknown, req: undefined, ctx: FSSyncContext): string; |
| 123 | + function mkdtemp(prefix: string, encoding: unknown, usePromises: typeof kUsePromises): Promise<string>; |
| 124 | + |
| 125 | + function mkdir(path: string, mode: number, recursive: boolean, req: FSReqCallback<void | string>): void; |
| 126 | + function mkdir(path: string, mode: number, recursive: true, req: FSReqCallback<string>): void; |
| 127 | + function mkdir(path: string, mode: number, recursive: false, req: FSReqCallback<void>): void; |
| 128 | + function mkdir(path: string, mode: number, recursive: boolean, req: undefined, ctx: FSSyncContext): void | string; |
| 129 | + function mkdir(path: string, mode: number, recursive: true, req: undefined, ctx: FSSyncContext): string; |
| 130 | + function mkdir(path: string, mode: number, recursive: false, req: undefined, ctx: FSSyncContext): void; |
| 131 | + function mkdir(path: string, mode: number, recursive: boolean, usePromises: typeof kUsePromises): Promise<void | string>; |
| 132 | + function mkdir(path: string, mode: number, recursive: true, usePromises: typeof kUsePromises): Promise<string>; |
| 133 | + function mkdir(path: string, mode: number, recursive: false, usePromises: typeof kUsePromises): Promise<void>; |
| 134 | + |
| 135 | + function open(path: StringOrBuffer, flags: number, mode: number, req: FSReqCallback<number>): void; |
| 136 | + function open(path: StringOrBuffer, flags: number, mode: number, req: undefined, ctx: FSSyncContext): number; |
| 137 | + |
| 138 | + function openFileHandle(path: StringOrBuffer, flags: number, mode: number, usePromises: typeof kUsePromises): Promise<FileHandle>; |
| 139 | + |
| 140 | + function read(fd: number, buffer: ArrayBufferView, offset: number, length: number, position: number, req: FSReqCallback<number>): void; |
| 141 | + function read(fd: number, buffer: ArrayBufferView, offset: number, length: number, position: number, req: undefined, ctx: FSSyncContext): number; |
| 142 | + function read(fd: number, buffer: ArrayBufferView, offset: number, length: number, position: number, usePromises: typeof kUsePromises): Promise<number>; |
| 143 | + |
| 144 | + function readBuffers(fd: number, buffers: ArrayBufferView[], position: number, req: FSReqCallback<number>): void; |
| 145 | + function readBuffers(fd: number, buffers: ArrayBufferView[], position: number, req: undefined, ctx: FSSyncContext): number; |
| 146 | + function readBuffers(fd: number, buffers: ArrayBufferView[], position: number, usePromises: typeof kUsePromises): Promise<number>; |
| 147 | + |
| 148 | + function readdir(path: StringOrBuffer, encoding: unknown, withFileTypes: boolean, req: FSReqCallback<string[] | [string[], number[]]>): void; |
| 149 | + function readdir(path: StringOrBuffer, encoding: unknown, withFileTypes: true, req: FSReqCallback<[string[], number[]]>): void; |
| 150 | + function readdir(path: StringOrBuffer, encoding: unknown, withFileTypes: false, req: FSReqCallback<string[]>): void; |
| 151 | + function readdir(path: StringOrBuffer, encoding: unknown, withFileTypes: boolean, req: undefined, ctx: FSSyncContext): string[] | [string[], number[]]; |
| 152 | + function readdir(path: StringOrBuffer, encoding: unknown, withFileTypes: true, req: undefined, ctx: FSSyncContext): [string[], number[]]; |
| 153 | + function readdir(path: StringOrBuffer, encoding: unknown, withFileTypes: false, req: undefined, ctx: FSSyncContext): string[]; |
| 154 | + function readdir(path: StringOrBuffer, encoding: unknown, withFileTypes: boolean, usePromises: typeof kUsePromises): Promise<string[] | [string[], number[]]>; |
| 155 | + function readdir(path: StringOrBuffer, encoding: unknown, withFileTypes: true, usePromises: typeof kUsePromises): Promise<[string[], number[]]>; |
| 156 | + function readdir(path: StringOrBuffer, encoding: unknown, withFileTypes: false, usePromises: typeof kUsePromises): Promise<string[]>; |
| 157 | + |
| 158 | + function readlink(path: StringOrBuffer, encoding: unknown, req: FSReqCallback<string | Buffer>): void; |
| 159 | + function readlink(path: StringOrBuffer, encoding: unknown, req: undefined, ctx: FSSyncContext): string | Buffer; |
| 160 | + function readlink(path: StringOrBuffer, encoding: unknown, usePromises: typeof kUsePromises): Promise<string | Buffer>; |
| 161 | + |
| 162 | + function realpath(path: StringOrBuffer, encoding: unknown, req: FSReqCallback<string | Buffer>): void; |
| 163 | + function realpath(path: StringOrBuffer, encoding: unknown, req: undefined, ctx: FSSyncContext): string | Buffer; |
| 164 | + function realpath(path: StringOrBuffer, encoding: unknown, usePromises: typeof kUsePromises): Promise<string | Buffer>; |
| 165 | + |
| 166 | + function rename(oldPath: string, newPath: string, req: FSReqCallback): void; |
| 167 | + function rename(oldPath: string, newPath: string, req: undefined, ctx: FSSyncContext): void; |
| 168 | + function rename(oldPath: string, newPath: string, usePromises: typeof kUsePromises): Promise<void>; |
| 169 | + |
| 170 | + function rmdir(path: string, req: FSReqCallback): void; |
| 171 | + function rmdir(path: string, req: undefined, ctx: FSSyncContext): void; |
| 172 | + function rmdir(path: string, usePromises: typeof kUsePromises): Promise<void>; |
| 173 | + |
| 174 | + function stat(path: StringOrBuffer, useBigint: boolean, req: FSReqCallback<Float64Array | BigUint64Array>): void; |
| 175 | + function stat(path: StringOrBuffer, useBigint: true, req: FSReqCallback<BigUint64Array>): void; |
| 176 | + function stat(path: StringOrBuffer, useBigint: false, req: FSReqCallback<Float64Array>): void; |
| 177 | + function stat(path: StringOrBuffer, useBigint: boolean, req: undefined, ctx: FSSyncContext): Float64Array | BigUint64Array; |
| 178 | + function stat(path: StringOrBuffer, useBigint: true, req: undefined, ctx: FSSyncContext): BigUint64Array; |
| 179 | + function stat(path: StringOrBuffer, useBigint: false, req: undefined, ctx: FSSyncContext): Float64Array; |
| 180 | + function stat(path: StringOrBuffer, useBigint: boolean, usePromises: typeof kUsePromises): Promise<Float64Array | BigUint64Array>; |
| 181 | + function stat(path: StringOrBuffer, useBigint: true, usePromises: typeof kUsePromises): Promise<BigUint64Array>; |
| 182 | + function stat(path: StringOrBuffer, useBigint: false, usePromises: typeof kUsePromises): Promise<Float64Array>; |
| 183 | + |
| 184 | + function symlink(target: StringOrBuffer, path: StringOrBuffer, type: number, req: FSReqCallback): void; |
| 185 | + function symlink(target: StringOrBuffer, path: StringOrBuffer, type: number, req: undefined, ctx: FSSyncContext): void; |
| 186 | + function symlink(target: StringOrBuffer, path: StringOrBuffer, type: number, usePromises: typeof kUsePromises): Promise<void>; |
| 187 | + |
| 188 | + function unlink(path: string, req: FSReqCallback): void; |
| 189 | + function unlink(path: string, req: undefined, ctx: FSSyncContext): void; |
| 190 | + function unlink(path: string, usePromises: typeof kUsePromises): Promise<void>; |
| 191 | + |
| 192 | + function utimes(path: string, atime: number, mtime: number, req: FSReqCallback): void; |
| 193 | + function utimes(path: string, atime: number, mtime: number, req: undefined, ctx: FSSyncContext): void; |
| 194 | + function utimes(path: string, atime: number, mtime: number, usePromises: typeof kUsePromises): Promise<void>; |
| 195 | + |
| 196 | + function writeBuffer(fd: number, buffer: ArrayBufferView, offset: number, length: number, position: number | null, req: FSReqCallback<number>): void; |
| 197 | + function writeBuffer(fd: number, buffer: ArrayBufferView, offset: number, length: number, position: number | null, req: undefined, ctx: FSSyncContext): number; |
| 198 | + function writeBuffer(fd: number, buffer: ArrayBufferView, offset: number, length: number, position: number | null, usePromises: typeof kUsePromises): Promise<number>; |
| 199 | + |
| 200 | + function writeBuffers(fd: number, buffers: ArrayBufferView[], position: number, req: FSReqCallback<number>): void; |
| 201 | + function writeBuffers(fd: number, buffers: ArrayBufferView[], position: number, req: undefined, ctx: FSSyncContext): number; |
| 202 | + function writeBuffers(fd: number, buffers: ArrayBufferView[], position: number, usePromises: typeof kUsePromises): Promise<number>; |
| 203 | + |
| 204 | + function writeString(fd: number, value: string, pos: unknown, encoding: unknown, req: FSReqCallback<number>): void; |
| 205 | + function writeString(fd: number, value: string, pos: unknown, encoding: unknown, req: undefined, ctx: FSSyncContext): number; |
| 206 | + function writeString(fd: number, value: string, pos: unknown, encoding: unknown, usePromises: typeof kUsePromises): Promise<number>; |
| 207 | +} |
| 208 | + |
| 209 | +declare function InternalBinding(binding: 'fs'): { |
| 210 | + FSReqCallback: typeof InternalFSBinding.FSReqCallback; |
| 211 | + |
| 212 | + FileHandle: typeof InternalFSBinding.FileHandle; |
| 213 | + |
| 214 | + kUsePromises: typeof InternalFSBinding.kUsePromises; |
| 215 | + |
| 216 | + statValues: Float64Array; |
| 217 | + bigintStatValues: BigUint64Array; |
| 218 | + |
| 219 | + kFsStatsFieldsNumber: number; |
| 220 | + StatWatcher: typeof InternalFSBinding.StatWatcher; |
| 221 | + |
| 222 | + access: typeof InternalFSBinding.access; |
| 223 | + chmod: typeof InternalFSBinding.chmod; |
| 224 | + chown: typeof InternalFSBinding.chown; |
| 225 | + close: typeof InternalFSBinding.close; |
| 226 | + copyFile: typeof InternalFSBinding.copyFile; |
| 227 | + fchmod: typeof InternalFSBinding.fchmod; |
| 228 | + fchown: typeof InternalFSBinding.fchown; |
| 229 | + fdatasync: typeof InternalFSBinding.fdatasync; |
| 230 | + fstat: typeof InternalFSBinding.fstat; |
| 231 | + fsync: typeof InternalFSBinding.fsync; |
| 232 | + ftruncate: typeof InternalFSBinding.ftruncate; |
| 233 | + futimes: typeof InternalFSBinding.futimes; |
| 234 | + internalModuleReadJSON: typeof InternalFSBinding.internalModuleReadJSON; |
| 235 | + internalModuleStat: typeof InternalFSBinding.internalModuleStat; |
| 236 | + lchown: typeof InternalFSBinding.lchown; |
| 237 | + link: typeof InternalFSBinding.link; |
| 238 | + lstat: typeof InternalFSBinding.lstat; |
| 239 | + lutimes: typeof InternalFSBinding.lutimes; |
| 240 | + mkdtemp: typeof InternalFSBinding.mkdtemp; |
| 241 | + mkdir: typeof InternalFSBinding.mkdir; |
| 242 | + open: typeof InternalFSBinding.open; |
| 243 | + openFileHandle: typeof InternalFSBinding.openFileHandle; |
| 244 | + read: typeof InternalFSBinding.read; |
| 245 | + readBuffers: typeof InternalFSBinding.readBuffers; |
| 246 | + readdir: typeof InternalFSBinding.readdir; |
| 247 | + readlink: typeof InternalFSBinding.readlink; |
| 248 | + realpath: typeof InternalFSBinding.realpath; |
| 249 | + rename: typeof InternalFSBinding.rename; |
| 250 | + rmdir: typeof InternalFSBinding.rmdir; |
| 251 | + stat: typeof InternalFSBinding.stat; |
| 252 | + symlink: typeof InternalFSBinding.symlink; |
| 253 | + unlink: typeof InternalFSBinding.unlink; |
| 254 | + utimes: typeof InternalFSBinding.utimes; |
| 255 | + writeBuffer: typeof InternalFSBinding.writeBuffer; |
| 256 | + writeBuffers: typeof InternalFSBinding.writeBuffers; |
| 257 | + writeString: typeof InternalFSBinding.writeString; |
| 258 | +}; |
0 commit comments