1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/frontend/src/utils/objectId.ts

13 lines
259 B
TypeScript

// Get a unique ID for an object instance.
export const objectId = (value: object): number => {
if (!ids.has(value)) {
id++;
ids.set(value, id);
}
return ids.get(value)!;
};
const ids = new WeakMap<object, number>();
let id = 0;