Handle types which do not support getting an object

This commit is contained in:
Jarred Sumner
2022-11-07 00:50:49 -08:00
parent 072cd5a745
commit 179cd18f70

View File

@@ -207,7 +207,7 @@ pub const ZigString = extern struct {
return .{
.ptr = input.ptr,
.len = @truncate(u32, input.len),
.allocator = NullableAllocator.init(bun.default_allocator),
.allocator = .{},
};
}
@@ -2600,6 +2600,57 @@ pub const JSValue = enum(JSValueReprInt) {
Blob = 0b11111100,
_,
pub fn canGet(this: JSType) bool {
return switch (this) {
.Array,
.ArrayBuffer,
.BigInt64Array,
.BigUint64Array,
.BooleanObject,
.DOMWrapper,
.DataView,
.DerivedArray,
.DerivedStringObject,
.ErrorInstance,
.Event,
.FinalObject,
.Float32Array,
.Float64Array,
.GlobalObject,
.Int16Array,
.Int32Array,
.Int8Array,
.InternalFunction,
.JSArrayIterator,
.JSAsyncGenerator,
.JSDate,
.JSFunction,
.JSGenerator,
.JSMap,
.JSMapIterator,
.JSPromise,
.JSSet,
.JSSetIterator,
.JSStringIterator,
.JSWeakMap,
.JSWeakSet,
.ModuleNamespaceObject,
.NumberObject,
.Object,
.ProxyObject,
.RegExpObject,
.ShadowRealm,
.StringObject,
.Uint16Array,
.Uint32Array,
.Uint8Array,
.Uint8ClampedArray,
.WebAssemblyModule,
=> true,
else => false,
};
}
pub fn isObject(this: JSType) bool {
return switch (this) {
.Object, .FinalObject => true,