PageSourceSearch

https://edi-d6y.pages.dev/js/score.js

js edi-d6y.pages.dev collected 2026-10-03 05:10:53 UTC 1,350 bytes, 52 lines download raw bytes

1/**
2 * Numbers of decimal digits to round to
3 */
4const scale = 3;
5
6/**
7 * Calculate the score awarded when having a certain percentage on a list level
8 * @param {Number} rank Position on the list
9 * @param {Number} percent Percentage of completion
10 * @param {Number} minPercent Minimum percentage required
11 * @returns {Number}
12 */
13export function score(rank, percent, minPercent) {
14    if (rank > 75 && percent < 100) {
15        return 0;
16    }
17
18    // Old formula
19    /*
20    let score = (100 / Math.sqrt((rank - 1) / 50 + 0.444444) - 50) *
21        ((percent - (minPercent - 100)) / (100 - (minPercent - 100)));
22    */
23    // New formula
24    let score = (-24.9975*Math.pow(rank-1, 0.4) + 700) *
25        ((percent - (minPercent - 1)) / (100 - (minPercent - 1)));
26
27    score = Math.max(0, score);
28
29    if (percent != 100) {
30        return round(score - score / 3);
31        minPercent = 100
32    }
33
34    return Math.max(round(score), 0);
35}
36
37export function round(num) {
38    if (!('' + num).includes('e')) {
39        return +(Math.round(num + 'e+' + scale) + 'e-' + scale);
40    } else {
41        var arr = ('' + num).split('e');
42        var sig = '';
43        if (+arr[1] + scale > 0) {
44            sig = '+';
45        }
46        return +(
47            Math.round(+arr[0] + 'e' + sig + (+arr[1] + scale)) +
48            'e-' +
49            scale
50        );
51    }
52}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.