File tree Expand file tree Collapse file tree 3 files changed +21
-6
lines changed Expand file tree Collapse file tree 3 files changed +21
-6
lines changed Original file line number Diff line number Diff line change 2727type symbol
2828(* * Js symbol type only available in ES6 *)
2929
30+ type bigint_val
31+ (* * Js bigint type only available in ES2020 *)
32+
3033type obj_val
3134type undefined_val
3235(* * This type has only one value `undefined` *)
@@ -45,6 +48,7 @@ type _ t =
4548 | Function : function_val t
4649 | Object : obj_val t
4750 | Symbol : symbol t
51+ | BigInt : bigint_val t
4852
4953
5054
@@ -58,6 +62,7 @@ type tagged_t =
5862 | JSFunction of function_val
5963 | JSObject of obj_val
6064 | JSSymbol of symbol
65+ | JSBigInt of bigint_val
6166
6267let classify (x : 'a ) : tagged_t =
6368 let ty = Js. typeof x in
@@ -66,7 +71,7 @@ let classify (x : 'a) : tagged_t =
6671 if x == (Obj. magic Js_null. empty) then
6772 JSNull else
6873 if ty = " number" then
69- JSNumber (Obj. magic x ) else
74+ JSNumber (Obj. magic x) else
7075 if ty = " string" then
7176 JSString (Obj. magic x) else
7277 if ty = " boolean" then
@@ -75,9 +80,11 @@ let classify (x : 'a) : tagged_t =
7580 if ty = " function" then
7681 JSFunction (Obj. magic x) else
7782 if ty = " object" then
78- JSObject (Obj. magic x)
79- else
83+ JSObject (Obj. magic x) else
84+ if ty = " symbol " then
8085 JSSymbol (Obj. magic x)
86+ else
87+ JSBigInt (Obj. magic x)
8188
8289
8390let test (type a ) (x : 'a ) (v : a t ) : bool =
@@ -105,5 +112,7 @@ let test (type a) (x : 'a) (v : a t) : bool =
105112 Js. typeof x = " object"
106113 | Symbol
107114 ->
108- Js. typeof x = " symbol"
109-
115+ Js. typeof x = " symbol"
116+ | BigInt
117+ ->
118+ Js. typeof x = " bigint"
Original file line number Diff line number Diff line change 2828type symbol
2929(* * Js symbol type only available in ES6 *)
3030
31+ type bigint_val
32+ (* * Js bigint type only available in ES2020 *)
33+
3134type obj_val
3235type undefined_val
3336(* * This type has only one value `undefined` *)
@@ -46,6 +49,7 @@ type _ t =
4649 | Function : function_val t
4750 | Object : obj_val t
4851 | Symbol : symbol t
52+ | BigInt : bigint_val t
4953
5054
5155val test : 'a -> 'b t -> bool
@@ -66,6 +70,7 @@ type tagged_t =
6670 | JSFunction of function_val
6771 | JSObject of obj_val
6872 | JSSymbol of symbol
73+ | JSBigInt of bigint_val
6974
7075
7176val classify : 'a -> tagged_t
Original file line number Diff line number Diff line change @@ -10,7 +10,8 @@ let string_or_number (type t) x =
1010 | JSFalse | JSTrue -> false
1111 | JSFunction _ -> Js. log (" Function" ); false
1212 | JSObject _ -> false
13- | JSSymbol _ -> false
13+ | JSSymbol _ -> false
14+ | JSBigInt _ -> false
1415
1516let suites = Mt. [
1617 " int_type" , (fun _ -> Eq (Js. typeof 3 , " number" ) );
You can’t perform that action at this time.
0 commit comments