MCPcopy Create free account
hub / github.com/anomalyco/opencode / compose

Function compose

packages/http-recorder/src/redactor.ts:18–25  ·  view source on GitHub ↗
(...redactors: ReadonlyArray<Partial<Redactor>>)

Source from the content-addressed store, hash-verified

16}
17
18export const compose = (...redactors: ReadonlyArray<Partial<Redactor>>): Redactor => {
19 const requests = redactors.map((r) => r.request).filter((fn): fn is Redactor["request"] => fn !== undefined)
20 const responses = redactors.map((r) => r.response).filter((fn): fn is Redactor["response"] => fn !== undefined)
21 return {
22 request: requests.length === 0 ? identity : (snapshot) => requests.reduce((acc, fn) => fn(acc), snapshot),
23 response: responses.length === 0 ? identity : (snapshot) => responses.reduce((acc, fn) => fn(acc), snapshot),
24 }
25}
26
27export interface HeaderOptions {
28 readonly allow?: ReadonlyArray<string>

Callers 2

makeFunction · 0.70
defaultsFunction · 0.70

Calls 1

fnFunction · 0.50

Tested by

no test coverage detected