fn

composePlugins

v0.0.1

Flattens 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

ParameterTypeDescription
pluginsreadonly FetchPlugin[] | undefined
userDefaultsFetchOptions | undefined

Returns

ComposedPlugins
PropertyTypeDescription
defaultsFetchOptionsMerged 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
executeFetchExecuteMiddleware | undefinedPre-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).