diginext-utils 2.0.13 → 2.0.15

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 (162) hide show
  1. package/dist/Checker.d.ts +5 -2
  2. package/dist/Checker.js +2 -0
  3. package/dist/Checker.js.map +1 -1
  4. package/dist/EventDispatcher.d.ts +3 -1
  5. package/dist/EventDispatcher.js +1 -0
  6. package/dist/EventDispatcher.js.map +1 -1
  7. package/dist/FileUpload.d.ts +1 -0
  8. package/dist/FileUpload.js +1 -0
  9. package/dist/FileUpload.js.map +1 -1
  10. package/dist/Slug.d.ts +7 -2
  11. package/dist/Slug.js +2 -0
  12. package/dist/Slug.js.map +1 -1
  13. package/dist/Timer.d.ts +2 -1
  14. package/dist/Timer.js +2 -2
  15. package/dist/Timer.js.map +1 -1
  16. package/dist/Validation.d.ts +2 -1
  17. package/dist/Validation.js +2 -2
  18. package/dist/Validation.js.map +1 -1
  19. package/dist/array.d.ts +22 -0
  20. package/dist/array.js +22 -0
  21. package/dist/array.js.map +1 -1
  22. package/dist/color.d.ts +13 -0
  23. package/dist/color.js +12 -9
  24. package/dist/color.js.map +1 -1
  25. package/dist/console/enableConsole.d.ts +1 -0
  26. package/dist/console/enableConsole.js +1 -0
  27. package/dist/console/enableConsole.js.map +1 -1
  28. package/dist/console/index.d.ts +8 -1
  29. package/dist/console/index.js +4 -25
  30. package/dist/console/index.js.map +1 -1
  31. package/dist/file/findFilesByExt.d.ts +11 -3
  32. package/dist/file/findFilesByExt.js +8 -2
  33. package/dist/file/findFilesByExt.js.map +1 -1
  34. package/dist/file/index.d.ts +9 -0
  35. package/dist/file/index.js +11 -0
  36. package/dist/file/index.js.map +1 -0
  37. package/dist/index.d.ts +37 -17
  38. package/dist/index.js +37 -18
  39. package/dist/index.js.map +1 -1
  40. package/dist/json.d.ts +8 -0
  41. package/dist/json.js +32 -0
  42. package/dist/json.js.map +1 -0
  43. package/dist/math/index.d.ts +15 -1
  44. package/dist/math/index.js +5 -25
  45. package/dist/math/index.js.map +1 -1
  46. package/dist/name/en.d.ts +4 -0
  47. package/dist/name/en.js +2 -1
  48. package/dist/name/en.js.map +1 -1
  49. package/dist/name/index.d.ts +12 -3
  50. package/dist/name/index.js +9 -26
  51. package/dist/name/index.js.map +1 -1
  52. package/dist/name/vi.d.ts +4 -0
  53. package/dist/name/vi.js +2 -0
  54. package/dist/name/vi.js.map +1 -1
  55. package/dist/object.d.ts +23 -0
  56. package/dist/object.js +9 -0
  57. package/dist/object.js.map +1 -1
  58. package/dist/permission/index.d.ts +8 -1
  59. package/dist/permission/index.js +4 -25
  60. package/dist/permission/index.js.map +1 -1
  61. package/dist/string/index.d.ts +30 -1
  62. package/dist/string/index.js +31 -25
  63. package/dist/string/index.js.map +1 -1
  64. package/dist/string/random.d.ts +5 -0
  65. package/dist/string/random.js +2 -0
  66. package/dist/string/random.js.map +1 -1
  67. package/dist/string/url.d.ts +10 -0
  68. package/dist/string/url.js +2 -0
  69. package/dist/string/url.js.map +1 -1
  70. package/esm/Checker.d.ts +5 -2
  71. package/esm/Checker.js +3 -2
  72. package/esm/Checker.js.map +1 -1
  73. package/esm/EventDispatcher.d.ts +3 -1
  74. package/esm/EventDispatcher.js +3 -1
  75. package/esm/EventDispatcher.js.map +1 -1
  76. package/esm/FileUpload.d.ts +1 -0
  77. package/esm/FileUpload.js +1 -0
  78. package/esm/FileUpload.js.map +1 -1
  79. package/esm/Slug.d.ts +7 -2
  80. package/esm/Slug.js +3 -2
  81. package/esm/Slug.js.map +1 -1
  82. package/esm/Timer.d.ts +2 -1
  83. package/esm/Timer.js +2 -1
  84. package/esm/Timer.js.map +1 -1
  85. package/esm/Validation.d.ts +2 -1
  86. package/esm/Validation.js +2 -1
  87. package/esm/Validation.js.map +1 -1
  88. package/esm/array.d.ts +22 -0
  89. package/esm/array.js +22 -0
  90. package/esm/array.js.map +1 -1
  91. package/esm/color.d.ts +13 -0
  92. package/esm/color.js +12 -9
  93. package/esm/color.js.map +1 -1
  94. package/esm/console/enableConsole.d.ts +1 -0
  95. package/esm/console/enableConsole.js +1 -0
  96. package/esm/console/enableConsole.js.map +1 -1
  97. package/esm/console/index.d.ts +8 -1
  98. package/esm/console/index.js +3 -1
  99. package/esm/console/index.js.map +1 -1
  100. package/esm/file/findFilesByExt.d.ts +11 -3
  101. package/esm/file/findFilesByExt.js +8 -3
  102. package/esm/file/findFilesByExt.js.map +1 -1
  103. package/esm/file/index.d.ts +9 -0
  104. package/esm/file/index.js +6 -0
  105. package/esm/file/index.js.map +1 -0
  106. package/esm/index.d.ts +37 -17
  107. package/esm/index.js +37 -17
  108. package/esm/index.js.map +1 -1
  109. package/esm/json.d.ts +8 -0
  110. package/esm/json.js +28 -0
  111. package/esm/json.js.map +1 -0
  112. package/esm/math/index.d.ts +15 -1
  113. package/esm/math/index.js +4 -1
  114. package/esm/math/index.js.map +1 -1
  115. package/esm/name/en.d.ts +4 -0
  116. package/esm/name/en.js +2 -1
  117. package/esm/name/en.js.map +1 -1
  118. package/esm/name/index.d.ts +12 -3
  119. package/esm/name/index.js +5 -3
  120. package/esm/name/index.js.map +1 -1
  121. package/esm/name/vi.d.ts +4 -0
  122. package/esm/name/vi.js +2 -0
  123. package/esm/name/vi.js.map +1 -1
  124. package/esm/object.d.ts +23 -0
  125. package/esm/object.js +9 -0
  126. package/esm/object.js.map +1 -1
  127. package/esm/permission/index.d.ts +8 -1
  128. package/esm/permission/index.js +4 -1
  129. package/esm/permission/index.js.map +1 -1
  130. package/esm/string/index.d.ts +30 -1
  131. package/esm/string/index.js +30 -1
  132. package/esm/string/index.js.map +1 -1
  133. package/esm/string/random.d.ts +5 -0
  134. package/esm/string/random.js +2 -0
  135. package/esm/string/random.js.map +1 -1
  136. package/esm/string/url.d.ts +10 -0
  137. package/esm/string/url.js +2 -0
  138. package/esm/string/url.js.map +1 -1
  139. package/package.json +1 -1
  140. package/src/Checker.ts +4 -2
  141. package/src/EventDispatcher.ts +3 -1
  142. package/src/FileUpload.ts +1 -0
  143. package/src/Slug.ts +3 -2
  144. package/src/Timer.ts +3 -1
  145. package/src/Validation.ts +2 -1
  146. package/src/array.ts +24 -0
  147. package/src/color.ts +15 -17
  148. package/src/console/enableConsole.ts +2 -0
  149. package/src/console/index.ts +5 -1
  150. package/src/file/findFilesByExt.ts +10 -3
  151. package/src/file/index.ts +7 -0
  152. package/src/index.ts +37 -17
  153. package/src/json.ts +29 -0
  154. package/src/math/index.ts +6 -1
  155. package/src/name/en.ts +2 -1
  156. package/src/name/index.ts +7 -3
  157. package/src/name/vi.ts +3 -0
  158. package/src/object.ts +10 -0
  159. package/src/permission/index.ts +6 -1
  160. package/src/string/index.ts +32 -1
  161. package/src/string/random.ts +5 -1
  162. package/src/string/url.ts +5 -0
