<commit_before>'use strict';

module.exports = {

  // TODO: cache
  transpile(src, filename, babelConfig, tsCompilerOptions) {
    const babel = require('babel-core');
    const tsc = require('typescript');
    const gulpTsc = require('gulp-typescript');

    const transformWithBabel = content =>
      babel.transform(content, Object.assign({}, babelConfig, {
        filename,
        retainLines: true
      })).code;

    if (filename.indexOf('node_modules') !== -1) {
      // skip node_modules
      return src;
    } else if (/\.tsx?$/.test(filename)) {
      // use gulp-typescript to convert the settings for tsc
      const tsProject = gulpTsc.createProject(Object.assign({}, tsCompilerOptions, {
        inlineSourceMap: true,
        declaration: false
      }));

      return transformWithBabel(tsc.transpile(src, tsProject.options));
    } else if (!babel.util.canCompile(filename)) {
      // You might use a webpack loader in your project
      // that allows you to load custom files (e.g. css, less, scss).
      // Although it is working with webpack but jest
      // don't know how to handle these files.
      // You should never use these files unmocked
      // otherwise you might encounter unexpected behavior.
      // Changing the content of these files
      // to return the raw content.
      return `module.exports = ${JSON.stringify(src)}`;
    }

    return transformWithBabel(src);
  }
};
<commit_msg>Fix mocha test (ts support)<commit_after>'use strict';

module.exports = {

  // TODO: cache
  transpile(src, filename, babelConfig, tsCompilerOptions) {
    const babel = require('babel-core');
    const tsc = require('typescript');
    const gulpTsc = require('gulp-typescript');

    const transformWithBabel = content =>
      babel.transform(content, Object.assign({}, babelConfig, {
        filename,
        retainLines: true
      })).code;

    if (filename.indexOf('node_modules') !== -1) {
      // skip node_modules
      return src;
    } else if (/\.tsx?$/.test(filename)) {
      // use gulp-typescript to convert the settings for tsc
      const tsProject = gulpTsc.createProject(Object.assign({}, tsCompilerOptions, {
        typescript: tsc,
        inlineSourceMap: true,
        declaration: false
      }));

      return transformWithBabel(tsc.transpile(src, tsProject.options));
    } else if (!babel.util.canCompile(filename)) {
      // You might use a webpack loader in your project
      // that allows you to load custom files (e.g. css, less, scss).
      // Although it is working with webpack but jest
      // don't know how to handle these files.
      // You should never use these files unmocked
      // otherwise you might encounter unexpected behavior.
      // Changing the content of these files
      // to return the raw content.
      return `module.exports = ${JSON.stringify(src)}`;
    }

    return transformWithBabel(src);
  }
};

{'fraction_non_alphanumeric': 0.11655810764484059, 'fraction_numerical': 0.0006856359273225917, 'mean_word_length': 2.679697351828499, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '105191', 'n_tokens_mistral': 840, 'n_tokens_neox': 820, 'n_words': 254}