{"size": 222, "ext": "js", "max_stars_repo_path": "PathfinderSpellDB/scripts/RandomGen/chooseRandomWithWeight.js", "max_stars_repo_name": "fyjham-ts/Pathfinder-SpellDB", "max_stars_repo_stars_event_min_datetime": "2020-05-30T00:13:34.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-30T00:13:34.000Z", "max_issues_repo_path": "PathfinderSpellDB/scripts/RandomGen/chooseRandomWithWeight.js", "max_issues_repo_name": "fyjham-ts/Pathfinder-SpellDB", "max_issues_repo_issues_event_min_datetime": "2018-08-30T01:06:06.000Z", "max_issues_repo_issues_event_max_datetime": "2018-09-04T01:12:43.000Z", "max_forks_repo_path": "PathfinderSpellDB/scripts/RandomGen/chooseRandomWithWeight.js", "max_forks_repo_name": "fyjham-ts/Pathfinder-SpellDB", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 4, "max_forks_count": null, "avg_line_length": 27.75, "max_line_length": 68, "alphanum_fraction": 0.5540540541}
module.exports = function chooseRandomWithWeight(arr, totalWeight) {
    var rnum = (Math.random() * totalWeight + 1) | 0;
    var i = 0;
    while (rnum > 0) {
        rnum -= arr[i++].w;
    }
    return arr[i - 1].v;
};