@aitianyu.cn/types 0.0.6 → 0.0.8
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 +3 -1
- package/dist/lib/utilities/core/Log.js +1 -1
- package/dist/lib/utilities/core/object/Operator.js +35 -0
- package/dist/lib/utilities/security/Guid.js +5 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/utilities/core/object/Operator.d.ts +11 -0
- package/package.json +1 -1
package/dist/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**@format */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.hash = exports.guid = exports.ObjectHelper = exports.ObjectCalculater = exports.getBoolean = exports.Performance = exports.Log = exports.parseAreaString = exports.parseAreaCode = exports.ObjectDiffMergeFailedException = exports.ObjectDiffApplyInvalidStatusException = exports.ObjectMergeStatusCheckFailedException = exports.ObjectCloneFunctionNotSupportException = exports.ArgumentNullOrEmptyException = exports.Path = exports.PathDirAndFileConvertInvaild = exports.PathDirectoryValidationFailException = exports.PathProcessorSourceLostException = exports.TMap = exports.EncryptOption = exports.PathBase = exports.LogLevel = exports.Exception = exports.AreaCode = void 0;
|
|
4
|
+
exports.hash = exports.guid = exports.ArrayHelper = exports.ObjectHelper = exports.ObjectCalculater = exports.getBoolean = exports.Performance = exports.Log = exports.parseAreaString = exports.parseAreaCode = exports.ObjectDiffMergeFailedException = exports.ObjectDiffApplyInvalidStatusException = exports.ObjectMergeStatusCheckFailedException = exports.ObjectCloneFunctionNotSupportException = exports.ArgumentNullOrEmptyException = exports.Path = exports.PathDirAndFileConvertInvaild = exports.PathDirectoryValidationFailException = exports.PathProcessorSourceLostException = exports.TMap = exports.EncryptOption = exports.PathBase = exports.LogLevel = exports.Exception = exports.AreaCode = void 0;
|
|
5
5
|
// src/types
|
|
6
6
|
var AreaCode_1 = require("./types/AreaCode");
|
|
7
7
|
Object.defineProperty(exports, "AreaCode", { enumerable: true, get: function () { return AreaCode_1.AreaCode; } });
|
|
@@ -43,6 +43,8 @@ var Calculater_1 = require("./utilities/core/object/Calculater");
|
|
|
43
43
|
Object.defineProperty(exports, "ObjectCalculater", { enumerable: true, get: function () { return Calculater_1.ObjectCalculater; } });
|
|
44
44
|
var Helper_1 = require("./utilities/core/object/Helper");
|
|
45
45
|
Object.defineProperty(exports, "ObjectHelper", { enumerable: true, get: function () { return Helper_1.ObjectHelper; } });
|
|
46
|
+
var Operator_1 = require("./utilities/core/object/Operator");
|
|
47
|
+
Object.defineProperty(exports, "ArrayHelper", { enumerable: true, get: function () { return Operator_1.ArrayHelper; } });
|
|
46
48
|
// security
|
|
47
49
|
var Guid_1 = require("./utilities/security/Guid");
|
|
48
50
|
Object.defineProperty(exports, "guid", { enumerable: true, get: function () { return Guid_1.guid; } });
|
|
@@ -21,7 +21,7 @@ function _consoleLog(level, msg, timer) {
|
|
|
21
21
|
if (timer) {
|
|
22
22
|
const date = new Date(Date.now());
|
|
23
23
|
const millisecondString = date.getMilliseconds().toString();
|
|
24
|
-
timeString = `[${date.
|
|
24
|
+
timeString = `[${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}.${millisecondString.substring(0, millisecondString.length > 3 ? 3 : millisecondString.length)}]`;
|
|
25
25
|
}
|
|
26
26
|
const logMessage = `[${level.name}] ${timeString} ${msg}`;
|
|
27
27
|
switch (level.value) {
|
|
@@ -0,0 +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;
|
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
/**@format */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.guid = void 0;
|
|
5
|
-
const perf_hooks_1 = require("perf_hooks");
|
|
6
5
|
/** Generate a Guid value string */
|
|
7
6
|
function guid() {
|
|
8
7
|
let d = new Date().getTime();
|
|
9
|
-
|
|
8
|
+
if (typeof performance === "undefined") {
|
|
9
|
+
// global.performance = require("perf_hooks").performance;
|
|
10
|
+
global.performance = eval("require")("perf_hooks").performance;
|
|
11
|
+
}
|
|
12
|
+
d += performance.now(); //use high-precision timer if available
|
|
10
13
|
const uuid = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
|
|
11
14
|
const r = (d + Math.random() * 16) % 16 | 0; // d是随机种子
|
|
12
15
|
d = Math.floor(d / 16);
|
package/dist/types/index.d.ts
CHANGED
|
@@ -15,5 +15,6 @@ export { Log, Performance } from "./utilities/core/Log";
|
|
|
15
15
|
export { getBoolean } from "./utilities/core/TypeConvertion";
|
|
16
16
|
export { ObjectCalculater } from "./utilities/core/object/Calculater";
|
|
17
17
|
export { ObjectHelper } from "./utilities/core/object/Helper";
|
|
18
|
+
export { ArrayHelper } from "./utilities/core/object/Operator";
|
|
18
19
|
export { guid } from "./utilities/security/Guid";
|
|
19
20
|
export { hash } from "./utilities/security/Hash";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**@format */
|
|
2
|
+
/** Array type related tools */
|
|
3
|
+
export declare class ArrayHelper {
|
|
4
|
+
/**
|
|
5
|
+
* To merge multiple arrays into a new array and remove duplicated elements.
|
|
6
|
+
*
|
|
7
|
+
* @param {any[]} array arrays
|
|
8
|
+
* @returns return a new array
|
|
9
|
+
*/
|
|
10
|
+
static merge(...array: any[]): any[];
|
|
11
|
+
}
|