UNPKG

@virtualstate/app-history

Version:

Native JavaScript [app-history](https://github.com/WICG/app-history) implementation

18 lines 641 B
import { Request } from "@opennetwork/http-representation"; import { deferred } from "../../util/deferred.js"; import { dispatchEvent } from "../../event-target/global.js"; export async function fetch(url, init) { const request = new Request(new URL(url, "https://example.com").toString(), init); const { resolve, reject, promise } = deferred(); const event = { type: "fetch", request, signal: init?.signal, respondWith(value) { Promise.resolve(value).then(resolve, reject); } }; await dispatchEvent(event); return await promise; } //# sourceMappingURL=fetch.js.map