diginext-utils 2.0.5 → 2.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.
Files changed (178) hide show
  1. package/dist/Checker.d.ts +0 -1
  2. package/dist/Checker.js +27 -45
  3. package/dist/Checker.js.map +1 -0
  4. package/dist/EventDispatcher.d.ts +1 -3
  5. package/dist/EventDispatcher.js +47 -70
  6. package/dist/EventDispatcher.js.map +1 -0
  7. package/dist/FileUpload.d.ts +0 -1
  8. package/dist/FileUpload.js +61 -79
  9. package/dist/FileUpload.js.map +1 -0
  10. package/dist/Slug.d.ts +0 -1
  11. package/dist/Slug.js +329 -347
  12. package/dist/Slug.js.map +1 -0
  13. package/dist/Timer.d.ts +1 -3
  14. package/dist/Timer.js +8 -32
  15. package/dist/Timer.js.map +1 -0
  16. package/dist/Validation.d.ts +1 -3
  17. package/dist/Validation.js +38 -55
  18. package/dist/Validation.js.map +1 -0
  19. package/dist/array.d.ts +19 -21
  20. package/dist/array.js +264 -242
  21. package/dist/array.js.map +1 -0
  22. package/dist/color.d.ts +7 -9
  23. package/dist/color.js +78 -87
  24. package/dist/color.js.map +1 -0
  25. package/dist/console/enableConsole.d.ts +1 -3
  26. package/dist/console/enableConsole.js +10 -36
  27. package/dist/console/enableConsole.js.map +1 -0
  28. package/dist/console/index.d.ts +3 -5
  29. package/dist/console/index.js +15 -42
  30. package/dist/console/index.js.map +1 -0
  31. package/dist/device/browser.d.ts +5 -7
  32. package/dist/device/browser.js +33 -60
  33. package/dist/device/browser.js.map +1 -0
  34. package/dist/device/camera.d.ts +7 -16
  35. package/dist/device/camera.js +167 -187
  36. package/dist/device/camera.js.map +1 -0
  37. package/dist/device.d.ts +4 -6
  38. package/dist/device.js +210 -190
  39. package/dist/device.js.map +1 -0
  40. package/dist/file/createDir.d.ts +1 -2
  41. package/dist/file/createDir.js +14 -34
  42. package/dist/file/createDir.js.map +1 -0
  43. package/dist/file/fileMove.d.ts +1 -3
  44. package/dist/file/fileMove.js +30 -49
  45. package/dist/file/fileMove.js.map +1 -0
  46. package/dist/file/findFilesByExt.d.ts +0 -1
  47. package/dist/file/findFilesByExt.js +40 -58
  48. package/dist/file/findFilesByExt.js.map +1 -0
  49. package/dist/index.d.ts +16 -12
  50. package/dist/index.js +33 -906
  51. package/dist/index.js.map +1 -0
  52. package/dist/math/diffDate.d.ts +1 -3
  53. package/dist/math/diffDate.js +11 -31
  54. package/dist/math/diffDate.js.map +1 -0
  55. package/dist/math/index.d.ts +8 -10
  56. package/dist/math/index.js +87 -71
  57. package/dist/math/index.js.map +1 -0
  58. package/dist/math/positiveNumber.d.ts +1 -3
  59. package/dist/math/positiveNumber.js +14 -51
  60. package/dist/math/positiveNumber.js.map +1 -0
  61. package/dist/name/en.d.ts +1 -3
  62. package/dist/name/en.js +18 -34
  63. package/dist/name/en.js.map +1 -0
  64. package/dist/name/vi.d.ts +1 -3
  65. package/dist/name/vi.js +24 -60
  66. package/dist/name/vi.js.map +1 -0
  67. package/dist/object.d.ts +9 -11
  68. package/dist/object.js +57 -82
  69. package/dist/object.js.map +1 -0
  70. package/dist/permission/requestCamera.d.ts +2 -3
  71. package/dist/permission/requestCamera.js +38 -47
  72. package/dist/permission/requestCamera.js.map +1 -0
  73. package/dist/permission/requestDeviceOrientationControl.d.ts +0 -1
  74. package/dist/permission/requestDeviceOrientationControl.js +36 -198
  75. package/dist/permission/requestDeviceOrientationControl.js.map +1 -0
  76. package/dist/string/formatNumber.d.ts +1 -3
  77. package/dist/string/formatNumber.js +12 -51
  78. package/dist/string/formatNumber.js.map +1 -0
  79. package/dist/string/generatePassword.d.ts +1 -3
  80. package/dist/string/generatePassword.js +21 -50
  81. package/dist/string/generatePassword.js.map +1 -0
  82. package/dist/string/generateUUID.d.ts +1 -3
  83. package/dist/string/generateUUID.js +34 -35
  84. package/dist/string/generateUUID.js.map +1 -0
  85. package/dist/string/index.d.ts +8 -10
  86. package/dist/string/index.js +119 -127
  87. package/dist/string/index.js.map +1 -0
  88. package/dist/string/random.d.ts +6 -8
  89. package/dist/string/random.js +21 -50
  90. package/dist/string/random.js.map +1 -0
  91. package/dist/string/trimNull.d.ts +1 -3
  92. package/dist/string/trimNull.js +15 -41
  93. package/dist/string/trimNull.js.map +1 -0
  94. package/dist/string/url.d.ts +7 -14
  95. package/dist/string/url.js +93 -108
  96. package/dist/string/url.js.map +1 -0
  97. package/package.json +6 -9
  98. package/src/Checker.ts +27 -0
  99. package/src/EventDispatcher.ts +60 -0
  100. package/src/FileUpload.ts +65 -0
  101. package/src/Slug.ts +364 -0
  102. package/src/Timer.ts +5 -0
  103. package/src/Validation.ts +35 -0
  104. package/src/array.ts +261 -0
  105. package/src/color.ts +89 -0
  106. package/src/console/enableConsole.ts +6 -0
  107. package/src/console/index.ts +11 -0
  108. package/src/device/browser.ts +29 -0
  109. package/src/device/camera.ts +209 -0
  110. package/src/device.ts +223 -0
  111. package/src/file/createDir.ts +14 -0
  112. package/src/file/fileMove.ts +32 -0
  113. package/src/file/findFilesByExt.ts +39 -0
  114. package/src/index.ts +17 -0
  115. package/src/math/diffDate.ts +8 -0
  116. package/src/math/index.ts +88 -0
  117. package/src/math/positiveNumber.ts +10 -0
  118. package/src/name/en.ts +24 -0
  119. package/src/name/vi.ts +21 -0
  120. package/src/object.ts +49 -0
  121. package/src/permission/requestCamera.ts +43 -0
  122. package/src/permission/requestDeviceOrientationControl.ts +33 -0
  123. package/src/string/formatNumber.ts +10 -0
  124. package/src/string/generatePassword.ts +16 -0
  125. package/src/string/generateUUID.ts +35 -0
  126. package/src/string/index.ts +145 -0
  127. package/src/string/random.ts +20 -0
  128. package/src/string/trimNull.ts +11 -0
  129. package/src/string/url.ts +109 -0
  130. package/dist/.DS_Store +0 -0
  131. package/dist/Checker.mjs +0 -26
  132. package/dist/EventDispatcher.mjs +0 -52
  133. package/dist/FileUpload.mjs +0 -60
  134. package/dist/Slug.mjs +0 -328
  135. package/dist/Timer.mjs +0 -7
  136. package/dist/Validation.mjs +0 -34
  137. package/dist/array.mjs +0 -44
  138. package/dist/chunk-2R5DRG2S.mjs +0 -28
  139. package/dist/chunk-3NMJTC44.mjs +0 -146
  140. package/dist/chunk-5AL36RZR.mjs +0 -54
  141. package/dist/chunk-7UXN7I4K.mjs +0 -96
  142. package/dist/chunk-A4YWYLCH.mjs +0 -23
  143. package/dist/chunk-AHFJBIQJ.mjs +0 -10
  144. package/dist/chunk-AKU6F3WT.mjs +0 -11
  145. package/dist/chunk-ALNAD4H7.mjs +0 -10
  146. package/dist/chunk-FOWYH6LL.mjs +0 -38
  147. package/dist/chunk-FTE6FZSH.mjs +0 -24
  148. package/dist/chunk-LXQIKFED.mjs +0 -17
  149. package/dist/chunk-NLQXFCPR.mjs +0 -30
  150. package/dist/chunk-QXFH3X2K.mjs +0 -49
  151. package/dist/chunk-R2BH5I6O.mjs +0 -9
  152. package/dist/chunk-S2U7F2JJ.mjs +0 -207
  153. package/dist/chunk-UKRVCU5M.mjs +0 -171
  154. package/dist/color.mjs +0 -68
  155. package/dist/console/enableConsole.mjs +0 -11
  156. package/dist/console/index.mjs +0 -18
  157. package/dist/device/browser.mjs +0 -39
  158. package/dist/device/camera.mjs +0 -146
  159. package/dist/device.mjs +0 -13
  160. package/dist/file/createDir.mjs +0 -16
  161. package/dist/file/fileMove.mjs +0 -32
  162. package/dist/file/findFilesByExt.mjs +0 -42
  163. package/dist/index.mjs +0 -143
  164. package/dist/math/diffDate.mjs +0 -11
  165. package/dist/math/index.mjs +0 -21
  166. package/dist/math/positiveNumber.mjs +0 -19
  167. package/dist/name/en.mjs +0 -18
  168. package/dist/name/vi.mjs +0 -34
  169. package/dist/object.mjs +0 -17
  170. package/dist/permission/requestCamera.mjs +0 -7
  171. package/dist/permission/requestDeviceOrientationControl.mjs +0 -176
  172. package/dist/string/formatNumber.mjs +0 -13
  173. package/dist/string/generatePassword.mjs +0 -22
  174. package/dist/string/generateUUID.mjs +0 -15
  175. package/dist/string/index.mjs +0 -96
  176. package/dist/string/random.mjs +0 -17
  177. package/dist/string/trimNull.mjs +0 -16
  178. package/dist/string/url.mjs +0 -79
