pagraphcontrol/utils/weakmap-id.js
2019-08-11 00:39:28 +03:00

13 lines
195 B
JavaScript

let counter = 0;
const weakmap = new WeakMap();
const weakmapId = o => {
if (!weakmap.has(o)) {
weakmap.set(o, String(counter++));
}
return weakmap.get(o);
};
module.exports = weakmapId;