avocado-old/packages/net/s13n/registrar.js
2020-06-17 04:35:59 -05:00

24 lines
585 B
JavaScript

const {all, idFrom: idFromRaw} = require('./s13n.scwp');
let hasMapped = false;
const synchronizedTo = new Map();
function mapSynchronizedsToMs() {
const entries = Object.entries(all());
for (let i = 0; i < entries.length; i++) {
const [, M] = entries[i];
const {default: Synchronized} = M;
synchronizedTo.set(Synchronized, M);
}
}
export function idFrom(Synchronized) {
if (!hasMapped) {
mapSynchronizedsToMs();
hasMapped = true;
}
return idFromRaw(synchronizedTo.get(Synchronized));
}
module.hot?.accept(['./s13n.scwp'], () => hasMapped = false);