Bug 123527 - Provide a way to iterate over WeakMap
Summary: Provide a way to iterate over WeakMap
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Oliver Hunt
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-30 13:46 PDT by Timothy Hatcher
Modified: 2017-01-18 23:39 PST (History)
3 users (show)

See Also:


Attachments
Desired Use Case in the Inspector (6.35 KB, application/x-javascript)
2013-10-30 13:46 PDT, Timothy Hatcher
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Timothy Hatcher 2013-10-30 13:46:19 PDT
Created attachment 215559 [details]
Desired Use Case in the Inspector

For the Inspector, we want to start using WeakMap for our event listener and dispatch base Object prototype. However, WeakMap can't be enumerated at all, unlike Map. I understand this is a design decision baked into ES6. But it really limits the uses to WeakMap.
Comment 1 Geoffrey Garen 2013-11-01 13:33:57 PDT
I believe the spec folks objected based on the fact that iteration would make GC behavior observable. I'm not sure I agree with that objection. Given that a WebKit-only client would use WeakMap iteration, it might be worth implementing even if other browsers don't implement it.
Comment 2 Timothy Hatcher 2013-11-07 16:12:57 PST
Lets do it then!
Comment 3 Oliver Hunt 2013-11-07 16:16:03 PST
(In reply to comment #1)
> I believe the spec folks objected based on the fact that iteration would make GC behavior observable. I'm not sure I agree with that objection. Given that a WebKit-only client would use WeakMap iteration, it might be worth implementing even if other browsers don't implement it.

Yes, my plan was to make this a privileged API


(In reply to comment #2)
> Lets do it then!

Would you be okay with a magical "get an array of entries" style API? (This simplifies the semantics dramatically)
Comment 4 Timothy Hatcher 2013-11-07 16:18:50 PST
Any API would do. We would need the key and value pairs.