<commit_before>// Here we mock the global `process` variable in case we are not in Node's environment.

export interface IProcess {
  getuid(): number;
  getgid(): number;
  cwd(): string;
  platform: string;
  nextTick: (callback: (...args) => void, ...args) => void;
  emitWarning: (message: string, type: string) => void;
  env: {
    MEMFS_DONT_WARN?: boolean;
  };
}

export function createProcess(p: IProcess = process): IProcess {
  if (!p) {
    try {
      p = require('process');
    } catch (e) {}
  }
  if (!p) p = {} as IProcess;

  if (!p.getuid) p.getuid = () => 0;
  if (!p.getgid) p.getgid = () => 0;
  if (!p.cwd) p.cwd = () => '/';
  if (!p.nextTick) p.nextTick = require('./setImmediate').default;
  if (!p.emitWarning)
    p.emitWarning = (message, type) => {
      // tslint:disable-next-line:no-console
      console.warn(`${type}${type ? ': ' : ''}${message}`);
    };
  if (!p.env) p.env = {};
  return p;
}

export default createProcess();<commit_msg>fix: check for process (#396)<commit_after>// Here we mock the global `process` variable in case we are not in Node's environment.

export interface IProcess {
  getuid(): number;
  getgid(): number;
  cwd(): string;
  platform: string;
  nextTick: (callback: (...args) => void, ...args) => void;
  emitWarning: (message: string, type: string) => void;
  env: {
    MEMFS_DONT_WARN?: boolean;
  };
}

export function createProcess(): IProcess {
  let p: IProcess = typeof process !== 'undefined' && process;
  if (!p) {
    try {
      p = require('process');
    } catch (e) {}
  }
  if (!p) p = {} as IProcess;

  if (!p.getuid) p.getuid = () => 0;
  if (!p.getgid) p.getgid = () => 0;
  if (!p.cwd) p.cwd = () => '/';
  if (!p.nextTick) p.nextTick = require('./setImmediate').default;
  if (!p.emitWarning)
    p.emitWarning = (message, type) => {
      // tslint:disable-next-line:no-console
      console.warn(`${type}${type ? ': ' : ''}${message}`);
    };
  if (!p.env) p.env = {};
  return p;
}

export default createProcess();
{'fraction_non_alphanumeric': 0.20079522862823063, 'fraction_numerical': 0.0034791252485089465, 'mean_word_length': 3.091463414634146, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '5850576', 'n_tokens_mistral': 735, 'n_tokens_neox': 714, 'n_words': 190}