TGViewer
JavaScript JavaScript @javascript · 31.1K subscribers
Post #2647 3.67K
CHALLENGE

const moduleCache = new Map();

async function loadModule(name) {
if (moduleCache.has(name)) {
return moduleCache.get(name);
}

const module = await Promise.resolve({
default: () => `Module ${name} loaded`,
version: '1.0.0'
});

moduleCache.set(name, module);
return module;
}

const results = [];
loadModule('auth').then(m => results.push(m.default()));
loadModule('auth').then(m => results.push(m.version));
loadModule('utils').then(m => results.push(m.default()));

setTimeout(() => console.log(results.join(', ')), 0);
  • 🤔 4
  • ❤ 3
More from @javascript
  1. Oct 1, 2026Post #3530
  2. Oct 1, 2026CHALLENGE class Counter { #count = 0; static #instances = 0; constructor() { Counter.#inst…
  3. Sep 30, 2026Post #3528
  4. Sep 30, 2026CHALLENGE const message = 'a😀bc'; const codePoints = [...message]; const combined = { raw…
  5. Sep 29, 2026Post #3526
  6. Sep 29, 2026CHALLENGE const order = []; order.push('start'); setTimeout(() => { order.push('timeout');…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →