mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
Handle types which do not support getting an object
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user