As an aside, Irakli Gozashvili and I independently realized that you
could use a WeakMap for parallel objects with inheritance. Very
similar to Brendan’s createStorage, we put together a parallel
universe constructor.

function Parallel(root) {
    var parallel = new WeakMap();
    root = root || null;
    function get(object) {
        if (!parallel.has(object)) {
            parallel.set(object,
Object.create(get(Object.getPrototypeOf(object))));
        }
        return parallel.get(object);
    }
    return get;
}

Irakli’s was a Namespace constructor that appeared somewhere in the
Mozilla Add-on toolkit, but the links have gone stale.

Kris Kowal
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to