MCPcopy Create free account
hub / github.com/babel/babel / getEncoding

Function getEncoding

scripts/parser-tests/typescript/index.js:13–16  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11 * @returns {"utf-8" | "utf-16le" | "utf-16be"}
12 */
13const getEncoding = path =>
14 ({ fffe: "utf-16le", feff: "utf-16be" })[
15 fs.readFileSync(path).subarray(0, 2).toString("hex")
16 ] || "utf-8";
17
18const ErrorCodeRegExp = new RegExp(ErrorCodes.join("|"));
19

Callers 1

loadTestsFunction · 0.85

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected