MCPcopy Create free account
hub / github.com/scriptscat/scriptcat / isText

Function isText

src/pkg/utils/istextorbinary.ts:23–27  ·  view source on GitHub ↗
(buffer: Uint8Array | undefined | null)

Source from the content-addressed store, hash-verified

21 * @returns Will be `null` if neither `filename` nor `buffer` were provided. Otherwise will be a boolean value with the detection result.
22 */
23export function isText(buffer: Uint8Array | undefined | null): boolean {
24 // Fallback to encoding if extension check was not enough
25 if (!buffer || typeof buffer !== "object") return false;
26 return getEncoding(buffer) === "utf8";
27}
28
29/**
30 * Get the encoding of a buffer.

Callers 4

parseMethod · 0.90
opfs_tools.test.tsFile · 0.90
createOPFSToolsFunction · 0.90

Calls 1

getEncodingFunction · 0.85

Tested by

no test coverage detected