rescript-nodejs icon indicating copy to clipboard operation
rescript-nodejs copied to clipboard

readFileSyncWith should return string

Open punund opened this issue 1 year ago • 2 comments

--- a/src/Fs.res
+++ b/src/Fs.res
@@ -248,7 +248,7 @@ external openSyncWith: (string, ~flag: Flag.t=?, ~mode: int=?) => fd = "openSync
 @module("node:fs")
 external readFileSync: string => Buffer.t = "readFileSync"
 @module("node:fs")
-external readFileSyncWith: (string, readFileOptions) => Buffer.t = "readFileSync"
+external readFileSyncWith: (string, readFileOptions) => string = "readFileSync"

 @module("node:fs") external existsSync: string => bool = "existsSync"

punund avatar Mar 11 '24 15:03 punund

If it's true there, it would be true of readFileSync as well.

Turns out the return value is based on the encoding option: https://nodejs.org/api/fs.html#filehandlereadfileoptions

That's going to be interesting to bind.

TheSpyder avatar Mar 11 '24 22:03 TheSpyder

The same goes for write, I think

vadimyen avatar Jun 09 '24 15:06 vadimyen