Skip to content

Commit b2bb9ee

Browse files
committed
make runtime ## free
1 parent 6f5eabf commit b2bb9ee

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

Diff for: jscomp/runtime/caml_obj.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ module O = struct
3737
[%raw{|function(o,foo){
3838
for (var x in o) { foo(x) }}
3939
|}]
40-
41-
let hasOwnProperty (o: Caml_obj_extern.t) (key: key) : bool = (Obj.magic o)##hasOwnProperty(key)
40+
external hasOwnProperty :
41+
t -> key -> bool = "hasOwnProperty" [@@bs.send]
4242
external get_value : Caml_obj_extern.t -> key -> Caml_obj_extern.t = ""[@@bs.get_index]
4343
external shallowCopy :
4444
(_ [@bs.as {json|{}|json}]) -> t -> t = "assign"

Diff for: jscomp/runtime/caml_sys.ml

+6-3
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,12 @@ external readAs : spawnResult ->
7878

7979
let caml_sys_system_command _cmd = 127
8080

81-
let caml_sys_getcwd () =
82-
if Js.typeof [%raw{|process|}] = "undefined" then "/"
83-
else [%raw{|process|}]##cwd ()
81+
let caml_sys_getcwd : unit -> string = [%raw{|function(param){
82+
if (typeof process === "undefined" || process.cwd === undefined){
83+
return "/"
84+
}
85+
return process.cwd()
86+
}|}]
8487

8588

8689
(* Called by {!Sys} in the toplevel, should never fail*)

Diff for: lib/js/caml_sys.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,12 @@ function caml_sys_system_command(_cmd) {
3030
return 127;
3131
}
3232

33-
function caml_sys_getcwd(param) {
34-
if (typeof process === "undefined") {
35-
return "/";
36-
} else {
37-
return process.cwd();
38-
}
39-
}
33+
var caml_sys_getcwd = (function(param){
34+
if (typeof process === "undefined" || process.cwd === undefined){
35+
return "/"
36+
}
37+
return process.cwd()
38+
});
4039

4140
function caml_sys_get_argv(param) {
4241
if (typeof process === "undefined") {

0 commit comments

Comments
 (0)