mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-16 13:32:37 +01:00
24 lines
371 B
JavaScript
24 lines
371 B
JavaScript
|
|
export class MObject {
|
|
|
|
TYPE;
|
|
|
|
id;
|
|
ext = {};
|
|
|
|
constructor(TYPE, id) {
|
|
this.TYPE = TYPE;
|
|
this.id = id;
|
|
}
|
|
}
|
|
|
|
const ID_REGISTRY = new Map();
|
|
|
|
export const MObjectIdGenerator = {
|
|
next: entityType => {
|
|
const id = ID_REGISTRY.get(entityType) || 0;
|
|
ID_REGISTRY.set(entityType, id + 1);
|
|
return id;
|
|
},
|
|
reset: () => ID_REGISTRY.clear()
|
|
};
|