aboutsummaryrefslogtreecommitdiff
path: root/dev/util.js
diff options
context:
space:
mode:
authorDarius Jahandarie <djahandarie@gmail.com>2023-12-06 03:53:16 +0000
committerGitHub <noreply@github.com>2023-12-06 03:53:16 +0000
commitbd5bc1a5db29903bc098995cd9262c4576bf76af (patch)
treec9214189e0214480fcf6539ad1c6327aef6cbd1c /dev/util.js
parentfd6bba8a2a869eaf2b2c1fa49001f933fce3c618 (diff)
parent23e6fb76319c9ed7c9bcdc3efba39bc5dd38f288 (diff)
Merge pull request #339 from toasted-nutbread/type-annotations
Type annotations
Diffstat (limited to 'dev/util.js')
-rw-r--r--dev/util.js21
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);