Skip to content

@xtandard/lib/web

Browser utilities: FormData → object, fetchWithProgress, an HTTP interceptor, keepSubDelims (peer up-fetch).

import { … } from "@xtandard/lib/web";
Name Summary
createHttpInterceptor Create an HTTP interceptor that patches fetch and XMLHttpRequest to capture requests/responses based on configurable rules. Each transport is patched only if the runtime has it: on a server (no XMLHttpRequest) only fetch is patched, and restore() puts back exactly what was replaced.
fetchWithProgress Drop-in fetch replacement that adds upload/download progress tracking. Compatible with Eden Treaty’s fetcher option.
formDataToObject Convert a FormData into a plain object. A key that appears once becomes a single value; a key that appears more than once (checkbox groups, multi-selects) becomes an array, in submission order.
Name Summary
HttpInterceptor
InterceptEvent
InterceptHandle
InterceptRule
Name Summary
BodyResult
FetchWithProgressInit fetch init for fetchWithProgress: RequestInit plus an onProgress callback.
HttpMethod HTTP interceptor for fetch and XMLHttpRequest. Patches whichever of the two the runtime has (servers: fetch only) to capture requests/responses based on configurable rules. Useful for debugging, analytics, monitoring, and testing.
ProgressInfo