From: Ardis Lu Date: Sun, 19 Nov 2023 02:52:55 +0000 (-0800) Subject: Add support for "deno doc" X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=1d13ad859288c1ccbd438748faf93edcfc6f8d97;p=seed-phrase-transposer Add support for "deno doc" --- diff --git a/main.ts b/main.ts index 91777d4..b06325d 100644 --- a/main.ts +++ b/main.ts @@ -1,4 +1,9 @@ -export function parseInput(input: string | null) { +/** + * Normalizes a seed phrase to remove extraneous whitespace, then splits the words into an array. + * @param {string} input A seed phrase with any number of whitespace in-between words. + * @returns {Array} An array of the seed phrase words. + */ +export function parseInput(input: string | null): Array { if (input === null) { throw new Error("No seed phrase entered."); } @@ -9,7 +14,13 @@ export function parseInput(input: string | null) { return words; } -export function getPermutations(words: Array, columns: number) { +/** + * Gets the permutations of a seed phrase that was recorded from a transposition error. + * @param {Array} words An array of words. + * @param {number} columns The number of columns in the grid that the words were displayed in. + * @returns {Array} An array of the permutations that the words could take. + */ +export function getPermutations(words: Array, columns: number): Array { if (words.length % columns !== 0) { throw new Error( "Seed phrase length must be divisible by number of columns.", @@ -34,8 +45,12 @@ export function getPermutations(words: Array, columns: number) { return [verticalLR.join(" "), horizontalTB.join(" ")]; } -// Gets all factors that are >= 2 and not a multiple of another factor -export function getLowerFactors(num: number) { +/** + * Gets all factors of a number that are >= 2 and not a multiple of another factor (the "lower" factors). + * @param {number} num A number to get the lower factors of. + * @returns {Array} An array of the lower factors of the input. + */ +export function getLowerFactors(num: number): Array { const lowerFactors = []; for (let i = 2; i < num / (lowerFactors.at(-1) ?? 1); i++) { if (num % i === 0) {