<commit_before>'use strict';

const R            = require('ramda');
const Bluebird     = require('bluebird');
const fs           = require('fs');
const path         = require('path');

const compute_first_verification_digit = require('./compute_first_verification_digit');
const compute_second_verification_digit = require('./compute_second_verification_digit');
const not_all_equal = require('./not_all_equal');

module.exports = () => {
  const five_digits_combinations = generate_all_digits_combinations(5);
  const four_digits_combinations = generate_all_digits_combinations(4);

  const file_path = path.resolve(path.join('.', 'all_cpfs.txt'));
  const cpfs_file = fs.openSync(file_path, 'w');

  return Bluebird.map(five_digits_combinations, (five_digits_combination, first_index) => {
    return Bluebird.map(four_digits_combinations, (four_digits_combination, second_index) => {
      const ten_digits_combination = `${five_digits_combination}${four_digits_combination}`;
      const cpf_digits = ten_digits_combination.split('').map(digit => parseInt(digit, 10));

      cpf_digits.push(compute_first_verification_digit(cpf_digits));
      cpf_digits.push(compute_second_verification_digit(cpf_digits));

      if (not_all_equal(cpf_digits)) {
        const cpf = cpf_digits.join('');

        fs.writeSync(cpfs_file, `${cpf}\n`);
      }
    }, {concurrency: 15});
  }, {concurrency: 15});
};

function generate_all_digits_combinations (length) {
  const digits_matrix = [];
  const indexes = [];<commit_msg>Makes output file path a function parameter of generate_all_cpfs<commit_after>'use strict';

const R            = require('ramda');
const Bluebird     = require('bluebird');
const fs           = require('fs');
const path         = require('path');

const compute_first_verification_digit = require('./compute_first_verification_digit');
const compute_second_verification_digit = require('./compute_second_verification_digit');
const not_all_equal = require('./not_all_equal');

module.exports = output_file_path => {
  const five_digits_combinations = generate_all_digits_combinations(5);
  const four_digits_combinations = generate_all_digits_combinations(4);

  const file_path = path.resolve(output_file_path);
  const cpfs_file = fs.openSync(file_path, 'w');

  return Bluebird.map(five_digits_combinations, (five_digits_combination, first_index) => {
    return Bluebird.map(four_digits_combinations, (four_digits_combination, second_index) => {
      const ten_digits_combination = `${five_digits_combination}${four_digits_combination}`;
      const cpf_digits = ten_digits_combination.split('').map(digit => parseInt(digit, 10));

      cpf_digits.push(compute_first_verification_digit(cpf_digits));
      cpf_digits.push(compute_second_verification_digit(cpf_digits));

      if (not_all_equal(cpf_digits)) {
        const cpf = cpf_digits.join('');

        fs.writeSync(cpfs_file, `${cpf}\n`);
      }
    }, {concurrency: 15});
  }, {concurrency: 15});
};

function generate_all_digits_combinations (length) {
  const digits_matrix = [];
  const indexes = [];
{'fraction_non_alphanumeric': 0.12431207510521204, 'fraction_numerical': 0.005179669796050502, 'mean_word_length': 5.242424242424242, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '5182980', 'n_tokens_mistral': 1040, 'n_tokens_neox': 992, 'n_words': 156}