<commit_before>'use strict';
var projects = [];

function Project (projectDataObj) {
  this.name = projectDataObj.name,
  this.imagePath = projectDataObj.imagePath,
  this.projectUrl = projectDataObj.projectUrl,
  this.content = projectDataObj.content;
}

Project.prototype.toHtml = function() {
  var handlebarsTemplateString = $('#handlebarsTemplate').html();
  var compiled = Handlebars.compile(handlebarsTemplateString);
  var html = compiled(this);
  return html;
};

Project.loadAllProject = function(projectData) {
  projectData.forEach(function(projectObject) {
    projects.push(new Project(projectObject));
  })
}

Project.mapAllProject = func

Project.retrieveAllProject = function() {
  if (localStorage.projectData) {
    Project.loadAllProject(JSON.parse(localStorage.getItem('projectdata')));
  } else {
    var path = '../data/project.json';
    $.get(path).then(function functionSuccess(data) {
      var stringfiedData = JSON.stringify(data);
      localStorage.setItem('data', stringfiedData);
      var parsedData = JSON.parse(stringfiedData)
      Project.loadAllProject(parsedData);
      projects.forEach(function(project) {
        $('#projects').append(project.toHtml());
      });
    }, function functionError(err) {
      console.err(err);
    });
  }
}<commit_msg>refractored code to add map method<commit_after>'use strict';
var projects = [];

function Project (projectDataObj) {
  this.name = projectDataObj.name,
  this.imagePath = projectDataObj.imagePath,
  this.projectUrl = projectDataObj.projectUrl,
  this.content = projectDataObj.content;
}

Project.prototype.toHtml = function() {
  var handlebarsTemplateString = $('#handlebarsTemplate').html();
  var compiled = Handlebars.compile(handlebarsTemplateString);
  var html = compiled(this);
  return html;
};

Project.loadAllProject = function(projectData) {
  projects = projectData.map(function(ele) {
    return new Project(ele);
  });
};

Project.retrieveAllProject = function() {
  if (localStorage.projectData) {
    Project.loadAllProject(JSON.parse(localStorage.getItem('projectData')));
    projects.forEach(function(project) {
      $('#projects').append(project.toHtml());
    });
  } else {
    var path = '../data/project.json';
    $.get(path).then(function functionSuccess(data) {
      var stringfiedData = JSON.stringify(data);
      localStorage.setItem('projectData', stringfiedData);
      var parsedData = JSON.parse(stringfiedData);
      Project.loadAllProject(parsedData);
      projects.forEach(function(project) {
        $('#projects').append(project.toHtml());
      });
    }, function functionError(err) {
      console.error(err);
    });
  }
}
{'fraction_non_alphanumeric': 0.13963963963963963, 'fraction_numerical': 0.0, 'mean_word_length': 4.372983870967742, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5906362', 'n_tokens_mistral': 773, 'n_tokens_neox': 778, 'n_words': 127}