{"size": 1036, "ext": "js", "max_stars_repo_path": "src/common.js", "max_stars_repo_name": "shahabkhalvati/fns", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/common.js", "max_issues_repo_name": "shahabkhalvati/fns", "max_issues_repo_issues_event_min_datetime": "2020-09-06T12:54:36.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-01T19:22:11.000Z", "max_forks_repo_path": "src/common.js", "max_forks_repo_name": "shahabkhalvati/regular-fns", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 4, "max_forks_count": null, "avg_line_length": 28.0, "max_line_length": 75, "alphanum_fraction": 0.7268339768}
const R = require('ramda')

const evaluateIf = R.curry(
  function (predicate, fn, defaultValue) {
    return R.ifElse(predicate, fn, R.always(defaultValue))
  })
const evaluateIfNot = R.curry(
  function (predicate, fn, defaultValue) {
    return R.ifElse(predicate, R.always(defaultValue), fn)
  })

const random = Math.random
const randomInRange = R.curry(
  (fractionDigits, min, max) => {
    const fractionMultiplier = Math.pow(10, fractionDigits)
    const result = Math.round(
      (Math.random() * (max - min) + min) * fractionMultiplier
    ) / fractionMultiplier
    return fractionDigits === 0 ? Math.floor(result) : result
  })

const randomIntInRange = randomInRange(0)
const randomInt = () => randomIntInRange(0, Number.MAX_SAFE_INTEGER)
const randomIntSmallerThan = randomIntInRange(0)
const randomIntLargerThan = randomIntInRange(R.__)(Number.MAX_SAFE_INTEGER)

export default {
  evaluateIf,
  evaluateIfNot,
  random,
  randomInt,
  randomInRange,
  randomIntInRange,
  randomIntLargerThan,
  randomIntSmallerThan
}
