@aitianyu.cn/types 0.0.11 → 0.0.13
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/lib/index.js +54 -54
- package/dist/lib/types/AreaCode.js +269 -269
- package/dist/lib/types/Exception.js +19 -19
- package/dist/lib/types/Logs.js +20 -20
- package/dist/lib/types/Object.js +3 -3
- package/dist/lib/types/PathBase.js +109 -109
- package/dist/lib/types/Security.js +10 -10
- package/dist/lib/types/TMap.js +138 -138
- package/dist/lib/types/Types.js +3 -3
- package/dist/lib/types/index.js +17 -17
- package/dist/lib/utilities/coding/Error.js +44 -44
- package/dist/lib/utilities/coding/Path.js +198 -198
- package/dist/lib/utilities/coding/index.js +10 -10
- package/dist/lib/utilities/core/Errors.js +86 -86
- package/dist/lib/utilities/core/Language.js +559 -559
- package/dist/lib/utilities/core/Log.js +108 -108
- package/dist/lib/utilities/core/TypeConvertion.js +25 -25
- package/dist/lib/utilities/core/index.js +21 -21
- package/dist/lib/utilities/core/interface/ITJSON.js +3 -0
- package/dist/lib/utilities/core/interface/ITianyuType.js +3 -0
- package/dist/lib/utilities/core/object/ArrayHelper.js +35 -35
- package/dist/lib/utilities/core/object/Calculater.js +230 -230
- package/dist/lib/utilities/core/object/Helper.js +201 -201
- package/dist/lib/utilities/core/object/StringHelper.js +22 -22
- package/dist/lib/utilities/core/type/TArray.js +7 -0
- package/dist/lib/utilities/core/type/TBoolean.js +7 -0
- package/dist/lib/utilities/core/type/TJSON.js +7 -0
- package/dist/lib/utilities/core/type/TNumber.js +7 -0
- package/dist/lib/utilities/core/type/TObject.js +7 -0
- package/dist/lib/utilities/core/type/TString.js +7 -0
- package/dist/lib/utilities/security/Guid.js +20 -20
- package/dist/lib/utilities/security/Hash.js +15 -15
- package/dist/lib/utilities/security/index.js +8 -8
- package/dist/types/index.d.ts +21 -21
- package/dist/types/types/AreaCode.d.ts +135 -135
- package/dist/types/types/Exception.d.ts +11 -11
- package/dist/types/types/Logs.d.ts +64 -64
- package/dist/types/types/Object.d.ts +18 -18
- package/dist/types/types/PathBase.d.ts +76 -76
- package/dist/types/types/Security.d.ts +23 -23
- package/dist/types/types/TMap.d.ts +80 -80
- package/dist/types/types/Types.d.ts +25 -20
- package/dist/types/types/index.d.ts +9 -9
- package/dist/types/utilities/coding/Error.d.ts +27 -27
- package/dist/types/utilities/coding/Path.d.ts +61 -61
- package/dist/types/utilities/coding/index.d.ts +3 -3
- package/dist/types/utilities/core/Errors.d.ts +47 -47
- package/dist/types/utilities/core/Language.d.ts +17 -17
- package/dist/types/utilities/core/Log.d.ts +12 -12
- package/dist/types/utilities/core/TypeConvertion.d.ts +2 -2
- package/dist/types/utilities/core/index.d.ts +6 -6
- package/dist/types/utilities/core/interface/ITJSON.d.ts +5 -0
- package/dist/types/utilities/core/interface/ITianyuType.d.ts +5 -0
- package/dist/types/utilities/core/object/ArrayHelper.d.ts +11 -11
- package/dist/types/utilities/core/object/Calculater.d.ts +22 -22
- package/dist/types/utilities/core/object/Helper.d.ts +39 -39
- package/dist/types/utilities/core/object/StringHelper.d.ts +4 -4
- package/dist/types/utilities/core/type/TArray.d.ts +3 -0
- package/dist/types/utilities/core/type/TBoolean.d.ts +3 -0
- package/dist/types/utilities/core/type/TJSON.d.ts +3 -0
- package/dist/types/utilities/core/type/TNumber.d.ts +3 -0
- package/dist/types/utilities/core/type/TObject.d.ts +3 -0
- package/dist/types/utilities/core/type/TString.d.ts +3 -0
- package/dist/types/utilities/security/Guid.d.ts +3 -3
- package/dist/types/utilities/security/Hash.d.ts +3 -3
- package/dist/types/utilities/security/index.d.ts +3 -3
- package/package.json +51 -51
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**@format */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.Performance = exports.Log = void 0;
|
|
5
|
-
const Logs_1 = require("../../types/Logs");
|
|
6
|
-
const Guid_1 = require("../security/Guid");
|
|
7
|
-
const _LogLevel = {
|
|
8
|
-
DEBUG: { value: 0, name: "DEBUG" },
|
|
9
|
-
ERROR: { value: 3, name: "ERROR" },
|
|
10
|
-
FATAL: { value: 4, name: "FATAL" },
|
|
11
|
-
INFO: { value: 1, name: "INFO" },
|
|
12
|
-
WARNING: { value: 2, name: "WARNING" },
|
|
13
|
-
LOG: { value: -1, name: "LOG" },
|
|
14
|
-
};
|
|
15
|
-
function _consoleLog(level, msg, timer) {
|
|
16
|
-
if (level.value >= 100) {
|
|
17
|
-
console.log(`[${level.name}] ${msg}`);
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
let timeString = "";
|
|
21
|
-
if (timer) {
|
|
22
|
-
const date = new Date(Date.now());
|
|
23
|
-
const millisecondString = date.getMilliseconds().toString();
|
|
24
|
-
timeString = `[${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}.${millisecondString.substring(0, millisecondString.length > 3 ? 3 : millisecondString.length)}]`;
|
|
25
|
-
}
|
|
26
|
-
const logMessage = `[${level.name}] ${timeString} ${msg}`;
|
|
27
|
-
switch (level.value) {
|
|
28
|
-
case 0:
|
|
29
|
-
console.debug(logMessage);
|
|
30
|
-
break;
|
|
31
|
-
case 1:
|
|
32
|
-
console.info(logMessage);
|
|
33
|
-
break;
|
|
34
|
-
case 2:
|
|
35
|
-
console.warn(logMessage);
|
|
36
|
-
break;
|
|
37
|
-
case 3:
|
|
38
|
-
console.error(logMessage);
|
|
39
|
-
break;
|
|
40
|
-
case 4:
|
|
41
|
-
console.error(logMessage);
|
|
42
|
-
break;
|
|
43
|
-
default:
|
|
44
|
-
console.log(msg);
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
const _log = {
|
|
49
|
-
log: function (msg, level, timer) {
|
|
50
|
-
const logLevel = level ?? Logs_1.LogLevel.INFO;
|
|
51
|
-
switch (logLevel) {
|
|
52
|
-
case Logs_1.LogLevel.DEBUG:
|
|
53
|
-
_consoleLog(_LogLevel["DEBUG"], msg, !!timer);
|
|
54
|
-
break;
|
|
55
|
-
case Logs_1.LogLevel.WARNING:
|
|
56
|
-
_consoleLog(_LogLevel["WARNING"], msg, !!timer);
|
|
57
|
-
break;
|
|
58
|
-
case Logs_1.LogLevel.ERROR:
|
|
59
|
-
_consoleLog(_LogLevel["ERROR"], msg, !!timer);
|
|
60
|
-
break;
|
|
61
|
-
case Logs_1.LogLevel.FATAL:
|
|
62
|
-
_consoleLog(_LogLevel["FATAL"], msg, !!timer);
|
|
63
|
-
break;
|
|
64
|
-
case Logs_1.LogLevel.INFO:
|
|
65
|
-
_consoleLog(_LogLevel["INFO"], msg, !!timer);
|
|
66
|
-
break;
|
|
67
|
-
default:
|
|
68
|
-
_consoleLog(_LogLevel["LOG"], msg, !!timer);
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
info: function (msg, timer) {
|
|
73
|
-
_consoleLog(_LogLevel["INFO"], msg, !!timer);
|
|
74
|
-
},
|
|
75
|
-
warn: function (msg, timer) {
|
|
76
|
-
_consoleLog(_LogLevel["WARNING"], msg, !!timer);
|
|
77
|
-
},
|
|
78
|
-
debug: function (msg, timer) {
|
|
79
|
-
_consoleLog(_LogLevel["DEBUG"], msg, !!timer);
|
|
80
|
-
},
|
|
81
|
-
error: function (msg, timer) {
|
|
82
|
-
_consoleLog(_LogLevel["ERROR"], msg, !!timer);
|
|
83
|
-
},
|
|
84
|
-
fatal: function (msg, timer) {
|
|
85
|
-
_consoleLog(_LogLevel["FATAL"], msg, !!timer);
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
function _startPerf(id) {
|
|
89
|
-
return {
|
|
90
|
-
id: id || (0, Guid_1.guid)(),
|
|
91
|
-
start: Date.now(),
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
function _endPerf(recorder, console) {
|
|
95
|
-
const perfTime = Date.now() - recorder.start;
|
|
96
|
-
if (console) {
|
|
97
|
-
const consoleString = `[${recorder.id}] perf time - ${perfTime}`;
|
|
98
|
-
_consoleLog({ value: 100, name: "Performance" }, consoleString, false);
|
|
99
|
-
}
|
|
100
|
-
return perfTime;
|
|
101
|
-
}
|
|
102
|
-
/** Tianyu Log Instance */
|
|
103
|
-
exports.Log = _log;
|
|
104
|
-
/** Tianyu Performance Instance */
|
|
105
|
-
exports.Performance = {
|
|
106
|
-
startPerf: _startPerf,
|
|
107
|
-
endPerf: _endPerf,
|
|
108
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
/**@format */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Performance = exports.Log = void 0;
|
|
5
|
+
const Logs_1 = require("../../types/Logs");
|
|
6
|
+
const Guid_1 = require("../security/Guid");
|
|
7
|
+
const _LogLevel = {
|
|
8
|
+
DEBUG: { value: 0, name: "DEBUG" },
|
|
9
|
+
ERROR: { value: 3, name: "ERROR" },
|
|
10
|
+
FATAL: { value: 4, name: "FATAL" },
|
|
11
|
+
INFO: { value: 1, name: "INFO" },
|
|
12
|
+
WARNING: { value: 2, name: "WARNING" },
|
|
13
|
+
LOG: { value: -1, name: "LOG" },
|
|
14
|
+
};
|
|
15
|
+
function _consoleLog(level, msg, timer) {
|
|
16
|
+
if (level.value >= 100) {
|
|
17
|
+
console.log(`[${level.name}] ${msg}`);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
let timeString = "";
|
|
21
|
+
if (timer) {
|
|
22
|
+
const date = new Date(Date.now());
|
|
23
|
+
const millisecondString = date.getMilliseconds().toString();
|
|
24
|
+
timeString = `[${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}.${millisecondString.substring(0, millisecondString.length > 3 ? 3 : millisecondString.length)}]`;
|
|
25
|
+
}
|
|
26
|
+
const logMessage = `[${level.name}] ${timeString} ${msg}`;
|
|
27
|
+
switch (level.value) {
|
|
28
|
+
case 0:
|
|
29
|
+
console.debug(logMessage);
|
|
30
|
+
break;
|
|
31
|
+
case 1:
|
|
32
|
+
console.info(logMessage);
|
|
33
|
+
break;
|
|
34
|
+
case 2:
|
|
35
|
+
console.warn(logMessage);
|
|
36
|
+
break;
|
|
37
|
+
case 3:
|
|
38
|
+
console.error(logMessage);
|
|
39
|
+
break;
|
|
40
|
+
case 4:
|
|
41
|
+
console.error(logMessage);
|
|
42
|
+
break;
|
|
43
|
+
default:
|
|
44
|
+
console.log(msg);
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const _log = {
|
|
49
|
+
log: function (msg, level, timer) {
|
|
50
|
+
const logLevel = level ?? Logs_1.LogLevel.INFO;
|
|
51
|
+
switch (logLevel) {
|
|
52
|
+
case Logs_1.LogLevel.DEBUG:
|
|
53
|
+
_consoleLog(_LogLevel["DEBUG"], msg, !!timer);
|
|
54
|
+
break;
|
|
55
|
+
case Logs_1.LogLevel.WARNING:
|
|
56
|
+
_consoleLog(_LogLevel["WARNING"], msg, !!timer);
|
|
57
|
+
break;
|
|
58
|
+
case Logs_1.LogLevel.ERROR:
|
|
59
|
+
_consoleLog(_LogLevel["ERROR"], msg, !!timer);
|
|
60
|
+
break;
|
|
61
|
+
case Logs_1.LogLevel.FATAL:
|
|
62
|
+
_consoleLog(_LogLevel["FATAL"], msg, !!timer);
|
|
63
|
+
break;
|
|
64
|
+
case Logs_1.LogLevel.INFO:
|
|
65
|
+
_consoleLog(_LogLevel["INFO"], msg, !!timer);
|
|
66
|
+
break;
|
|
67
|
+
default:
|
|
68
|
+
_consoleLog(_LogLevel["LOG"], msg, !!timer);
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
info: function (msg, timer) {
|
|
73
|
+
_consoleLog(_LogLevel["INFO"], msg, !!timer);
|
|
74
|
+
},
|
|
75
|
+
warn: function (msg, timer) {
|
|
76
|
+
_consoleLog(_LogLevel["WARNING"], msg, !!timer);
|
|
77
|
+
},
|
|
78
|
+
debug: function (msg, timer) {
|
|
79
|
+
_consoleLog(_LogLevel["DEBUG"], msg, !!timer);
|
|
80
|
+
},
|
|
81
|
+
error: function (msg, timer) {
|
|
82
|
+
_consoleLog(_LogLevel["ERROR"], msg, !!timer);
|
|
83
|
+
},
|
|
84
|
+
fatal: function (msg, timer) {
|
|
85
|
+
_consoleLog(_LogLevel["FATAL"], msg, !!timer);
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
function _startPerf(id) {
|
|
89
|
+
return {
|
|
90
|
+
id: id || (0, Guid_1.guid)(),
|
|
91
|
+
start: Date.now(),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function _endPerf(recorder, console) {
|
|
95
|
+
const perfTime = Date.now() - recorder.start;
|
|
96
|
+
if (console) {
|
|
97
|
+
const consoleString = `[${recorder.id}] perf time - ${perfTime}`;
|
|
98
|
+
_consoleLog({ value: 100, name: "Performance" }, consoleString, false);
|
|
99
|
+
}
|
|
100
|
+
return perfTime;
|
|
101
|
+
}
|
|
102
|
+
/** Tianyu Log Instance */
|
|
103
|
+
exports.Log = _log;
|
|
104
|
+
/** Tianyu Performance Instance */
|
|
105
|
+
exports.Performance = {
|
|
106
|
+
startPerf: _startPerf,
|
|
107
|
+
endPerf: _endPerf,
|
|
108
|
+
};
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**@format */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.getBoolean = void 0;
|
|
5
|
-
function getBoolean(value) {
|
|
6
|
-
if (value === null) {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
switch (typeof value) {
|
|
10
|
-
case "boolean":
|
|
11
|
-
return value;
|
|
12
|
-
case "number":
|
|
13
|
-
return !!value;
|
|
14
|
-
case "string":
|
|
15
|
-
if (!value) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
return value.toLowerCase() === "false" ? false : true;
|
|
19
|
-
case "undefined":
|
|
20
|
-
return false;
|
|
21
|
-
default:
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.getBoolean = getBoolean;
|
|
1
|
+
"use strict";
|
|
2
|
+
/**@format */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getBoolean = void 0;
|
|
5
|
+
function getBoolean(value) {
|
|
6
|
+
if (value === null) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
switch (typeof value) {
|
|
10
|
+
case "boolean":
|
|
11
|
+
return value;
|
|
12
|
+
case "number":
|
|
13
|
+
return !!value;
|
|
14
|
+
case "string":
|
|
15
|
+
if (!value) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
return value.toLowerCase() === "false" ? false : true;
|
|
19
|
+
case "undefined":
|
|
20
|
+
return false;
|
|
21
|
+
default:
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.getBoolean = getBoolean;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**@format */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.ObjectHelper = exports.ObjectCalculater = exports.Performance = exports.Log = exports.parseAreaString = exports.parseAreaCode = exports.ObjectDiffMergeFailedException = exports.ObjectDiffApplyInvalidStatusException = exports.ObjectMergeStatusCheckFailedException = exports.ObjectCloneFunctionNotSupportException = exports.ArgumentNullOrEmptyException = void 0;
|
|
5
|
-
var Errors_1 = require("./Errors");
|
|
6
|
-
Object.defineProperty(exports, "ArgumentNullOrEmptyException", { enumerable: true, get: function () { return Errors_1.ArgumentNullOrEmptyException; } });
|
|
7
|
-
Object.defineProperty(exports, "ObjectCloneFunctionNotSupportException", { enumerable: true, get: function () { return Errors_1.ObjectCloneFunctionNotSupportException; } });
|
|
8
|
-
Object.defineProperty(exports, "ObjectMergeStatusCheckFailedException", { enumerable: true, get: function () { return Errors_1.ObjectMergeStatusCheckFailedException; } });
|
|
9
|
-
Object.defineProperty(exports, "ObjectDiffApplyInvalidStatusException", { enumerable: true, get: function () { return Errors_1.ObjectDiffApplyInvalidStatusException; } });
|
|
10
|
-
Object.defineProperty(exports, "ObjectDiffMergeFailedException", { enumerable: true, get: function () { return Errors_1.ObjectDiffMergeFailedException; } });
|
|
11
|
-
var Language_1 = require("./Language");
|
|
12
|
-
Object.defineProperty(exports, "parseAreaCode", { enumerable: true, get: function () { return Language_1.parseAreaCode; } });
|
|
13
|
-
Object.defineProperty(exports, "parseAreaString", { enumerable: true, get: function () { return Language_1.parseAreaString; } });
|
|
14
|
-
var Log_1 = require("./Log");
|
|
15
|
-
Object.defineProperty(exports, "Log", { enumerable: true, get: function () { return Log_1.Log; } });
|
|
16
|
-
Object.defineProperty(exports, "Performance", { enumerable: true, get: function () { return Log_1.Performance; } });
|
|
17
|
-
//// object
|
|
18
|
-
var Calculater_1 = require("./object/Calculater");
|
|
19
|
-
Object.defineProperty(exports, "ObjectCalculater", { enumerable: true, get: function () { return Calculater_1.ObjectCalculater; } });
|
|
20
|
-
var Helper_1 = require("./object/Helper");
|
|
21
|
-
Object.defineProperty(exports, "ObjectHelper", { enumerable: true, get: function () { return Helper_1.ObjectHelper; } });
|
|
1
|
+
"use strict";
|
|
2
|
+
/**@format */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ObjectHelper = exports.ObjectCalculater = exports.Performance = exports.Log = exports.parseAreaString = exports.parseAreaCode = exports.ObjectDiffMergeFailedException = exports.ObjectDiffApplyInvalidStatusException = exports.ObjectMergeStatusCheckFailedException = exports.ObjectCloneFunctionNotSupportException = exports.ArgumentNullOrEmptyException = void 0;
|
|
5
|
+
var Errors_1 = require("./Errors");
|
|
6
|
+
Object.defineProperty(exports, "ArgumentNullOrEmptyException", { enumerable: true, get: function () { return Errors_1.ArgumentNullOrEmptyException; } });
|
|
7
|
+
Object.defineProperty(exports, "ObjectCloneFunctionNotSupportException", { enumerable: true, get: function () { return Errors_1.ObjectCloneFunctionNotSupportException; } });
|
|
8
|
+
Object.defineProperty(exports, "ObjectMergeStatusCheckFailedException", { enumerable: true, get: function () { return Errors_1.ObjectMergeStatusCheckFailedException; } });
|
|
9
|
+
Object.defineProperty(exports, "ObjectDiffApplyInvalidStatusException", { enumerable: true, get: function () { return Errors_1.ObjectDiffApplyInvalidStatusException; } });
|
|
10
|
+
Object.defineProperty(exports, "ObjectDiffMergeFailedException", { enumerable: true, get: function () { return Errors_1.ObjectDiffMergeFailedException; } });
|
|
11
|
+
var Language_1 = require("./Language");
|
|
12
|
+
Object.defineProperty(exports, "parseAreaCode", { enumerable: true, get: function () { return Language_1.parseAreaCode; } });
|
|
13
|
+
Object.defineProperty(exports, "parseAreaString", { enumerable: true, get: function () { return Language_1.parseAreaString; } });
|
|
14
|
+
var Log_1 = require("./Log");
|
|
15
|
+
Object.defineProperty(exports, "Log", { enumerable: true, get: function () { return Log_1.Log; } });
|
|
16
|
+
Object.defineProperty(exports, "Performance", { enumerable: true, get: function () { return Log_1.Performance; } });
|
|
17
|
+
//// object
|
|
18
|
+
var Calculater_1 = require("./object/Calculater");
|
|
19
|
+
Object.defineProperty(exports, "ObjectCalculater", { enumerable: true, get: function () { return Calculater_1.ObjectCalculater; } });
|
|
20
|
+
var Helper_1 = require("./object/Helper");
|
|
21
|
+
Object.defineProperty(exports, "ObjectHelper", { enumerable: true, get: function () { return Helper_1.ObjectHelper; } });
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**@format */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.ArrayHelper = void 0;
|
|
5
|
-
/** Array type related tools */
|
|
6
|
-
class ArrayHelper {
|
|
7
|
-
/**
|
|
8
|
-
* To merge multiple arrays into a new array and remove duplicated elements.
|
|
9
|
-
*
|
|
10
|
-
* @param {any[]} array arrays
|
|
11
|
-
* @returns return a new array
|
|
12
|
-
*/
|
|
13
|
-
static merge(...array) {
|
|
14
|
-
if (array.length === 0) {
|
|
15
|
-
return [];
|
|
16
|
-
}
|
|
17
|
-
const result = [];
|
|
18
|
-
for (const item of array) {
|
|
19
|
-
if (Array.isArray(item)) {
|
|
20
|
-
for (const arrItem of item) {
|
|
21
|
-
if (!result.includes(arrItem)) {
|
|
22
|
-
result.push(arrItem);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
if (!result.includes(item)) {
|
|
28
|
-
result.push(item);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return result;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.ArrayHelper = ArrayHelper;
|
|
1
|
+
"use strict";
|
|
2
|
+
/**@format */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ArrayHelper = void 0;
|
|
5
|
+
/** Array type related tools */
|
|
6
|
+
class ArrayHelper {
|
|
7
|
+
/**
|
|
8
|
+
* To merge multiple arrays into a new array and remove duplicated elements.
|
|
9
|
+
*
|
|
10
|
+
* @param {any[]} array arrays
|
|
11
|
+
* @returns return a new array
|
|
12
|
+
*/
|
|
13
|
+
static merge(...array) {
|
|
14
|
+
if (array.length === 0) {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
const result = [];
|
|
18
|
+
for (const item of array) {
|
|
19
|
+
if (Array.isArray(item)) {
|
|
20
|
+
for (const arrItem of item) {
|
|
21
|
+
if (!result.includes(arrItem)) {
|
|
22
|
+
result.push(arrItem);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
if (!result.includes(item)) {
|
|
28
|
+
result.push(item);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.ArrayHelper = ArrayHelper;
|