MCPcopy Index your code
hub / github.com/nodejs/node / wrapRequestBody

Function wrapRequestBody

deps/undici/undici.js:1611–1634  ·  view source on GitHub ↗
(body)

Source from the content-addressed store, hash-verified

1609 }
1610 __name(noop, "noop");
1611 function wrapRequestBody(body) {
1612 if (isStream(body)) {
1613 if (bodyLength(body) === 0) {
1614 body.on("data", function() {
1615 assert(false);
1616 });
1617 }
1618 if (typeof body.readableDidRead !== "boolean") {
1619 body[kBodyUsed] = false;
1620 EE.prototype.on.call(body, "data", function() {
1621 this[kBodyUsed] = true;
1622 });
1623 }
1624 return body;
1625 } else if (body && typeof body.pipeTo === "function") {
1626 return new BodyAsyncIterable(body);
1627 } else if (body && isFormDataLike(body)) {
1628 return body;
1629 } else if (body && typeof body !== "string" && !ArrayBuffer.isView(body) && isIterable(body)) {
1630 return new BodyAsyncIterable(body);
1631 } else {
1632 return body;
1633 }
1634 }
1635 __name(wrapRequestBody, "wrapRequestBody");
1636 function isStream(obj) {
1637 return obj && typeof obj === "object" && typeof obj.pipe === "function" && typeof obj.on === "function";

Callers

nothing calls this directly

Calls 7

isStreamFunction · 0.70
bodyLengthFunction · 0.70
isFormDataLikeFunction · 0.70
isIterableFunction · 0.70
assertFunction · 0.50
onMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected