File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Sources/JavaScriptEventLoop Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -232,6 +232,24 @@ public extension JSPromise {
232232 }
233233 }
234234
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+
235253 /// Wait for the promise to complete, returning its result or exception as a Result.
236254 var result : JSPromise . Result {
237255 get async {
You can’t perform that action at this time.
0 commit comments