<commit_before>import Mapping from "./mapping";
// import getValue from "./object-mapper/get-key-value";
// import setValue from "./object-mapper/set-key-value";

const SINGLE_MODE = 0;
const MULTI_MODE = 1;
const OR_MODE = 2;

const isValueArray = new RegExp(/^\[\]|\[\d+\]/);

export default class Mapper {

  constructor(opts, om) {

    this.om = om;
    this.experimental = opts.experimental;
    this.options = opts;

    this.assignment = [];
    this.mapCache_ = null;

    this.chainArray = [];

  }

  registerMapping_(mapping) {

    this.assignment.push(mapping);
  }


  map(source) {

    // create a mapping for a single or multiple source field(s) and return the mapping object
    // the mapping object enables the fluent/chainable interface

    const mapping = new Mapping(source, this, this.options);
    this.registerMapping_(mapping);

    return mapping;

  }

  each(sourceArray) {

    // validate inputs
    if (!sourceArray) {
      // TODO: This should probably return undefined
      return null;
    }

    if (Array.isArray(sourceArray) !== true) {
      throw new Error("The sourceArray parameter must be an array");
    }

    return sourceArray.map(item => {
      return this.execute(item, null);
    });
    // // iterate over an array of values and map each one
    // if (sourceArray.length > 0) {
    //   return sourceArray.map(item => {
    //     return this.execute(item, null);
    //   });
    // }
    //
    // // TODO: This should probably return undefined
    // return null;
  }

  execute(source, destination) {

    // validate inputs
    if (source === null || source === undefined) {
      throw new Error("A source object is required");
    }

    // ensure we have a destination object to target
    if (destination === null || destination === undefined) {
      destination = {};<commit_msg>[cleanup]<commit_after>import Mapping from "./mapping";
// import getValue from "./object-mapper/get-key-value";
// import setValue from "./object-mapper/set-key-value";

const SINGLE_MODE = 0;
const MULTI_MODE = 1;
const OR_MODE = 2;

const isValueArray = new RegExp(/^\[\]|\[\d+\]/);

export default class Mapper {

  constructor(opts, om) {

    this.om = om;
    this.experimental = opts.experimental;
    this.options = opts;

    this.assignment = [];
    this.mapCache_ = null;

    this.chainArray = [];

  }

  registerMapping_(mapping) {

    this.assignment.push(mapping);
  }


  map(source) {

    // create a mapping for a single or multiple source field(s) and return the mapping object
    // the mapping object enables the fluent/chainable interface

    const mapping = new Mapping(source, this, this.options);
    this.registerMapping_(mapping);

    return mapping;

  }

  each(sourceArray) {

    // validate inputs
    if (!sourceArray) {
      // TODO: This should probably return undefined
      return null;
    }

    if (Array.isArray(sourceArray) !== true) {
      throw new Error("The sourceArray parameter must be an array");
    }

    // iterate over an array of values and map each one
    return sourceArray.map(item => {
      return this.execute(item, null);
    });
  }

  execute(source, destination) {

    // validate inputs
    if (source === null || source === undefined) {
      throw new Error("A source object is required");
    }

    // ensure we have a destination object to target
    if (destination === null || destination === undefined) {
      destination = {};
{'fraction_non_alphanumeric': 0.12792376552122436, 'fraction_numerical': 0.0020213687554143807, 'mean_word_length': 2.654008438818565, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7203029', 'n_tokens_mistral': 1032, 'n_tokens_neox': 983, 'n_words': 306}