diff --git a/Sources/JavaScriptKit/JSObject.swift b/Sources/JavaScriptKit/JSObject.swift index a0ce58bb..103d3dcb 100644 --- a/Sources/JavaScriptKit/JSObject.swift +++ b/Sources/JavaScriptKit/JSObject.swift @@ -8,19 +8,14 @@ public class JSObjectRef: Equatable { } @_disfavoredOverload - public subscript(_ name: String) -> ((JSValueEncodable...) -> JSValue)? { + public subscript(_ name: String) -> JSFunctionRef? { guard let function = self[name].function else { return nil } - return { (arguments: JSValueEncodable...) in - function(this: self, args: arguments) - } + return function } @_disfavoredOverload - public subscript(dynamicMember name: String) -> ((JSValueEncodable...) -> JSValue)? { - guard let function = self[name].function else { return nil } - return { (arguments: JSValueEncodable...) in - function(this: self, args: arguments) - } + public subscript(dynamicMember name: String) -> JSFunctionRef? { + self[name] } public subscript(dynamicMember name: String) -> JSValue { diff --git a/Sources/JavaScriptKit/JSValueConvertible.swift b/Sources/JavaScriptKit/JSValueConvertible.swift index 870820da..7e0bb0d8 100644 --- a/Sources/JavaScriptKit/JSValueConvertible.swift +++ b/Sources/JavaScriptKit/JSValueConvertible.swift @@ -155,10 +155,9 @@ extension Dictionary: JSValueDecodable where Value: JSValueDecodable, Key == Str public init(jsValue: JSValue) { let objectRef: JSObjectRef = jsValue.object! - let keys: [String] = JSObject.keys!(objectRef.jsValue()).fromJSValue() self = Dictionary(uniqueKeysWithValues: keys.map { - ($0, objectRef[dynamicMember: $0].fromJSValue()) + ($0, objectRef[$0].fromJSValue()) }) } }