Skip to content

Commit

Permalink
throwing methods
Browse files Browse the repository at this point in the history
  • Loading branch information
SusanDoggie committed Apr 5, 2020
1 parent 14a9de3 commit a202ed8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Sources/SwiftJS/JSPropertyDescriptor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public struct JSPropertyDescriptor {

fileprivate let _setter: JSObject?

public let getter: ((JSObject) -> JSObject)?
public let getter: ((JSObject) throws -> JSObject)?

public let setter: ((JSObject, JSObject) -> Void)?
public let setter: ((JSObject, JSObject) throws -> Void)?

public var configurable: Bool? = nil

Expand Down Expand Up @@ -154,13 +154,13 @@ extension JSObject {
if let getter = descriptor._getter {
desc["get"] = getter
} else if let getter = descriptor.getter {
desc["get"] = JSObject(newFunctionIn: context) { _, this, _ in getter(this!) }
desc["get"] = JSObject(newFunctionIn: context) { _, this, _ in try getter(this!) }
}
if let setter = descriptor._setter {
desc["set"] = setter
} else if let setter = descriptor.setter {
desc["set"] = JSObject(newFunctionIn: context) { context, this, arguments in
setter(this!, arguments[0])
try setter(this!, arguments[0])
return JSObject(undefinedIn: context)
}
}
Expand Down

0 comments on commit a202ed8

Please sign in to comment.