inspect-js / object-inspect

string representations of objects in node and the browser
MIT License
142 stars 36 forks source link

Support ES2015 Map/Set #3

Closed mjackson closed 8 years ago

mjackson commented 8 years ago

Using object-inspect version 1.0.2:

inspect(new Set('a')) // {}

var map = new Map()
map.set('a', 'b')
inspect(map) // {}

These aren't very descriptive. In babel's CLI, I get Set { 'a' } and Map { 'a' => 'b' } respectively. It would be great to get the same (or similar) using object-inspect.

ljharb commented 8 years ago

I'm not sure the hash rocket is the best separator, since in JS that can be confused with an arrow function, but this should definitely be supported.

ljharb commented 8 years ago

Do you think it would be useful to explicitly indicate the size? Like Set (2) { 'a', 'b' } and Map (2) { [[2, 3], [3, 4]] }?

ljharb commented 8 years ago

After clicking around in browsers, I think sticking with the hash rocket works. I'm going to go with Chrome's interpretation, but add the size of the collection.