Skip to content

Commit 2034377

Browse files
committed
Add JS_SealObject and JS_FreezeObject methods
1 parent a236c4c commit 2034377

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

quickjs.c

+12
Original file line numberDiff line numberDiff line change
@@ -37208,6 +37208,18 @@ static JSValue js_object_isSealed(JSContext *ctx, JSValue this_val,
3720837208
return JS_EXCEPTION;
3720937209
}
3721037210

37211+
JSValue JS_SealObject(JSContext *ctx, JSValue obj)
37212+
{
37213+
JS_FreeValue(ctx, js_object_seal(ctx, JS_UNDEFINED, 1, &obj, 0));
37214+
return obj;
37215+
}
37216+
37217+
JSValue JS_FreezeObject(JSContext *ctx, JSValue obj)
37218+
{
37219+
JS_FreeValue(ctx, js_object_seal(ctx, JS_UNDEFINED, 1, &obj, 1));
37220+
return obj;
37221+
}
37222+
3721137223
static JSValue js_object_fromEntries(JSContext *ctx, JSValue this_val,
3721237224
int argc, JSValue *argv)
3721337225
{

quickjs.h

+2
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,8 @@ JS_EXTERN int JS_SetPrototype(JSContext *ctx, JSValue obj, JSValue proto_val);
705705
JS_EXTERN JSValue JS_GetPrototype(JSContext *ctx, JSValue val);
706706
JS_EXTERN int JS_GetLength(JSContext *ctx, JSValue obj, int64_t *pres);
707707
JS_EXTERN int JS_SetLength(JSContext *ctx, JSValue obj, int64_t len);
708+
JS_EXTERN JSValue JS_SealObject(JSContext *ctx, JSValue obj);
709+
JS_EXTERN JSValue JS_FreezeObject(JSContext *ctx, JSValue obj);
708710

709711
#define JS_GPN_STRING_MASK (1 << 0)
710712
#define JS_GPN_SYMBOL_MASK (1 << 1)

0 commit comments

Comments
 (0)