mirror of
https://github.com/renovatebot/renovate.git
synced 2026-11-02 18:43:40 +00:00
2561284dc4
* build(deps): update dependency got to v15 | datasource | package | from | to | | ---------- | ------- | ------ | ------ | | npm | got | 14.6.6 | 15.0.5 | * chore: adapt code to breaking changes * test: fix test --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: secustor <sebastian@poxhofer.at> Co-authored-by: Michael Kriese <michael.kriese@mend.io>
24 lines
571 B
TypeScript
24 lines
571 B
TypeScript
import { clone } from '../clone.ts';
|
|
import type { HttpResponse } from './types.ts';
|
|
|
|
// Copying will help to avoid circular structure
|
|
// and mutation of the cached response.
|
|
export function copyResponse<T>(
|
|
{ statusCode, headers, body, cached }: HttpResponse<T>,
|
|
deep: boolean,
|
|
): HttpResponse<T> {
|
|
const res: HttpResponse<T> = { statusCode, headers, body };
|
|
|
|
if (deep) {
|
|
res.headers = clone(headers);
|
|
res.body =
|
|
body instanceof Uint8Array ? (body.subarray() as T) : clone<T>(body);
|
|
}
|
|
|
|
if (cached) {
|
|
res.cached = true;
|
|
}
|
|
|
|
return res;
|
|
}
|