Skip to content

Commit 00b4d09

Browse files
committed
doc fix
1 parent b0a0566 commit 00b4d09

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

doc/quickjs-emscripten/README.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -384,21 +384,19 @@ without introducing asynchronous host code, described by the type [JSPromiseStat
384384

385385
```typescript
386386
type JSPromiseState =
387-
| { type: 'pending', error: Error }
388-
| { type: 'fulfilled', value: QuickJSHandle, notAPromise?: boolean }
389-
| { type: 'rejected', error: QuickJSHandle }
387+
| { type: "pending"; error: Error }
388+
| { type: "fulfilled"; value: QuickJSHandle; notAPromise?: boolean }
389+
| { type: "rejected"; error: QuickJSHandle }
390390
```
391391
392392
The result conforms to the `SuccessOrFail` type returned by `context.evalCode`, so you can use `context.unwrapResult(context.getPromiseState(promiseHandle))` to assert a promise is settled successfully and retrieve its value. Calling `context.unwrapResult` on a pending or rejected promise will throw an error.
393393
394394
```typescript
395-
const promiseHandle = context.evalCode(`Promise.resolve(42)`);
396-
const resultHandle = context.unwrapResult(
397-
context.getPromiseState(promiseHandle)
398-
);
399-
context.getNumber(resultHandle) === 42; // true
400-
resultHandle.dispose();
401-
promiseHandle.dispose();
395+
const promiseHandle = context.evalCode(`Promise.resolve(42)`)
396+
const resultHandle = context.unwrapResult(context.getPromiseState(promiseHandle))
397+
context.getNumber(resultHandle) === 42 // true
398+
resultHandle.dispose()
399+
promiseHandle.dispose()
402400
```
403401

404402
[JSPromiseState]: https://github.com/justjake/quickjs-emscripten/blob/main/doc/quickjs-emscripten/exports.md#jspromisestate

0 commit comments

Comments
 (0)