MCPcopy Create free account
hub / github.com/nodejs/node / chunksDecode

Function chunksDecode

deps/undici/undici.js:17370–17382  ·  view source on GitHub ↗
(chunks, length, encoding)

Source from the content-addressed store, hash-verified

17368 }
17369 __name(consumeStart, "consumeStart");
17370 function chunksDecode(chunks, length, encoding) {
17371 if (chunks.length === 0 || length === 0) {
17372 return "";
17373 }
17374 const buffer = chunks.length === 1 ? chunks[0] : Buffer.concat(chunks, length);
17375 const bufferLength = buffer.length;
17376 const start = bufferLength > 2 && buffer[0] === 239 && buffer[1] === 187 && buffer[2] === 191 ? 3 : 0;
17377 if (!encoding || encoding === "utf8" || encoding === "utf-8") {
17378 return buffer.utf8Slice(start, bufferLength);
17379 } else {
17380 return buffer.subarray(start, bufferLength).toString(encoding);
17381 }
17382 }
17383 __name(chunksDecode, "chunksDecode");
17384 function chunksConcat(chunks, length) {
17385 if (chunks.length === 0 || length === 0) {

Callers 1

consumeEndFunction · 0.70

Calls 3

concatMethod · 0.80
utf8SliceMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected