5etools-utils 0.1.15 → 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/UtilFs.js +15 -8
  2. package/package.json +1 -1
package/lib/UtilFs.js CHANGED
@@ -48,18 +48,25 @@ function listJsonFiles (dir, opts) {
48
48
  }, []);
49
49
  }
50
50
 
51
+ function _runOnDirs_getDirs () {
52
+ return fs.readdirSync(".", "utf8")
53
+ .filter(dir => isDirectory(dir) && !dir.startsWith(".") && !dir.startsWith("_") && dir !== "node_modules");
54
+ }
55
+
51
56
  function runOnDirs (fn) {
52
- fs.readdirSync(".", "utf8")
53
- .filter(dir => isDirectory(dir) && !dir.startsWith(".") && !dir.startsWith("_") && dir !== "node_modules")
57
+ _runOnDirs_getDirs()
54
58
  .forEach(dir => fn(dir));
55
59
  }
56
60
 
57
- async function pRunOnDirs (pFn) {
58
- await Promise.allSettled(
59
- fs.readdirSync(".", "utf8")
60
- .filter(dir => isDirectory(dir) && !dir.startsWith(".") && !dir.startsWith("_") && dir !== "node_modules")
61
- .map(dir => pFn(dir)),
62
- );
61
+ async function pRunOnDirs (pFn, {isSerial = false} = {}) {
62
+ const dirs = _runOnDirs_getDirs();
63
+
64
+ if (isSerial) {
65
+ for (const dir of dirs) await pFn(dir);
66
+ return;
67
+ }
68
+
69
+ await Promise.allSettled(dirs.map(dir => pFn(dir)));
63
70
  }
64
71
 
65
72
  function mkDirs (pathToCreate) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "5etools-utils",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "description": "Shared utilities for the 5etools ecosystem.",
5
5
  "type": "module",
6
6
  "main": "lib/Api.js",