Skip to content

Commit 86073c9

Browse files
committed
Add encoding as an option to various methods (sikanhe/reason-nodejs#53)
1 parent 9228a1f commit 86073c9

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/Fs.res

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,14 @@ type fd = private int
196196

197197
type writeFileOptions
198198
@obj
199-
external writeFileOptions: (~mode: int=?, ~flag: string=?, unit) => writeFileOptions = ""
199+
external writeFileOptions: (~mode: int=?, ~flag: string=?, ~encoding: string=?, unit) => writeFileOptions = ""
200200

201201
type appendFileOptions
202202
@obj
203-
external appendFileOptions: (~mode: int=?, ~flag: Flag.t=?, unit) => appendFileOptions = ""
203+
external appendFileOptions: (~mode: int=?, ~flag: Flag.t=?, ~encoding: string=?, unit) => appendFileOptions = ""
204204

205205
type readFileOptions
206-
@obj external readFileOptions: (~flag: Flag.t=?, unit) => readFileOptions = ""
206+
@obj external readFileOptions: (~flag: Flag.t=?, ~encoding: string=?, unit) => readFileOptions = ""
207207

208208
@ocaml.doc("
209209
* `readdirSync(path)`
@@ -246,14 +246,10 @@ external openSyncWith: (string, ~flag: Flag.t=?, ~mode: int=?) => fd = "openSync
246246
external readFileSync: (string, ~options: readFileOptions=?, unit) => Buffer.t = "readFileSync"
247247
@module("fs") external existsSync: string => bool = "existsSync"
248248

249-
type writeFileSyncOptions
250-
@obj
251-
external writeFileSyncOptions: (~mode: int=?, ~flag: Flag.t=?, unit) => writeFileSyncOptions = ""
252-
253249
@val @module("fs")
254250
external writeFileSync: (string, Buffer.t) => unit = "writeFileSync"
255251
@val @module("fs")
256-
external writeFileSyncWith: (string, Buffer.t, writeFileSyncOptions) => unit = "writeFileSync"
252+
external writeFileSyncWith: (string, Buffer.t, writeFileOptions) => unit = "writeFileSync"
257253

258254
module FileHandle = {
259255
type t
@@ -307,7 +303,7 @@ module FileHandle = {
307303

308304
type writeFileOptions
309305
@obj
310-
external writeFileOptions: (~mode: int=?, ~flag: Flag.t=?, unit) => writeFileOptions = ""
306+
external writeFileOptions: (~mode: int=?, ~flag: Flag.t=?, ~encoding: string=?, unit) => writeFileOptions = ""
311307

312308
@send
313309
external writeFile: (t, Buffer.t) => Js.Promise.t<unit> = "writeFile"
@@ -380,10 +376,10 @@ external mkdirSync: string => unit = "mkdirSync"
380376
external mkdirSyncWith: (string, mkdirOptions) => unit = "mkdirSync"
381377

382378
type mkdtempOptions
383-
@obj external mdktempOptions: unit => mkdtempOptions = ""
379+
@obj external mdktempOptions: (~encoding: string=?, unit) => mkdtempOptions = ""
384380

385381
@module("fs") @scope("promises")
386-
external mkdtemp: (string, mkdtempOptions) => Js.Promise.t<string> = "mkddtemp"
382+
external mkdtemp: (string) => Js.Promise.t<string> = "mkddtemp"
387383

388384
@module("fs") @scope("promises")
389385
external mkdtempWith: (string, mkdtempOptions) => Js.Promise.t<string> = "mkddtemp"
@@ -454,6 +450,7 @@ type createReadStreamOptions
454450
@obj
455451
external createReadStreamOptions: (
456452
~flags: string=?,
453+
~encoding: string=?,
457454
~fd: fd=?,
458455
~mode: int=?,
459456
~autoClose: bool=?,
@@ -474,6 +471,7 @@ type createWriteStreamOptions
474471
@obj
475472
external createWriteStreamOptions: (
476473
~flags: string=?,
474+
~encoding: string=?,
477475
~fd: fd=?,
478476
~mode: int=?,
479477
~autoClose: bool=?,

0 commit comments

Comments
 (0)