File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change 33public protocol JSBridgedType : JSValueCodable , CustomStringConvertible {
44 var objectRef : JSObject { get }
55 init ? ( objectRef: JSObject )
6- static func canDecode( _ object: JSObject ) -> Bool
76}
87
98extension JSBridgedType {
109 public static func construct( from value: JSValue ) -> Self ? {
11- guard let object = value. object, canDecode ( object) else {
12- return nil
13- }
10+ guard let object = value. object else { return nil }
1411 return Self . init ( objectRef: object)
1512 }
1613
@@ -26,11 +23,13 @@ extension JSBridgedType {
2623
2724public protocol JSBridgedClass : JSBridgedType {
2825 static var classRef : JSFunction { get }
26+ init ( withCompatibleObject objectRef: JSObject )
2927}
3028
3129extension JSBridgedClass {
32- public static func canDecode( from jsValue: JSValue ) -> Bool {
33- jsValue. isInstanceOf ( Self . classRef)
30+ public init ? ( objectRef: JSObject ) {
31+ guard objectRef. isInstanceOf ( Self . classRef) else { return nil }
32+ self . init ( withCompatibleObject: objectRef)
3433 }
3534}
3635
You can’t perform that action at this time.
0 commit comments