Skip to content

Commit

Permalink
console, feat: simply display objects and arrays in object properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
xicilion committed Aug 19, 2021
1 parent 3051272 commit 52f8d08
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fibjs/src/util/util_format_table.cpp
Expand Up @@ -345,7 +345,10 @@ exlib::string object_format(v8::Local<v8::Value> v, bool color, bool l2 = false)
buf.append(": ");

v = obj->Get(_context, v);
buf.append(json_format(v, color));
if (isSimpleValue(v))
buf.append(json_format(v, color));
else
buf.append(object_format(v, color, true));
}
buf.append(" }");

Expand Down
8 changes: 8 additions & 0 deletions test/util_test.js
Expand Up @@ -1364,6 +1364,14 @@ describe('util', () => {
├─────────┼──────────────┤
│ a │ { "a": 100 } │
└─────────┴──────────────┘
`);

test_table({ a: { a: { a: 100, b: [1, 2, 3] }, b: 200 } }, `
┌─────────┬────────────────────────────┬─────┐
│ (index) │ a │ b │
├─────────┼────────────────────────────┼─────┤
│ a │ { "a": 100, "b": [Array] } │ 200 │
└─────────┴────────────────────────────┴─────┘
`);

test_table({ a: { x: { a: 100, b: 200 } } }, `
Expand Down

0 comments on commit 52f8d08

Please sign in to comment.