@powfix/core-js 0.11.9 → 0.11.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/dist/src/services/time/TimeService.d.ts +1 -1
- package/dist/src/services/time/TimeService.js +13 -11
- package/dist/src/utils/AxiosUtils.d.ts +5 -0
- package/dist/src/utils/AxiosUtils.js +53 -0
- package/dist/src/utils/index.d.ts +2 -1
- package/dist/src/utils/index.js +2 -1
- package/package.json +1 -1
|
@@ -28,7 +28,7 @@ export declare class TimeService {
|
|
|
28
28
|
getClientTime(defaultValue?: TimeService.TimeStamp): TimeService.TimeStamp;
|
|
29
29
|
getServerTime(): TimeService.TimeStamp | null;
|
|
30
30
|
getTime(): number;
|
|
31
|
-
private
|
|
31
|
+
private fetchServerNTPResult;
|
|
32
32
|
getStatus(): TimeServiceStatus;
|
|
33
33
|
start(): void;
|
|
34
34
|
stop(): void;
|
|
@@ -32,17 +32,6 @@ class TimeService {
|
|
|
32
32
|
this.on = this.emitter.on.bind(this.emitter);
|
|
33
33
|
this.off = this.emitter.off.bind(this.emitter);
|
|
34
34
|
this.emit = this.emitter.emit.bind(this.emitter);
|
|
35
|
-
this.fetchServerNTPResult = (t1) => __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
try {
|
|
37
|
-
if (typeof this.option.serverTimeProvider === 'function') {
|
|
38
|
-
return yield this.option.serverTimeProvider(t1);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
catch (e) {
|
|
42
|
-
console.error(e);
|
|
43
|
-
}
|
|
44
|
-
return null;
|
|
45
|
-
});
|
|
46
35
|
this.option = option;
|
|
47
36
|
if (option.autoStart) {
|
|
48
37
|
this.start();
|
|
@@ -119,6 +108,19 @@ class TimeService {
|
|
|
119
108
|
getTime() {
|
|
120
109
|
return this.getServerTime() || this.getClientTime();
|
|
121
110
|
}
|
|
111
|
+
fetchServerNTPResult(t1) {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
try {
|
|
114
|
+
if (typeof this.option.serverTimeProvider === 'function') {
|
|
115
|
+
return yield this.option.serverTimeProvider(t1);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
catch (e) {
|
|
119
|
+
console.error(e);
|
|
120
|
+
}
|
|
121
|
+
return null;
|
|
122
|
+
});
|
|
123
|
+
}
|
|
122
124
|
getStatus() {
|
|
123
125
|
return this.status;
|
|
124
126
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AxiosUtils = void 0;
|
|
4
|
+
class AxiosUtils {
|
|
5
|
+
static headerValue2String(value) {
|
|
6
|
+
if (value === undefined) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
if (value === null || typeof value === 'string') {
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
if (Array.isArray(value)) {
|
|
13
|
+
if (value.length > 0) {
|
|
14
|
+
for (const e of value) {
|
|
15
|
+
if (typeof e === 'string') {
|
|
16
|
+
return e;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
// There is no any values having string type
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return String(value);
|
|
27
|
+
}
|
|
28
|
+
static headerValue2Number(value) {
|
|
29
|
+
if (value === undefined) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
if (value === null || typeof value === 'number') {
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
if (Array.isArray(value)) {
|
|
36
|
+
if (value.length > 0) {
|
|
37
|
+
for (const e of value) {
|
|
38
|
+
if (typeof e === 'number') {
|
|
39
|
+
return e;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// There is no any values having string type
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const result = Number(value);
|
|
50
|
+
return isNaN(result) ? null : result;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.AxiosUtils = AxiosUtils;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export * from './global';
|
|
2
|
+
export * from './ArrayUtils';
|
|
3
|
+
export * from './AxiosUtils';
|
|
2
4
|
export * from './StringUtils';
|
|
3
5
|
export * from './UuidUtils';
|
|
4
|
-
export * from './ArrayUtils';
|
|
5
6
|
export * from './BooleanUtils';
|
|
6
7
|
export * from './CoordinateUtils';
|
|
7
8
|
export * from './DateUtils';
|
package/dist/src/utils/index.js
CHANGED
|
@@ -15,9 +15,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./global"), exports);
|
|
18
|
+
__exportStar(require("./ArrayUtils"), exports);
|
|
19
|
+
__exportStar(require("./AxiosUtils"), exports);
|
|
18
20
|
__exportStar(require("./StringUtils"), exports);
|
|
19
21
|
__exportStar(require("./UuidUtils"), exports);
|
|
20
|
-
__exportStar(require("./ArrayUtils"), exports);
|
|
21
22
|
__exportStar(require("./BooleanUtils"), exports);
|
|
22
23
|
__exportStar(require("./CoordinateUtils"), exports);
|
|
23
24
|
__exportStar(require("./DateUtils"), exports);
|