@e-mc/module 0.5.10 → 0.5.11
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/index.js +20 -24
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -586,7 +586,7 @@ class Module extends EventEmitter {
|
|
|
586
586
|
this[_f] = new AbortController();
|
|
587
587
|
this[_g] = null;
|
|
588
588
|
}
|
|
589
|
-
static get VERSION() { return "0.5.
|
|
589
|
+
static get VERSION() { return "0.5.11"; }
|
|
590
590
|
static get LOG_TYPE() { return types_1.LOG_TYPE; }
|
|
591
591
|
static get STATUS_TYPE() { return types_1.STATUS_TYPE; }
|
|
592
592
|
static get MAX_TIMEOUT() { return 2147483647; }
|
|
@@ -1097,41 +1097,37 @@ class Module extends EventEmitter {
|
|
|
1097
1097
|
}
|
|
1098
1098
|
return cacheKey ? (0, types_1.generateUUID)() : '';
|
|
1099
1099
|
}
|
|
1100
|
-
static asHash(data, algorithm,
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
options = minLength;
|
|
1104
|
-
minLength = 0;
|
|
1105
|
-
}
|
|
1106
|
-
if (typeof algorithm === 'number') {
|
|
1107
|
-
minLength = algorithm;
|
|
1108
|
-
algorithm = '';
|
|
1109
|
-
}
|
|
1110
|
-
else if ((0, types_1.isObject)(algorithm)) {
|
|
1111
|
-
options = algorithm;
|
|
1112
|
-
algorithm = '';
|
|
1100
|
+
static asHash(data, algorithm, digest) {
|
|
1101
|
+
if (!algorithm && !digest) {
|
|
1102
|
+
return crypto.createHash("sha256").update(data).digest("hex");
|
|
1113
1103
|
}
|
|
1114
|
-
let
|
|
1115
|
-
if (
|
|
1116
|
-
options = { ...
|
|
1117
|
-
if ('minLength' in options) {
|
|
1118
|
-
minLength = options.minLength;
|
|
1119
|
-
delete options.minLength;
|
|
1120
|
-
}
|
|
1104
|
+
let options;
|
|
1105
|
+
if ((0, types_1.isObject)(algorithm)) {
|
|
1106
|
+
options = { ...algorithm };
|
|
1121
1107
|
if ('algorithm' in options) {
|
|
1122
1108
|
algorithm = options.algorithm;
|
|
1123
1109
|
delete options.algorithm;
|
|
1124
1110
|
}
|
|
1111
|
+
else {
|
|
1112
|
+
algorithm = undefined;
|
|
1113
|
+
}
|
|
1125
1114
|
if ('digest' in options) {
|
|
1126
1115
|
digest = options.digest;
|
|
1127
1116
|
delete options.digest;
|
|
1128
1117
|
}
|
|
1118
|
+
else {
|
|
1119
|
+
digest = undefined;
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
else if ((0, types_1.isObject)(digest)) {
|
|
1123
|
+
options = digest;
|
|
1124
|
+
digest = undefined;
|
|
1129
1125
|
}
|
|
1130
|
-
if (
|
|
1131
|
-
|
|
1126
|
+
else if (typeof digest !== 'string') {
|
|
1127
|
+
digest = undefined;
|
|
1132
1128
|
}
|
|
1133
1129
|
try {
|
|
1134
|
-
return crypto.createHash(algorithm ||
|
|
1130
|
+
return crypto.createHash(algorithm || "sha256", options).update(data).digest(digest || "hex");
|
|
1135
1131
|
}
|
|
1136
1132
|
catch {
|
|
1137
1133
|
return '';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/module",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.11",
|
|
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.5.
|
|
23
|
+
"@e-mc/types": "0.5.11",
|
|
24
24
|
"abort-controller": "^3.0.0",
|
|
25
25
|
"chalk": "4.1.2",
|
|
26
26
|
"event-target-shim": "^5.0.1",
|