On a small tangent, it turns out you can provide a nearly perfect shim for
WeakMap given ES5. That is: O(1) lookup time, keys hold reference to values
strongly and not vice versa, being a WeakMap key or value doesn't prevent
an object from being gced, weakmaps themselves can be gced while
object/keys in it still exist, key->value mappings are non-forgeable and
non-interceptable, and all of this done [almost] non-observerably. This
gist by Gozala demonstrates the concept in action (
https://gist.github.com/1269991).  I built on the technique he used as well
as some ideas from the SES WeakMap impl by Mark Miller (
http://code.google.com/p/es-lab/source/browse/trunk/src/ses/WeakMap.js )
and redid my original not-so-good es6 collection shim with one that is very
close in functionality and interface to the real thing:
https://github.com/Benvie/ES6-Harmony-Collections-Shim . Compatibility goes
to IE9 (relies on defineProperty and getOwnPropertyNames).

On Thu, May 10, 2012 at 12:34 PM, Mikeal Rogers <[email protected]>wrote:

>
> People in the community don't ask for "WeakMap" until there is a proposal.
> Instead they come up with other crazy ways to accomplish their end goals
> without needing such a type to varying degrees success (we're still finding
> leaks in FreeList in node.js http.js that might have been prevented had we
> had WeakMap a few years ago).
>
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to