<commit_before>require('babel-polyfill')
const async = require('async')

function parallel (promiseFunctions) {
  return generatePromise(promiseFunctions, async.parallel)
}

function series (promiseFunctions) {
  return generatePromise(promiseFunctions, async.series)
}

function generatePromise (promiseFunctions, asyncMethod) {
  return new Promise((resolve, reject) => {
    let callbacks = promiseFunctions
      .map(promiseFunction =>
        async (callback) => {
          try {
            callback(null, await promiseFunction())
          } catch (err) {
            callback(err)
          }
        }
      )

    asyncMethod(callbacks, (err, results) => {
      if (err) {
        return reject(err)
      }
      resolve(results)
    })
  })
}

module.exports = {parallel, series}
<commit_msg>Remove the need for the babel polyfill<commit_after>const async = require('async')

function parallel (promiseFunctions) {
  return generatePromise(promiseFunctions, async.parallel)
}

function series (promiseFunctions) {
  return generatePromise(promiseFunctions, async.series)
}

function generatePromise (promiseFunctions, asyncMethod) {
  return new Promise((resolve, reject) => {
    // Generate a function that executes the promise function and
    // calls back in a way that the async library requires
    let callbacks = promiseFunctions.map(promiseFunction =>
        (callback) => {
          promiseFunction().then(
            data => callback(null, data),
            err => callback(err)
          )
        }
      )

    asyncMethod(callbacks, (err, results) => {
      if (err) {
        return reject(err)
      }
      resolve(results)
    })
  })
}

module.exports = {parallel, series}

{'fraction_non_alphanumeric': 0.10676779463243874, 'fraction_numerical': 0.0, 'mean_word_length': 2.871331828442438, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '563331', 'n_tokens_mistral': 466, 'n_tokens_neox': 462, 'n_words': 117}