@@ -98,19 +98,20 @@ extension Dictionary: JSValueConvertible where Value == JSValueConvertible, Key
9898private let NativeJSArray = JSObject . global. Array. function!
9999extension Dictionary : JSValueConstructible where Value: JSValueConstructible , Key == String {
100100 public static func construct( from value: JSValue ) -> Self ? {
101- if let objectRef = value. object,
102- let keys: [ String ] = Object . keys!( objectRef. jsValue ( ) ) . fromJSValue ( ) {
103- var entries = [ ( String, Value) ] ( )
104- entries. reserveCapacity ( keys. count)
105- for key in keys {
106- guard let value: Value = objectRef [ key] . fromJSValue ( ) else {
107- return nil
108- }
109- entries. append ( ( key, value) )
101+ guard
102+ let objectRef = value. object,
103+ let keys: [ String ] = Object . keys!( objectRef. jsValue ( ) ) . fromJSValue ( )
104+ else { return nil }
105+
106+ var entries = [ ( String, Value) ] ( )
107+ entries. reserveCapacity ( keys. count)
108+ for key in keys {
109+ guard let value: Value = objectRef [ key] . fromJSValue ( ) else {
110+ return nil
110111 }
111- return Dictionary ( uniqueKeysWithValues : entries )
112+ entries . append ( ( key , value ) )
112113 }
113- return nil
114+ return Dictionary ( uniqueKeysWithValues : entries )
114115 }
115116}
116117
@@ -152,20 +153,21 @@ extension Array: JSValueConvertible where Element == JSValueConvertible {
152153
153154extension Array : JSValueConstructible where Element: JSValueConstructible {
154155 public static func construct( from value: JSValue ) -> [ Element ] ? {
155- if let objectRef = value . object ,
156- objectRef. isInstanceOf ( JSObject . global . Array . function! ) {
157- let count : Int = objectRef. length . fromJSValue ( ) !
158- var array = [ Element ] ( )
159- array . reserveCapacity ( count )
160-
161- for i in 0 ..< count {
162- guard let value : Element = objectRef [ i ] . fromJSValue ( ) else { return nil }
163- array . append ( value )
164- }
165-
166- return array
156+ guard
157+ let objectRef = value . object ,
158+ objectRef. isInstanceOf ( JSObject . global . Array . function! )
159+ else { return nil }
160+
161+ let count : Int = objectRef . length . fromJSValue ( ) !
162+ var array = [ Element ] ( )
163+ array . reserveCapacity ( count )
164+
165+ for i in 0 ..< count {
166+ guard let value : Element = objectRef [ i ] . fromJSValue ( ) else { return nil }
167+ array. append ( value )
167168 }
168- return nil
169+
170+ return array
169171 }
170172}
171173
0 commit comments