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

Function bodyLength

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

Source from the content-addressed store, hash-verified

1762 }
1763 __name(hasSafeIterator, "hasSafeIterator");
1764 function bodyLength(body) {
1765 if (body == null) {
1766 return 0;
1767 } else if (isStream(body)) {
1768 const state = body._readableState;
1769 return state && state.objectMode === false && state.ended === true && Number.isFinite(state.length) ? state.length : null;
1770 } else if (isBlobLike(body)) {
1771 return body.size != null ? body.size : null;
1772 } else if (isBuffer(body)) {
1773 return body.byteLength;
1774 }
1775 return null;
1776 }
1777 __name(bodyLength, "bodyLength");
1778 function isDestroyed(body) {
1779 return body && !!(body.destroyed || body[kDestroyed] || stream.isDestroyed?.(body));

Callers 1

wrapRequestBodyFunction · 0.70

Calls 3

isStreamFunction · 0.70
isBlobLikeFunction · 0.70
isBufferFunction · 0.70

Tested by

no test coverage detected