diff --git a/src/bun.js/ConsoleObject.zig b/src/bun.js/ConsoleObject.zig index 8ad8ec525a..25b9df0ae0 100644 --- a/src/bun.js/ConsoleObject.zig +++ b/src/bun.js/ConsoleObject.zig @@ -342,7 +342,7 @@ const TablePrinter = struct { // - otherwise: iterate the object properties, and create the columns on-demand if (!this.properties.isUndefined()) { for (columns.items[1..]) |*column| { - if (row_value.getWithString(this.globalObject, column.name)) |value| { + if (row_value.getOwn(this.globalObject, column.name)) |value| { column.width = @max(column.width, this.getWidthForValue(value)); } } @@ -436,7 +436,7 @@ const TablePrinter = struct { value = row_value; } } else if (row_value.isObject()) { - value = row_value.getWithString(this.globalObject, col.name) orelse JSValue.zero; + value = row_value.getOwn(this.globalObject, col.name) orelse JSValue.zero; } if (value.isEmpty()) { diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp index 8409ffa856..0c1edd2273 100644 --- a/src/bun.js/bindings/bindings.cpp +++ b/src/bun.js/bindings/bindings.cpp @@ -3712,23 +3712,6 @@ JSC__JSValue JSC__JSValue__getIfPropertyExistsImpl(JSC__JSValue JSValue0, return JSC::JSValue::encode(Bun::getIfPropertyExistsPrototypePollutionMitigation(vm, globalObject, object, property)); } -extern "C" JSC__JSValue JSC__JSValue__getIfPropertyExistsImplString(JSC__JSValue JSValue0, JSC__JSGlobalObject* globalObject, BunString* propertyName) -{ - ASSERT_NO_PENDING_EXCEPTION(globalObject); - JSValue value = JSC::JSValue::decode(JSValue0); - JSC::JSObject* object = value.getObject(); - if (UNLIKELY(!object)) - return JSValue::encode({}); - - JSC::VM& vm = globalObject->vm(); - - WTF::String propertyNameString = propertyName->tag == BunStringTag::Empty ? WTF::String(""_s) : propertyName->toWTFString(BunString::ZeroCopy); - auto identifier = JSC::Identifier::fromString(vm, propertyNameString); - auto property = JSC::PropertyName(identifier); - - return JSC::JSValue::encode(Bun::getIfPropertyExistsPrototypePollutionMitigation(vm, globalObject, object, property)); -} - extern "C" JSC__JSValue JSC__JSValue__getOwn(JSC__JSValue JSValue0, JSC__JSGlobalObject* globalObject, BunString* propertyName) { ASSERT_NO_PENDING_EXCEPTION(globalObject); diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig index 0623c96d34..75b755bce1 100644 --- a/src/bun.js/bindings/bindings.zig +++ b/src/bun.js/bindings/bindings.zig @@ -5275,14 +5275,6 @@ pub const JSValue = enum(JSValueReprInt) { return if (value.isEmpty()) null else value; } - extern fn JSC__JSValue__getIfPropertyExistsImplString(value: JSValue, globalObject: *JSGlobalObject, propertyName: [*c]const bun.String) JSValue; - - pub fn getWithString(this: JSValue, global: *JSGlobalObject, property_name: anytype) ?JSValue { - var property_name_str = bun.String.init(property_name); - const value = JSC__JSValue__getIfPropertyExistsImplString(this, global, &property_name_str); - return if (@intFromEnum(value) != 0) value else return null; - } - extern fn JSC__JSValue__getOwn(value: JSValue, globalObject: *JSGlobalObject, propertyName: [*c]const bun.String) JSValue; /// Get *own* property value (i.e. does not resolve property in the prototype chain) diff --git a/test/js/bun/console/__snapshots__/console-table.test.ts.snap b/test/js/bun/console/__snapshots__/console-table.test.ts.snap index 83bf72ab2b..28d4755f7e 100644 --- a/test/js/bun/console/__snapshots__/console-table.test.ts.snap +++ b/test/js/bun/console/__snapshots__/console-table.test.ts.snap @@ -194,3 +194,12 @@ exports[`console.table expected output for: properties - interesting character 1 └───┴────────┘ " `; + +exports[`console.table expected output for: number keys 1`] = ` +"┌──────┬─────┬─────┐ +│ │ 10 │ 100 │ +├──────┼─────┼─────┤ +│ test │ 123 │ 154 │ +└──────┴─────┴─────┘ +" +`; diff --git a/test/js/bun/console/console-table.test.ts b/test/js/bun/console/console-table.test.ts index 22d780ac82..24b5848c13 100644 --- a/test/js/bun/console/console-table.test.ts +++ b/test/js/bun/console/console-table.test.ts @@ -134,6 +134,14 @@ describe("console.table", () => { ], }, ], + [ + "number keys", + { + args: () => [ + {test: {"10": 123, "100": 154}}, + ], + }, + ], ])("expected output for: %s", (label, { args }) => { const { stdout } = spawnSync({ cmd: [bunExe(), `${import.meta.dir}/console-table-run.ts`, args.toString()],