<commit_before>
import os from 'os';
import path from 'path';
import debug from 'debug';
import assign from 'object-assign';
import { name as pkgName } from '../package.json';
import createConversion from './conversion';

const debugMe = debug(pkgName);

function conversionFactory(userOptions = {}) {
  let conversion;

  const optionsDefault = {
    timeout: 10000,
    numberOfWorkers: 2,
    chromeCommandLineSwitches: {},
    allowLocalFilesAccess: false,
    // namespace for tmp dir
    tmpDir: path.join(os.tmpDir(), pkgName + '-tmp-data'),
    strategy: 'electron-server'
  };

  const options = assign({}, optionsDefault, userOptions);

  if (Object.keys(options.chromeCommandLineSwitches).length === 0) {
    options.chromeCommandLineSwitches['ignore-certificate-errors'] = null;
  }

  debugMe('Creating a new conversion function with options:', options);

  // always set env var names for electron-workers (don't let the user override this config)
  options.hostEnvVarName = 'ELECTRON_WORKER_HOST';
  options.portEnvVarName = 'ELECTRON_WORKER_PORT';

  conversion = createConversion(options);<commit_msg>[update] default to electron-ipc strategy<commit_after>
import os from 'os';
import path from 'path';
import debug from 'debug';
import assign from 'object-assign';
import { name as pkgName } from '../package.json';
import createConversion from './conversion';

const debugMe = debug(pkgName);

function conversionFactory(userOptions = {}) {
  let conversion;

  const optionsDefault = {
    timeout: 10000,
    numberOfWorkers: 2,
    chromeCommandLineSwitches: {},
    allowLocalFilesAccess: false,
    // namespace for tmp dir
    tmpDir: path.join(os.tmpDir(), pkgName + '-tmp-data'),
    strategy: 'electron-ipc'
  };

  const options = assign({}, optionsDefault, userOptions);

  if (Object.keys(options.chromeCommandLineSwitches).length === 0) {
    options.chromeCommandLineSwitches['ignore-certificate-errors'] = null;
  }

  debugMe('Creating a new conversion function with options:', options);

  // always set env var names for electron-workers (don't let the user override this config)
  options.hostEnvVarName = 'ELECTRON_WORKER_HOST';
  options.portEnvVarName = 'ELECTRON_WORKER_PORT';

  conversion = createConversion(options);
{'fraction_non_alphanumeric': 0.1172047766475011, 'fraction_numerical': 0.006191950464396285, 'mean_word_length': 4.626865671641791, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2039566', 'n_tokens_mistral': 681, 'n_tokens_neox': 639, 'n_words': 185}