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

Function consumeEnd

deps/undici/src/lib/api/readable.js:521–541  ·  view source on GitHub ↗

* @param {Consume} consume * @param {BufferEncoding} encoding * @returns {void}

(consume, encoding)

Source from the content-addressed store, hash-verified

519 * @returns {void}
520 */
521function consumeEnd (consume, encoding) {
522 const { type, body, resolve, stream, length } = consume
523
524 try {
525 if (type === 'text') {
526 resolve(chunksDecode(body, length, encoding))
527 } else if (type === 'json') {
528 resolve(JSON.parse(chunksDecode(body, length, encoding)))
529 } else if (type === 'arrayBuffer') {
530 resolve(chunksConcat(body, length).buffer)
531 } else if (type === 'blob') {
532 resolve(new Blob(body, { type: stream[kContentType] }))
533 } else if (type === 'bytes') {
534 resolve(chunksConcat(body, length))
535 }
536
537 consumeFinish(consume)
538 } catch (err) {
539 stream.destroy(err)
540 }
541}
542
543/**
544 * @param {Consume} consume

Callers 1

consumeStartFunction · 0.70

Calls 6

chunksDecodeFunction · 0.70
chunksConcatFunction · 0.70
consumeFinishFunction · 0.70
parseMethod · 0.65
resolveFunction · 0.50
destroyMethod · 0.45

Tested by

no test coverage detected