Skip to content

Commit 6d64933

Browse files
authored
Add JS_IsRegExp function (#804)
1 parent 36e3513 commit 6d64933

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

quickjs.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10100,6 +10100,13 @@ BOOL JS_SetConstructorBit(JSContext *ctx, JSValue func_obj, BOOL val)
1010010100
return TRUE;
1010110101
}
1010210102

10103+
JS_BOOL JS_IsRegExp(JSValue val)
10104+
{
10105+
if (JS_VALUE_GET_TAG(val) != JS_TAG_OBJECT)
10106+
return FALSE;
10107+
return JS_VALUE_GET_OBJ(val)->class_id == JS_CLASS_REGEXP;
10108+
}
10109+
1010310110
BOOL JS_IsError(JSContext *ctx, JSValue val)
1010410111
{
1010510112
JSObject *p;

quickjs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,8 @@ JS_EXTERN JS_BOOL JS_IsFunction(JSContext* ctx, JSValue val);
672672
JS_EXTERN JS_BOOL JS_IsConstructor(JSContext* ctx, JSValue val);
673673
JS_EXTERN JS_BOOL JS_SetConstructorBit(JSContext *ctx, JSValue func_obj, JS_BOOL val);
674674

675+
JS_EXTERN JS_BOOL JS_IsRegExp(JSValue val);
676+
675677
JS_EXTERN JSValue JS_NewArray(JSContext *ctx);
676678
JS_EXTERN int JS_IsArray(JSContext *ctx, JSValue val);
677679

0 commit comments

Comments
 (0)