On Jul 12, 2013, at 12:14 PM, Jeremy Martin wrote:
> In brief: allow Symbol's to be constructed with a single parameter, with the
> following behavior:
>
> > var obj = {};
> undefined
> > new Symbol({}) === new Symbol({})
> false
> > new Symbol(obj) === new Symbol(obj)
> true
You can use a WeakMap to build your own object-selected Symbol factory:
let known = new WeakMap;
function ObjSymFactory(obj) {
//handle obj === undefined however you want
let sym = known.get(obj);
If (!sym) {
sym = new Symbol;
known.set(obj,sym);
}
return sym;
}
Allen
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss