22 lines
626 B
JavaScript
22 lines
626 B
JavaScript
let synchronizedId = 0;
|
|
const synchronizedToIdMap = new Map();
|
|
const idToSynchronizedMap = new Map();
|
|
export function allSynchronizeds() {
|
|
return Array.from(idToSynchronizedMap.values());
|
|
}
|
|
export function idFromSynchronized(Synchronized) {
|
|
return synchronizedToIdMap.get(Synchronized);
|
|
}
|
|
export function synchronizedFromId(id) {
|
|
return idToSynchronizedMap.get(id);
|
|
}
|
|
export function registerSynchronized(Synchronized) {
|
|
if (synchronizedToIdMap.has(Synchronized)) {
|
|
return;
|
|
}
|
|
const id = synchronizedId++;
|
|
synchronizedToIdMap.set(Synchronized, id);
|
|
idToSynchronizedMap.set(id, Synchronized);
|
|
return id;
|
|
}
|