diff options
author | Darius Jahandarie <djahandarie@gmail.com> | 2023-12-06 03:53:16 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-06 03:53:16 +0000 |
commit | bd5bc1a5db29903bc098995cd9262c4576bf76af (patch) | |
tree | c9214189e0214480fcf6539ad1c6327aef6cbd1c /dev/util.js | |
parent | fd6bba8a2a869eaf2b2c1fa49001f933fce3c618 (diff) | |
parent | 23e6fb76319c9ed7c9bcdc3efba39bc5dd38f288 (diff) |
Merge pull request #339 from toasted-nutbread/type-annotations
Type annotations
Diffstat (limited to 'dev/util.js')
-rw-r--r-- | dev/util.js | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/dev/util.js b/dev/util.js index cabc40aa..3299dec4 100644 --- a/dev/util.js +++ b/dev/util.js @@ -20,6 +20,11 @@ import fs from 'fs'; import JSZip from 'jszip'; import path from 'path'; +/** + * @param {string[]} args + * @param {Map<?string, (boolean|null|number|string|string[])>} argMap + * @returns {Map<?string, (boolean|null|number|string|string[])>} + */ export function getArgs(args, argMap) { let key = null; let canKey = true; @@ -64,11 +69,16 @@ export function getArgs(args, argMap) { return argMap; } +/** + * @param {string} baseDirectory + * @param {?(fileName: string) => boolean} predicate + * @returns {string[]} + */ export function getAllFiles(baseDirectory, predicate=null) { const results = []; const directories = [baseDirectory]; while (directories.length > 0) { - const directory = directories.shift(); + const directory = /** @type {string} */ (directories.shift()); const fileNames = fs.readdirSync(directory); for (const fileName of fileNames) { const fullFileName = path.join(directory, fileName); @@ -86,6 +96,11 @@ export function getAllFiles(baseDirectory, predicate=null) { return results; } +/** + * @param {string} dictionaryDirectory + * @param {string} [dictionaryName] + * @returns {import('jszip')} + */ export function createDictionaryArchive(dictionaryDirectory, dictionaryName) { const fileNames = fs.readdirSync(dictionaryDirectory); @@ -125,6 +140,10 @@ export function createDictionaryArchive(dictionaryDirectory, dictionaryName) { // return zipFileBlob; } +/** + * @param {(...args: import('core').SafeAny[]) => (unknown|Promise<unknown>)} func + * @param {...import('core').SafeAny} args + */ export async function testMain(func, ...args) { try { await func(...args); |