<commit_before>const { chunk } = require('lodash')
const os = require('os')
const fs = require('fs')
const path = require('path')
const util = require('util')
const mkdirp = require('mkdirp')
const { performance } = require('perf_hooks')
const {
  Worker,
  isMainThread,
  parentPort,
  workerData,
} = require('worker_threads')

const ProgressBar = require('progress')
const { createBundleRenderer } = require('vue-server-renderer')

const languages = require('../src/i18n/locales.js')
const availableLanguages = languages.map(lang => lang.alternate || lang.locale)

const threads = os.cpus().length
const resolve = file => path.resolve(__dirname, file)

function readFile (file) {
  return fs.readFileSync(resolve(file), 'utf-8')
}
const writeFile = util.promisify(fs.writeFile)

/**
 * Call cb for each item in arr, waiting for a returned
 * promise to resolve before calling on the next item
 *
 * @param {any[]} arr
 * @param {function(*): Promise<void>} cb
 * @return {Promise<void>}
 */
function forEachSequential (arr, cb) {
  return arr.reduce((p, val) => {
    return p.then(() => {
      return cb(val)
    })
  }, Promise.resolve())
}

function postMessage (data) {
  if (isMainThread) {
    onMessage(data)
  } else {
    parentPort.postMessage(data)
  }
}<commit_msg>chore(prerender.js): use fs.promises for writeFile<commit_after>const { chunk } = require('lodash')
const os = require('os')
const fs = require('fs')
const path = require('path')
const mkdirp = require('mkdirp')
const { performance } = require('perf_hooks')
const {
  Worker,
  isMainThread,
  parentPort,
  workerData,
} = require('worker_threads')

const ProgressBar = require('progress')
const { createBundleRenderer } = require('vue-server-renderer')

const languages = require('../src/i18n/locales.js')
const availableLanguages = languages.map(lang => lang.alternate || lang.locale)

const threads = os.cpus().length
const resolve = file => path.resolve(__dirname, file)

function readFile (file) {
  return fs.readFileSync(resolve(file), 'utf-8')
}
const writeFile = fs.promises.writeFile

/**
 * Call cb for each item in arr, waiting for a returned
 * promise to resolve before calling on the next item
 *
 * @param {any[]} arr
 * @param {function(*): Promise<void>} cb
 * @return {Promise<void>}
 */
function forEachSequential (arr, cb) {
  return arr.reduce((p, val) => {
    return p.then(() => {
      return cb(val)
    })
  }, Promise.resolve())
}

function postMessage (data) {
  if (isMainThread) {
    onMessage(data)
  } else {
    parentPort.postMessage(data)
  }
}
{'fraction_non_alphanumeric': 0.15048732943469786, 'fraction_numerical': 0.0023391812865497076, 'mean_word_length': 4.424947145877378, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '4129997', 'n_tokens_mistral': 821, 'n_tokens_neox': 814, 'n_words': 215}