A write: the marker header, and a JSON body when there is one to send.
(path: string, method: string, body?: unknown, signal?: AbortSignal)
| 342 | |
| 343 | /** A write: the marker header, and a JSON body when there is one to send. */ |
| 344 | function write<T>(path: string, method: string, body?: unknown, signal?: AbortSignal): Promise<T> { |
| 345 | const headers: Record<string, string> = { |
| 346 | accept: 'application/json', |
| 347 | [WRITE_HEADER]: '1', |
| 348 | }; |
| 349 | if (body !== undefined) headers['content-type'] = 'application/json'; |
| 350 | return call<T>( |
| 351 | path, |
| 352 | { method, headers, ...(body === undefined ? {} : { body: JSON.stringify(body) }) }, |
| 353 | signal |
| 354 | ); |
| 355 | } |
| 356 | |
| 357 | return { |
| 358 | stats: (signal) => getJson<WireStats>('api/stats', signal), |
no test coverage detected