Skip to content

Commit 8f8201b

Browse files
authored
Node.Fs -> Node.Fs2 (#3312)
1 parent a44de71 commit 8f8201b

File tree

13 files changed

+287
-114
lines changed

13 files changed

+287
-114
lines changed

jscomp/others/build.ninja

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,10 @@ build others/dom_storage.cmi : cc others/dom_storage.mli | others/dom_storage2.c
204204
build others/dom_storage2.cmi : cc others/dom_storage2.mli | runtime
205205
build others/node_buffer.cmi others/node_buffer.cmj : cc others/node_buffer.ml | others/node.cmi others/node.cmj js_pkg runtime
206206
build others/node_child_process.cmi others/node_child_process.cmj : cc others/node_child_process.ml | others/node.cmi others/node.cmj js_pkg runtime
207-
build others/node_fs.cmi others/node_fs.cmj : cc others/node_fs.ml | others/js_string.cmj others/node.cmi others/node.cmj js_pkg runtime
207+
build others/node_fs.cmi others/node_fs.cmj : cc others/node_fs.ml | others/js_string.cmj others/node.cmi others/node.cmj others/node_fs2.cmj js_pkg runtime
208+
build others/node_fs2.cmi others/node_fs2.cmj : cc others/node_fs2.ml | others/js_string.cmj others/node.cmi others/node.cmj js_pkg runtime
208209
build others/node_module.cmi others/node_module.cmj : cc others/node_module.ml | others/js_dict.cmj others/node.cmi others/node.cmj js_pkg runtime
209210
build others/node_path.cmi others/node_path.cmj : cc others/node_path.ml | runtime
210211
build others/node_process.cmj : cc others/node_process.ml | others/js_dict.cmj others/node.cmi others/node_process.cmi js_pkg runtime
211212
build others/node_process.cmi : cc others/node_process.mli | others/js_dict.cmi others/node.cmi js_pkg runtime
212-
build others : phony others/belt_Array.cmi others/belt_Array.cmj others/belt_Debug.cmi others/belt_Debug.cmj others/belt_HashMap.cmi others/belt_HashMap.cmj others/belt_HashMapInt.cmi others/belt_HashMapInt.cmj others/belt_HashMapString.cmi others/belt_HashMapString.cmj others/belt_HashSet.cmi others/belt_HashSet.cmj others/belt_HashSetInt.cmi others/belt_HashSetInt.cmj others/belt_HashSetString.cmi others/belt_HashSetString.cmj others/belt_Id.cmi others/belt_Id.cmj others/belt_List.cmi others/belt_List.cmj others/belt_Map.cmi others/belt_Map.cmj others/belt_MapDict.cmi others/belt_MapDict.cmj others/belt_MapInt.cmi others/belt_MapInt.cmj others/belt_MapString.cmi others/belt_MapString.cmj others/belt_MutableMap.cmi others/belt_MutableMap.cmj others/belt_MutableMapInt.cmi others/belt_MutableMapInt.cmj others/belt_MutableMapString.cmi others/belt_MutableMapString.cmj others/belt_MutableQueue.cmi others/belt_MutableQueue.cmj others/belt_MutableSet.cmi others/belt_MutableSet.cmj others/belt_MutableSetInt.cmi others/belt_MutableSetInt.cmj others/belt_MutableSetString.cmi others/belt_MutableSetString.cmj others/belt_MutableStack.cmi others/belt_MutableStack.cmj others/belt_Option.cmi others/belt_Option.cmj others/belt_Range.cmi others/belt_Range.cmj others/belt_Result.cmi others/belt_Result.cmj others/belt_Set.cmi others/belt_Set.cmj others/belt_SetDict.cmi others/belt_SetDict.cmj others/belt_SetInt.cmi others/belt_SetInt.cmj others/belt_SetString.cmi others/belt_SetString.cmj others/belt_SortArray.cmi others/belt_SortArray.cmj others/belt_SortArrayInt.cmi others/belt_SortArrayInt.cmj others/belt_SortArrayString.cmi others/belt_SortArrayString.cmj others/belt_internalAVLset.cmi others/belt_internalAVLset.cmj others/belt_internalAVLtree.cmi others/belt_internalAVLtree.cmj others/belt_internalBuckets.cmi others/belt_internalBuckets.cmj others/belt_internalBucketsType.cmi others/belt_internalBucketsType.cmj others/belt_internalMapInt.cmi others/belt_internalMapInt.cmj others/belt_internalMapString.cmi others/belt_internalMapString.cmj others/belt_internalSetBuckets.cmi others/belt_internalSetBuckets.cmj others/belt_internalSetInt.cmi others/belt_internalSetInt.cmj others/belt_internalSetString.cmi others/belt_internalSetString.cmj others/dom.cmi others/dom_storage.cmi others/dom_storage2.cmi others/node_buffer.cmi others/node_buffer.cmj others/node_child_process.cmi others/node_child_process.cmj others/node_fs.cmi others/node_fs.cmj others/node_module.cmi others/node_module.cmj others/node_path.cmi others/node_path.cmj others/node_process.cmi others/node_process.cmj
213+
build others : phony others/belt_Array.cmi others/belt_Array.cmj others/belt_Debug.cmi others/belt_Debug.cmj others/belt_HashMap.cmi others/belt_HashMap.cmj others/belt_HashMapInt.cmi others/belt_HashMapInt.cmj others/belt_HashMapString.cmi others/belt_HashMapString.cmj others/belt_HashSet.cmi others/belt_HashSet.cmj others/belt_HashSetInt.cmi others/belt_HashSetInt.cmj others/belt_HashSetString.cmi others/belt_HashSetString.cmj others/belt_Id.cmi others/belt_Id.cmj others/belt_List.cmi others/belt_List.cmj others/belt_Map.cmi others/belt_Map.cmj others/belt_MapDict.cmi others/belt_MapDict.cmj others/belt_MapInt.cmi others/belt_MapInt.cmj others/belt_MapString.cmi others/belt_MapString.cmj others/belt_MutableMap.cmi others/belt_MutableMap.cmj others/belt_MutableMapInt.cmi others/belt_MutableMapInt.cmj others/belt_MutableMapString.cmi others/belt_MutableMapString.cmj others/belt_MutableQueue.cmi others/belt_MutableQueue.cmj others/belt_MutableSet.cmi others/belt_MutableSet.cmj others/belt_MutableSetInt.cmi others/belt_MutableSetInt.cmj others/belt_MutableSetString.cmi others/belt_MutableSetString.cmj others/belt_MutableStack.cmi others/belt_MutableStack.cmj others/belt_Option.cmi others/belt_Option.cmj others/belt_Range.cmi others/belt_Range.cmj others/belt_Result.cmi others/belt_Result.cmj others/belt_Set.cmi others/belt_Set.cmj others/belt_SetDict.cmi others/belt_SetDict.cmj others/belt_SetInt.cmi others/belt_SetInt.cmj others/belt_SetString.cmi others/belt_SetString.cmj others/belt_SortArray.cmi others/belt_SortArray.cmj others/belt_SortArrayInt.cmi others/belt_SortArrayInt.cmj others/belt_SortArrayString.cmi others/belt_SortArrayString.cmj others/belt_internalAVLset.cmi others/belt_internalAVLset.cmj others/belt_internalAVLtree.cmi others/belt_internalAVLtree.cmj others/belt_internalBuckets.cmi others/belt_internalBuckets.cmj others/belt_internalBucketsType.cmi others/belt_internalBucketsType.cmj others/belt_internalMapInt.cmi others/belt_internalMapInt.cmj others/belt_internalMapString.cmi others/belt_internalMapString.cmj others/belt_internalSetBuckets.cmi others/belt_internalSetBuckets.cmj others/belt_internalSetInt.cmi others/belt_internalSetInt.cmj others/belt_internalSetString.cmi others/belt_internalSetString.cmj others/dom.cmi others/dom_storage.cmi others/dom_storage2.cmi others/node_buffer.cmi others/node_buffer.cmj others/node_child_process.cmi others/node_child_process.cmj others/node_fs.cmi others/node_fs.cmj others/node_fs2.cmi others/node_fs2.cmj others/node_module.cmi others/node_module.cmj others/node_path.cmi others/node_path.cmj others/node_process.cmi others/node_process.cmj

jscomp/others/node.ml

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
2-
*
2+
*
33
* This program is free software: you can redistribute it and/or modify
44
* it under the terms of the GNU Lesser General Public License as published by
55
* the Free Software Foundation, either version 3 of the License, or
@@ -17,7 +17,7 @@
1717
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1818
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1919
* GNU Lesser General Public License for more details.
20-
*
20+
*
2121
* You should have received a copy of the GNU Lesser General Public License
2222
* along with this program; if not, write to the Free Software
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
@@ -27,30 +27,31 @@
2727
module Path = Node_path
2828

2929
module Fs = Node_fs
30+
module Fs2 = Node_fs2
3031

3132
module Process = Node_process
3233

3334
module Module = Node_module
3435
module Buffer = Node_buffer
3536
module Child_process = Node_child_process
3637

37-
type node_exports
38+
type node_exports
3839
type node_module = <
3940
id : string ;
4041
exports : node_exports ;
4142
parrent : node_module Js.null_undefined;
4243
(* in REPL V4 it is [undefined]
4344
in CLI it can be [null]
44-
*)
45-
46-
filename : string ;
45+
*)
46+
47+
filename : string ;
4748

