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

Method decodeText

out/cli.cjs:69357–69379  ·  view source on GitHub ↗
(bytes)

Source from the content-addressed store, hash-verified

69355 lines = [this.buffer.join("") + lines[0], ...lines.slice(1)];
69356 this.buffer = [];
69357 }
69358 if (!trailingNewline) {
69359 this.buffer = [lines.pop() || ""];
69360 }
69361 return lines;
69362 }
69363 decodeText(bytes) {
69364 if (bytes == null)
69365 return "";
69366 if (typeof bytes === "string")
69367 return bytes;
69368 if (typeof Buffer !== "undefined") {
69369 if (bytes instanceof Buffer) {
69370 return bytes.toString();
69371 }
69372 if (bytes instanceof Uint8Array) {
69373 return Buffer.from(bytes).toString();
69374 }
69375 throw new AnthropicError(`Unexpected: received non-Uint8Array (${bytes.constructor.name}) stream chunk in an environment with a global "Buffer" defined, which this library assumes to be Node. Please report this error.`);
69376 }
69377 if (typeof TextDecoder !== "undefined") {
69378 if (bytes instanceof Uint8Array || bytes instanceof ArrayBuffer) {
69379 this.textDecoder ?? (this.textDecoder = new TextDecoder("utf8"));
69380 return this.textDecoder.decode(bytes);
69381 }
69382 throw new AnthropicError(`Unexpected: received non-Uint8Array/ArrayBuffer (${bytes.constructor.name}) in a web platform. Please report this error.`);

Callers 1

decodeMethod · 0.95

Calls 3

toStringMethod · 0.45
fromMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected