Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display iterables as arrays (if “pure”) #20

Closed
mbostock opened this issue Oct 13, 2017 · 2 comments
Closed

Display iterables as arrays (if “pure”) #20

mbostock opened this issue Oct 13, 2017 · 2 comments

Comments

@mbostock
Copy link
Member

If a value is iterable (implements [Symbol.iterator] method), and the resulting iterator is a different object than the value (so as to avoid mutating common map and Set iterators that return this), we should display it in the inspector like an array.

@tmcw
Copy link
Contributor

tmcw commented Oct 13, 2017

To clarify here:

For native types - Set, Map, Array - switching to treating everything as just an 'iterable' wouldn't constitute much of an improvement. A Map would be displayed as an array of [key, value] pairs, instead of as a key => value mapping as it is currently displayed. Additionally, for arrays with extra non-numeric properties, like [1, 2, key: 'value'], relying solely on the iterator method would regress our current ability to display those properties - the iterator doesn't iterate over extra properties.

But for new types that implement Symbol.iterator, this would be a nice convenience - this will make debugging frame objects easier.

@mbostock
Copy link
Member Author

Moved to observablehq/inspector#13.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants