MCPcopy Create free account
hub / github.com/nodejs/node / cloneBody

Function cloneBody

deps/undici/src/lib/web/fetch/body.js:276–293  ·  view source on GitHub ↗
(body)

Source from the content-addressed store, hash-verified

274}
275
276function cloneBody (body) {
277 // To clone a body body, run these steps:
278
279 // https://fetch.spec.whatwg.org/#concept-body-clone
280
281 // 1. Let « out1, out2 » be the result of teeing body’s stream.
282 const { 0: out1, 1: out2 } = body.stream.tee()
283
284 // 2. Set body’s stream to out1.
285 body.stream = out1
286
287 // 3. Return a body whose stream is out2 and other members are copied from body.
288 return {
289 stream: out2,
290 length: body.length,
291 source: body.source
292 }
293}
294
295function bodyMixinMethods (instance, getInternalState) {
296 const methods = {

Callers 2

cloneRequestFunction · 0.70
cloneResponseFunction · 0.70

Calls 1

teeMethod · 0.80

Tested by

no test coverage detected