Skip to content

Commit bcfa3cb

Browse files
committed
Use new simplified JSPromise API
1 parent a733efb commit bcfa3cb

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

Sources/JavaScriptKit/PauseExecution.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public func pauseExecution(milliseconds: Int32) {
99
}
1010

1111

12-
extension JSPromise where Success == JSValue, Failure == JSError {
12+
extension JSPromise {
1313
/// Unwind Wasm module execution stack and rewind it after promise resolves,
1414
/// allowing JavaScript events to continue to be processed in the meantime.
1515
/// - Parameters:
@@ -18,19 +18,15 @@ extension JSPromise where Success == JSValue, Failure == JSError {
1818
///
1919
/// **Important**: Wasm module must be [asyncified](https://emscripten.org/docs/porting/asyncify.html),
2020
/// otherwise JavaScriptKit's runtime will throw an exception.
21-
public func syncAwait() -> Result<Success, Failure> {
21+
public func syncAwait() -> Result<JSValue, JSValue> {
2222
var kindAndFlags = JavaScriptValueKindAndFlags()
2323
var payload1 = JavaScriptPayload1()
2424
var payload2 = JavaScriptPayload2()
2525

2626
_syncAwait(jsObject.id, &kindAndFlags, &payload1, &payload2)
2727
let result = RawJSValue(kind: kindAndFlags.kind, payload1: payload1, payload2: payload2).jsValue()
2828
if kindAndFlags.isException {
29-
if let error = JSError(from: result) {
30-
return .failure(error)
31-
} else {
32-
return .failure(JSError(message: "Could not build proper JSError from result \(result)"))
33-
}
29+
return .failure(result)
3430
} else {
3531
return .success(result)
3632
}

0 commit comments

Comments
 (0)