fix: adding docstrings to the files where it was missing (#2101)

* fix: adding docstrings to missing files

* style: format code

* style: improve formatting

Co-authored-by: Jagruti Tiwari <jagrutit@cdac.in>
Co-authored-by: rickstaa <rick.staa@outlook.com>
This commit is contained in:
Jagruti Tiwari
2022-10-03 16:33:23 +05:30
committed by GitHub
parent 9e1fc0b7da
commit c03bb2f250
4 changed files with 59 additions and 6 deletions
+9
View File
@@ -1,5 +1,14 @@
import { CustomError, logger } from "./utils.js";
/**
* 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) => {
if (retries > 7) {
throw new CustomError("Maximum retries exceeded", CustomError.MAX_RETRY);
+14 -5
View File
@@ -74,7 +74,10 @@ function parseBoolean(value) {
}
/**
* @param {string} str
* 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 [];
@@ -82,9 +85,12 @@ function parseArray(str) {
}
/**
* @param {number} number
* @param {number} min
* @param {number} max
* 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
@@ -93,7 +99,10 @@ function clampValue(number, min, max) {
}
/**
* @param {string[]} colors
* 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]);