Skip to content

Commit a85ee3f

Browse files
Apply suggestions from code review
Co-authored-by: Jed Fox <git@jedfox.com>
1 parent 58ca905 commit a85ee3f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Diff for: Sources/JavaScriptKit/BasicObjects/JSPromise.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public final class JSPromise: JSBridgedClass {
4646
/** Creates a new `JSPromise` instance from a given `resolver` closure. `resolver` takes
4747
two closure that your code should call to either resolve or reject this `JSPromise` instance.
4848
*/
49-
public convenience init(resolver: @escaping (@escaping (Result<JSValue, JSValue>) -> ()) -> ()) {
49+
public convenience init(resolver: @escaping (@escaping (Result< JSValueConvertible, JSValueConvertible >) -> ()) -> ()) {
5050
let closure = JSOneshotClosure { arguments in
5151
// The arguments are always coming from the `Promise` constructor, so we should be
5252
// safe to assume their type here
@@ -66,18 +66,18 @@ public final class JSPromise: JSBridgedClass {
6666
self.init(unsafelyWrapping: Self.constructor.new(closure))
6767
}
6868

69-
public static func resolve(_ value: JSValue) -> JSPromise {
69+
public static func resolve(_ value: JSValueConvertible) -> JSPromise {
7070
self.init(unsafelyWrapping: Self.constructor.resolve!(value).object!)
7171
}
7272

73-
public static func reject(_ reason: JSValue) -> JSPromise {
73+
public static func reject(_ reason: JSValueConvertible) -> JSPromise {
7474
self.init(unsafelyWrapping: Self.constructor.reject!(reason).object!)
7575
}
7676

7777
/** Schedules the `success` closure to be invoked on sucessful completion of `self`.
7878
*/
7979
@discardableResult
80-
public func then(success: @escaping (JSValue) -> JSValue) -> JSPromise {
80+
public func then(success: @escaping (JSValue) -> JSValueConvertible) -> JSPromise {
8181
let closure = JSOneshotClosure {
8282
return success($0[0])
8383
}
@@ -87,8 +87,8 @@ public final class JSPromise: JSBridgedClass {
8787
/** Schedules the `success` closure to be invoked on sucessful completion of `self`.
8888
*/
8989
@discardableResult
90-
public func then(success: @escaping (JSValue) -> JSValue,
91-
failure: @escaping (JSValue) -> JSValue) -> JSPromise {
90+
public func then(success: @escaping (JSValue) -> JSValueConvertible,
91+
failure: @escaping (JSValue) -> JSValueConvertible) -> JSPromise {
9292
let successClosure = JSOneshotClosure {
9393
return success($0[0])
9494
}
@@ -101,7 +101,7 @@ public final class JSPromise: JSBridgedClass {
101101
/** Schedules the `failure` closure to be invoked on rejected completion of `self`.
102102
*/
103103
@discardableResult
104-
public func `catch`(failure: @escaping (JSValue) -> JSValue) -> JSPromise {
104+
public func `catch`(failure: @escaping (JSValue) -> JSValueConvertible) -> JSPromise {
105105
let closure = JSOneshotClosure {
106106
return failure($0[0])
107107
}

0 commit comments

Comments
 (0)