* @param {Buffer[]} chunks * @param {number} length * @returns {Uint8Array}
(chunks, length)
| 535 | * @returns {Uint8Array} |
| 536 | */ |
| 537 | function 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 |
no test coverage detected
searching dependent graphs…