@@ -84,21 +84,22 @@ public final class JSPromise: JSBridgedClass {
84
84
}
85
85
#endif
86
86
87
- #if !hasFeature(Embedded)
88
87
/// Schedules the `success` closure to be invoked on successful completion of `self`.
89
88
@discardableResult
90
- public func then( success: @escaping ( JSValue ) -> ConvertibleToJSValue ) -> JSPromise {
89
+ public func then( success: @escaping ( JSValue ) -> JSValue ) -> JSPromise {
91
90
let closure = JSOneshotClosure {
92
91
success ( $0 [ 0 ] ) . jsValue
93
92
}
94
93
return JSPromise ( unsafelyWrapping: jsObject. then!( closure) . object!)
95
94
}
96
95
97
- #if compiler(>=5.5)
96
+ #if compiler(>=5.5) && (!hasFeature(Embedded) || os(WASI))
98
97
/// Schedules the `success` closure to be invoked on successful completion of `self`.
99
98
@available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * )
100
99
@discardableResult
101
- public func then( success: sending @escaping ( sending JSValue) async throws -> ConvertibleToJSValue ) -> JSPromise {
100
+ public func then(
101
+ success: sending @escaping ( sending JSValue) async throws -> JSValue
102
+ ) -> JSPromise {
102
103
let closure = JSOneshotClosure . async {
103
104
try await success ( $0 [ 0 ] ) . jsValue
104
105
}
@@ -109,8 +110,8 @@ public final class JSPromise: JSBridgedClass {
109
110
/// Schedules the `success` closure to be invoked on successful completion of `self`.
110
111
@discardableResult
111
112
public func then(
112
- success: @escaping ( sending JSValue) -> ConvertibleToJSValue ,
113
- failure: @escaping ( sending JSValue) -> ConvertibleToJSValue
113
+ success: @escaping ( sending JSValue) -> JSValue ,
114
+ failure: @escaping ( sending JSValue) -> JSValue
114
115
) -> JSPromise {
115
116
let successClosure = JSOneshotClosure {
116
117
success ( $0 [ 0 ] ) . jsValue
@@ -121,13 +122,13 @@ public final class JSPromise: JSBridgedClass {
121
122
return JSPromise ( unsafelyWrapping: jsObject. then!( successClosure, failureClosure) . object!)
122
123
}
123
124
124
- #if compiler(>=5.5)
125
+ #if compiler(>=5.5) && (!hasFeature(Embedded) || os(WASI))
125
126
/// Schedules the `success` closure to be invoked on successful completion of `self`.
126
127
@available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * )
127
128
@discardableResult
128
129
public func then(
129
- success: sending @escaping ( sending JSValue) async throws -> ConvertibleToJSValue ,
130
- failure: sending @escaping ( sending JSValue) async throws -> ConvertibleToJSValue
130
+ success: sending @escaping ( sending JSValue) async throws -> JSValue ,
131
+ failure: sending @escaping ( sending JSValue) async throws -> JSValue
131
132
) -> JSPromise {
132
133
let successClosure = JSOneshotClosure . async {
133
134
try await success ( $0 [ 0 ] ) . jsValue
@@ -141,19 +142,24 @@ public final class JSPromise: JSBridgedClass {
141
142
142
143
/// Schedules the `failure` closure to be invoked on rejected completion of `self`.
143
144
@discardableResult
144
- public func `catch`( failure: @escaping ( sending JSValue) -> ConvertibleToJSValue ) -> JSPromise {
145
+ public func `catch`(
146
+ failure: @escaping ( sending JSValue) -> JSValue
147
+ )
148
+ -> JSPromise
149
+ {
145
150
let closure = JSOneshotClosure {
146
151
failure ( $0 [ 0 ] ) . jsValue
147
152
}
148
153
return . init( unsafelyWrapping: jsObject. catch!( closure) . object!)
149
154
}
150
155
151
- #if compiler(>=5.5)
156
+ #if compiler(>=5.5) && (!hasFeature(Embedded) || os(WASI))
152
157
/// Schedules the `failure` closure to be invoked on rejected completion of `self`.
153
158
@available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * )
154
159
@discardableResult
155
- public func `catch`( failure: sending @escaping ( sending JSValue) async throws -> ConvertibleToJSValue ) -> JSPromise
156
- {
160
+ public func `catch`(
161
+ failure: sending @escaping ( sending JSValue) async throws -> JSValue
162
+ ) -> JSPromise {
157
163
let closure = JSOneshotClosure . async {
158
164
try await failure ( $0 [ 0 ] ) . jsValue
159
165
}
@@ -171,5 +177,4 @@ public final class JSPromise: JSBridgedClass {
171
177
}
172
178
return . init( unsafelyWrapping: jsObject. finally!( closure) . object!)
173
179
}
174
- #endif
175
180
}
0 commit comments