Skip to content

Commit

Permalink
style: improve formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
rickstaa committed Oct 3, 2022
1 parent c94baaf commit fbcfbab
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 23 deletions.
26 changes: 15 additions & 11 deletions src/calculateRank.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
/**
* Calculates the probability of x taking on x or a value less than x in a normal distribution
* with mean and standard deviation.
*
* @see https://stackoverflow.com/a/5263759/10629172
*
* @param {string} mean
* @param {number} sigma
* @param {number} to
* @returns {number}
* @returns {number} Probability.
*/

function normalcdf(mean, sigma, to) {
var z = (to - mean) / Math.sqrt(2 * sigma * sigma);
var t = 1 / (1 + 0.3275911 * Math.abs(z));
Expand All @@ -24,16 +27,17 @@ function normalcdf(mean, sigma, to) {
}

/**
* @param {any} totalRepos
* @param {any} totalCommits
* @param {any} contributions
* @params {ant} followers
* @param {any} prs
* @param {any} issues
* @param {any} stargazers
* @returns {{level: string, score: number}}}
* Calculates the users rank.
*
* @param {number} totalRepos
* @param {number} totalCommits
* @param {number} contributions
* @param {number} followers
* @param {number} prs
* @param {number} issues
* @param {number} stargazers
* @returns {{level: string, score: number}}} The users rank.
*/

function calculateRank({
totalRepos,
totalCommits,
Expand Down
13 changes: 11 additions & 2 deletions src/cards/stats-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,17 @@ import { getStyles } from "../getStyles.js";
import { statCardLocales } from "../translations.js";

/**
* @param {{icon: string, label: string, value: number, id: string, index:number, showIcons: boolean, shiftValuePos: number, bold:boolean}} params
* @returns {string}
* Create a stats card text item.
*
* @param {object[]} createTextNodeParams Object that contains the createTextNode parameters.
* @param {string} createTextNodeParams.label The label to display.
* @param {string} createTextNodeParams.value The value to display.
* @param {string} createTextNodeParams.id The id of the stat.
* @param {number} createTextNodeParams.index The index of the stat.
* @param {boolean} createTextNodeParams.showIcons Whether to show icons.
* @param {number} createTextNodeParams.shiftValuePos Number of pixels the value has to be shifted to the right.
* @param {boolean} createTextNodeParams.bold Whether to bold the label.
* @returns
*/
const createTextNode = ({
icon,
Expand Down
7 changes: 6 additions & 1 deletion src/common/retryer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { CustomError, logger } from "./utils.js";

/**
* @param {{fetcher: any, variables: any, retries: number}} params
* Try to execute the fetcher function until it succeeds or the max number of retries is reached.
*
* @param {object[]} retryerParams Object that contains the createTextNode parameters.
* @param {object[]} retryerParams.fetcher The fetcher function.
* @param {object[]} retryerParams.variables Object with arguments to pass to the fetcher function.
* @param {number} retryerParams.retries How many times to retry.
* @returns Promise<retryer>
*/
const retryer = async (fetcher, variables, retries = 0) => {
Expand Down
23 changes: 14 additions & 9 deletions src/common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,23 @@ function parseBoolean(value) {
}

/**
* @param {string} str
* @returns {string[]}
* Parse string to array of strings.
*
* @param {string} str The string to parse.
* @returns {string[]} The array of strings.
*/
function parseArray(str) {
if (!str) return [];
return str.split(",");
}

/**
* @param {number} number
* @param {number} min
* @param {number} max
* returns {number}
* Clamp the given number between the given range.
*
* @param {number} number The number to clamp.
* @param {number} min The minimum value.
* @param {number} max The maximum value.
* returns {number} The clamped number.
*/
function clampValue(number, min, max) {
// @ts-ignore
Expand All @@ -96,8 +99,10 @@ function clampValue(number, min, max) {
}

/**
* @param {string[]} colors
* returns {boolean}
* Check if the given string is a valid gradient.
*
* @param {string[]} colors Array of colors.
* returns {boolean} True if the given string is a valid gradient.
*/
function isValidGradient(colors) {
return isValidHexColor(colors[1]) && isValidHexColor(colors[2]);
Expand Down

0 comments on commit fbcfbab

Please sign in to comment.