<commit_before>  var PixelImage = require('./PixelImage');
  var ColorMap = require('./ColorMap');

  function Remapper(targetPixelImage) {
      this.targetPixelImage = targetPixelImage;
  }

  /**
  Convert ImageData to a ColorMap, using the same properties as the target image.
  */
  Remapper.prototype.getColorMap = function(imageData) {
      'use strict';
      var w = imageData.width,
          h = imageData.height,
          unrestrictedImage = PixelImage.create(w, h, new ColorMap(w, h, 1, 1), this.targetPixelImage.pWidth, this.targetPixelImage.pHeight);

      unrestrictedImage.palette = this.targetPixelImage.palette;
      unrestrictedImage.dither = this.targetPixelImage.dither;
      unrestrictedImage.mappingWeight = this.targetPixelImage.mappingWeight;
      unrestrictedImage.errorDiffusionDither = this.targetPixelImage.errorDiffusionDither;
      unrestrictedImage.drawImageData(imageData);
      return unrestrictedImage.colorMaps[0];
  };

  /**
  Map ImageData onto the target image.
  */
  Remapper.prototype.mapImageData = function(imageData) {
      'use strict';

      var ci,
          colorMap = this.getColorMap(imageData);

      // fill up the colormaps in the restricted image based on the colors in the unrestricted image
      for (ci = 0; ci < this.targetPixelImage.colorMaps.length; ci += 1) {
          colorMap.extractColorMap(this.targetPixelImage.colorMaps[ci]);
      }

      // draw the image again in the restricted image
      this.targetPixelImage.drawImageData(imageData);
  };

module.exports = Remapper;
<commit_msg>Refactored Remapper<commit_after>  var PixelImage = require('./PixelImage');
  var ColorMap = require('./ColorMap');

  /**
  Convert ImageData to a ColorMap, using the same properties as the target image.
  */
  function getColorMap(imageData, targetPixelImage) {
      'use strict';
      var w = imageData.width,
          h = imageData.height,
          unrestrictedImage = PixelImage.create(w, h, new ColorMap(w, h, 1, 1), targetPixelImage.pWidth, targetPixelImage.pHeight);

      unrestrictedImage.palette = targetPixelImage.palette;
      unrestrictedImage.dither = targetPixelImage.dither;
      unrestrictedImage.mappingWeight = targetPixelImage.mappingWeight;
      unrestrictedImage.errorDiffusionDither = targetPixelImage.errorDiffusionDither;
      unrestrictedImage.drawImageData(imageData);
      return unrestrictedImage.colorMaps[0];
  }

  /**
  Map ImageData onto the target image.
  */
  function mapImageData(imageData, targetPixelImage) {
      'use strict';

      var ci,
          colorMap = getColorMap(imageData, targetPixelImage);

      // fill up the colormaps in the restricted image based on the colors in the unrestricted image
      for (ci = 0; ci < targetPixelImage.colorMaps.length; ci += 1) {
          colorMap.extractColorMap(targetPixelImage.colorMaps[ci]);
      }

      // draw the image again in the restricted image
      targetPixelImage.drawImageData(imageData);
  }

module.exports = {
  mapImageData : mapImageData
};

{'fraction_non_alphanumeric': 0.09375, 'fraction_numerical': 0.003289473684210526, 'mean_word_length': 3.432944606413994, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6381127', 'n_tokens_mistral': 902, 'n_tokens_neox': 851, 'n_words': 207}