@e-mc/module 0.10.13 → 0.10.14

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 (3) hide show
  1. package/README.md +6 -6
  2. package/index.js +29 -27
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  ## Interface
11
11
 
12
- * [View Source](https://www.unpkg.com/@e-mc/types@0.10.13/lib/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.10.14/lib/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { LogStatus } from "./squared";
@@ -407,11 +407,11 @@ interface LoggerModule {
407
407
 
408
408
  ## References
409
409
 
410
- - https://www.unpkg.com/@e-mc/types@0.10.13/lib/core.d.ts
411
- - https://www.unpkg.com/@e-mc/types@0.10.13/lib/logger.d.ts
412
- - https://www.unpkg.com/@e-mc/types@0.10.13/lib/module.d.ts
413
- - https://www.unpkg.com/@e-mc/types@0.10.13/lib/node.d.ts
414
- - https://www.unpkg.com/@e-mc/types@0.10.13/lib/settings.d.ts
410
+ - https://www.unpkg.com/@e-mc/types@0.10.14/lib/core.d.ts
411
+ - https://www.unpkg.com/@e-mc/types@0.10.14/lib/logger.d.ts
412
+ - https://www.unpkg.com/@e-mc/types@0.10.14/lib/module.d.ts
413
+ - https://www.unpkg.com/@e-mc/types@0.10.14/lib/node.d.ts
414
+ - https://www.unpkg.com/@e-mc/types@0.10.14/lib/settings.d.ts
415
415
 
416
416
  * https://www.npmjs.com/package/@types/node
417
417
 
package/index.js CHANGED
@@ -959,7 +959,7 @@ class Module extends EventEmitter {
959
959
  this[_g] = null;
960
960
  }
961
961
  static get VERSION() {
962
- return "0.10.13";
962
+ return "0.10.14";
963
963
  }
964
964
  static get LOG_TYPE() {
965
965
  return types_1.LOG_TYPE;
@@ -1459,35 +1459,35 @@ class Module extends EventEmitter {
1459
1459
  return cacheKey ? crypto.randomUUID() : '';
1460
1460
  }
1461
1461
  static asHash(data, algorithm, digest) {
1462
- if (!algorithm && !digest) {
1463
- return crypto.createHash("sha256").update(data).digest("hex");
1464
- }
1465
- let options;
1466
- if ((0, types_1.isObject)(algorithm)) {
1467
- options = { ...algorithm };
1468
- if ('algorithm' in options) {
1469
- algorithm = options.algorithm;
1470
- delete options.algorithm;
1462
+ try {
1463
+ if (!algorithm && !digest) {
1464
+ return crypto.createHash("sha256").update(data).digest("hex");
1471
1465
  }
1472
- else {
1473
- algorithm = undefined;
1466
+ let options;
1467
+ if ((0, types_1.isObject)(algorithm)) {
1468
+ options = { ...algorithm };
1469
+ if ('algorithm' in options) {
1470
+ algorithm = options.algorithm;
1471
+ delete options.algorithm;
1472
+ }
1473
+ else {
1474
+ algorithm = undefined;
1475
+ }
1476
+ if ('digest' in options) {
1477
+ digest = options.digest;
1478
+ delete options.digest;
1479
+ }
1480
+ else {
1481
+ digest = undefined;
1482
+ }
1474
1483
  }
1475
- if ('digest' in options) {
1476
- digest = options.digest;
1477
- delete options.digest;
1484
+ else if ((0, types_1.isObject)(digest)) {
1485
+ options = digest;
1486
+ digest = undefined;
1478
1487
  }
1479
- else {
1488
+ else if (typeof digest !== 'string') {
1480
1489
  digest = undefined;
1481
1490
  }
1482
- }
1483
- else if ((0, types_1.isObject)(digest)) {
1484
- options = digest;
1485
- digest = undefined;
1486
- }
1487
- else if (typeof digest !== 'string') {
1488
- digest = undefined;
1489
- }
1490
- try {
1491
1491
  return crypto.createHash(algorithm || "sha256", options).update(data).digest(digest || "hex");
1492
1492
  }
1493
1493
  catch {
@@ -1680,11 +1680,13 @@ class Module extends EventEmitter {
1680
1680
  if (typeof values[values.length - 1] === 'boolean') {
1681
1681
  normalize = values.pop();
1682
1682
  }
1683
- const paths = values.map(item => typeof item === 'string' ? item.trim() : '').filter(item => item).map(value => this.toPosix(value, normalize));
1683
+ const paths = values.filter(item => (0, types_1.isString)(item)).map(value => this.toPosix(value, normalize));
1684
1684
  let result = paths[0] || '';
1685
1685
  for (let i = 1; i < paths.length; ++i) {
1686
1686
  const trailing = paths[i];
1687
- result += (!trailing.startsWith('/') && !result.endsWith('/') ? '/' : '') + trailing;
1687
+ if (trailing) {
1688
+ result += (!trailing.startsWith('/') && !result.endsWith('/') ? '/' : '') + trailing;
1689
+ }
1688
1690
  }
1689
1691
  return result;
1690
1692
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/module",
3
- "version": "0.10.13",
3
+ "version": "0.10.14",
4
4
  "description": "Module base class for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -20,7 +20,7 @@
20
20
  "license": "MIT",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "@e-mc/types": "0.10.13",
23
+ "@e-mc/types": "0.10.14",
24
24
  "chalk": "4.1.2",
25
25
  "file-type": "^18.7.0",
26
26
  "js-yaml": "^4.1.0",