mirror of https://github.com/nodejs/node.git
typings: add `fs_dir` types
PR-URL: https://github.com/nodejs/node/pull/53631 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: James M Snell <jasnell@gmail.com>pull/53826/head
parent
bac28678e6
commit
0e25faea0a
|
@ -4,6 +4,7 @@ import {ConfigBinding} from "./internalBinding/config";
|
|||
import {ConstantsBinding} from "./internalBinding/constants";
|
||||
import {HttpParserBinding} from "./internalBinding/http_parser";
|
||||
import {FsBinding} from "./internalBinding/fs";
|
||||
import {FsDirBinding} from "./internalBinding/fs_dir";
|
||||
import {MessagingBinding} from "./internalBinding/messaging";
|
||||
import {OptionsBinding} from "./internalBinding/options";
|
||||
import {OSBinding} from "./internalBinding/os";
|
||||
|
@ -35,6 +36,7 @@ interface InternalBindingMap {
|
|||
config: ConfigBinding;
|
||||
constants: ConstantsBinding;
|
||||
fs: FsBinding;
|
||||
fs_dir: FsDirBinding;
|
||||
http_parser: HttpParserBinding;
|
||||
messaging: MessagingBinding;
|
||||
modules: ModulesBinding;
|
||||
|
|
|
@ -1,5 +1,18 @@
|
|||
import { ConstantsBinding } from './constants';
|
||||
|
||||
interface ReadFileContext {
|
||||
fd: number | undefined;
|
||||
isUserFd: boolean | undefined;
|
||||
size: number;
|
||||
callback: (err?: Error, data?: string | Uint8Array) => unknown;
|
||||
buffers: Uint8Array[];
|
||||
buffer: Uint8Array;
|
||||
pos: number;
|
||||
encoding: string;
|
||||
err: Error | null;
|
||||
signal: unknown /* AbortSignal | undefined */;
|
||||
}
|
||||
|
||||
declare namespace InternalFSBinding {
|
||||
class FSReqCallback<ResultType = unknown> {
|
||||
constructor(bigint?: boolean);
|
||||
|
@ -7,19 +20,6 @@ declare namespace InternalFSBinding {
|
|||
context: ReadFileContext;
|
||||
}
|
||||
|
||||
interface ReadFileContext {
|
||||
fd: number | undefined;
|
||||
isUserFd: boolean | undefined;
|
||||
size: number;
|
||||
callback: (err?: Error, data?: string | Buffer) => unknown;
|
||||
buffers: Buffer[];
|
||||
buffer: Buffer;
|
||||
pos: number;
|
||||
encoding: string;
|
||||
err: Error | null;
|
||||
signal: unknown /* AbortSignal | undefined */;
|
||||
}
|
||||
|
||||
interface FSSyncContext {
|
||||
fd?: number;
|
||||
path?: string;
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
import {InternalFSBinding, ReadFileContext} from './fs';
|
||||
|
||||
declare namespace InternalFSDirBinding {
|
||||
import FSReqCallback = InternalFSBinding.FSReqCallback;
|
||||
type Buffer = Uint8Array;
|
||||
type StringOrBuffer = string | Buffer;
|
||||
|
||||
class DirHandle {
|
||||
read(encoding: string, bufferSize: number, _: unknown, ctx: ReadFileContext): string[] | undefined;
|
||||
close(_: unknown, ctx: ReadFileContext): void;
|
||||
}
|
||||
|
||||
function opendir(path: StringOrBuffer, encoding: string, req: FSReqCallback): DirHandle;
|
||||
function opendir(path: StringOrBuffer, encoding: string, _: undefined, ctx: ReadFileContext): DirHandle;
|
||||
function opendirSync(path: StringOrBuffer): DirHandle;
|
||||
}
|
||||
|
||||
export interface FsDirBinding {
|
||||
opendir: typeof InternalFSDirBinding.opendir;
|
||||
opendirSync: typeof InternalFSDirBinding.opendirSync;
|
||||
}
|
Loading…
Reference in New Issue