@@ -6,89 +6,39 @@ type t = bigint
66@val  external  asIntN : (~width : int , bigint ) =>  bigint  =  "BigInt.asIntN" 
77@val  external  asUintN : (~width : int , bigint ) =>  bigint  =  "BigInt.asUintN" 
88
9+ @val  external  fromString : string  =>  bigint  =  "BigInt" 
10+ 
911@val 
1012/** 
1113Parses the given `string` into a `bigint` using JavaScript semantics. Return the 
12- number as a `bigint` if successfully parsed. Throws a  syntax exception otherwise. 
14+ number as a `bigint` if successfully parsed. Uncaught  syntax exception otherwise. 
1315
1416## Examples 
1517
1618```rescript 
17- BigInt.fromStringOrThrow ("123")->assertEqual(123n) 
19+ BigInt.fromStringExn ("123")->assertEqual(123n) 
1820
19- BigInt.fromStringOrThrow ("")->assertEqual(0n) 
21+ BigInt.fromStringExn ("")->assertEqual(0n) 
2022
21- BigInt.fromStringOrThrow ("0x11")->assertEqual(17n) 
23+ BigInt.fromStringExn ("0x11")->assertEqual(17n) 
2224
23- BigInt.fromStringOrThrow ("0b11")->assertEqual(3n) 
25+ BigInt.fromStringExn ("0b11")->assertEqual(3n) 
2426
25- BigInt.fromStringOrThrow ("0o11")->assertEqual(9n) 
27+ BigInt.fromStringExn ("0o11")->assertEqual(9n) 
2628
2729/* catch exception */ 
28- switch BigInt.fromStringOrThrow ("a") { 
30+ switch BigInt.fromStringExn ("a") { 
2931| exception JsExn(_error) => assert(true) 
3032| _bigInt => assert(false) 
3133} 
3234``` 
3335*/ 
34- external  fromStringOrThrow : string  =>  bigint  =  "BigInt" 
35- 
36- /** 
37- Parses the given `string` into a `bigint` using JavaScript semantics. Returns  
38- `Some(bigint)` if the string can be parsed, `None` otherwise. 
39- 
40- ## Examples 
41- 
42- ```rescript 
43- BigInt.fromString("123")->assertEqual(Some(123n)) 
44- 
45- BigInt.fromString("")->assertEqual(Some(0n)) 
46- 
47- BigInt.fromString("0x11")->assertEqual(Some(17n)) 
48- 
49- BigInt.fromString("0b11")->assertEqual(Some(3n)) 
50- 
51- BigInt.fromString("0o11")->assertEqual(Some(9n)) 
52- 
53- BigInt.fromString("invalid")->assertEqual(None) 
54- ``` 
55- */ 
56- let  fromString  =  (value : string ) =>  {
57-   try  Some (fromStringOrThrow (value )) catch  {
58-   | _  =>  None 
59-   }
60- }
61- 
62- @deprecated ("Use `fromStringOrThrow` instead" ) @val 
6336external  fromStringExn : string  =>  bigint  =  "BigInt" 
64- 
6537@val  external  fromInt : int  =>  bigint  =  "BigInt" 
66- 
67- @val 
68- /** 
69- Converts a `float` to a `bigint` using JavaScript semantics.  
70- Throws an exception if the float is not an integer or is infinite/NaN. 
71- 
72- ## Examples 
73- 
74- ```rescript 
75- BigInt.fromFloatOrThrow(123.0)->assertEqual(123n) 
76- 
77- BigInt.fromFloatOrThrow(0.0)->assertEqual(0n) 
78- 
79- BigInt.fromFloatOrThrow(-456.0)->assertEqual(-456n) 
80- 
81- /* This will throw an exception */ 
82- switch BigInt.fromFloatOrThrow(123.5) { 
83- | exception JsExn(_error) => assert(true) 
84- | _bigInt => assert(false) 
85- } 
86- ``` 
87- */ 
88- external  fromFloatOrThrow : float  =>  bigint  =  "BigInt" 
38+ @val  external  fromFloat : float  =>  bigint  =  "BigInt" 
8939
9040let  fromFloat  =  (value : float ) =>  {
91-   try  Some (fromFloatOrThrow (value )) catch  {
41+   try  Some (fromFloat (value )) catch  {
9242  | _  =>  None 
9343  }
9444}
0 commit comments