diff --git a/mquickjs.c b/mquickjs.c index a950f3c..14aaa75 100644 --- a/mquickjs.c +++ b/mquickjs.c @@ -1150,6 +1150,16 @@ static JSObject *js_get_object_class(JSContext *ctx, JSValue val, int class_id) } } +BOOL JS_IsArray(JSContext *ctx, JSValue val) +{ + if (!JS_IsPtr(val)) { + return FALSE; + } else { + JSObject *p = JS_VALUE_TO_PTR(val); + return (p->mtag == JS_MTAG_OBJECT && p->class_id == JS_CLASS_ARRAY); + } +} + BOOL JS_IsFunction(JSContext *ctx, JSValue val) { if (!JS_IsPtr(val)) { diff --git a/mquickjs.h b/mquickjs.h index a1557fe..10341ef 100644 --- a/mquickjs.h +++ b/mquickjs.h @@ -206,6 +206,7 @@ static inline JSValue JS_NewBool(int val) JS_BOOL JS_IsNumber(JSContext *ctx, JSValue val); JS_BOOL JS_IsString(JSContext *ctx, JSValue val); JS_BOOL JS_IsError(JSContext *ctx, JSValue val); +JS_BOOL JS_IsArray(JSContext *ctx, JSValue val); JS_BOOL JS_IsFunction(JSContext *ctx, JSValue val); int JS_GetClassID(JSContext *ctx, JSValue val);