4849
loaded : bool;
4950
children : node_module array ;
50-
paths : string array;
51+
paths : string array;
5152
> Js.t
52-
(* WARN:
53-
its path name should not be changed
53+
(* WARN:
54+
its path name should not be changed
5455
see {!Ppx_entry}
5556
*)
5657

@@ -59,24 +60,24 @@ type node_require = <
5960

6061
resolve : string -> string [@bs]
6162
(* @raise exception *)
62-
> Js.t
63+
> Js.t
6364
(* WARN:
64-
its path name should not be changed
65+
its path name should not be changed
6566
see {!Ppx_entry}
6667
*)
6768

6869
type string_buffer (* can be either string or buffer *)
6970

70-
type buffer
71+
type buffer
7172

72-
type _ string_buffer_kind =
73+
type _ string_buffer_kind =
7374
| String : string string_buffer_kind
7475
| Buffer : buffer string_buffer_kind
7576

7677

7778
(** We expect a good inliner will eliminate such boxing in the future *)
78-
let test (type t) (x : string_buffer) : (t string_buffer_kind * t)=
79-
if Js.typeof x = "string" then
79+
let test (type t) (x : string_buffer) : (t string_buffer_kind * t)=
80+
if Js.typeof x = "string" then
8081
(Obj.magic String : t string_buffer_kind), (Obj.magic x : t)
81-
else
82+
else
8283
(Obj.magic Buffer : t string_buffer_kind), (Obj.magic x : t)

jscomp/others/node_fs.ml

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
2-
*
2+
*
33
* This program is free software: you can redistribute it and/or modify
44
* it under the terms of the GNU Lesser General Public License as published by
55
* the Free Software Foundation, either version 3 of the License, or
@@ -17,7 +17,7 @@
1717
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1818
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1919
* GNU Lesser General Public License for more details.
20-
*
20+
*
2121
* You should have received a copy of the GNU Lesser General Public License
2222
* along with this program; if not, write to the Free Software
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
@@ -31,60 +31,60 @@
3131
callback is used that rethrows errors. To get a trace to the original call
3232
site, set the `NODE_DEBUG` environment variable:
3333
*)
34-
external readdirSync : string -> string array = "" [@@bs.module "fs"]
34+
external readdirSync : string -> string array = "" [@@bs.module "fs"]
3535

