diginext-utils 2.1.19 → 2.1.21
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/Checker.d.ts +8 -0
- package/dist/Checker.js +32 -0
- package/dist/Checker.js.map +1 -0
- package/dist/EventDispatcher.d.ts +13 -0
- package/dist/EventDispatcher.js +52 -0
- package/dist/EventDispatcher.js.map +1 -0
- package/dist/FileUpload.d.ts +12 -0
- package/dist/FileUpload.js +65 -0
- package/dist/FileUpload.js.map +1 -0
- package/dist/Slug.d.ts +9 -0
- package/dist/Slug.js +334 -0
- package/dist/Slug.js.map +1 -0
- package/dist/Timer.d.ts +4 -0
- package/dist/Timer.js +9 -0
- package/dist/Timer.js.map +1 -0
- package/dist/Validation.d.ts +5 -0
- package/dist/Validation.js +39 -0
- package/dist/Validation.js.map +1 -0
- package/dist/array.d.ts +113 -0
- package/dist/array.js +298 -0
- package/dist/array.js.map +1 -0
- package/dist/color.d.ts +25 -0
- package/dist/color.js +96 -0
- package/dist/color.js.map +1 -0
- package/dist/console/enableConsole.d.ts +2 -0
- package/dist/console/enableConsole.js +14 -0
- package/dist/console/enableConsole.js.map +1 -0
- package/dist/console/index.d.ts +11 -0
- package/dist/console/index.js +18 -0
- package/dist/console/index.js.map +1 -0
- package/dist/console/log.d.ts +15 -0
- package/dist/console/log.js +45 -0
- package/dist/console/log.js.map +1 -0
- package/dist/device/browser.d.ts +5 -0
- package/dist/device/browser.js +38 -0
- package/dist/device/browser.js.map +1 -0
- package/dist/device/camera.d.ts +7 -0
- package/dist/device/camera.js +172 -0
- package/dist/device/camera.js.map +1 -0
- package/dist/device/index.d.ts +5 -0
- package/dist/device/index.js +225 -0
- package/dist/device/index.js.map +1 -0
- package/dist/device/os.d.ts +11 -0
- package/dist/device/os.js +38 -0
- package/dist/device/os.js.map +1 -0
- package/dist/file/createDir.d.ts +5 -0
- package/dist/file/createDir.js +16 -0
- package/dist/file/createDir.js.map +1 -0
- package/dist/file/fileMove.d.ts +4 -0
- package/dist/file/fileMove.js +33 -0
- package/dist/file/fileMove.js.map +1 -0
- package/dist/file/findFilesByExt.d.ts +13 -0
- package/dist/file/findFilesByExt.js +50 -0
- package/dist/file/findFilesByExt.js.map +1 -0
- package/dist/file/getAllFiles.d.ts +1 -0
- package/dist/file/getAllFiles.js +27 -0
- package/dist/file/getAllFiles.js.map +1 -0
- package/dist/file/index.d.ts +9 -0
- package/dist/file/index.js +11 -0
- package/dist/file/index.js.map +1 -0
- package/dist/gameboi/index.d.ts +10 -0
- package/dist/gameboi/index.js +68 -0
- package/dist/gameboi/index.js.map +1 -0
- package/dist/images/downloadByUrl.d.ts +1 -0
- package/dist/images/downloadByUrl.js +56 -0
- package/dist/images/downloadByUrl.js.map +1 -0
- package/dist/images/index.d.ts +2 -0
- package/dist/images/index.js +9 -0
- package/dist/images/index.js.map +1 -0
- package/dist/images/loadImage.d.ts +1 -0
- package/dist/images/loadImage.js +18 -0
- package/dist/images/loadImage.js.map +1 -0
- package/dist/images/resize.d.ts +2 -0
- package/dist/images/resize.js +38 -0
- package/dist/images/resize.js.map +1 -0
- package/dist/images/upload.d.ts +10 -0
- package/dist/images/upload.js +27 -0
- package/dist/images/upload.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +63 -0
- package/dist/index.js.map +1 -0
- package/dist/json.d.ts +8 -0
- package/dist/json.js +32 -0
- package/dist/json.js.map +1 -0
- package/dist/math/diffDate.d.ts +5 -0
- package/dist/math/diffDate.js +14 -0
- package/dist/math/diffDate.js.map +1 -0
- package/dist/math/index.d.ts +30 -0
- package/dist/math/index.js +93 -0
- package/dist/math/index.js.map +1 -0
- package/dist/math/positiveNumber.d.ts +2 -0
- package/dist/math/positiveNumber.js +17 -0
- package/dist/math/positiveNumber.js.map +1 -0
- package/dist/name/en.d.ts +5 -0
- package/dist/name/en.js +26 -0
- package/dist/name/en.js.map +1 -0
- package/dist/name/index.d.ts +12 -0
- package/dist/name/index.js +13 -0
- package/dist/name/index.js.map +1 -0
- package/dist/name/vi.d.ts +5 -0
- package/dist/name/vi.js +28 -0
- package/dist/name/vi.js.map +1 -0
- package/dist/object.d.ts +59 -0
- package/dist/object.js +80 -0
- package/dist/object.js.map +1 -0
- package/dist/permission/index.d.ts +8 -0
- package/dist/permission/index.js +7 -0
- package/dist/permission/index.js.map +1 -0
- package/dist/permission/requestCamera.d.ts +5 -0
- package/dist/permission/requestCamera.js +43 -0
- package/dist/permission/requestCamera.js.map +1 -0
- package/dist/permission/requestDeviceOrientationControl.d.ts +2 -0
- package/dist/permission/requestDeviceOrientationControl.js +39 -0
- package/dist/permission/requestDeviceOrientationControl.js.map +1 -0
- package/dist/response/index.d.ts +49 -0
- package/dist/response/index.js +52 -0
- package/dist/response/index.js.map +1 -0
- package/dist/string/convertPathnameAndQuery.d.ts +4 -0
- package/dist/string/convertPathnameAndQuery.js +25 -0
- package/dist/string/convertPathnameAndQuery.js.map +1 -0
- package/dist/string/formatNumber.d.ts +6 -0
- package/dist/string/formatNumber.js +15 -0
- package/dist/string/formatNumber.js.map +1 -0
- package/dist/string/generatePassword.d.ts +9 -0
- package/dist/string/generatePassword.js +24 -0
- package/dist/string/generatePassword.js.map +1 -0
- package/dist/string/generateUUID.d.ts +2 -0
- package/dist/string/generateUUID.js +37 -0
- package/dist/string/generateUUID.js.map +1 -0
- package/dist/string/getTextBetweenCharByIndex.d.ts +1 -0
- package/dist/string/getTextBetweenCharByIndex.js +21 -0
- package/dist/string/getTextBetweenCharByIndex.js.map +1 -0
- package/dist/string/index.d.ts +65 -0
- package/dist/string/index.js +162 -0
- package/dist/string/index.js.map +1 -0
- package/dist/string/indexesOf.d.ts +1 -0
- package/dist/string/indexesOf.js +15 -0
- package/dist/string/indexesOf.js.map +1 -0
- package/dist/string/makeDaySlug.d.ts +31 -0
- package/dist/string/makeDaySlug.js +23 -0
- package/dist/string/makeDaySlug.js.map +1 -0
- package/dist/string/random.d.ts +18 -0
- package/dist/string/random.js +41 -0
- package/dist/string/random.js.map +1 -0
- package/dist/string/trimNull.d.ts +2 -0
- package/dist/string/trimNull.js +21 -0
- package/dist/string/trimNull.js.map +1 -0
- package/dist/string/url.d.ts +22 -0
- package/dist/string/url.js +75 -0
- package/dist/string/url.js.map +1 -0
- package/esm/Checker.d.ts +8 -0
- package/esm/Checker.js +28 -0
- package/esm/Checker.js.map +1 -0
- package/esm/EventDispatcher.d.ts +13 -0
- package/esm/EventDispatcher.js +49 -0
- package/esm/EventDispatcher.js.map +1 -0
- package/esm/FileUpload.d.ts +12 -0
- package/esm/FileUpload.js +62 -0
- package/esm/FileUpload.js.map +1 -0
- package/esm/Slug.d.ts +9 -0
- package/esm/Slug.js +330 -0
- package/esm/Slug.js.map +1 -0
- package/esm/Timer.d.ts +4 -0
- package/esm/Timer.js +7 -0
- package/esm/Timer.js.map +1 -0
- package/esm/Validation.d.ts +5 -0
- package/esm/Validation.js +37 -0
- package/esm/Validation.js.map +1 -0
- package/esm/array.d.ts +113 -0
- package/esm/array.js +276 -0
- package/esm/array.js.map +1 -0
- package/esm/color.d.ts +25 -0
- package/esm/color.js +86 -0
- package/esm/color.js.map +1 -0
- package/esm/console/enableConsole.d.ts +2 -0
- package/esm/console/enableConsole.js +7 -0
- package/esm/console/enableConsole.js.map +1 -0
- package/esm/console/index.d.ts +11 -0
- package/esm/console/index.js +13 -0
- package/esm/console/index.js.map +1 -0
- package/esm/console/log.d.ts +15 -0
- package/esm/console/log.js +33 -0
- package/esm/console/log.js.map +1 -0
- package/esm/device/browser.d.ts +5 -0
- package/esm/device/browser.js +30 -0
- package/esm/device/browser.js.map +1 -0
- package/esm/device/camera.d.ts +7 -0
- package/esm/device/camera.js +168 -0
- package/esm/device/camera.js.map +1 -0
- package/esm/device/index.d.ts +5 -0
- package/esm/device/index.js +217 -0
- package/esm/device/index.js.map +1 -0
- package/esm/device/os.d.ts +11 -0
- package/esm/device/os.js +28 -0
- package/esm/device/os.js.map +1 -0
- package/esm/file/createDir.d.ts +5 -0
- package/esm/file/createDir.js +13 -0
- package/esm/file/createDir.js.map +1 -0
- package/esm/file/fileMove.d.ts +4 -0
- package/esm/file/fileMove.js +29 -0
- package/esm/file/fileMove.js.map +1 -0
- package/esm/file/findFilesByExt.d.ts +13 -0
- package/esm/file/findFilesByExt.js +46 -0
- package/esm/file/findFilesByExt.js.map +1 -0
- package/esm/file/getAllFiles.d.ts +1 -0
- package/esm/file/getAllFiles.js +21 -0
- package/esm/file/getAllFiles.js.map +1 -0
- package/esm/file/index.d.ts +9 -0
- package/esm/file/index.js +6 -0
- package/esm/file/index.js.map +1 -0
- package/esm/gameboi/index.d.ts +10 -0
- package/esm/gameboi/index.js +62 -0
- package/esm/gameboi/index.js.map +1 -0
- package/esm/images/downloadByUrl.d.ts +1 -0
- package/esm/images/downloadByUrl.js +53 -0
- package/esm/images/downloadByUrl.js.map +1 -0
- package/esm/images/index.d.ts +2 -0
- package/esm/images/index.js +4 -0
- package/esm/images/index.js.map +1 -0
- package/esm/images/loadImage.d.ts +1 -0
- package/esm/images/loadImage.js +15 -0
- package/esm/images/loadImage.js.map +1 -0
- package/esm/images/resize.d.ts +2 -0
- package/esm/images/resize.js +31 -0
- package/esm/images/resize.js.map +1 -0
- package/esm/images/upload.d.ts +10 -0
- package/esm/images/upload.js +20 -0
- package/esm/images/upload.js.map +1 -0
- package/esm/index.d.ts +37 -0
- package/esm/index.js +38 -0
- package/esm/index.js.map +1 -0
- package/esm/json.d.ts +8 -0
- package/esm/json.js +28 -0
- package/esm/json.js.map +1 -0
- package/esm/math/diffDate.d.ts +5 -0
- package/esm/math/diffDate.js +10 -0
- package/esm/math/diffDate.js.map +1 -0
- package/esm/math/index.d.ts +30 -0
- package/esm/math/index.js +78 -0
- package/esm/math/index.js.map +1 -0
- package/esm/math/positiveNumber.d.ts +2 -0
- package/esm/math/positiveNumber.js +13 -0
- package/esm/math/positiveNumber.js.map +1 -0
- package/esm/name/en.d.ts +5 -0
- package/esm/name/en.js +22 -0
- package/esm/name/en.js.map +1 -0
- package/esm/name/index.d.ts +12 -0
- package/esm/name/index.js +6 -0
- package/esm/name/index.js.map +1 -0
- package/esm/name/vi.d.ts +5 -0
- package/esm/name/vi.js +24 -0
- package/esm/name/vi.js.map +1 -0
- package/esm/object.d.ts +59 -0
- package/esm/object.js +70 -0
- package/esm/object.js.map +1 -0
- package/esm/permission/index.d.ts +8 -0
- package/esm/permission/index.js +5 -0
- package/esm/permission/index.js.map +1 -0
- package/esm/permission/requestCamera.d.ts +5 -0
- package/esm/permission/requestCamera.js +39 -0
- package/esm/permission/requestCamera.js.map +1 -0
- package/esm/permission/requestDeviceOrientationControl.d.ts +2 -0
- package/esm/permission/requestDeviceOrientationControl.js +35 -0
- package/esm/permission/requestDeviceOrientationControl.js.map +1 -0
- package/esm/response/index.d.ts +49 -0
- package/esm/response/index.js +46 -0
- package/esm/response/index.js.map +1 -0
- package/esm/string/convertPathnameAndQuery.d.ts +4 -0
- package/esm/string/convertPathnameAndQuery.js +22 -0
- package/esm/string/convertPathnameAndQuery.js.map +1 -0
- package/esm/string/formatNumber.d.ts +6 -0
- package/esm/string/formatNumber.js +11 -0
- package/esm/string/formatNumber.js.map +1 -0
- package/esm/string/generatePassword.d.ts +9 -0
- package/esm/string/generatePassword.js +20 -0
- package/esm/string/generatePassword.js.map +1 -0
- package/esm/string/generateUUID.d.ts +2 -0
- package/esm/string/generateUUID.js +33 -0
- package/esm/string/generateUUID.js.map +1 -0
- package/esm/string/getTextBetweenCharByIndex.d.ts +1 -0
- package/esm/string/getTextBetweenCharByIndex.js +15 -0
- package/esm/string/getTextBetweenCharByIndex.js.map +1 -0
- package/esm/string/index.d.ts +65 -0
- package/esm/string/index.js +151 -0
- package/esm/string/index.js.map +1 -0
- package/esm/string/indexesOf.d.ts +1 -0
- package/esm/string/indexesOf.js +12 -0
- package/esm/string/indexesOf.js.map +1 -0
- package/esm/string/makeDaySlug.d.ts +31 -0
- package/esm/string/makeDaySlug.js +16 -0
- package/esm/string/makeDaySlug.js.map +1 -0
- package/esm/string/random.d.ts +18 -0
- package/esm/string/random.js +34 -0
- package/esm/string/random.js.map +1 -0
- package/esm/string/trimNull.d.ts +2 -0
- package/esm/string/trimNull.js +14 -0
- package/esm/string/trimNull.js.map +1 -0
- package/esm/string/url.d.ts +22 -0
- package/esm/string/url.js +65 -0
- package/esm/string/url.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexesOf.js","sourceRoot":"","sources":["../../src/string/indexesOf.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,GAAW,EAAE,KAAU;IACxD,IAAI,KAAU,EACb,OAAO,GAAG,EAAS,CAAC;IAErB,MAAM,IAAI,GAAG,EAAE,CAAC;IAEhB,KAAK,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;IAE1B,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE;QACjC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;QAC/C,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;KACvB;IAED,OAAO,IAAI,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
type DaySlugOptions = {
|
|
2
|
+
/**
|
|
3
|
+
* @default ""
|
|
4
|
+
*/
|
|
5
|
+
prefix?: string;
|
|
6
|
+
/**
|
|
7
|
+
* @default ""
|
|
8
|
+
*/
|
|
9
|
+
surfix?: string;
|
|
10
|
+
/**
|
|
11
|
+
* @default true
|
|
12
|
+
*/
|
|
13
|
+
useDate?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* @default true
|
|
16
|
+
*/
|
|
17
|
+
useTime?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* @default "-"
|
|
20
|
+
*/
|
|
21
|
+
divider?: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Format the input number with commas
|
|
25
|
+
* @example 1000000 -> 1,000,000
|
|
26
|
+
*/
|
|
27
|
+
export declare function makeDaySlug(options?: DaySlugOptions): string;
|
|
28
|
+
declare const _default: {
|
|
29
|
+
makeDaySlug: typeof makeDaySlug;
|
|
30
|
+
};
|
|
31
|
+
export default _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
/**
|
|
3
|
+
* Format the input number with commas
|
|
4
|
+
* @example 1000000 -> 1,000,000
|
|
5
|
+
*/
|
|
6
|
+
export function makeDaySlug(options = {}) {
|
|
7
|
+
const { prefix = "", surfix = "", divider = "-", useDate = true, useTime = true } = options;
|
|
8
|
+
let mainStr = "";
|
|
9
|
+
if (useDate)
|
|
10
|
+
mainStr += dayjs().format(`YYYY${divider}MM${divider}DD`);
|
|
11
|
+
if (useTime)
|
|
12
|
+
mainStr += (mainStr == "" ? "" : divider) + dayjs().format(`HH${divider}mm${divider}ss`);
|
|
13
|
+
return prefix + (prefix ? divider : "") + mainStr + (surfix ? divider : "") + surfix;
|
|
14
|
+
}
|
|
15
|
+
export default { makeDaySlug };
|
|
16
|
+
//# sourceMappingURL=makeDaySlug.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"makeDaySlug.js","sourceRoot":"","sources":["../../src/string/makeDaySlug.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAyB1B;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,UAA0B,EAAE;IACvD,MAAM,EAAE,MAAM,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,EAAE,OAAO,GAAG,GAAG,EAAE,OAAO,GAAG,IAAI,EAAE,OAAO,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAE5F,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,IAAI,OAAO;QAAE,OAAO,IAAI,KAAK,EAAE,CAAC,MAAM,CAAC,OAAO,OAAO,KAAK,OAAO,IAAI,CAAC,CAAC;IACvE,IAAI,OAAO;QAAE,OAAO,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,KAAK,EAAE,CAAC,MAAM,CAAC,KAAK,OAAO,KAAK,OAAO,IAAI,CAAC,CAAC;IAEtG,OAAO,MAAM,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC;AACtF,CAAC;AAED,eAAe,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const textLowCase = "abcdefghijklmnopqrstuvwxyz";
|
|
2
|
+
export declare const numeric = "0123456789";
|
|
3
|
+
export declare const punctuation = "!@#$%^&*()_+~|}{[];?><,./-=";
|
|
4
|
+
export declare const allCharacter = "\u0111\u0110a\u00E1\u00E0\u1EA3\u00E3\u1EA1\u0103\u1EAF\u1EB1\u1EB3\u1EB5\u1EB7\u00E2\u1EA5\u1EA7\u1EA9\u1EAB\u1EADe\u00E9\u00E8\u1EBB\u1EBD\u1EB9\u00EA\u1EBF\u1EC1\u1EC3\u1EC5\u1EC7o\u00F3\u00F2\u1ECF\u00F5\u1ECD\u00F4\u1ED1\u1ED3\u1ED5\u1ED7\u1ED9\u01A1\u1EDB\u1EDD\u1EDF\u1EE1\u1EE3i\u00ED\u00EC\u1EC9\u0129\u1ECBu\u00FA\u00F9\u1EE7\u0169\u1EE5\u01B0\u1EE9\u1EEB\u1EED\u1EEF\u1EF1y\u00FD\u1EF3\u1EF7\u1EF9\u1EF5A\u00C1\u00C0\u1EA2\u00C3\u1EA0\u0102\u1EAE\u1EB0\u1EB2\u1EB4\u1EB6\u00C2\u1EA4\u1EA6\u1EA8\u1EAA\u1EACE\u00C9\u00C8\u1EBA\u1EBC\u1EB8\u00CA\u1EBE\u1EC0\u1EC2\u1EC4\u1EC6O\u00D3\u00D2\u1ECE\u00D5\u1ECC\u00D4\u1ED0\u1ED2\u1ED4\u1ED6\u1ED8\u01A0\u1EDA\u1EDC\u1EDE\u1EE0\u1EE2I\u00CD\u00CC\u1EC8\u0128\u1ECAU\u00DA\u00D9\u1EE6\u0168\u1EE4\u01AF\u1EE8\u1EEA\u1EEC\u1EEE\u1EF0Y\u00DD\u1EF2 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}";
|
|
5
|
+
/**
|
|
6
|
+
* allCharacter = `đĐaáàảãạăắằẳẵặâấầẩẫậeéèẻẽẹêếềểễệoóòỏõọôốồổỗộơớờởỡợiíìỉĩịuúùủũụưứừửữựyýỳỷỹỵAÁÀẢÃẠĂẮẰẲẴẶÂẤẦẨẪẬEÉÈẺẼẸÊẾỀỂỄỆOÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢIÍÌỈĨỊUÚÙỦŨỤƯỨỪỬỮỰYÝỲ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_\`abcdefghijklmnopqrstuvwxyz{|}`;
|
|
7
|
+
*/
|
|
8
|
+
export declare const randAllCharacterByLength: (length?: number) => string;
|
|
9
|
+
export declare const randomStringByLength: (length: number, str?: string) => string;
|
|
10
|
+
export declare const randomStringAndNumberByLength: (length: number, str?: string) => string;
|
|
11
|
+
export declare const uniqueSortByTime: (length?: number, str?: string) => string;
|
|
12
|
+
declare const random: {
|
|
13
|
+
randAllCharacterByLength: (length?: number) => string;
|
|
14
|
+
randomStringByLength: (length: number, str?: string) => string;
|
|
15
|
+
randomStringAndNumberByLength: (length: number, str?: string) => string;
|
|
16
|
+
uniqueSortByTime: (length?: number, str?: string) => string;
|
|
17
|
+
};
|
|
18
|
+
export default random;
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
* allCharacter = `đĐaáàảãạăắằẳẵặâấầẩẫậeéèẻẽẹêếềểễệoóòỏõọôốồổỗộơớờởỡợiíìỉĩịuúùủũụưứừửữựyýỳỷỹỵAÁÀẢÃẠĂẮẰẲẴẶÂẤẦẨẪẬEÉÈẺẼẸÊẾỀỂỄỆOÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢIÍÌỈĨỊUÚÙỦŨỤƯỨỪỬỮỰYÝỲ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_\`abcdefghijklmnopqrstuvwxyz{|}`;
|
|
7
|
+
*/
|
|
8
|
+
export const randAllCharacterByLength = (length = 0) => {
|
|
9
|
+
return randomStringByLength(length, allCharacter);
|
|
10
|
+
};
|
|
11
|
+
export const randomStringByLength = (length, str = textLowCase) => {
|
|
12
|
+
let result = "";
|
|
13
|
+
for (let i = 0; i < length; i++) {
|
|
14
|
+
result += str.charAt(Math.floor(Math.random() * str.length));
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
};
|
|
18
|
+
export const randomStringAndNumberByLength = (length, str = `${textLowCase}${numeric}`) => {
|
|
19
|
+
let result = "";
|
|
20
|
+
for (let i = 0; i < length; i++) {
|
|
21
|
+
result += str.charAt(Math.floor(Math.random() * str.length));
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
export const uniqueSortByTime = (length = 6, str = `${textLowCase}${numeric}`) => {
|
|
26
|
+
let result = `${+new Date()}-`;
|
|
27
|
+
for (let i = 0; i < length; i++) {
|
|
28
|
+
result += str.charAt(Math.floor(Math.random() * str.length));
|
|
29
|
+
}
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
const random = { randAllCharacterByLength, randomStringByLength, randomStringAndNumberByLength, uniqueSortByTime };
|
|
33
|
+
export default random;
|
|
34
|
+
//# sourceMappingURL=random.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"random.js","sourceRoot":"","sources":["../../src/string/random.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,4BAA4B,CAAC;AACxD,MAAM,CAAC,MAAM,OAAO,GAAG,YAAY,CAAC;AACpC,MAAM,CAAC,MAAM,WAAW,GAAG,6BAA6B,CAAC;AACzD,MAAM,CAAC,MAAM,YAAY,GAAG,gPAAgP,CAAC;AAE7Q;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,EAAE;IACtD,OAAO,oBAAoB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AACnD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,MAAc,EAAE,GAAG,GAAG,WAAW,EAAE,EAAE;IACzE,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,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+
import trim from "lodash/trim";
|
|
2
|
+
export function trimNull(str) {
|
|
3
|
+
if (!str)
|
|
4
|
+
return "";
|
|
5
|
+
str = str.toString();
|
|
6
|
+
str = str.replace(/\0/g, "");
|
|
7
|
+
while (str.indexOf(" ") >= 0) {
|
|
8
|
+
str = str.replaceAll(" ", " ");
|
|
9
|
+
}
|
|
10
|
+
str = trim(str);
|
|
11
|
+
return str;
|
|
12
|
+
}
|
|
13
|
+
export default trimNull;
|
|
14
|
+
//# sourceMappingURL=trimNull.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trimNull.js","sourceRoot":"","sources":["../../src/string/trimNull.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,aAAa,CAAC;AAE/B,MAAM,UAAU,QAAQ,CAAC,GAAW;IACnC,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IACpB,GAAG,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC;IACrB,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAE7B,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QAC9B,GAAG,GAAG,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;KAChC;IACD,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IAEhB,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const addQueryParam: (_url: string, key: string, value: any) => string;
|
|
2
|
+
export declare const getUrlParams: (parameter: string, staticURL?: string, decode?: boolean) => string | false | undefined;
|
|
3
|
+
export declare const isLink: (str: string) => boolean;
|
|
4
|
+
export declare const getFileNameWithoutExtension: (url: string) => string;
|
|
5
|
+
export declare const getFileNameWithExtension: (url: string) => string;
|
|
6
|
+
export declare const getFileExtension: (url: string) => string | null | undefined;
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param {string} url
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
export declare const isImage: (url: string) => boolean;
|
|
13
|
+
declare const xurl: {
|
|
14
|
+
addQueryParam: (_url: string, key: string, value: any) => string;
|
|
15
|
+
getUrlParams: (parameter: string, staticURL?: string, decode?: boolean) => string | false | undefined;
|
|
16
|
+
isLink: (str: string) => boolean;
|
|
17
|
+
getFileNameWithoutExtension: (url: string) => string;
|
|
18
|
+
getFileNameWithExtension: (url: string) => string;
|
|
19
|
+
getFileExtension: (url: string) => string | null | undefined;
|
|
20
|
+
isImage: (url: string) => boolean;
|
|
21
|
+
};
|
|
22
|
+
export default xurl;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var urlRegex = /(https?:\/\/[^\s]+)/g;
|
|
2
|
+
export const addQueryParam = (_url, key, value) => {
|
|
3
|
+
_url += (_url.split("?")[1] ? "&" : "?") + `${key}=${value}`;
|
|
4
|
+
return _url;
|
|
5
|
+
};
|
|
6
|
+
export const getUrlParams = (parameter, staticURL, decode = true) => {
|
|
7
|
+
if (typeof window == "undefined")
|
|
8
|
+
return "";
|
|
9
|
+
staticURL = staticURL == undefined ? window.location.host : staticURL;
|
|
10
|
+
var currLocation = staticURL.length > 0 ? staticURL : window.location.search;
|
|
11
|
+
if (currLocation.split("?").length < 2)
|
|
12
|
+
return "";
|
|
13
|
+
var parArr = currLocation.split("?")[1].split("&"), returnBool = true;
|
|
14
|
+
for (var i = 0; i < parArr.length; i++) {
|
|
15
|
+
var parr = parArr[i].split("=");
|
|
16
|
+
if (parr[0] == parameter) {
|
|
17
|
+
return decode ? decodeURIComponent(parr[1]) : parr[1];
|
|
18
|
+
returnBool = true;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
returnBool = false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (!returnBool)
|
|
25
|
+
return false;
|
|
26
|
+
};
|
|
27
|
+
export const isLink = (str) => {
|
|
28
|
+
return urlRegex.test(str);
|
|
29
|
+
};
|
|
30
|
+
export const getFileNameWithoutExtension = (url) => {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
return ((_b = (_a = getFileNameWithExtension(url)) === null || _a === void 0 ? void 0 : _a.split(".")) === null || _b === void 0 ? void 0 : _b[0]) || "";
|
|
33
|
+
};
|
|
34
|
+
export const getFileNameWithExtension = (url) => {
|
|
35
|
+
url = url.replaceAll("\\", "/");
|
|
36
|
+
const _url = decodeURIComponent(url);
|
|
37
|
+
const m = `${_url.toString().match(/(?:.*\/)?([^\/]+)/)}`;
|
|
38
|
+
if (m && m.split(",").length > 1) {
|
|
39
|
+
return m.split(",")[1].replace(/(\?.*)|(\&.*)/, "");
|
|
40
|
+
}
|
|
41
|
+
return "";
|
|
42
|
+
};
|
|
43
|
+
export const getFileExtension = (url) => {
|
|
44
|
+
const arr = getFileNameWithExtension(url).split(".");
|
|
45
|
+
if (arr.length > 1)
|
|
46
|
+
return getFileNameWithExtension(url).split(".").pop();
|
|
47
|
+
return null;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* @param {string} url
|
|
52
|
+
* @returns
|
|
53
|
+
*/
|
|
54
|
+
export const isImage = (url) => {
|
|
55
|
+
if (!url)
|
|
56
|
+
return false;
|
|
57
|
+
const arr = [".png", ".jpg", ".jpeg", ".jpe", ".jif", ".jfif", ".gif", ".svg"];
|
|
58
|
+
const index = arr.findIndex((item) => {
|
|
59
|
+
return url.indexOf(item) >= 0;
|
|
60
|
+
});
|
|
61
|
+
return index >= 0;
|
|
62
|
+
};
|
|
63
|
+
const xurl = { addQueryParam, getUrlParams, isLink, getFileNameWithoutExtension, getFileNameWithExtension, getFileExtension, isImage };
|
|
64
|
+
export default xurl;
|
|
65
|
+
//# sourceMappingURL=url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/string/url.ts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C/C,MAAM,GAAG,GAAG,wBAAwB,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACrD,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,wBAAwB,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;IAC1E,OAAO,IAAI,CAAC;AACb,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,GAAW,EAAE,EAAE;IACtC,IAAI,CAAC,GAAG;QAAE,OAAO,KAAK,CAAC;IAEvB,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAE/E,MAAM,KAAK,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE;QACpC,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,IAAI,CAAC,CAAC;AACnB,CAAC,CAAC;AAEF,MAAM,IAAI,GAAG,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,EAAE,2BAA2B,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAAC;AAEvI,eAAe,IAAI,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "diginext-utils",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.21",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"readme": "README.md",
|
|
6
6
|
"homepage": "https://wearetopgroup.com",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"build": "npm run prebuild && tsc --module commonjs --outDir dist && tsc --module esnext --outDir esm && npm run test",
|
|
27
27
|
"build_tsup": "tsup src/**/*.ts --format esm,cjs --dts --legacy-output",
|
|
28
28
|
"prebuild": "rm -rf dist && rm -rf esm",
|
|
29
|
-
"release": "npm run
|
|
29
|
+
"release": "npm run build && npm publish",
|
|
30
30
|
"dev": "npm run prebuild && concurrently \"tsup src/**/*.ts --format esm,cjs --dts --watch\"",
|
|
31
31
|
"test": "mocha test/*.test.js",
|
|
32
32
|
"publish": "npm run build && npm run test && npm publish",
|