* @param {Blob|Buffer|import ('stream').Stream} body * @returns {number|null}
(body)
| 330 | * @returns {number|null} |
| 331 | */ |
| 332 | function bodyLength (body) { |
| 333 | if (body == null) { |
| 334 | return 0 |
| 335 | } else if (isStream(body)) { |
| 336 | const state = body._readableState |
| 337 | return state && state.objectMode === false && state.ended === true && Number.isFinite(state.length) |
| 338 | ? state.length |
| 339 | : null |
| 340 | } else if (isBlobLike(body)) { |
| 341 | return body.size != null ? body.size : null |
| 342 | } else if (isBuffer(body)) { |
| 343 | return body.byteLength |
| 344 | } |
| 345 | |
| 346 | return null |
| 347 | } |
| 348 | |
| 349 | /** |
| 350 | * @param {import ('stream').Stream} body |
no test coverage detected