Add JS_IsRegExp function (#804)

This commit is contained in:
Ivan Komissarov 2025-01-08 23:29:41 +03:00 committed by GitHub
parent 36e3513d4e
commit 6d64933328
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 0 deletions

View file

@ -10100,6 +10100,13 @@ BOOL JS_SetConstructorBit(JSContext *ctx, JSValue func_obj, BOOL val)
return TRUE;
}
JS_BOOL JS_IsRegExp(JSValue val)
{
if (JS_VALUE_GET_TAG(val) != JS_TAG_OBJECT)
return FALSE;
return JS_VALUE_GET_OBJ(val)->class_id == JS_CLASS_REGEXP;
}
BOOL JS_IsError(JSContext *ctx, JSValue val)
{
JSObject *p;

View file

@ -672,6 +672,8 @@ JS_EXTERN JS_BOOL JS_IsFunction(JSContext* ctx, JSValue val);
JS_EXTERN JS_BOOL JS_IsConstructor(JSContext* ctx, JSValue val);
JS_EXTERN JS_BOOL JS_SetConstructorBit(JSContext *ctx, JSValue func_obj, JS_BOOL val);
JS_EXTERN JS_BOOL JS_IsRegExp(JSValue val);
JS_EXTERN JSValue JS_NewArray(JSContext *ctx);
JS_EXTERN int JS_IsArray(JSContext *ctx, JSValue val);