package/src/index.ts CHANGED
@@ -1,19 +1,39 @@
1
- export * as array from "./array";
2
- export * as device from "./device";
3
- export * as console from "./console";
4
- export * as browser from "./device/browser";
5
- export * as camera from "./device/camera";
6
- export * as math from "./math";
7
- export * as object from "./object";
8
- export * as string from "./string";
9
- export * as url from "./string/url";
10
- export * as createDir from "./file/createDir";
11
- export * as fileMove from "./file/fileMove";
12
- export * as findFilesByExt from "./file/findFilesByExt";
1
+ import * as array from "./array";
2
+ import * as device from "./device";
3
+ import * as console from "./console";
4
+ import * as browser from "./device/browser";
5
+ import * as camera from "./device/camera";
6
+ import * as math from "./math";
7
+ import * as xname from "./name";
8
+ import * as object from "./object";
9
+ import * as string from "./string";
10
+ import * as url from "./string/url";
11
+ import * as createDir from "./file/createDir";
12
+ import * as fileMove from "./file/fileMove";
13
+ import * as findFilesByExt from "./file/findFilesByExt";
14
+ import * as Timer from "./Timer";
15
+ import * as requestCamera from "./permission/requestCamera";
16
+ import * as requestDeviceOrientationControl from "./permission/requestDeviceOrientationControl";
17
+ import * as enableConsole from "./console/enableConsole";
13
18
 
