[Webkit-unassigned] [Bug 38664] Web Inspector: add a "table" method to console, to allow output of tabular data

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon May 31 07:10:37 PDT 2010


https://bugs.webkit.org/show_bug.cgi?id=38664





--- Comment #15 from Jan Odvarko <odvarko at gmail.com>  2010-05-31 07:10:35 PST ---
> I think both should be supported, arrays are just objects with numeric
> property names (at the basic level).
Sorry, I didn't express myself clearly, I also think both should be supported.


So just to summarize all comments, to make sure we are all on the same page.

1) 2d array
var object = [[1,2,3],[4,5,6]];
console.table(object);

0  1  2
-------
1  2  3
4  5  6

Columns can be customized using 'columns' argument.
console.table(object, [0, 2]);

0  2
----
1  3
4  6


2) Simple object:
var object = {a: 1, b: 2, c: 3}
console.table(object);

Prop Value
----------
a     1
b     2
c     3


3) List of objects:
var object = [{name: "Mike", age: 30},{name: "John", age: 5}];
console.table(object);

name age
--------
Mike  30
John   5


4) Complex object:
var object = {father: {name: "Mike", age: 30}, son: {name: "John", age: 5}};
console.table(object);

name age
--------
Mike  30
John   5

If row headers are supported it would look like as follows:

         name age
         --------
father | Mike  30
son    | John   5



5) Customizing displayed properties
var object = {father: {name: "Mike", age: 30}, son: {name: "John", age: 5}};
console.table(object, ["name"]);

name
----
Mike
John


6) Expandable log
var object = {father: {name: "Mike", age: 30}, son: {name: "John", age: 5}};
console.table("My Family", object);

+ My Family

The user needs to expand to see the actual data.


7) Since the 'columns' argument specifies, which properties/columns should be displayed, a custom column header (e.g. custom labels) would have to be specified as another additional parameter.

var object = {father: {name: "Mike", age: 30}, son: {name: "John", age: 5}};
console.table(object, ["name"], ["Just Names"]);

Just Names
----------
   Mike
   John


Are the examples correct?


Comments:
- The first data row (ie. the first object in the provided array, or the first array in the provided array of the first found property in the provided object) is used as the template and the others are expected to be the same.

- I am not big fan of the header being part of the data structure, but I am open here.

- Not sure if customizing sort-type is interesting for anyone.

Honza

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list