{"size": 2315, "ext": "js", "max_stars_repo_path": "src/utils/convert-by-timescale.js", "max_stars_repo_name": "ValerieKenyon/cliff-effects", "max_stars_repo_stars_event_min_datetime": "2017-09-13T00:46:28.000Z", "max_stars_repo_stars_event_max_datetime": "2020-01-24T07:04:34.000Z", "max_issues_repo_path": "src/utils/convert-by-timescale.js", "max_issues_repo_name": "ValerieKenyon/cliff-effects", "max_issues_repo_issues_event_min_datetime": "2017-09-06T00:45:24.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-30T06:08:25.000Z", "max_forks_repo_path": "src/utils/convert-by-timescale.js", "max_forks_repo_name": "knod/cliff-effects-1", "max_forks_repo_forks_event_min_datetime": "2017-09-04T11:50:21.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-30T06:07:43.000Z"}
{"max_stars_count": 36, "max_issues_count": 673, "max_forks_count": 97, "avg_line_length": 23.15, "max_line_length": 79, "alphanum_fraction": 0.6358531317}
/**
 * Convert (usually money) amounts between weekly, monthly, and yearly amounts.
 */

/** Returns `amount` converted from whatever 'timescale' it was before
 *     to a yearly amount
 *
 * @param {number} amount - numeric value to be converted
 * @param {string} startTimescale - timescale of the original
 *     value. Can be 'weekly', 'monthly', or 'yearly'.
 */
let toYearlyFrom = function (amount, startTimescale) {
  
  let converted = amount;

  if (startTimescale === `weekly`) {
    converted = amount * 52;
  } else if (startTimescale === `monthly`) {
    converted = amount * 12;
  } else if (startTimescale === `yearly`) {
    // do nothing
  }

  return converted;
};


/** Returns `amount` converted from whatever 'timescale' it was before
 *     to a monthly amount
 *
 * @param {number} amount - numeric value to be converted
 * @param {string} startTimescale - timescale of the original
 *     value. Can be 'weekly', 'monthly', or 'yearly'.
 */
let toMonthlyFrom = function (amount, startTimescale) {
  
  let converted = amount;

  if (startTimescale === `weekly`) {
    converted = amount * (4 + (1 / 3));
  } else if (startTimescale === `monthly`) {
    // do nothing
  } else if (startTimescale === `yearly`) {
    converted = amount / 12;
  }

  return converted;
};


/** Returns `amount` converted from whatever 'timescale' it was before
 *     to a weekly amount
 *
 * @param {number} amount - numeric value to be converted
 * @param {string} startTimescale - timescale of the original
 *     value. Can be 'weekly', 'monthly', or 'yearly'.
 */
let toWeeklyFrom = function (amount, startTimescale) {
  
  let converted = amount;

  if (startTimescale === `weekly`) {
    // do nothing
  } else if (startTimescale === `monthly`) {
    converted = amount / (4 + (1 / 3));
  } else if (startTimescale === `yearly`) {
    converted = amount * 52;
  }

  return converted;
};

let timescaleMultipliers = {};

timescaleMultipliers.fromYearly = {
  Weekly:  1 / 12 / (4 + 1 / 3),
  Monthly: 1 / 12,
  Yearly:  1,
};

timescaleMultipliers.fromMonthly = {
  Weekly:  1 / (4 + 1 / 3),
  Monthly: 1,
  Yearly:  12,
};

timescaleMultipliers.fromWeekly = {
  Weekly:  1,
  Monthly: (4 + 1 / 3),
  Yearly:  52,
};


export {
  toYearlyFrom,
  toMonthlyFrom,
  toWeeklyFrom,
  timescaleMultipliers,
};
