MCPcopy
hub / github.com/nodejs/undici / consumeEnd

Function consumeEnd

lib/api/readable.js:562–582  ·  view source on GitHub ↗

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

(consume, encoding)

Source from the content-addressed store, hash-verified

560 * @returns {void}
561 */
562function consumeEnd (consume, encoding) {
563 const { type, body, resolve, stream, length } = consume
564
565 try {
566 if (type === 'text') {
567 resolve(chunksDecode(body, length, encoding))
568 } else if (type === 'json') {
569 resolve(JSON.parse(chunksDecode(body, length, encoding)))
570 } else if (type === 'arrayBuffer') {
571 resolve(chunksConcat(body, length).buffer)
572 } else if (type === 'blob') {
573 resolve(new Blob(body, { type: stream[kContentType] }))
574 } else if (type === 'bytes') {
575 resolve(chunksConcat(body, length))
576 }
577
578 consumeFinish(consume)
579 } catch (err) {
580 stream.destroy(err)
581 }
582}
583
584/**
585 * @param {Consume} consume

Callers 1

consumeStartFunction · 0.85

Calls 5

resolveFunction · 0.85
chunksDecodeFunction · 0.85
chunksConcatFunction · 0.85
consumeFinishFunction · 0.85
destroyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…