diff options
-rw-r--r-- | src/bun.js/bindings/exports.zig | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/bun.js/bindings/exports.zig b/src/bun.js/bindings/exports.zig index 9d4db4309..d37633772 100644 --- a/src/bun.js/bindings/exports.zig +++ b/src/bun.js/bindings/exports.zig @@ -2138,25 +2138,30 @@ pub const ZigConsoleClient = struct { writer.writeAll(" }"); }, .TypedArray => { - const len = value.getLengthOfArray(this.globalThis); - if (len == 0) { + const arrayBuffer = value.asArrayBuffer(this.globalThis).?; + if (arrayBuffer.len == 0) { writer.writeAll("[]"); return; } - writer.writeAll("[ "); - var i: u32 = 0; - var buffer = JSC.Buffer.fromJS(this.globalThis, value, null).?; - const slice = buffer.slice(); - while (i < len) : (i += 1) { - if (i > 0) { - this.printComma(Writer, writer_, enable_ansi_colors) catch unreachable; - writer.writeAll(" "); - } + writer.writeAll(std.mem.span(@tagName(arrayBuffer.typed_array_type))); + writer.print("({d}) [ ", .{arrayBuffer.len}); - writer.print(comptime Output.prettyFmt("<r><yellow>{d}<r>", enable_ansi_colors), .{slice[i]}); + const slice = arrayBuffer.slice(); + writer.print(comptime Output.prettyFmt("<r><yellow>{d}<r>", enable_ansi_colors), .{slice[0]}); + var leftover = slice[1..]; + const max = 512; + leftover = leftover[0..@minimum(leftover.len, max)]; + for (leftover) |el| { + this.printComma(Writer, writer_, enable_ansi_colors) catch unreachable; + writer.writeAll(" "); + + writer.print(comptime Output.prettyFmt("<r><yellow>{d}<r>", enable_ansi_colors), .{el}); } + if (slice.len > max + 1) { + writer.print(comptime Output.prettyFmt("<r><d>, ... {d} more<r>", enable_ansi_colors), .{slice.len - max - 1}); + } writer.writeAll(" ]"); }, else => {}, |