@e-mc/module 0.9.21 → 0.9.22
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 +6 -6
- package/index.js +29 -27
- 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.9.
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.9.22/lib/index.d.ts)
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { LogStatus } from "./squared";
|
|
@@ -394,11 +394,11 @@ type ForegroundColor = typeof IForegroundColor | `#${string}`;
|
|
|
394
394
|
|
|
395
395
|
## References
|
|
396
396
|
|
|
397
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
398
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
399
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
400
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
401
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
397
|
+
- https://www.unpkg.com/@e-mc/types@0.9.22/lib/core.d.ts
|
|
398
|
+
- https://www.unpkg.com/@e-mc/types@0.9.22/lib/logger.d.ts
|
|
399
|
+
- https://www.unpkg.com/@e-mc/types@0.9.22/lib/module.d.ts
|
|
400
|
+
- https://www.unpkg.com/@e-mc/types@0.9.22/lib/node.d.ts
|
|
401
|
+
- https://www.unpkg.com/@e-mc/types@0.9.22/lib/settings.d.ts
|
|
402
402
|
|
|
403
403
|
* https://www.npmjs.com/package/@types/node
|
|
404
404
|
|
package/index.js
CHANGED
|
@@ -744,7 +744,7 @@ class Module extends EventEmitter {
|
|
|
744
744
|
this[_f] = new AbortController();
|
|
745
745
|
this[_g] = null;
|
|
746
746
|
}
|
|
747
|
-
static get VERSION() { return "0.9.
|
|
747
|
+
static get VERSION() { return "0.9.22"; }
|
|
748
748
|
static get LOG_TYPE() { return types_1.LOG_TYPE; }
|
|
749
749
|
static get STATUS_TYPE() { return types_1.STATUS_TYPE; }
|
|
750
750
|
static get MAX_TIMEOUT() { return 2147483647; }
|
|
@@ -1263,35 +1263,35 @@ class Module extends EventEmitter {
|
|
|
1263
1263
|
return cacheKey ? (0, types_1.generateUUID)() : '';
|
|
1264
1264
|
}
|
|
1265
1265
|
static asHash(data, algorithm, digest) {
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
let options;
|
|
1270
|
-
if ((0, types_1.isObject)(algorithm)) {
|
|
1271
|
-
options = { ...algorithm };
|
|
1272
|
-
if ('algorithm' in options) {
|
|
1273
|
-
algorithm = options.algorithm;
|
|
1274
|
-
delete options.algorithm;
|
|
1266
|
+
try {
|
|
1267
|
+
if (!algorithm && !digest) {
|
|
1268
|
+
return crypto.createHash("sha256").update(data).digest("hex");
|
|
1275
1269
|
}
|
|
1276
|
-
|
|
1277
|
-
|
|
1270
|
+
let options;
|
|
1271
|
+
if ((0, types_1.isObject)(algorithm)) {
|
|
1272
|
+
options = { ...algorithm };
|
|
1273
|
+
if ('algorithm' in options) {
|
|
1274
|
+
algorithm = options.algorithm;
|
|
1275
|
+
delete options.algorithm;
|
|
1276
|
+
}
|
|
1277
|
+
else {
|
|
1278
|
+
algorithm = undefined;
|
|
1279
|
+
}
|
|
1280
|
+
if ('digest' in options) {
|
|
1281
|
+
digest = options.digest;
|
|
1282
|
+
delete options.digest;
|
|
1283
|
+
}
|
|
1284
|
+
else {
|
|
1285
|
+
digest = undefined;
|
|
1286
|
+
}
|
|
1278
1287
|
}
|
|
1279
|
-
if (
|
|
1280
|
-
|
|
1281
|
-
|
|
1288
|
+
else if ((0, types_1.isObject)(digest)) {
|
|
1289
|
+
options = digest;
|
|
1290
|
+
digest = undefined;
|
|
1282
1291
|
}
|
|
1283
|
-
else {
|
|
1292
|
+
else if (typeof digest !== 'string') {
|
|
1284
1293
|
digest = undefined;
|
|
1285
1294
|
}
|
|
1286
|
-
}
|
|
1287
|
-
else if ((0, types_1.isObject)(digest)) {
|
|
1288
|
-
options = digest;
|
|
1289
|
-
digest = undefined;
|
|
1290
|
-
}
|
|
1291
|
-
else if (typeof digest !== 'string') {
|
|
1292
|
-
digest = undefined;
|
|
1293
|
-
}
|
|
1294
|
-
try {
|
|
1295
1295
|
return crypto.createHash(algorithm || "sha256", options).update(data).digest(digest || "hex");
|
|
1296
1296
|
}
|
|
1297
1297
|
catch {
|
|
@@ -1483,11 +1483,13 @@ class Module extends EventEmitter {
|
|
|
1483
1483
|
if (typeof values[values.length - 1] === 'boolean') {
|
|
1484
1484
|
normalize = values.pop();
|
|
1485
1485
|
}
|
|
1486
|
-
const paths = values.
|
|
1486
|
+
const paths = values.filter(item => (0, types_1.isString)(item)).map(value => this.toPosix(value, normalize));
|
|
1487
1487
|
let result = paths[0] || '';
|
|
1488
1488
|
for (let i = 1; i < paths.length; ++i) {
|
|
1489
1489
|
const trailing = paths[i];
|
|
1490
|
-
|
|
1490
|
+
if (trailing) {
|
|
1491
|
+
result += (!trailing.startsWith('/') && !result.endsWith('/') ? '/' : '') + trailing;
|
|
1492
|
+
}
|
|
1491
1493
|
}
|
|
1492
1494
|
return result;
|
|
1493
1495
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/module",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.22",
|
|
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.9.
|
|
23
|
+
"@e-mc/types": "0.9.22",
|
|
24
24
|
"chalk": "4.1.2",
|
|
25
25
|
"file-type": "16.5.4",
|
|
26
26
|
"js-yaml": "^4.1.0",
|