<commit_before>var fs = require('fs');

var DEFAULT_DIRECTORY = '../Source/';
var DEFAULT_FILE = '.swift$';

fs.readdir(process.argv[2] || DEFAULT_DIRECTORY, function(error, files) {
   if (error) throw error;

   if (process.argv[3]) {
       parseFile(process.argv[3]);
   } else {
       for (var file in files) {
           file = files[file];
           if (/.swift$/.test(file)) {
               parseFile(file);
           }
           break;
       }
   }
});

function parseFile(file) {
    fs.readFile(DEFAULT_DIRECTORY + file, function (error, data) {
      if (error) { throw error; }
      data = data.toString();
      var comments = data.match(/(\/\*\*(?:(?!\*\/).|[\n\r])*\*\/)([\n\r])*(.*\{)/g);
      for (var i = comments.length - 1; 0 <= i; --i) {
          comments[i] = comments[i].replace(/(\/\*\*)/, '').replace(/(\*\/)/, '');
          var description = comments[i].replace(/^\s+|\s+$/g, '').split('\n');
          comments[i] = '### ' + description.shift() + '\n';

          var declaration = description.pop();
          declaration = declaration.split(' ');
          declaration.pop();

          for (var j = description.length - 1; 0 <= j; --j) {
              description[j] = description[j].replace(/^\s+|\s+$/g, '');
          }
          comments[i] += description.join(' ');
          comments[i] += '\n```swift\n' + declaration.join(' ').replace(/^\s+|\s+$/g, '') + '\n```';
      }
      comments.shift();
      console.log(comments.join('\n'));
    });
}<commit_msg>Issue-63: parser outputting now as object literal array<commit_after>var fs = require('fs');

var DEFAULT_DIRECTORY = '../Source/';
var DEFAULT_FILE = '.swift$';

fs.readdir(process.argv[2] || DEFAULT_DIRECTORY, function(error, files) {
   if (error) throw error;

   if (process.argv[3]) {
       parseFile(process.argv[3]);
   } else {
       for (var file in files) {
           file = files[file];
           if (/.swift$/.test(file)) {
               parseFile(file);
           }
           break;
       }
   }
});

function parseFile(file) {
    fs.readFile(DEFAULT_DIRECTORY + file, function (error, data) {
      if (error) { throw error; }
      data = data.toString();
      var myArray = [];
      var comments = data.match(/(\/\*\*(?:(?!\*\/).|[\n\r])*\*\/)([\n\r])*(.*\{)/g);
      for (var i = comments.length - 1; 0 <= i; --i) {
          comments[i] = comments[i].replace(/(\/\*\*)/, '').replace(/(\*\/)/, '');
          var description = comments[i].replace(/^\s+|\s+$/g, '').split('\n');
          var myObject = {};
          myObject.title = description.shift();

          var declaration = description.pop();
          declaration = declaration.split(' ');
          declaration.pop();

          for (var j = description.length - 1; 0 <= j; --j) {
              description[j] = description[j].replace(/^\s+|\s+$/g, '');
          }

          myObject.description = description.join(' ')
          myObject.declaration = declaration.join(' ').replace(/^\s+|\s+$/g, '');
          myArray.push(myObject);
      }
      console.log(myArray);
    });
}
{'fraction_non_alphanumeric': 0.2249269717624148, 'fraction_numerical': 0.00519311911716975, 'mean_word_length': 2.0514851485148515, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6385701', 'n_tokens_mistral': 1011, 'n_tokens_neox': 982, 'n_words': 190}