Skip to content

Commit f22dee0

Browse files
authored
Add JS_IsPromise function (#807)
1 parent ffcdb41 commit f22dee0

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

quickjs.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48552,6 +48552,13 @@ JSValue JS_PromiseResult(JSContext *ctx, JSValue promise)
4855248552
return JS_DupValue(ctx, s->promise_result);
4855348553
}
4855448554

48555+
JS_BOOL JS_IsPromise(JSValue val)
48556+
{
48557+
if (JS_VALUE_GET_TAG(val) != JS_TAG_OBJECT)
48558+
return FALSE;
48559+
return JS_VALUE_GET_OBJ(val)->class_id == JS_CLASS_PROMISE;
48560+
}
48561+
4855548562
static int js_create_resolving_functions(JSContext *ctx, JSValue *args,
4855648563
JSValue promise);
4855748564

quickjs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,7 @@ typedef enum JSPromiseStateEnum {
824824
JS_EXTERN JSValue JS_NewPromiseCapability(JSContext *ctx, JSValue *resolving_funcs);
825825
JS_EXTERN JSPromiseStateEnum JS_PromiseState(JSContext *ctx, JSValue promise);
826826
JS_EXTERN JSValue JS_PromiseResult(JSContext *ctx, JSValue promise);
827+
JS_EXTERN JS_BOOL JS_IsPromise(JSValue val);
827828

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

0 commit comments

Comments
 (0)