File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
Sources/JavaScriptKit/FundamentalObjects Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change 1
1
import _CJavaScriptKit
2
2
3
- public class JSBigInt : JSObject {
4
- var int64Value : Int64 { _bigint_to_i64 ( id, true ) }
5
- var uInt64Value : UInt64 {
3
+ private let constructor = JSObject . global. BigInt. function!
4
+
5
+ public final class JSBigInt : JSObject {
6
+ public var int64Value : Int64 {
7
+ _bigint_to_i64 ( id, true )
8
+ }
9
+ public var uInt64Value : UInt64 {
6
10
UInt64 ( bitPattern: _bigint_to_i64 ( id, false ) )
7
11
}
8
12
9
13
public convenience init ( _ value: Int64 ) {
10
14
self . init ( id: _i64_to_bigint ( value, true ) )
11
15
}
12
- public convenience init ( _ value: UInt64 ) {
16
+ public convenience init ( unsigned value: UInt64 ) {
13
17
self . init ( id: _i64_to_bigint ( Int64 ( bitPattern: value) , false ) )
14
18
}
15
19
@@ -24,4 +28,12 @@ public class JSBigInt: JSObject {
24
28
override public var jsValue : JSValue {
25
29
. bigInt( self )
26
30
}
31
+
32
+ public func clamped( bitSize: Int , signed: Bool ) -> JSBigInt {
33
+ if signed {
34
+ return constructor. asIntN!( bitSize, self ) . bigInt!
35
+ } else {
36
+ return constructor. asUintN!( bitSize, self ) . bigInt!
37
+ }
38
+ }
27
39
}
You can’t perform that action at this time.
0 commit comments