14
- export * as Timer from "./Timer";
15
- export * as requestCamera from "./permission/requestCamera";
16
- export * as requestDeviceOrientationControl from "./permission/requestDeviceOrientationControl";
17
- export * as enableConsole from "./console/enableConsole";
19
+ const utils = {
20
+ xname,
21
+ array,
22
+ device,
23
+ console,
24
+ browser,
25
+ camera,
26
+ math,
27
+ object,
28
+ string,
29
+ url,
30
+ createDir,
31
+ fileMove,
32
+ findFilesByExt,
33
+ Timer,
34
+ requestCamera,
35
+ requestDeviceOrientationControl,
36
+ enableConsole,
37
+ };
18
38
 
19
- export * as utils from ".";
39
+ export default utils;
package/src/json.ts ADDED
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Check if the object or string is in JSON format
3
+ */
4
+ export const isValid = (content: object | string) => {
5
+ if (typeof content == "object") {
6
+ try {
7
+ content = JSON.stringify(content);
8
+ } catch (err) {
9
+ return false;
10
+ }
11
+ }
12
+
13
+ if (typeof content == "string") {
14
+ try {
15
+ content = JSON.parse(content);
16
+ } catch (err) {
17
+ return false;
18
+ }
19
+ }
20
+
21
+ if (typeof content != "object") {
22
+ return false;
23
+ }
24
+ return true;
25
+ };
26
+
27
+ const xjson = { isValid };
28
+
29
+ export default xjson;
package/src/math/index.ts CHANGED
@@ -87,4 +87,9 @@ export const angleBetweenPoints = (cx: number, cy: number, ex: number, ey: numbe
87
87
  return theta;
88
88
  };
89
89
 
90
- export * as math from ".";
90
+ import { diffDate } from "./diffDate";
91
+ import { positiveNumber } from "./positiveNumber";
92
+
93
+ const xmath = { rand, randRound, randHalt, randInt, randFloat, degToRad, radToDeg, angleBetweenPoints, diffDate, positiveNumber };
94
+
95
+ export default xmath;
package/src/name/en.ts CHANGED
@@ -23,4 +23,5 @@ export function generateName() {
23
23
  return name;
24
24
  }
25
25
 