36-
external renameSync : string -> string = "" [@@bs.module "fs"]
36+
external renameSync : string -> string = "" [@@bs.module "fs"]
3737

38-
type fd = private int
38+
type fd = Node_fs2.fd
3939

4040
type path = string
4141
(**
4242
The relative path to a filename can be used. Remember, however, that this path
4343
will be relative to [process.cwd()].
44-
*)
44+
*)
4545

46-
module Watch = struct
47-
type t
48-
type config
46+
module Watch = struct
47+
type t = Node_fs2.Watch.t
48+
type config = Node_fs2.Watch.config
4949
external config :
5050
?persistent: bool ->
51-
?recursive: bool ->
52-
?encoding: Js_string.t ->
53-
unit -> config =
51+
?recursive: bool ->
52+
?encoding: Js_string.t ->
53+
unit -> config =
5454
"" [@@bs.obj]
5555

5656
external watch :
57-
string ->
58-
?config:config ->
59-
unit ->
60-
t = ""
57+
string ->
58+
?config:config ->
59+
unit ->
60+
t = ""
6161
[@@bs.module "fs"]
62-
(** there is no need to accept listener, since we return a [watcher]
62+
(** there is no need to accept listener, since we return a [watcher]
6363
back it can register event listener there .
64-
Currently we introduce a type [string_buffer], for the
65-
[filename], it will be [Buffer] when the encoding is `utf8.
66-
This is dependent type which can be tracked by GADT in some way,
64+
Currently we introduce a type [string_buffer], for the
65+
[filename], it will be [Buffer] when the encoding is `utf8.
66+
This is dependent type which can be tracked by GADT in some way,
6767
but to make things simple, let's just introduce an or type
6868
*)
6969
external on :
7070
([
7171
`change of (string (*eventType*) -> Node.string_buffer (* filename *) -> unit [@bs])
7272
| `error of (unit -> unit [@bs])
7373
] [@bs.string]
74-
) -> t = ""
74+
) -> t = ""
7575
[@@bs.send.pipe: t]
7676

