<commit_before>import * as os from 'os'
import * as fs from 'fs';
import * as path from 'path';

let baseTempFolder = os.tmpdir() + path.sep + 'stryker';
let tempFolder = baseTempFolder + path.sep + random();
ensureFolderExists(baseTempFolder);
ensureFolderExists(tempFolder);

function createRandomFolder(prefix: string) {
  return ensureFolderExists(tempFolder + path.sep + prefix + random());
}

function random() {
  Math.ceil(Math.random() * 10000000)
}

function ensureFolderExists(path: string) {
  if (!fileOrFolderExists(path)) {
    fs.mkdirSync(path);
  }
  return path;
}

function writeFile(fileName: string, data: string): Promise<void> {
  return new Promise<void>((resolve, reject) => {
    fs.writeFile(fileName, data, { encoding: 'utf8' }, (error) => {
      if (error) {
        reject(error);
      } else {
        resolve();
      }
    });
  });
}
  
/**
   * Checks if a file or folder exists.
   * @function
   * @param path - The path to the file or folder.
   * @returns True if the file exists.
   */
function fileOrFolderExists(path: string): boolean {
  try {
    var stats = fs.lstatSync(path);
    return true;
  } catch (errror) {
    return false;
  }
};

export default {
  createRandomFolder,
  writeFile
};<commit_msg>Fixed typo<commit_after>import * as os from 'os'
import * as fs from 'fs';
import * as path from 'path';

let baseTempFolder = os.tmpdir() + path.sep + 'stryker';
let tempFolder = baseTempFolder + path.sep + random();
ensureFolderExists(baseTempFolder);
ensureFolderExists(tempFolder);

function createRandomFolder(prefix: string) {
  return ensureFolderExists(tempFolder + path.sep + prefix + random());
}

function random() {
  Math.ceil(Math.random() * 10000000)
}

function ensureFolderExists(path: string) {
  if (!fileOrFolderExists(path)) {
    fs.mkdirSync(path);
  }
  return path;
}

function writeFile(fileName: string, data: string): Promise<void> {
  return new Promise<void>((resolve, reject) => {
    fs.writeFile(fileName, data, { encoding: 'utf8' }, (error) => {
      if (error) {
        reject(error);
      } else {
        resolve();
      }
    });
  });
}
  
/**
   * Checks if a file or folder exists.
   * @function
   * @param path - The path to the file or folder.
   * @returns True if the file exists.
   */
function fileOrFolderExists(path: string): boolean {
  try {
    var stats = fs.lstatSync(path);
    return true;
  } catch (error) {
    return false;
  }
};

export default {
  createRandomFolder,
  writeFile
};
{'fraction_non_alphanumeric': 0.13647246608140462, 'fraction_numerical': 0.007182761372705506, 'mean_word_length': 3.476785714285714, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '3202616', 'n_tokens_mistral': 812, 'n_tokens_neox': 799, 'n_words': 217}