diff --git a/utils/helpers/arrayToString.ts b/utils/helpers/arrayToString.ts index 3865d642e..91db38ce4 100644 --- a/utils/helpers/arrayToString.ts +++ b/utils/helpers/arrayToString.ts @@ -1,3 +1,6 @@ +/** + * Returns the input array as a comma separated string. + */ export function arrayToString(a: T[]) { return `[${a.join(", ")}]`; } diff --git a/utils/helpers/createProgressBarText.ts b/utils/helpers/createProgressBarText.ts index c9618043f..1ce2b7b89 100644 --- a/utils/helpers/createProgressBarText.ts +++ b/utils/helpers/createProgressBarText.ts @@ -1,3 +1,6 @@ +/** + * Represents the possible configuration values that can be provided when creating the progress bar text. + */ interface IProgressBarConfiguration { /** * Current progress, taken as a decimal (i.e. '0.6' to represent '60%') @@ -10,6 +13,9 @@ interface IProgressBarConfiguration { totalTicks?: number; } +/** + * Represents concrete configuration values when creating the progress bar text. + */ interface IProgressBarConfigurationMaterialized extends IProgressBarConfiguration { progress: number; totalTicks: number; diff --git a/utils/helpers/isPowerOfTwo.ts b/utils/helpers/isPowerOfTwo.ts index ea7924954..6f98ccf83 100644 --- a/utils/helpers/isPowerOfTwo.ts +++ b/utils/helpers/isPowerOfTwo.ts @@ -7,7 +7,11 @@ export function isPowerOfTwo(n: number) { return false; } + if (n === 0) { + return false; + } + // Disabiling the bitwise rule because it's honestly the most effecient way to check for this. // tslint:disable-next-line:no-bitwise - return n && (n & (n - 1)) === 0; + return (n & (n - 1)) === 0; } diff --git a/utils/uiHelpers/createAccordionElement.ts b/utils/uiHelpers/createAccordionElement.ts index 09ab49334..1ac746d62 100644 --- a/utils/uiHelpers/createAccordionElement.ts +++ b/utils/uiHelpers/createAccordionElement.ts @@ -1,5 +1,8 @@ import { createElement } from "./createElement"; +/** + * Possible configuration parameters when creating the accordion element. + */ interface IAccordionConfigurationParameters { /** * The HTML to appear in the accordion header. @@ -16,6 +19,7 @@ interface IAccordionConfigurationParameters { */ panelText?: string; } + /** * Creates both the header and panel element of an accordion and sets the click handler * @param params The creation parameters. @@ -28,11 +32,11 @@ export function createAccordionElement(params: IAccordionConfigurationParameters const pnl: CSSStyleDeclaration = (this.nextElementSibling as HTMLDivElement).style; pnl.display = pnl.display === "block" ? "none" : "block"; }, - id: params.id ? `${params.id}-hdr` : undefined, + id: params.id !== undefined ? `${params.id}-hdr` : undefined, innerHTML: params.hdrText, }) as HTMLButtonElement; const panel: HTMLDivElement = createElement("div", { - id: params.id ? `${params.id}-panel` : undefined, + id: params.id !== undefined ? `${params.id}-panel` : undefined, innerHTML: params.panelText, }) as HTMLDivElement; diff --git a/utils/uiHelpers/createElement.ts b/utils/uiHelpers/createElement.ts index 9e9b76430..dae1b4a4c 100644 --- a/utils/uiHelpers/createElement.ts +++ b/utils/uiHelpers/createElement.ts @@ -1,9 +1,15 @@ +/** + * Options specific to creating an anchor ("") element. + */ interface ICreateElementAnchorOptions { href?: string; target?: string; text?: string; } +/** + * Options specific to creating an input ("") element. + */ interface ICreateElementInputOptions { checked?: boolean; maxLength?: number; @@ -14,10 +20,16 @@ interface ICreateElementInputOptions { value?: string; } +/** + * Options specific to creating a label ("