26
- // export * as en from ".";
26
+ const NameEN = { generateName };
27
+ export default NameEN;
package/src/name/index.ts CHANGED
@@ -1,4 +1,8 @@
1
- export * as NameEN from "./en";
2
- export * as NameVI from "./vi";
1
+ import NameEN from "./en";
2
+ import NameVI from "./vi";
3
3
 
4
- export * as name from ".";
4
+ export { NameEN, NameVI };
5
+
6
+ const xname = { NameEN, NameVI };
7
+
8
+ export default xname;
package/src/name/vi.ts CHANGED
@@ -19,3 +19,6 @@ export const generateName = (useGender = false, male = false) => {
19
19
  return randomElement([...MALE, ...FEMALE]);
20
20
  }
21
21
  };
22
+
23
+ const NameVI = { generateName };
24
+ export default NameVI;
package/src/object.ts CHANGED
@@ -47,3 +47,13 @@ export const objectToArray = (obj: { [key: string]: any }) => {
47
47
  }
48
48
  return array;
49
49
  };
50
+
51
+ const xobject = {
52
+ isNull,
53
+ toBool,
54
+ toInt,
55
+ toFloat,
56
+ toArray,
57
+ objectToArray,
58
+ };
59
+ export default xobject;
@@ -1 +1,6 @@
1
- export * as permission from ".";
1
+ import { requestCamera } from "./requestCamera";
2
+ import { requestDeviceOrientationControl } from "./requestDeviceOrientationControl";
3
+
4
+ const permission = { requestCamera, requestDeviceOrientationControl };
5
+
6
+ export default permission;
@@ -144,4 +144,35 @@ export const clearUnicodeCharacters = (s: string, opt: { [key: string]: any } =
144
144
  return opt.lowercase ? s.toLowerCase() : s;
145
145
  };
146
146
 
147
- export * as string from ".";
147
+ import { generateUUID } from "./generateUUID";
148
+ import { randAllCharacterByLength, randomStringByLength } from "./random";
149
+ import { formatNumber } from "./formatNumber";
150
+ import { generatePassword } from "./generatePassword";
151
+ import { trimNull } from "./trimNull";
152
+ import { addQueryParam, getUrlParams, isLink, getFileNameWithoutExtension, getFileNameWithExtension, getFileExtension, isImage } from "./url";
153
+
154
+ const xstring = {
155
+ getBetween,
156
+ makeString,
157
+ toUpperCase,
158
+ toLowerCase,
159
+ titleize,
160
+ capitalize,
161
+ capitalizeName,
162
+ clearUnicodeCharacters,
163
+ generateUUID,
164
+ randAllCharacterByLength,
165
+ randomStringByLength,
166
+ formatNumber,
167
+ generatePassword,
168
+ trimNull,
169
+ addQueryParam,
170
+ getUrlParams,
171
+ isLink,
172
+ getFileNameWithoutExtension,
173
+ getFileNameWithExtension,
174
+ getFileExtension,
175
+ isImage,
176
+ };
177
+
178
+ export default xstring;
@@ -10,7 +10,7 @@ export const randAllCharacterByLength = (length = 0) => {
10
10
  return randomStringByLength(length, allCharacter);
11
11
  };
12
12
 
13
- export const randomStringByLength = (length:number, str = textLowCase) => {
13
+ export const randomStringByLength = (length: number, str = textLowCase) => {
14
14
  let result = "";
15
15
 
16
16
  for (let i = 0; i < length; i++) {
@@ -18,3 +18,7 @@ export const randomStringByLength = (length:number, str = textLowCase) => {
18
18
  }
19
19
  return result;
20
20
  };
21
+
22
+ const random = { randAllCharacterByLength, randomStringByLength };
23
+
24
+ export default random;
package/src/string/url.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { url } from "inspector";
1
2
  import { isNull } from "../object";
2
3
 
3
4
  var urlRegex = /(https?:\/\/[^\s]+)/g;
@@ -107,3 +108,7 @@ export const isImage = (url: string) => {
107
108
 
108
109
  return index >= 0;
109
110
  };
111
+
112
+ const xurl = { addQueryParam, getUrlParams, isLink, getFileNameWithoutExtension, getFileNameWithExtension, getFileExtension, isImage };
113
+
114
+ export default xurl;