File tree 1 file changed +18
-0
lines changed
Sources/JavaScriptEventLoop
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -232,6 +232,24 @@ public extension JSPromise {
232
232
}
233
233
}
234
234
235
+ /// Wait for the promise to complete, returning its result or exception as a Result.
236
+ ///
237
+ /// - Note: Calling this function does not switch from the caller's isolation domain.
238
+ func value( isolation: isolated ( any Actor ) ? = #isolation) async throws -> JSValue {
239
+ try await withUnsafeThrowingContinuation ( isolation: isolation) { [ self ] continuation in
240
+ self . then (
241
+ success: {
242
+ continuation. resume ( returning: $0)
243
+ return JSValue . undefined
244
+ } ,
245
+ failure: {
246
+ continuation. resume ( throwing: JSException ( $0) )
247
+ return JSValue . undefined
248
+ }
249
+ )
250
+ }
251
+ }
252
+
235
253
/// Wait for the promise to complete, returning its result or exception as a Result.
236
254
var result : JSPromise . Result {
237
255
get async {
You can’t perform that action at this time.
0 commit comments