Skip to content

Commit

Permalink
show arrays properly like they are written
Browse files Browse the repository at this point in the history
  • Loading branch information
dragoncoder047 committed Oct 23, 2024
1 parent 5cb3dd0 commit fbd6232
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions examples/prettyDebug.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const pretty = {
even: {
nested: "objects",
},
arrays: ["show", "like", "you", "would", "write", "them"],
"own toString is used": vec2(10, 10)
}

Expand Down
10 changes: 9 additions & 1 deletion src/gfx/draw/drawDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,20 @@ export function drawDebug() {
}

function prettyDebug(object: any | undefined, inside: boolean = false): string {
var outStr = "", tmp;
if (inside && typeof object === "string") {
object = JSON.stringify(object);
}
if (Array.isArray(object)) {
outStr = [
"[",
object.map(e => prettyDebug(e, true)).join(", "),
"]"
].join("");
object = outStr;
}
if (typeof object === "object"
&& object.toString === Object.prototype.toString) {
var outStr = "", tmp;
if (object.constructor !== Object) outStr += object.constructor.name + " ";
outStr += [
"{",
Expand Down

0 comments on commit fbd6232

Please sign in to comment.