13 lines
195 B
JavaScript
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;
|