Implement fs.readFile / fs.writeFile

Summary: Per title. Made an explicit distinction between binary and non binary files, since they need to be encoded differently. This keeps both the implementation and API simpler (in terms of overloading / type checking)

Reviewed By: aigoncharov

Differential Revision: D33016031

fbshipit-source-id: 3c99956eb016849a908a171d88a7a64a88b76268
This commit is contained in:
Michel Weststrate
2021-12-13 05:46:42 -08:00
committed by Facebook GitHub Bot
parent 7e9ad72baa
commit d95b15094f
5 changed files with 75 additions and 1 deletions

View File

@@ -66,6 +66,17 @@ export type RemoteServerContext = {
copyFile(src: string, dest: string, flags?: number): Promise<void>;
stat(path: string): Promise<FSStatsLike>;
readlink(path: string): Promise<string>;
readFile(
path: string,
options?: {encoding?: BufferEncoding},
): Promise<string>;
readFileBinary(path: string): Promise<Uint8Array>; // No Buffer, which is not a browser type
writeFile(
path: string,
contents: string,
options?: {encoding?: BufferEncoding},
): Promise<void>;
writeFileBinary(path: string, contents: Uint8Array): Promise<void>;
};
downloadFile(
url: string,