5etools-utils 0.15.9 → 0.15.10

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.
package/README.md CHANGED
@@ -1,13 +1,13 @@
1
- # 5etools Utils
2
-
3
- Available commands:
4
-
5
- ```
6
- npx clean-html
7
- npx test-file-names [--name-regex <regex>]
8
- npx test-file-contents --img-repo-name <repo> --url-prefix-expected <prefix>
9
- npx test-json-brew [file] [--dir <dir>]
10
- npx test-json-ua [file] [--dir <dir>]
11
- ```
12
-
13
- And more; see `bin/`.
1
+ # 5etools Utils
2
+
3
+ Available commands:
4
+
5
+ ```
6
+ npx clean-html
7
+ npx test-file-names [--name-regex <regex>]
8
+ npx test-file-contents --img-repo-name <repo> --url-prefix-expected <prefix>
9
+ npx test-json-brew [file] [--dir <dir>]
10
+ npx test-json-ua [file] [--dir <dir>]
11
+ ```
12
+
13
+ And more; see `bin/`.
package/bin/clean-html.js CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,13 +1,12 @@
1
1
  import {Worker} from "node:worker_threads";
2
2
  import fs from "node:fs";
3
- import os from "node:os";
4
3
  import he from "he";
5
4
  import sanitizeHtml from "sanitize-html";
6
5
  import {getCleanJson} from "./UtilClean.js";
7
6
  import {ObjectWalker} from "./ObjectWalker.js";
8
7
  import * as Uf from "./UtilFs.js";
9
8
  import Um from "./UtilMisc.js";
10
- import {Deferred, WorkerList} from "./WorkerList.js";
9
+ import {Deferred, WorkerList, getCntWorkers} from "./WorkerList.js";
11
10
 
12
11
  export class BrewCleanerHtml {
13
12
  static _LOG_TAG = `HTML`;
@@ -107,7 +106,7 @@ export class BrewCleanerHtml {
107
106
  static async pGetErrorsOnDirsWorkers ({isFailFast = false} = {}) {
108
107
  Um.info(this._LOG_TAG, `Testing for HTML...`);
109
108
 
110
- const cntWorkers = Math.max(1, os.cpus().length - 1);
109
+ const cntWorkers = getCntWorkers();
111
110
 
112
111
  const messages = [];
113
112
 
package/lib/TestJson.js CHANGED
@@ -1,4 +1,3 @@
1
- import * as os from "os";
2
1
  import * as path from "path";
3
2
  import * as url from "url";
4
3
  import {Worker} from "worker_threads";
@@ -7,7 +6,7 @@ import * as jsonSourceMap from "json-source-map";
7
6
 
8
7
  import * as Uf from "./UtilFs.js";
9
8
  import Um from "./UtilMisc.js";
10
- import {WorkerList, Deferred} from "./WorkerList.js";
9
+ import {WorkerList, Deferred, getCntWorkers} from "./WorkerList.js";
11
10
  import {ObjectWalker} from "./ObjectWalker.js";
12
11
  import {UrlUtil} from "./UrlUtil.js";
13
12
  import {UtilAjv} from "./UtilAjv.js";
@@ -211,7 +210,7 @@ class JsonTester {
211
210
  async pGetErrorsOnDirsWorkers ({isFailFast = false, fileList = null} = {}) {
212
211
  Um.info(this._tagLog, `Validating JSON against schemas in dir: ${this._dirSchema}`);
213
212
 
214
- const cntWorkers = Math.max(1, os.cpus().length - 1);
213
+ const cntWorkers = getCntWorkers();
215
214
 
216
215
  const errors = [];
217
216
  const errorsFull = [];
package/lib/WorkerList.js CHANGED
@@ -1,4 +1,6 @@
1
- class Deferred {
1
+ import os from "node:os";
2
+
3
+ export class Deferred {
2
4
  constructor () {
3
5
  this._resolve = null;
4
6
  this._reject = null;
@@ -13,7 +15,7 @@ class Deferred {
13
15
  get promise () { return this._promise; }
14
16
  }
15
17
 
16
- class WorkerList {
18
+ export class WorkerList {
17
19
  /**
18
20
  * @param {Array} workers
19
21
  */
@@ -44,4 +46,4 @@ class WorkerList {
44
46
  get cntAvailableWorkers () { return this._workers.length; }
45
47
  }
46
48
 
47
- export {Deferred, WorkerList};
49
+ export const getCntWorkers = () => Math.max(1, os.cpus().length - 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "5etools-utils",
3
- "version": "0.15.9",
3
+ "version": "0.15.10",
4
4
  "description": "Shared utilities for the 5etools ecosystem.",
5
5
  "type": "module",
6
6
  "main": "lib/Api.js",