-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Map.keys() returns empty object (4.1.1) #3107
Comments
It's not an empty object, it's just how console represents iterator object |
Ah I see, I also realize I was using the wrong paradigm to iterator over it which is why it seemed empty to me. This can be closed unless you think the representation should be updated. |
Suggestions on how to improve it? I'm actually not sure what a good way is of detecting iterator objects apart from V8 specific magic like |
Well, |
I don't think that's tamper resistant enough. With
|
@bnoordhuis right, but the same applies to |
Also we can use mirrors, they are already used to inspect promises |
Yes, but that's a) a status quo appeal, and b) code that predates ES6.
That's not a bad idea although it might be slow for large object graphs. I suppose we could test with |
@bnoordhuis didn't know about those, if we have them, then why use mirrors? though we could probably take advantage of |
That sounds plausible. We use a promise mirror for the same reason, so we can print the status. In case you're wondering why we're not using |
Ben, why |
It's faster and creates less garbage than |
Do these three methods return |
@targos Yes. |
I just realized we don't have to wait for a V8 upgrade to switch to |
Previously, a MapIterator or SetIterator would not be inspected properly. This change makes it possible to inspect them by creating a Debug Mirror and previewing the iterators to not consume the actual iterator that we are trying to inspect. This change also adds a node_util binding that uses v8's Value::IsSetIterator and Value::IsMapIterator to verify that the values passed in are actual iterators. Fixes: #3107 PR-URL: #3119 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Calling
keys()
on a Map returns an empty object rather than the keys of the Map:This works in Chrome45 which is using a similar v8 (V8 4.5.103.35):
The text was updated successfully, but these errors were encountered: