MCPcopy Index your code
hub / github.com/di-sukharev/opencommit / parseCloseBody

Method parseCloseBody

out/cli.cjs:63537–63561  ·  view source on GitHub ↗
(onlyCode, data)

Source from the content-addressed store, hash-verified

63535 } else {
63536 buffer.set(this.#buffers.shift(), offset);
63537 offset += next.length;
63538 }
63539 }
63540 this.#byteOffset -= n2;
63541 return buffer;
63542 }
63543 parseCloseBody(onlyCode, data) {
63544 let code;
63545 if (data.length >= 2) {
63546 code = data.readUInt16BE(0);
63547 }
63548 if (onlyCode) {
63549 if (!isValidStatusCode(code)) {
63550 return null;
63551 }
63552 return { code };
63553 }
63554 let reason = data.subarray(2);
63555 if (reason[0] === 239 && reason[1] === 187 && reason[2] === 191) {
63556 reason = reason.subarray(3);
63557 }
63558 if (code !== void 0 && !isValidStatusCode(code)) {
63559 return null;
63560 }
63561 try {
63562 reason = new TextDecoder("utf-8", { fatal: true }).decode(reason);
63563 } catch {
63564 return null;

Callers 1

runMethod · 0.80

Calls 2

isValidStatusCodeFunction · 0.85
decodeMethod · 0.45

Tested by

no test coverage detected