{"size": 792, "ext": "js", "max_stars_repo_path": "src/extended-repeater.js", "max_stars_repo_name": "abadire/basic-js", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/extended-repeater.js", "max_issues_repo_name": "abadire/basic-js", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/extended-repeater.js", "max_forks_repo_name": "abadire/basic-js", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.75, "max_line_length": 139, "alphanum_fraction": 0.5934343434}
const CustomError = require("../extensions/custom-error");

function repeater(str, options) {
  let addition = '';
  if ('addition' in options)
  {
    addition += options.addition;
    if ('additionRepeatTimes' in options)
    {
      for (let i = 1; i < options.additionRepeatTimes; ++i)
      {
        addition += options.additionSeparator || '|';
        addition += options.addition;
      }
    }
  }

  let ret = str + addition;
  if ('repeatTimes' in options)
  {
    for (let i = 1; i < options.repeatTimes; ++i)
    {
      ret += options.separator || '+';
      ret += str + addition;
    }
  }
  return ret;
};

module.exports = repeater;

// console.log(repeater('STRING', { repeatTimes: 3, separator: '**', addition: 'PLUS', additionRepeatTimes: 3, additionSeparator: '00' }));