Add function to check if object is an arraybuffer
All checks were successful
ci / Linux (Ubuntu) (push) Successful in 13s
ci / Windows (mingw) (push) Successful in 18s

This commit is contained in:
2025-03-03 18:36:10 -06:00
parent 245fc673a6
commit e40d0e1c93
2 changed files with 10 additions and 0 deletions

View File

@@ -53347,6 +53347,15 @@ void JS_DetachArrayBuffer(JSContext *ctx, JSValueConst obj)
}
}
int JS_IsArrayBuffer(JSContext *js, JSValueConst obj)
{
JSObject *p;
if (JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT) return 0;
p = JS_VALUE_GET_OBJ(obj);
if (p->class_id != JS_CLASS_ARRAY_BUFFER && p->class_id != JS_CLASS_SHARED_ARRAY_BUFFER) return 0;
return 1;
}
/* get an ArrayBuffer or SharedArrayBuffer */
static JSArrayBuffer *js_get_array_buffer(JSContext *ctx, JSValueConst obj)
{

View File

@@ -911,6 +911,7 @@ JSValue JS_NewArrayBuffer(JSContext *ctx, uint8_t *buf, size_t len,
JS_BOOL is_shared);
JSValue JS_NewArrayBufferCopy(JSContext *ctx, const uint8_t *buf, size_t len);
void JS_DetachArrayBuffer(JSContext *ctx, JSValueConst obj);
int JS_IsArrayBuffer(JSContext *js, JSValueConst obj);
uint8_t *JS_GetArrayBuffer(JSContext *ctx, size_t *psize, JSValueConst obj);
typedef enum JSTypedArrayEnum {