TheSpyder / rescript-nodejs

Node bindings for ReScript
MIT License
80 stars 16 forks source link

readFileSyncWith should return string #27

Open punund opened 8 months ago

punund commented 8 months ago
--- 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"
TheSpyder commented 8 months ago

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.

vadimyen commented 5 months ago

The same goes for write, I think