<commit_before>import { jschardet } from "./vscodeModules";

jschardet.Constants.MINIMUM_THRESHOLD = 0.2;
jschardet.MacCyrillicModel.mTypicalPositiveRatio += 0.001;

function detectEncodingByBOM(buffer: Buffer): string | null {
  if (!buffer || buffer.length < 2) {
    return null;
  }

  const b0 = buffer.readUInt8(0);
  const b1 = buffer.readUInt8(1);

  // UTF-16 BE
  if (b0 === 0xfe && b1 === 0xff) {
    return "utf16be";<commit_msg>fix: Added check for jschardet constants (#745)<commit_after>import { jschardet } from "./vscodeModules";

if (jschardet.Constants) {
  jschardet.Constants.MINIMUM_THRESHOLD = 0.2;
  jschardet.MacCyrillicModel.mTypicalPositiveRatio += 0.001;
}

function detectEncodingByBOM(buffer: Buffer): string | null {
  if (!buffer || buffer.length < 2) {
    return null;
  }

  const b0 = buffer.readUInt8(0);
  const b1 = buffer.readUInt8(1);

  // UTF-16 BE
  if (b0 === 0xfe && b1 === 0xff) {
    return "utf16be";
{'fraction_non_alphanumeric': 0.14436248682824027, 'fraction_numerical': 0.04741833508956796, 'mean_word_length': 3.9479166666666665, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4690622', 'n_tokens_mistral': 388, 'n_tokens_neox': 355, 'n_words': 75}