7777

7878
external close : unit = "" [@@bs.send.pipe:t]
7979
end
8080

81-
external ftruncateSync : fd -> int -> unit = "" [@@bs.module "fs"]
81+
external ftruncateSync : fd -> int -> unit = "" [@@bs.module "fs"]
8282

83-
external truncateSync : string -> int -> unit = "" [@@bs.module "fs"]
83+
external truncateSync : string -> int -> unit = "" [@@bs.module "fs"]
8484

85-
external chownSync : string -> uid:int -> gid:int -> unit = "" [@@bs.module "fs"]
85+
external chownSync : string -> uid:int -> gid:int -> unit = "" [@@bs.module "fs"]
8686

87-
external fchownSync : fd -> uid:int -> gid:int -> unit = "" [@@bs.module "fs"]
87+
external fchownSync : fd -> uid:int -> gid:int -> unit = "" [@@bs.module "fs"]
8888

8989
external readlinkSync : string -> string = "" [@@bs.module "fs"]
9090

@@ -93,7 +93,7 @@ external unlinkSync : string -> unit = "" [@@bs.module "fs"]
9393
external rmdirSync : string -> unit = "" [@@bs.module "fs"]
9494

9595
(* TODO: [flags] support *)
96-
external openSync :
96+
external openSync :
9797
path ->
9898
(
9999
[ `Read [@bs.as "r"]
@@ -111,29 +111,29 @@ external openSync :
111111
unit = "" [@@bs.module "fs"]
112112

113113

114-
external readFileSync :
114+
external readFileSync :
115115
string ->
116-
(
116+
(
117117
[
118118
`hex
119119
| `utf8
120-
| `ascii
120+
| `ascii
121121
| `latin1
122-
| `base64
122+
| `base64
123123
| `ucs2
124124
| `base64
125-
| `binary
125+
| `binary
126126
| `utf16le ][@bs.string]) ->
127-
string = "readFileSync"
127+
string = "readFileSync"
128128
[@@bs.val] [@@bs.module "fs"]
129129

130-
external readFileAsUtf8Sync :
131-
string -> (_[@bs.as "utf8"]) ->
130+
external readFileAsUtf8Sync :
131+
string -> (_[@bs.as "utf8"]) ->
132132
string = "readFileSync"
133-
[@@bs.val] [@@bs.module "fs"]
133+
[@@bs.val] [@@bs.module "fs"]
134134

135135
external existsSync : string -> bool = ""
136-
[@@bs.val] [@@bs.module "fs"]
136+
[@@bs.val] [@@bs.module "fs"]
137137

138138
external writeFileSync :
139139
string ->

0 commit comments

Comments
 (0)