const held = new Map>(); const fetchPayload = async function fetchPayload(path: string): Promise { try { const response = await fetch(path); if (!response.ok) { return null; } const data: unknown = await response.json(); return data; } catch { return null; } }; export const loadPayload = async function loadPayload(path: string): Promise { const pending = held.get(path); if (pending !== undefined) { return pending; } const loading = fetchPayload(path).then((payload) => { if (payload === null) { held.delete(path); } return payload; }); held.set(path, loading); return loading; };