home.social

#weakmap — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #weakmap, aggregated by home.social.

  1. Literal #ShowerThought #idea: A #JavaScript "composite" #WeakMap. Returns a value for a given array of references. All weakly referenced to avoid memory leaks. Something like:

    ```
    const map = new CompositeWeakMap();
    const keys = [ {}, {}, {} ];

    map.set(keys, 'test');
    map.get(keys); // 'test'
    ```

    Not 100% sure it's possible since `WeakMap` is only keyed by a single reference, but I think it's possible if you chain two `WeakMap` objects together. I have an implementation in my head, but I'll have to actually try it to see if it works for real. 🤔