fn
composePlugins
v0.0.1Flattens plugin defaults and hook arrays into a single shape suitable for long-lived storage on a fetch instance. Runs exactly once per createFetch call. Ordering: plugin defaults (in declaration order) → user defaults (user wins). Headers are merged independently through a single Headers instance.
Signature
ts
export function composePlugins(
plugins: readonly FetchPlugin[] | undefined,
userDefaults: FetchOptions | undefined,
): ComposedPlugins{ ... }Parameters
| Parameter | Type | Description |
|---|---|---|
plugins | readonly FetchPlugin[] | undefined | — |
userDefaults | FetchOptions | undefined | — |
Returns
ComposedPlugins| Property | Type | Description |
|---|---|---|
defaults | FetchOptions | Merged defaults — plugin defaults first, then user defaults (user wins) |
hooks | { readonly onRequest: readonly FetchHook[] | undefined; readonly onRequestError: readonly FetchHook[] | undefined; readonly onResponse: readonly FetchHook[] | undefined; readonly onResponseError: readonly FetchHook[] | undefined; } | Pre-flattened readonly hook arrays; undefined when no plugin contributed a phase |
execute | FetchExecuteMiddleware | undefined | Pre-composed onion chain of plugin execute middlewares, or undefined
when no plugin contributed one (fast path: caller invokes the core
executor directly without constructing a next closure). |