code: function makeCounterMap() {
    var map = new WeakMap();
    return {
      init(obj) { map.set(obj, 0); },
      incr(obj) {
        console.assert(map.has(obj), "Object must be in counter map.");
        map.set(obj, map.get(obj) + 1);
      },
       get(obj)  { return map.get(obj); }
    };
  }
docs: Make a counter for occurrences of something on an object, using weak map. For example, used to count recomputations of "keepXXX" results.