mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-01 00:08:27 +01:00
13 lines
259 B
TypeScript
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;
|