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

Function chunksConcat

lib/api/readable.js:537–555  ·  view source on GitHub ↗

* @param {Buffer[]} chunks * @param {number} length * @returns {Uint8Array}

(chunks, length)

Source from the content-addressed store, hash-verified

535 * @returns {Uint8Array}
536 */
537function chunksConcat (chunks, length) {
538 if (chunks.length === 0 || length === 0) {
539 return new Uint8Array(0)
540 }
541 if (chunks.length === 1) {
542 // fast-path
543 return new Uint8Array(chunks[0])
544 }
545 const buffer = new Uint8Array(Buffer.allocUnsafeSlow(length).buffer)
546
547 let offset = 0
548 for (let i = 0; i < chunks.length; ++i) {
549 const chunk = chunks[i]
550 buffer.set(chunk, offset)
551 offset += chunk.length
552 }
553
554 return buffer
555}
556
557/**
558 * @param {Consume} consume

Callers 1

consumeEndFunction · 0.85

Calls 1

setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…