Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -45116,7 +45116,7 @@ JSPromiseStateEnum JS_PromiseState(JSContext *ctx, JSValue promise)
{
JSPromiseData *s = JS_GetOpaque(promise, JS_CLASS_PROMISE);
if (!s)
return -1;
return JS_INVALID_PROMISE_STATE;
return s->promise_state;
}

Expand Down
4 changes: 4 additions & 0 deletions quickjs.h
Original file line number Diff line number Diff line change
Expand Up @@ -977,13 +977,17 @@ JS_EXTERN int JS_SetModuleExportList(JSContext *ctx, JSModuleDef *m,

/* Promise */

#define JS_INVALID_PROMISE_STATE -1

typedef enum JSPromiseStateEnum {
JS_PROMISE_PENDING,
JS_PROMISE_FULFILLED,
JS_PROMISE_REJECTED,
} JSPromiseStateEnum;

/* Returns JSPromiseReactionEnum for the promise or JS_INVALID_PROMISE_STATE if the value is not a promise. */
JS_EXTERN JSPromiseStateEnum JS_PromiseState(JSContext *ctx, JSValue promise);
/* Return the result of the promise if the promise's state is in the FULFILLED or REJECTED state. Otherwise returns JS_UNDEFINED. */
JS_EXTERN JSValue JS_PromiseResult(JSContext *ctx, JSValue promise);

/* Version */
Expand Down