MCPcopy Create free account
hub / github.com/di-sukharev/opencommit / decode

Method decode

out/cli.cjs:69326–69356  ·  view source on GitHub ↗
(chunk)

Source from the content-addressed store, hash-verified

69324 return null;
69325 }
69326};
69327var LineDecoder = class _LineDecoder {
69328 constructor() {
69329 this.buffer = [];
69330 this.trailingCR = false;
69331 }
69332 decode(chunk) {
69333 let text = this.decodeText(chunk);
69334 if (this.trailingCR) {
69335 text = "\r" + text;
69336 this.trailingCR = false;
69337 }
69338 if (text.endsWith("\r")) {
69339 this.trailingCR = true;
69340 text = text.slice(0, -1);
69341 }
69342 if (!text) {
69343 return [];
69344 }
69345 const trailingNewline = _LineDecoder.NEWLINE_CHARS.has(text[text.length - 1] || "");
69346 let lines = text.split(_LineDecoder.NEWLINE_REGEXP);
69347 if (trailingNewline) {
69348 lines.pop();
69349 }
69350 if (lines.length === 1 && !trailingNewline) {
69351 this.buffer.push(lines[0]);
69352 return [];
69353 }
69354 if (this.buffer.length > 0) {
69355 lines = [this.buffer.join("") + lines[0], ...lines.slice(1)];
69356 this.buffer = [];
69357 }
69358 if (!trailingNewline) {
69359 this.buffer = [lines.pop() || ""];

Callers

nothing calls this directly

Calls 5

decodeTextMethod · 0.95
endsWithMethod · 0.80
sliceMethod · 0.45
hasMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected