Skip to content

Commit

Permalink
Add JS_IsPromise function (#807)
Browse files Browse the repository at this point in the history
  • Loading branch information
ialex32x authored Jan 9, 2025
1 parent ffcdb41 commit f22dee0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -48552,6 +48552,13 @@ JSValue JS_PromiseResult(JSContext *ctx, JSValue promise)
return JS_DupValue(ctx, s->promise_result);
}

JS_BOOL JS_IsPromise(JSValue val)
{
if (JS_VALUE_GET_TAG(val) != JS_TAG_OBJECT)
return FALSE;
return JS_VALUE_GET_OBJ(val)->class_id == JS_CLASS_PROMISE;
}

static int js_create_resolving_functions(JSContext *ctx, JSValue *args,
JSValue promise);

Expand Down
1 change: 1 addition & 0 deletions quickjs.h
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ typedef enum JSPromiseStateEnum {
JS_EXTERN JSValue JS_NewPromiseCapability(JSContext *ctx, JSValue *resolving_funcs);
JS_EXTERN JSPromiseStateEnum JS_PromiseState(JSContext *ctx, JSValue promise);
JS_EXTERN JSValue JS_PromiseResult(JSContext *ctx, JSValue promise);
JS_EXTERN JS_BOOL JS_IsPromise(JSValue val);

JS_EXTERN JSValue JS_NewSymbol(JSContext *ctx, const char *description, JS_BOOL is_global);

Expand Down

0 comments on commit f22dee0

Please sign in to comment.