package/dist/Timer.js CHANGED
@@ -1,33 +1,9 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Timer = void 0;
4
+ exports.Timer = {
5
+ wait: async (ms) => {
6
+ return new Promise((resolve) => setTimeout(resolve, ms));
7
+ },
8
8
  };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/Timer.ts
20
- var Timer_exports = {};
21
- __export(Timer_exports, {
22
- Timer: () => Timer
23
- });
24
- module.exports = __toCommonJS(Timer_exports);
25
- var Timer = {
26
- wait: async (ms) => {
27
- return new Promise((resolve) => setTimeout(resolve, ms));
28
- }
29
- };
30
- // Annotate the CommonJS export names for ESM import in node:
31
- 0 && (module.exports = {
32
- Timer
33
- });
9
+ //# sourceMappingURL=Timer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Timer.js","sourceRoot":"","sources":["../src/Timer.ts"],"names":[],"mappings":";;;AAAa,QAAA,KAAK,GAAG;IACpB,IAAI,EAAE,KAAK,EAAE,EAAU,EAAE,EAAE;QAC1B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAC1D,CAAC;CACD,CAAC"}
@@ -1,6 +1,4 @@
1
- declare const Validation: {
1
+ export declare const Validation: {
2
2
  imageValidate(file: Blob): boolean;
3
3
  videoValidate(file: Blob): boolean;
4
4
  };
5
-
6
- export { Validation };
@@ -1,56 +1,39 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Validation = void 0;
4
+ exports.Validation = {
5
+ imageValidate(file) {
6
+ // console.log("imageValidate")
7
+ var maxSize = 10;
8
+ var fileSize = 1024 * 1024 * maxSize; // 10mb
9
+ var fileTypes = ["image/png", "image/jpeg"];
10
+ // var isFileValid = true;
11
+ if (!file || fileTypes.indexOf(file.type) < 0) {
12
+ alert("Vui lòng upload ảnh đúng định dạng jpg hay png");
13
+ return false;
14
+ }
15
+ else if (file.size > fileSize) {
16
+ alert("Vui lòng upload ảnh có dung lượng thấp hơn " + maxSize + "mb");
17
+ return false;
18
+ }
19
+ return true;
20
+ },
21
+ videoValidate(file) {
22
+ // console.log("videoValidate")
23
+ var maxSize = 15;
24
+ var fileSize = 1024 * 1024 * maxSize; // 10mb
25
+ var fileTypes = "video";
26
+ // console.log(file.type)
27
+ // var isFileValid = true;
28
+ if (!file || file.type.indexOf(fileTypes) < 0) {
29
+ alert("Vui lòng upload video");
30
+ return false;
31
+ }
32
+ else if (file.size > fileSize) {
33
+ alert("Vui lòng upload video có dung lượng thấp hơn " + maxSize + "mb");
34
+ return false;
35
+ }
36
+ return true;
37
+ },
8
38
  };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/Validation.ts
20
- var Validation_exports = {};
21
- __export(Validation_exports, {
22
- Validation: () => Validation
23
- });
24
- module.exports = __toCommonJS(Validation_exports);
25
- var Validation = {
26
- imageValidate(file) {
27
- var maxSize = 10;
28
- var fileSize = 1024 * 1024 * maxSize;
29
- var fileTypes = ["image/png", "image/jpeg"];
30
- if (!file || fileTypes.indexOf(file.type) < 0) {
31
- alert("Vui l\xF2ng upload \u1EA3nh \u0111\xFAng \u0111\u1ECBnh d\u1EA1ng jpg hay png");
32
- return false;
33
- } else if (file.size > fileSize) {
34
- alert("Vui l\xF2ng upload \u1EA3nh c\xF3 dung l\u01B0\u1EE3ng th\u1EA5p h\u01A1n " + maxSize + "mb");
35
- return false;
36
- }
37
- return true;
38
- },
39
- videoValidate(file) {
40
- var maxSize = 15;
41
- var fileSize = 1024 * 1024 * maxSize;
42
- var fileTypes = "video";
43
- if (!file || file.type.indexOf(fileTypes) < 0) {
44
- alert("Vui l\xF2ng upload video");
45
- return false;
46
- } else if (file.size > fileSize) {
47
- alert("Vui l\xF2ng upload video c\xF3 dung l\u01B0\u1EE3ng th\u1EA5p h\u01A1n " + maxSize + "mb");
48
- return false;
49
- }
50
- return true;
51
- }
52
- };
53
- // Annotate the CommonJS export names for ESM import in node:
54
- 0 && (module.exports = {
55
- Validation
56
- });
39
+ //# sourceMappingURL=Validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Validation.js","sourceRoot":"","sources":["../src/Validation.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG;IACzB,aAAa,CAAC,IAAU;QACvB,+BAA+B;QAC/B,IAAI,OAAO,GAAG,EAAE,CAAC;QACjB,IAAI,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,OAAO,CAAC,CAAC,OAAO;QAC7C,IAAI,SAAS,GAAG,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;QAC5C,0BAA0B;QAC1B,IAAI,CAAC,IAAI,IAAI,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YAC9C,KAAK,CAAC,gDAAgD,CAAC,CAAC;YACxD,OAAO,KAAK,CAAC;SACb;aAAM,IAAI,IAAI,CAAC,IAAI,GAAG,QAAQ,EAAE;YAChC,KAAK,CAAC,6CAA6C,GAAG,OAAO,GAAG,IAAI,CAAC,CAAC;YACtE,OAAO,KAAK,CAAC;SACb;QACD,OAAO,IAAI,CAAC;IACb,CAAC;IAED,aAAa,CAAC,IAAU;QACvB,+BAA+B;QAE/B,IAAI,OAAO,GAAG,EAAE,CAAC;QACjB,IAAI,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,OAAO,CAAC,CAAC,OAAO;QAC7C,IAAI,SAAS,GAAG,OAAO,CAAC;QACxB,yBAAyB;QACzB,0BAA0B;QAC1B,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;YAC9C,KAAK,CAAC,uBAAuB,CAAC,CAAC;YAC/B,OAAO,KAAK,CAAC;SACb;aAAM,IAAI,IAAI,CAAC,IAAI,GAAG,QAAQ,EAAE;YAChC,KAAK,CAAC,+CAA+C,GAAG,OAAO,GAAG,IAAI,CAAC,CAAC;YACxE,OAAO,KAAK,CAAC;SACb;QACD,OAAO,IAAI,CAAC;IACb,CAAC;CACD,CAAC"}
package/dist/array.d.ts CHANGED
@@ -1,85 +1,85 @@
1
- declare const sumArray: (array: [], key: string) => number;
1
+ export declare const sumArray: (array: [], key: string) => number;
2
2
  /**
3
3
  *
4
4
  * @param {Array} array
5
5
  * @param {string} key
6
6
  * @returns {Number}
7
7
  */
8
- declare const averageArray: (array: [], key: string) => number;
8
+ export declare const averageArray: (array: [], key: string) => number;
9
9
  /**
10
10
  *
11
11
  * @param {Array} array
12
12
  * @param {string} key
13
13
  * @returns {Number}
14
14
  */
15
- declare const minArray: (array: [], key: string) => number;
15
+ export declare const minArray: (array: [], key: string) => number;
16
16
  /**
17
17
  *
18
18
  * @param {Array} array
19
19
  * @param {string} key
20
20
  * @returns {Number}
21
21
  */
22
- declare const maxArray: (array: [], key: string) => number;
22
+ export declare const maxArray: (array: [], key: string) => number;
23
23
  /**
24
24
  *
25
25
  * @param {Array} array
26
26
  * @param {string} key
27
27
  * @returns {Array}
28
28
  */
29
- declare const sortElementByString: (array: any, key: string) => any[];
29
+ export declare const sortElementByString: (array: any, key: string) => any[] | undefined;
30
30
  /**
31
31
  *
32
32
  * @param {Array} array
33
33
  * @param {string} key
34
34
  * @returns {Array}
35
35
  */
36
- declare const sortElementByNumber: (array: any, key: string) => any[];
36
+ export declare const sortElementByNumber: (array: any, key: string) => any[] | undefined;
37
37
  /**
38
38
  *
39
39
  * @param {Array} array
40
40
  * @returns {any}
41
41
  */
42
- declare const firstElement: (array: any[]) => any;
42
+ export declare const firstElement: (array: any[]) => any;
43
43
  /**
44
44
  *
45
45
  * @param {Array} array
46
46
  * @returns {any}
47
47
  */
48
- declare const lastElement: (array: any[]) => any;
48
+ export declare const lastElement: (array: any[]) => any;
49
49
  /**
50
50
  *
51
51
  * @param {Array} array
52
52
  * @returns {any}
53
53
  */
54
- declare const randomIndex: (array: any[]) => number;
54
+ export declare const randomIndex: (array: any[]) => number;
55
55
  /**
56
56
  *
57
57
  * @param {Array} array
58
58
  * @returns {any}
59
59
  */
60
- declare const randomElement: (array: any[]) => any;
60
+ export declare const randomElement: (array: any[]) => any;
61
61
  /**
62
62
  * Remove same elements from 2 arrays
63
63
  */
64
- declare const mergeAndMakeUniqueElement: (list1: any[], list2: any[], key: string) => any[];
64
+ export declare const mergeAndMakeUniqueElement: (list1: any[], list2: any[], key: string) => any[] | undefined;
65
65
  /**
66
66
  * check target == toMatch
67
67
  * @param {Array} target
68
68
  * @param {Array} toMatch
69
69
  * @returns {Boolean}
70
70
  */
71
- declare const allMatchInArray: (target: any[], toMatch: any[]) => boolean;
72
- declare const removeItem: (item: any, array: any[]) => any[];
73
- declare const removeItemByKey: (key: string, value: any, array: any[]) => any[];
74
- declare const getRandom: (array: any[], n: number) => any[];
71
+ export declare const allMatchInArray: (target: any[], toMatch: any[]) => boolean;
72
+ export declare const removeItem: (item: any, array: any[]) => any[];
73
+ export declare const removeItemByKey: (key: string, value: any, array: any[]) => any[];
74
+ export declare const getRandom: (array: any[], n: number) => any[];
75
75
  /**
76
76
  * Get an array with shuffle element
77
77
  */
78
- declare const getHalfRandom: (array: any[], n: number) => any[];
78
+ export declare const getHalfRandom: (array: any[], n: number) => any[];
79
79
  /**
80
80
  * Make array shuffle itself
81
81
  */
82
- declare const shuffle: (array: any[]) => any[];
82
+ export declare const shuffle: (array: any[]) => any[];
83
83
  /**
84
84
  *
85
85
  * @param {Array} array
@@ -87,7 +87,5 @@ declare const shuffle: (array: any[]) => any[];
87
87
  * @param {Number} newIndex
88
88
  * @returns {Array}
89
89
  */
90
- declare const moveIndex: (array: any[], oldIndex: number, newIndex: number) => any[];
91
- declare const moveArray: (array: any[], oldIndex: number, newIndex: number) => any[];
92
-
93
- export { allMatchInArray, averageArray, firstElement, getHalfRandom, getRandom, lastElement, maxArray, mergeAndMakeUniqueElement, minArray, moveArray, moveIndex, randomElement, randomIndex, removeItem, removeItemByKey, shuffle, sortElementByNumber, sortElementByString, sumArray };
90
+ export declare const moveIndex: (array: any[], oldIndex: number, newIndex: number) => any[];
91
+ export declare const moveArray: (array: any[], oldIndex: number, newIndex: number) => any[];