diginext-utils 2.0.32 → 2.0.35
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 +162 -162
- package/package.json +66 -66
- package/src/Checker.ts +29 -29
- package/src/EventDispatcher.ts +62 -62
- package/src/FileUpload.ts +66 -66
- package/src/Slug.ts +365 -365
- package/src/Timer.ts +7 -7
- package/src/Validation.ts +36 -36
- package/src/array.ts +285 -285
- package/src/color.ts +87 -87
- package/src/console/enableConsole.ts +8 -8
- package/src/console/index.ts +17 -17
- package/src/console/log.ts +39 -39
- package/src/device/browser.ts +29 -29
- package/src/device/camera.ts +207 -207
- package/src/device/index.ts +230 -230
- package/src/device/os.ts +29 -29
- package/src/file/createDir.ts +14 -14
- package/src/file/fileMove.ts +32 -32
- package/src/file/findFilesByExt.ts +46 -46
- package/src/file/index.ts +7 -7
- package/src/images/index.ts +3 -3
- package/src/images/loadImage.ts +16 -0
- package/src/images/resize.ts +35 -35
- package/src/images/upload.ts +24 -24
- package/src/index.ts +39 -39
- package/src/json.ts +29 -29
- package/src/math/diffDate.ts +10 -10
- package/src/math/index.ts +90 -90
- package/src/math/positiveNumber.ts +12 -12
- package/src/name/en.ts +27 -27
- package/src/name/index.ts +8 -8
- package/src/name/vi.ts +23 -23
- package/src/object.ts +72 -72
- package/src/permission/index.ts +6 -6
- package/src/permission/requestCamera.ts +43 -43
- package/src/permission/requestDeviceOrientationControl.ts +33 -33
- package/src/response/index.ts +45 -45
- package/src/string/formatNumber.ts +12 -12
- package/src/string/generatePassword.ts +18 -18
- package/src/string/generateUUID.ts +37 -37
- package/src/string/index.ts +180 -180
- package/src/string/makeDaySlug.ts +40 -40
- package/src/string/random.ts +24 -24
- package/src/string/trimNull.ts +16 -16
- package/src/string/url.ts +116 -116
- package/dist/Checker.d.ts +0 -8
- package/dist/Checker.js +0 -32
- package/dist/Checker.js.map +0 -1
- package/dist/EventDispatcher.d.ts +0 -13
- package/dist/EventDispatcher.js +0 -52
- package/dist/EventDispatcher.js.map +0 -1
- package/dist/FileUpload.d.ts +0 -12
- package/dist/FileUpload.js +0 -65
- package/dist/FileUpload.js.map +0 -1
- package/dist/Slug.d.ts +0 -9
- package/dist/Slug.js +0 -334
- package/dist/Slug.js.map +0 -1
- package/dist/Timer.d.ts +0 -4
- package/dist/Timer.js +0 -9
- package/dist/Timer.js.map +0 -1
- package/dist/Validation.d.ts +0 -5
- package/dist/Validation.js +0 -39
- package/dist/Validation.js.map +0 -1
- package/dist/array.d.ts +0 -113
- package/dist/array.js +0 -297
- package/dist/array.js.map +0 -1
- package/dist/color.d.ts +0 -23
- package/dist/color.js +0 -89
- package/dist/color.js.map +0 -1
- package/dist/console/enableConsole.d.ts +0 -2
- package/dist/console/enableConsole.js +0 -14
- package/dist/console/enableConsole.js.map +0 -1
- package/dist/console/index.d.ts +0 -11
- package/dist/console/index.js +0 -18
- package/dist/console/index.js.map +0 -1
- package/dist/console/log.d.ts +0 -15
- package/dist/console/log.js +0 -45
- package/dist/console/log.js.map +0 -1
- package/dist/device/browser.d.ts +0 -5
- package/dist/device/browser.js +0 -38
- package/dist/device/browser.js.map +0 -1
- package/dist/device/camera.d.ts +0 -7
- package/dist/device/camera.js +0 -172
- package/dist/device/camera.js.map +0 -1
- package/dist/device/index.d.ts +0 -5
- package/dist/device/index.js +0 -225
- package/dist/device/index.js.map +0 -1
- package/dist/device/os.d.ts +0 -11
- package/dist/device/os.js +0 -38
- package/dist/device/os.js.map +0 -1
- package/dist/file/createDir.d.ts +0 -5
- package/dist/file/createDir.js +0 -16
- package/dist/file/createDir.js.map +0 -1
- package/dist/file/fileMove.d.ts +0 -4
- package/dist/file/fileMove.js +0 -33
- package/dist/file/fileMove.js.map +0 -1
- package/dist/file/findFilesByExt.d.ts +0 -13
- package/dist/file/findFilesByExt.js +0 -50
- package/dist/file/findFilesByExt.js.map +0 -1
- package/dist/file/index.d.ts +0 -9
- package/dist/file/index.js +0 -11
- package/dist/file/index.js.map +0 -1
- package/dist/images/index.d.ts +0 -2
- package/dist/images/index.js +0 -9
- package/dist/images/index.js.map +0 -1
- package/dist/images/resize.d.ts +0 -2
- package/dist/images/resize.js +0 -38
- package/dist/images/resize.js.map +0 -1
- package/dist/images/upload.d.ts +0 -10
- package/dist/images/upload.js +0 -27
- package/dist/images/upload.js.map +0 -1
- package/dist/index.d.ts +0 -37
- package/dist/index.js +0 -63
- package/dist/index.js.map +0 -1
- package/dist/json.d.ts +0 -8
- package/dist/json.js +0 -32
- package/dist/json.js.map +0 -1
- package/dist/math/diffDate.d.ts +0 -5
- package/dist/math/diffDate.js +0 -14
- package/dist/math/diffDate.js.map +0 -1
- package/dist/math/index.d.ts +0 -30
- package/dist/math/index.js +0 -93
- package/dist/math/index.js.map +0 -1
- package/dist/math/positiveNumber.d.ts +0 -2
- package/dist/math/positiveNumber.js +0 -17
- package/dist/math/positiveNumber.js.map +0 -1
- package/dist/name/en.d.ts +0 -5
- package/dist/name/en.js +0 -26
- package/dist/name/en.js.map +0 -1
- package/dist/name/index.d.ts +0 -12
- package/dist/name/index.js +0 -13
- package/dist/name/index.js.map +0 -1
- package/dist/name/vi.d.ts +0 -5
- package/dist/name/vi.js +0 -28
- package/dist/name/vi.js.map +0 -1
- package/dist/object.d.ts +0 -59
- package/dist/object.js +0 -80
- package/dist/object.js.map +0 -1
- package/dist/permission/index.d.ts +0 -8
- package/dist/permission/index.js +0 -7
- package/dist/permission/index.js.map +0 -1
- package/dist/permission/requestCamera.d.ts +0 -5
- package/dist/permission/requestCamera.js +0 -43
- package/dist/permission/requestCamera.js.map +0 -1
- package/dist/permission/requestDeviceOrientationControl.d.ts +0 -2
- package/dist/permission/requestDeviceOrientationControl.js +0 -39
- package/dist/permission/requestDeviceOrientationControl.js.map +0 -1
- package/dist/response/index.d.ts +0 -49
- package/dist/response/index.js +0 -52
- package/dist/response/index.js.map +0 -1
- package/dist/string/formatNumber.d.ts +0 -6
- package/dist/string/formatNumber.js +0 -15
- package/dist/string/formatNumber.js.map +0 -1
- package/dist/string/generatePassword.d.ts +0 -9
- package/dist/string/generatePassword.js +0 -24
- package/dist/string/generatePassword.js.map +0 -1
- package/dist/string/generateUUID.d.ts +0 -2
- package/dist/string/generateUUID.js +0 -37
- package/dist/string/generateUUID.js.map +0 -1
- package/dist/string/index.d.ts +0 -65
- package/dist/string/index.js +0 -161
- package/dist/string/index.js.map +0 -1
- package/dist/string/makeDaySlug.d.ts +0 -31
- package/dist/string/makeDaySlug.js +0 -23
- package/dist/string/makeDaySlug.js.map +0 -1
- package/dist/string/random.d.ts +0 -14
- package/dist/string/random.js +0 -25
- package/dist/string/random.js.map +0 -1
- package/dist/string/trimNull.d.ts +0 -2
- package/dist/string/trimNull.js +0 -21
- package/dist/string/trimNull.js.map +0 -1
- package/dist/string/url.d.ts +0 -36
- package/dist/string/url.js +0 -108
- package/dist/string/url.js.map +0 -1
- package/esm/Checker.d.ts +0 -8
- package/esm/Checker.js +0 -28
- package/esm/Checker.js.map +0 -1
- package/esm/EventDispatcher.d.ts +0 -13
- package/esm/EventDispatcher.js +0 -49
- package/esm/EventDispatcher.js.map +0 -1
- package/esm/FileUpload.d.ts +0 -12
- package/esm/FileUpload.js +0 -62
- package/esm/FileUpload.js.map +0 -1
- package/esm/Slug.d.ts +0 -9
- package/esm/Slug.js +0 -330
- package/esm/Slug.js.map +0 -1
- package/esm/Timer.d.ts +0 -4
- package/esm/Timer.js +0 -7
- package/esm/Timer.js.map +0 -1
- package/esm/Validation.d.ts +0 -5
- package/esm/Validation.js +0 -37
- package/esm/Validation.js.map +0 -1
- package/esm/array.d.ts +0 -113
- package/esm/array.js +0 -275
- package/esm/array.js.map +0 -1
- package/esm/color.d.ts +0 -23
- package/esm/color.js +0 -80
- package/esm/color.js.map +0 -1
- package/esm/console/enableConsole.d.ts +0 -2
- package/esm/console/enableConsole.js +0 -7
- package/esm/console/enableConsole.js.map +0 -1
- package/esm/console/index.d.ts +0 -11
- package/esm/console/index.js +0 -13
- package/esm/console/index.js.map +0 -1
- package/esm/console/log.d.ts +0 -15
- package/esm/console/log.js +0 -33
- package/esm/console/log.js.map +0 -1
- package/esm/device/browser.d.ts +0 -5
- package/esm/device/browser.js +0 -30
- package/esm/device/browser.js.map +0 -1
- package/esm/device/camera.d.ts +0 -7
- package/esm/device/camera.js +0 -168
- package/esm/device/camera.js.map +0 -1
- package/esm/device/index.d.ts +0 -5
- package/esm/device/index.js +0 -217
- package/esm/device/index.js.map +0 -1
- package/esm/device/os.d.ts +0 -11
- package/esm/device/os.js +0 -28
- package/esm/device/os.js.map +0 -1
- package/esm/file/createDir.d.ts +0 -5
- package/esm/file/createDir.js +0 -13
- package/esm/file/createDir.js.map +0 -1
- package/esm/file/fileMove.d.ts +0 -4
- package/esm/file/fileMove.js +0 -29
- package/esm/file/fileMove.js.map +0 -1
- package/esm/file/findFilesByExt.d.ts +0 -13
- package/esm/file/findFilesByExt.js +0 -46
- package/esm/file/findFilesByExt.js.map +0 -1
- package/esm/file/index.d.ts +0 -9
- package/esm/file/index.js +0 -6
- package/esm/file/index.js.map +0 -1
- package/esm/images/index.d.ts +0 -2
- package/esm/images/index.js +0 -4
- package/esm/images/index.js.map +0 -1
- package/esm/images/resize.d.ts +0 -2
- package/esm/images/resize.js +0 -31
- package/esm/images/resize.js.map +0 -1
- package/esm/images/upload.d.ts +0 -10
- package/esm/images/upload.js +0 -20
- package/esm/images/upload.js.map +0 -1
- package/esm/index.d.ts +0 -37
- package/esm/index.js +0 -38
- package/esm/index.js.map +0 -1
- package/esm/json.d.ts +0 -8
- package/esm/json.js +0 -28
- package/esm/json.js.map +0 -1
- package/esm/math/diffDate.d.ts +0 -5
- package/esm/math/diffDate.js +0 -10
- package/esm/math/diffDate.js.map +0 -1
- package/esm/math/index.d.ts +0 -30
- package/esm/math/index.js +0 -78
- package/esm/math/index.js.map +0 -1
- package/esm/math/positiveNumber.d.ts +0 -2
- package/esm/math/positiveNumber.js +0 -13
- package/esm/math/positiveNumber.js.map +0 -1
- package/esm/name/en.d.ts +0 -5
- package/esm/name/en.js +0 -22
- package/esm/name/en.js.map +0 -1
- package/esm/name/index.d.ts +0 -12
- package/esm/name/index.js +0 -6
- package/esm/name/index.js.map +0 -1
- package/esm/name/vi.d.ts +0 -5
- package/esm/name/vi.js +0 -24
- package/esm/name/vi.js.map +0 -1
- package/esm/object.d.ts +0 -59
- package/esm/object.js +0 -70
- package/esm/object.js.map +0 -1
- package/esm/permission/index.d.ts +0 -8
- package/esm/permission/index.js +0 -5
- package/esm/permission/index.js.map +0 -1
- package/esm/permission/requestCamera.d.ts +0 -5
- package/esm/permission/requestCamera.js +0 -39
- package/esm/permission/requestCamera.js.map +0 -1
- package/esm/permission/requestDeviceOrientationControl.d.ts +0 -2
- package/esm/permission/requestDeviceOrientationControl.js +0 -35
- package/esm/permission/requestDeviceOrientationControl.js.map +0 -1
- package/esm/response/index.d.ts +0 -49
- package/esm/response/index.js +0 -46
- package/esm/response/index.js.map +0 -1
- package/esm/string/formatNumber.d.ts +0 -6
- package/esm/string/formatNumber.js +0 -11
- package/esm/string/formatNumber.js.map +0 -1
- package/esm/string/generatePassword.d.ts +0 -9
- package/esm/string/generatePassword.js +0 -20
- package/esm/string/generatePassword.js.map +0 -1
- package/esm/string/generateUUID.d.ts +0 -2
- package/esm/string/generateUUID.js +0 -33
- package/esm/string/generateUUID.js.map +0 -1
- package/esm/string/index.d.ts +0 -65
- package/esm/string/index.js +0 -150
- package/esm/string/index.js.map +0 -1
- package/esm/string/makeDaySlug.d.ts +0 -31
- package/esm/string/makeDaySlug.js +0 -16
- package/esm/string/makeDaySlug.js.map +0 -1
- package/esm/string/random.d.ts +0 -14
- package/esm/string/random.js +0 -20
- package/esm/string/random.js.map +0 -1
- package/esm/string/trimNull.d.ts +0 -2
- package/esm/string/trimNull.js +0 -14
- package/esm/string/trimNull.js.map +0 -1
- package/esm/string/url.d.ts +0 -36
- package/esm/string/url.js +0 -98
- package/esm/string/url.js.map +0 -1
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import dayjs from "dayjs";
|
|
2
|
-
|
|
3
|
-
type DaySlugOptions = {
|
|
4
|
-
/**
|
|
5
|
-
* @default ""
|
|
6
|
-
*/
|
|
7
|
-
prefix?: string;
|
|
8
|
-
/**
|
|
9
|
-
* @default ""
|
|
10
|
-
*/
|
|
11
|
-
surfix?: string;
|
|
12
|
-
/**
|
|
13
|
-
* @default true
|
|
14
|
-
*/
|
|
15
|
-
useDate?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* @default true
|
|
18
|
-
*/
|
|
19
|
-
useTime?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* @default "-"
|
|
22
|
-
*/
|
|
23
|
-
divider?: string;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Format the input number with commas
|
|
28
|
-
* @example 1000000 -> 1,000,000
|
|
29
|
-
*/
|
|
30
|
-
export function makeDaySlug(options: DaySlugOptions = {}) {
|
|
31
|
-
const { prefix = "", surfix = "", divider = "-", useDate = true, useTime = true } = options;
|
|
32
|
-
|
|
33
|
-
let mainStr = "";
|
|
34
|
-
if (useDate) mainStr += dayjs().format(`YYYY${divider}MM${divider}DD`);
|
|
35
|
-
if (useTime) mainStr += (mainStr == "" ? "" : divider) + dayjs().format(`HH${divider}mm${divider}ss`);
|
|
36
|
-
|
|
37
|
-
return prefix + (prefix ? divider : "") + mainStr + (surfix ? divider : "") + surfix;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export default { makeDaySlug };
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
|
|
3
|
+
type DaySlugOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* @default ""
|
|
6
|
+
*/
|
|
7
|
+
prefix?: string;
|
|
8
|
+
/**
|
|
9
|
+
* @default ""
|
|
10
|
+
*/
|
|
11
|
+
surfix?: string;
|
|
12
|
+
/**
|
|
13
|
+
* @default true
|
|
14
|
+
*/
|
|
15
|
+
useDate?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* @default true
|
|
18
|
+
*/
|
|
19
|
+
useTime?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* @default "-"
|
|
22
|
+
*/
|
|
23
|
+
divider?: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Format the input number with commas
|
|
28
|
+
* @example 1000000 -> 1,000,000
|
|
29
|
+
*/
|
|
30
|
+
export function makeDaySlug(options: DaySlugOptions = {}) {
|
|
31
|
+
const { prefix = "", surfix = "", divider = "-", useDate = true, useTime = true } = options;
|
|
32
|
+
|
|
33
|
+
let mainStr = "";
|
|
34
|
+
if (useDate) mainStr += dayjs().format(`YYYY${divider}MM${divider}DD`);
|
|
35
|
+
if (useTime) mainStr += (mainStr == "" ? "" : divider) + dayjs().format(`HH${divider}mm${divider}ss`);
|
|
36
|
+
|
|
37
|
+
return prefix + (prefix ? divider : "") + mainStr + (surfix ? divider : "") + surfix;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default { makeDaySlug };
|
package/src/string/random.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
export const textLowCase = "abcdefghijklmnopqrstuvwxyz";
|
|
2
|
-
export const numeric = "0123456789";
|
|
3
|
-
export const punctuation = "!@#$%^&*()_+~|}{[];?><,./-=";
|
|
4
|
-
export const allCharacter = `đĐaáàảãạăắằẳẵặâấầẩẫậeéèẻẽẹêếềểễệoóòỏõọôốồổỗộơớờởỡợiíìỉĩịuúùủũụưứừửữựyýỳỷỹỵAÁÀẢÃẠĂẮẰẲẴẶÂẤẦẨẪẬEÉÈẺẼẸÊẾỀỂỄỆOÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢIÍÌỈĨỊUÚÙỦŨỤƯỨỪỬỮỰYÝỲ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_\`abcdefghijklmnopqrstuvwxyz{|}`;
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* allCharacter = `đĐaáàảãạăắằẳẵặâấầẩẫậeéèẻẽẹêếềểễệoóòỏõọôốồổỗộơớờởỡợiíìỉĩịuúùủũụưứừửữựyýỳỷỹỵAÁÀẢÃẠĂẮẰẲẴẶÂẤẦẨẪẬEÉÈẺẼẸÊẾỀỂỄỆOÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢIÍÌỈĨỊUÚÙỦŨỤƯỨỪỬỮỰYÝỲ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_\`abcdefghijklmnopqrstuvwxyz{|}`;
|
|
8
|
-
*/
|
|
9
|
-
export const randAllCharacterByLength = (length = 0) => {
|
|
10
|
-
return randomStringByLength(length, allCharacter);
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const randomStringByLength = (length: number, str = textLowCase) => {
|
|
14
|
-
let result = "";
|
|
15
|
-
|
|
16
|
-
for (let i = 0; i < length; i++) {
|
|
17
|
-
result += str.charAt(Math.floor(Math.random() * str.length));
|
|
18
|
-
}
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const random = { randAllCharacterByLength, randomStringByLength };
|
|
23
|
-
|
|
24
|
-
export default random;
|
|
1
|
+
export const textLowCase = "abcdefghijklmnopqrstuvwxyz";
|
|
2
|
+
export const numeric = "0123456789";
|
|
3
|
+
export const punctuation = "!@#$%^&*()_+~|}{[];?><,./-=";
|
|
4
|
+
export const allCharacter = `đĐaáàảãạăắằẳẵặâấầẩẫậeéèẻẽẹêếềểễệoóòỏõọôốồổỗộơớờởỡợiíìỉĩịuúùủũụưứừửữựyýỳỷỹỵAÁÀẢÃẠĂẮẰẲẴẶÂẤẦẨẪẬEÉÈẺẼẸÊẾỀỂỄỆOÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢIÍÌỈĨỊUÚÙỦŨỤƯỨỪỬỮỰYÝỲ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_\`abcdefghijklmnopqrstuvwxyz{|}`;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* allCharacter = `đĐaáàảãạăắằẳẵặâấầẩẫậeéèẻẽẹêếềểễệoóòỏõọôốồổỗộơớờởỡợiíìỉĩịuúùủũụưứừửữựyýỳỷỹỵAÁÀẢÃẠĂẮẰẲẴẶÂẤẦẨẪẬEÉÈẺẼẸÊẾỀỂỄỆOÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢIÍÌỈĨỊUÚÙỦŨỤƯỨỪỬỮỰYÝỲ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_\`abcdefghijklmnopqrstuvwxyz{|}`;
|
|
8
|
+
*/
|
|
9
|
+
export const randAllCharacterByLength = (length = 0) => {
|
|
10
|
+
return randomStringByLength(length, allCharacter);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const randomStringByLength = (length: number, str = textLowCase) => {
|
|
14
|
+
let result = "";
|
|
15
|
+
|
|
16
|
+
for (let i = 0; i < length; i++) {
|
|
17
|
+
result += str.charAt(Math.floor(Math.random() * str.length));
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const random = { randAllCharacterByLength, randomStringByLength };
|
|
23
|
+
|
|
24
|
+
export default random;
|
package/src/string/trimNull.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import trim from "lodash/trim";
|
|
2
|
-
|
|
3
|
-
export function trimNull(str: string) {
|
|
4
|
-
if (!str) return "";
|
|
5
|
-
str = str.toString();
|
|
6
|
-
str = str.replace(/\0/g, "");
|
|
7
|
-
|
|
8
|
-
while (str.indexOf(" ") >= 0) {
|
|
9
|
-
str = str.replaceAll(" ", " ");
|
|
10
|
-
}
|
|
11
|
-
str = trim(str);
|
|
12
|
-
|
|
13
|
-
return str;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export default trimNull;
|
|
1
|
+
import trim from "lodash/trim";
|
|
2
|
+
|
|
3
|
+
export function trimNull(str: string) {
|
|
4
|
+
if (!str) return "";
|
|
5
|
+
str = str.toString();
|
|
6
|
+
str = str.replace(/\0/g, "");
|
|
7
|
+
|
|
8
|
+
while (str.indexOf(" ") >= 0) {
|
|
9
|
+
str = str.replaceAll(" ", " ");
|
|
10
|
+
}
|
|
11
|
+
str = trim(str);
|
|
12
|
+
|
|
13
|
+
return str;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default trimNull;
|
package/src/string/url.ts
CHANGED
|
@@ -1,116 +1,116 @@
|
|
|
1
|
-
import { url } from "inspector";
|
|
2
|
-
import { isNull } from "../object";
|
|
3
|
-
|
|
4
|
-
var urlRegex = /(https?:\/\/[^\s]+)/g;
|
|
5
|
-
|
|
6
|
-
export const addQueryParam = (_url: string, key: string, value: any) => {
|
|
7
|
-
_url += (_url.split("?")[1] ? "&" : "?") + `${key}=${value}`;
|
|
8
|
-
|
|
9
|
-
return _url;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const getUrlParams = (parameter: string, staticURL?: string, decode: boolean = true) => {
|
|
13
|
-
if (typeof window == "undefined") return "";
|
|
14
|
-
|
|
15
|
-
staticURL = staticURL == undefined ? window.location.host : staticURL;
|
|
16
|
-
var currLocation = staticURL.length > 0 ? staticURL : window.location.search;
|
|
17
|
-
|
|
18
|
-
if (currLocation.split("?").length < 2) return "";
|
|
19
|
-
|
|
20
|
-
var parArr = currLocation.split("?")[1].split("&"),
|
|
21
|
-
returnBool = true;
|
|
22
|
-
|
|
23
|
-
for (var i = 0; i < parArr.length; i++) {
|
|
24
|
-
var parr = parArr[i].split("=");
|
|
25
|
-
if (parr[0] == parameter) {
|
|
26
|
-
return decode ? decodeURIComponent(parr[1]) : parr[1];
|
|
27
|
-
returnBool = true;
|
|
28
|
-
} else {
|
|
29
|
-
returnBool = false;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (!returnBool) return false;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
*
|
|
38
|
-
* @return {boolean}
|
|
39
|
-
*/
|
|
40
|
-
export const isLink = (str: string) => {
|
|
41
|
-
return urlRegex.test(str);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
// /**
|
|
45
|
-
// *
|
|
46
|
-
// * @return {JSX.Element}
|
|
47
|
-
// */
|
|
48
|
-
// export const strToJsxLink = (str, altText) => {
|
|
49
|
-
// return isLink(str) ? <a href={src}>{altText || src}</a> : str;
|
|
50
|
-
// };
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
*
|
|
54
|
-
* @param {string} url
|
|
55
|
-
* @return {string}
|
|
56
|
-
*/
|
|
57
|
-
export const getFileNameWithoutExtension = (url: string) => {
|
|
58
|
-
url = decodeURIComponent(url);
|
|
59
|
-
if (url) {
|
|
60
|
-
const m = url.toString().match(/.*\/(.+?)\./);
|
|
61
|
-
if (m && m.length > 1) {
|
|
62
|
-
return m[1];
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (!isNull(url)) {
|
|
66
|
-
return url.split(".").shift();
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return "";
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export const getFileNameWithExtension = (url: string) => {
|
|
73
|
-
const _url = decodeURIComponent(url);
|
|
74
|
-
|
|
75
|
-
const m = _url.toString().match(/.*\/(.*)$/) || [];
|
|
76
|
-
|
|
77
|
-
if (typeof m != "undefined" && m?.length > 1) {
|
|
78
|
-
const a = m?.[1].split("/")?.pop() || "";
|
|
79
|
-
const b = a.split("?")?.shift();
|
|
80
|
-
return b || m?.[1] || "";
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (!isNull(_url)) return url;
|
|
84
|
-
|
|
85
|
-
return "";
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
*
|
|
90
|
-
* @param {string} url
|
|
91
|
-
* @return {string}
|
|
92
|
-
*/
|
|
93
|
-
export const getFileExtension = (url: string) => {
|
|
94
|
-
return getFileNameWithExtension(url).split(".").pop();
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
*
|
|
99
|
-
* @param {string} url
|
|
100
|
-
* @returns
|
|
101
|
-
*/
|
|
102
|
-
export const isImage = (url: string) => {
|
|
103
|
-
if (!url) return false;
|
|
104
|
-
|
|
105
|
-
const arr = ["png", "jpg", "jpeg", "jpe", "jif", "jfif", "gif", "svg"];
|
|
106
|
-
|
|
107
|
-
const index = arr.findIndex((item) => {
|
|
108
|
-
return
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
return index >= 0;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
const xurl = { addQueryParam, getUrlParams, isLink, getFileNameWithoutExtension, getFileNameWithExtension, getFileExtension, isImage };
|
|
115
|
-
|
|
116
|
-
export default xurl;
|
|
1
|
+
import { url } from "inspector";
|
|
2
|
+
import { isNull } from "../object";
|
|
3
|
+
|
|
4
|
+
var urlRegex = /(https?:\/\/[^\s]+)/g;
|
|
5
|
+
|
|
6
|
+
export const addQueryParam = (_url: string, key: string, value: any) => {
|
|
7
|
+
_url += (_url.split("?")[1] ? "&" : "?") + `${key}=${value}`;
|
|
8
|
+
|
|
9
|
+
return _url;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const getUrlParams = (parameter: string, staticURL?: string, decode: boolean = true) => {
|
|
13
|
+
if (typeof window == "undefined") return "";
|
|
14
|
+
|
|
15
|
+
staticURL = staticURL == undefined ? window.location.host : staticURL;
|
|
16
|
+
var currLocation = staticURL.length > 0 ? staticURL : window.location.search;
|
|
17
|
+
|
|
18
|
+
if (currLocation.split("?").length < 2) return "";
|
|
19
|
+
|
|
20
|
+
var parArr = currLocation.split("?")[1].split("&"),
|
|
21
|
+
returnBool = true;
|
|
22
|
+
|
|
23
|
+
for (var i = 0; i < parArr.length; i++) {
|
|
24
|
+
var parr = parArr[i].split("=");
|
|
25
|
+
if (parr[0] == parameter) {
|
|
26
|
+
return decode ? decodeURIComponent(parr[1]) : parr[1];
|
|
27
|
+
returnBool = true;
|
|
28
|
+
} else {
|
|
29
|
+
returnBool = false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (!returnBool) return false;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* @return {boolean}
|
|
39
|
+
*/
|
|
40
|
+
export const isLink = (str: string) => {
|
|
41
|
+
return urlRegex.test(str);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// /**
|
|
45
|
+
// *
|
|
46
|
+
// * @return {JSX.Element}
|
|
47
|
+
// */
|
|
48
|
+
// export const strToJsxLink = (str, altText) => {
|
|
49
|
+
// return isLink(str) ? <a href={src}>{altText || src}</a> : str;
|
|
50
|
+
// };
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
* @param {string} url
|
|
55
|
+
* @return {string}
|
|
56
|
+
*/
|
|
57
|
+
export const getFileNameWithoutExtension = (url: string) => {
|
|
58
|
+
url = decodeURIComponent(url);
|
|
59
|
+
if (url) {
|
|
60
|
+
const m = url.toString().match(/.*\/(.+?)\./);
|
|
61
|
+
if (m && m.length > 1) {
|
|
62
|
+
return m[1];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (!isNull(url)) {
|
|
66
|
+
return url.split(".").shift();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return "";
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const getFileNameWithExtension = (url: string) => {
|
|
73
|
+
const _url = decodeURIComponent(url);
|
|
74
|
+
|
|
75
|
+
const m = _url.toString().match(/.*\/(.*)$/) || [];
|
|
76
|
+
|
|
77
|
+
if (typeof m != "undefined" && m?.length > 1) {
|
|
78
|
+
const a = m?.[1].split("/")?.pop() || "";
|
|
79
|
+
const b = a.split("?")?.shift();
|
|
80
|
+
return b || m?.[1] || "";
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (!isNull(_url)) return url;
|
|
84
|
+
|
|
85
|
+
return "";
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
*
|
|
90
|
+
* @param {string} url
|
|
91
|
+
* @return {string}
|
|
92
|
+
*/
|
|
93
|
+
export const getFileExtension = (url: string) => {
|
|
94
|
+
return getFileNameWithExtension(url).split(".").pop();
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
*
|
|
99
|
+
* @param {string} url
|
|
100
|
+
* @returns
|
|
101
|
+
*/
|
|
102
|
+
export const isImage = (url: string) => {
|
|
103
|
+
if (!url) return false;
|
|
104
|
+
|
|
105
|
+
const arr = [".png", ".jpg", ".jpeg", ".jpe", ".jif", ".jfif", ".gif", ".svg"];
|
|
106
|
+
|
|
107
|
+
const index = arr.findIndex((item) => {
|
|
108
|
+
return url.indexOf(item) >= 0;
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
return index >= 0;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const xurl = { addQueryParam, getUrlParams, isLink, getFileNameWithoutExtension, getFileNameWithExtension, getFileExtension, isImage };
|
|
115
|
+
|
|
116
|
+
export default xurl;
|
package/dist/Checker.d.ts
DELETED
package/dist/Checker.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isJSON = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Check if the object or string is in JSON format
|
|
6
|
-
*/
|
|
7
|
-
const isJSON = (content) => {
|
|
8
|
-
if (typeof content == "object") {
|
|
9
|
-
try {
|
|
10
|
-
content = JSON.stringify(content);
|
|
11
|
-
}
|
|
12
|
-
catch (err) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
if (typeof content == "string") {
|
|
17
|
-
try {
|
|
18
|
-
content = JSON.parse(content);
|
|
19
|
-
}
|
|
20
|
-
catch (err) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
if (typeof content != "object") {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
return true;
|
|
28
|
-
};
|
|
29
|
-
exports.isJSON = isJSON;
|
|
30
|
-
const Checker = { isJSON: exports.isJSON };
|
|
31
|
-
exports.default = Checker;
|
|
32
|
-
//# sourceMappingURL=Checker.js.map
|
package/dist/Checker.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Checker.js","sourceRoot":"","sources":["../src/Checker.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACI,MAAM,MAAM,GAAG,CAAC,OAAwB,EAAE,EAAE;IAClD,IAAI,OAAO,OAAO,IAAI,QAAQ,EAAE;QAC/B,IAAI;YACH,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;SAClC;QAAC,OAAO,GAAG,EAAE;YACb,OAAO,KAAK,CAAC;SACb;KACD;IAED,IAAI,OAAO,OAAO,IAAI,QAAQ,EAAE;QAC/B,IAAI;YACH,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;SAC9B;QAAC,OAAO,GAAG,EAAE;YACb,OAAO,KAAK,CAAC;SACb;KACD;IAED,IAAI,OAAO,OAAO,IAAI,QAAQ,EAAE;QAC/B,OAAO,KAAK,CAAC;KACb;IACD,OAAO,IAAI,CAAC;AACb,CAAC,CAAC;AArBW,QAAA,MAAM,UAqBjB;AAEF,MAAM,OAAO,GAAG,EAAE,MAAM,EAAN,cAAM,EAAE,CAAC;AAE3B,kBAAe,OAAO,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
declare class EventDispatcher {
|
|
2
|
-
constructor();
|
|
3
|
-
_listeners: any;
|
|
4
|
-
addEventListener(type: string, listener: any): void;
|
|
5
|
-
hasEventListener(type: string, listener: any): boolean;
|
|
6
|
-
removeEventListener(type: string, listener: any): void;
|
|
7
|
-
dispatchEvent(event: {
|
|
8
|
-
type: string;
|
|
9
|
-
target: any;
|
|
10
|
-
}): void;
|
|
11
|
-
}
|
|
12
|
-
export { EventDispatcher };
|
|
13
|
-
export default EventDispatcher;
|
package/dist/EventDispatcher.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EventDispatcher = void 0;
|
|
4
|
-
class EventDispatcher {
|
|
5
|
-
constructor() { }
|
|
6
|
-
addEventListener(type, listener) {
|
|
7
|
-
if (this._listeners === undefined)
|
|
8
|
-
this._listeners = {};
|
|
9
|
-
const listeners = this._listeners;
|
|
10
|
-
if (listeners[type] === undefined) {
|
|
11
|
-
listeners[type] = [];
|
|
12
|
-
}
|
|
13
|
-
if (listeners[type].indexOf(listener) === -1) {
|
|
14
|
-
listeners[type].push(listener);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
hasEventListener(type, listener) {
|
|
18
|
-
if (this._listeners === undefined)
|
|
19
|
-
return false;
|
|
20
|
-
const listeners = this._listeners;
|
|
21
|
-
return listeners[type] !== undefined && listeners[type].indexOf(listener) !== -1;
|
|
22
|
-
}
|
|
23
|
-
removeEventListener(type, listener) {
|
|
24
|
-
if (this._listeners === undefined)
|
|
25
|
-
return;
|
|
26
|
-
const listeners = this._listeners;
|
|
27
|
-
const listenerArray = listeners[type];
|
|
28
|
-
if (listenerArray !== undefined) {
|
|
29
|
-
const index = listenerArray.indexOf(listener);
|
|
30
|
-
if (index !== -1) {
|
|
31
|
-
listenerArray.splice(index, 1);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
dispatchEvent(event) {
|
|
36
|
-
if (this._listeners === undefined)
|
|
37
|
-
return;
|
|
38
|
-
const listeners = this._listeners;
|
|
39
|
-
const listenerArray = listeners[event.type];
|
|
40
|
-
if (listenerArray !== undefined) {
|
|
41
|
-
event.target = this;
|
|
42
|
-
// Make a copy, in case listeners are removed while iterating.
|
|
43
|
-
const array = listenerArray.slice(0);
|
|
44
|
-
for (let i = 0, l = array.length; i < l; i++) {
|
|
45
|
-
array[i].call(this, event);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.EventDispatcher = EventDispatcher;
|
|
51
|
-
exports.default = EventDispatcher;
|
|
52
|
-
//# sourceMappingURL=EventDispatcher.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EventDispatcher.js","sourceRoot":"","sources":["../src/EventDispatcher.ts"],"names":[],"mappings":";;;AAAA,MAAM,eAAe;IACpB,gBAAe,CAAC;IAIhB,gBAAgB,CAAC,IAAY,EAAE,QAAa;QAC3C,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS;YAAE,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QAExD,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC;QAElC,IAAI,SAAS,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE;YAClC,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;SACrB;QAED,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE;YAC7C,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAC/B;IACF,CAAC;IAED,gBAAgB,CAAC,IAAY,EAAE,QAAa;QAC3C,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QAEhD,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC;QAElC,OAAO,SAAS,CAAC,IAAI,CAAC,KAAK,SAAS,IA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-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FileUpload = void 0;
|
|
4
|
-
var logFile = "[FileUpload.js] ";
|
|
5
|
-
const FileUpload = {
|
|
6
|
-
uploadBlob(props) {
|
|
7
|
-
const { blob, url, params, onComplete, onError } = props;
|
|
8
|
-
var formData = new FormData();
|
|
9
|
-
formData.append("upload", blob, "img_" + +new Date() + ".jpg");
|
|
10
|
-
if (params) {
|
|
11
|
-
Object.keys(params).forEach((key) => {
|
|
12
|
-
var val = params[key];
|
|
13
|
-
formData.append(key, val);
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
var request = new XMLHttpRequest();
|
|
17
|
-
request.open("POST", url);
|
|
18
|
-
request.send(formData);
|
|
19
|
-
request.onreadystatechange = function () {
|
|
20
|
-
if (this.readyState == 4) {
|
|
21
|
-
// Typical action to be performed when the document is ready:
|
|
22
|
-
if (this.status == 200) {
|
|
23
|
-
// var response = JSON.parse(request.response) || "";
|
|
24
|
-
var response = {};
|
|
25
|
-
try {
|
|
26
|
-
response = JSON.parse(request.response) || "";
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
console.error(logFile, "Can't part JSON of the response");
|
|
30
|
-
}
|
|
31
|
-
var statusOfSafety = response.status || 0;
|
|
32
|
-
if (statusOfSafety == 1) {
|
|
33
|
-
console.log(logFile, "request: ", request);
|
|
34
|
-
var data = response.data || {};
|
|
35
|
-
console.log(logFile, data);
|
|
36
|
-
var _url = data["url"];
|
|
37
|
-
if (onComplete)
|
|
38
|
-
onComplete(_url);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
var errMsg = "Ảnh có nội dung không phù hợp.";
|
|
42
|
-
console.error(logFile, errMsg);
|
|
43
|
-
if (onError)
|
|
44
|
-
onError(errMsg);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
var errMsg = "Upload ảnh không thành công!";
|
|
49
|
-
console.error(logFile, errMsg);
|
|
50
|
-
if (onError)
|
|
51
|
-
onError(errMsg);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
request.onerror = function (res) {
|
|
56
|
-
var errMsg = "Upload ảnh không thành công!";
|
|
57
|
-
console.error(logFile, errMsg, "=>", res);
|
|
58
|
-
if (onError)
|
|
59
|
-
onError(errMsg);
|
|
60
|
-
};
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
exports.FileUpload = FileUpload;
|
|
64
|
-
exports.default = FileUpload;
|
|
65
|
-
//# sourceMappingURL=FileUpload.js.map
|
package/dist/FileUpload.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FileUpload.js","sourceRoot":"","sources":["../src/FileUpload.ts"],"names":[],"mappings":";;;AAAA,IAAI,OAAO,GAAG,kBAAkB,CAAC;AAIjC,MAAM,UAAU,GAAG;IAClB,UAAU,CAAC,KAAmB;QAC7B,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;QAEzD,IAAI,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC9B,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,IAAI,IAAI,EAAE,GAAG,MAAM,CAAC,CAAC;QAE/D,IAAI,MAAM,EAAE;YACX,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBACnC,IAAI,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;gBACtB,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC;SACH;QAED,IAAI,OAAO,GAAG,IAAI,cAAc,EAAE,CAAC;QACnC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC1B,O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