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.
Files changed (304) hide show
  1. package/README.md +162 -162
  2. package/package.json +66 -66
  3. package/src/Checker.ts +29 -29
  4. package/src/EventDispatcher.ts +62 -62
  5. package/src/FileUpload.ts +66 -66
  6. package/src/Slug.ts +365 -365
  7. package/src/Timer.ts +7 -7
  8. package/src/Validation.ts +36 -36
  9. package/src/array.ts +285 -285
  10. package/src/color.ts +87 -87
  11. package/src/console/enableConsole.ts +8 -8
  12. package/src/console/index.ts +17 -17
  13. package/src/console/log.ts +39 -39
  14. package/src/device/browser.ts +29 -29
  15. package/src/device/camera.ts +207 -207
  16. package/src/device/index.ts +230 -230
  17. package/src/device/os.ts +29 -29
  18. package/src/file/createDir.ts +14 -14
  19. package/src/file/fileMove.ts +32 -32
  20. package/src/file/findFilesByExt.ts +46 -46
  21. package/src/file/index.ts +7 -7
  22. package/src/images/index.ts +3 -3
  23. package/src/images/loadImage.ts +16 -0
  24. package/src/images/resize.ts +35 -35
  25. package/src/images/upload.ts +24 -24
  26. package/src/index.ts +39 -39
  27. package/src/json.ts +29 -29
  28. package/src/math/diffDate.ts +10 -10
  29. package/src/math/index.ts +90 -90
  30. package/src/math/positiveNumber.ts +12 -12
  31. package/src/name/en.ts +27 -27
  32. package/src/name/index.ts +8 -8
  33. package/src/name/vi.ts +23 -23
  34. package/src/object.ts +72 -72
  35. package/src/permission/index.ts +6 -6
  36. package/src/permission/requestCamera.ts +43 -43
  37. package/src/permission/requestDeviceOrientationControl.ts +33 -33
  38. package/src/response/index.ts +45 -45
  39. package/src/string/formatNumber.ts +12 -12
  40. package/src/string/generatePassword.ts +18 -18
  41. package/src/string/generateUUID.ts +37 -37
  42. package/src/string/index.ts +180 -180
  43. package/src/string/makeDaySlug.ts +40 -40
  44. package/src/string/random.ts +24 -24
  45. package/src/string/trimNull.ts +16 -16
  46. package/src/string/url.ts +116 -116
  47. package/dist/Checker.d.ts +0 -8
  48. package/dist/Checker.js +0 -32
  49. package/dist/Checker.js.map +0 -1
  50. package/dist/EventDispatcher.d.ts +0 -13
  51. package/dist/EventDispatcher.js +0 -52
  52. package/dist/EventDispatcher.js.map +0 -1
  53. package/dist/FileUpload.d.ts +0 -12
  54. package/dist/FileUpload.js +0 -65
  55. package/dist/FileUpload.js.map +0 -1
  56. package/dist/Slug.d.ts +0 -9
  57. package/dist/Slug.js +0 -334
  58. package/dist/Slug.js.map +0 -1
  59. package/dist/Timer.d.ts +0 -4
  60. package/dist/Timer.js +0 -9
  61. package/dist/Timer.js.map +0 -1
  62. package/dist/Validation.d.ts +0 -5
  63. package/dist/Validation.js +0 -39
  64. package/dist/Validation.js.map +0 -1
  65. package/dist/array.d.ts +0 -113
  66. package/dist/array.js +0 -297
  67. package/dist/array.js.map +0 -1
  68. package/dist/color.d.ts +0 -23
  69. package/dist/color.js +0 -89
  70. package/dist/color.js.map +0 -1
  71. package/dist/console/enableConsole.d.ts +0 -2
  72. package/dist/console/enableConsole.js +0 -14
  73. package/dist/console/enableConsole.js.map +0 -1
  74. package/dist/console/index.d.ts +0 -11
  75. package/dist/console/index.js +0 -18
  76. package/dist/console/index.js.map +0 -1
  77. package/dist/console/log.d.ts +0 -15
  78. package/dist/console/log.js +0 -45
  79. package/dist/console/log.js.map +0 -1
  80. package/dist/device/browser.d.ts +0 -5
  81. package/dist/device/browser.js +0 -38
  82. package/dist/device/browser.js.map +0 -1
  83. package/dist/device/camera.d.ts +0 -7
  84. package/dist/device/camera.js +0 -172
  85. package/dist/device/camera.js.map +0 -1
  86. package/dist/device/index.d.ts +0 -5
  87. package/dist/device/index.js +0 -225
  88. package/dist/device/index.js.map +0 -1
  89. package/dist/device/os.d.ts +0 -11
  90. package/dist/device/os.js +0 -38
  91. package/dist/device/os.js.map +0 -1
  92. package/dist/file/createDir.d.ts +0 -5
  93. package/dist/file/createDir.js +0 -16
  94. package/dist/file/createDir.js.map +0 -1
  95. package/dist/file/fileMove.d.ts +0 -4
  96. package/dist/file/fileMove.js +0 -33
  97. package/dist/file/fileMove.js.map +0 -1
  98. package/dist/file/findFilesByExt.d.ts +0 -13
  99. package/dist/file/findFilesByExt.js +0 -50
  100. package/dist/file/findFilesByExt.js.map +0 -1
  101. package/dist/file/index.d.ts +0 -9
  102. package/dist/file/index.js +0 -11
  103. package/dist/file/index.js.map +0 -1
  104. package/dist/images/index.d.ts +0 -2
  105. package/dist/images/index.js +0 -9
  106. package/dist/images/index.js.map +0 -1
  107. package/dist/images/resize.d.ts +0 -2
  108. package/dist/images/resize.js +0 -38
  109. package/dist/images/resize.js.map +0 -1
  110. package/dist/images/upload.d.ts +0 -10
  111. package/dist/images/upload.js +0 -27
  112. package/dist/images/upload.js.map +0 -1
  113. package/dist/index.d.ts +0 -37
  114. package/dist/index.js +0 -63
  115. package/dist/index.js.map +0 -1
  116. package/dist/json.d.ts +0 -8
  117. package/dist/json.js +0 -32
  118. package/dist/json.js.map +0 -1
  119. package/dist/math/diffDate.d.ts +0 -5
  120. package/dist/math/diffDate.js +0 -14
  121. package/dist/math/diffDate.js.map +0 -1
  122. package/dist/math/index.d.ts +0 -30
  123. package/dist/math/index.js +0 -93
  124. package/dist/math/index.js.map +0 -1
  125. package/dist/math/positiveNumber.d.ts +0 -2
  126. package/dist/math/positiveNumber.js +0 -17
  127. package/dist/math/positiveNumber.js.map +0 -1
  128. package/dist/name/en.d.ts +0 -5
  129. package/dist/name/en.js +0 -26
  130. package/dist/name/en.js.map +0 -1
  131. package/dist/name/index.d.ts +0 -12
  132. package/dist/name/index.js +0 -13
  133. package/dist/name/index.js.map +0 -1
  134. package/dist/name/vi.d.ts +0 -5
  135. package/dist/name/vi.js +0 -28
  136. package/dist/name/vi.js.map +0 -1
  137. package/dist/object.d.ts +0 -59
  138. package/dist/object.js +0 -80
  139. package/dist/object.js.map +0 -1
  140. package/dist/permission/index.d.ts +0 -8
  141. package/dist/permission/index.js +0 -7
  142. package/dist/permission/index.js.map +0 -1
  143. package/dist/permission/requestCamera.d.ts +0 -5
  144. package/dist/permission/requestCamera.js +0 -43
  145. package/dist/permission/requestCamera.js.map +0 -1
  146. package/dist/permission/requestDeviceOrientationControl.d.ts +0 -2
  147. package/dist/permission/requestDeviceOrientationControl.js +0 -39
  148. package/dist/permission/requestDeviceOrientationControl.js.map +0 -1
  149. package/dist/response/index.d.ts +0 -49
  150. package/dist/response/index.js +0 -52
  151. package/dist/response/index.js.map +0 -1
  152. package/dist/string/formatNumber.d.ts +0 -6
  153. package/dist/string/formatNumber.js +0 -15
  154. package/dist/string/formatNumber.js.map +0 -1
  155. package/dist/string/generatePassword.d.ts +0 -9
  156. package/dist/string/generatePassword.js +0 -24
  157. package/dist/string/generatePassword.js.map +0 -1
  158. package/dist/string/generateUUID.d.ts +0 -2
  159. package/dist/string/generateUUID.js +0 -37
  160. package/dist/string/generateUUID.js.map +0 -1
  161. package/dist/string/index.d.ts +0 -65
  162. package/dist/string/index.js +0 -161
  163. package/dist/string/index.js.map +0 -1
  164. package/dist/string/makeDaySlug.d.ts +0 -31
  165. package/dist/string/makeDaySlug.js +0 -23
  166. package/dist/string/makeDaySlug.js.map +0 -1
  167. package/dist/string/random.d.ts +0 -14
  168. package/dist/string/random.js +0 -25
  169. package/dist/string/random.js.map +0 -1
  170. package/dist/string/trimNull.d.ts +0 -2
  171. package/dist/string/trimNull.js +0 -21
  172. package/dist/string/trimNull.js.map +0 -1
  173. package/dist/string/url.d.ts +0 -36
  174. package/dist/string/url.js +0 -108
  175. package/dist/string/url.js.map +0 -1
  176. package/esm/Checker.d.ts +0 -8
  177. package/esm/Checker.js +0 -28
  178. package/esm/Checker.js.map +0 -1
  179. package/esm/EventDispatcher.d.ts +0 -13
  180. package/esm/EventDispatcher.js +0 -49
  181. package/esm/EventDispatcher.js.map +0 -1
  182. package/esm/FileUpload.d.ts +0 -12
  183. package/esm/FileUpload.js +0 -62
  184. package/esm/FileUpload.js.map +0 -1
  185. package/esm/Slug.d.ts +0 -9
  186. package/esm/Slug.js +0 -330
  187. package/esm/Slug.js.map +0 -1
  188. package/esm/Timer.d.ts +0 -4
  189. package/esm/Timer.js +0 -7
  190. package/esm/Timer.js.map +0 -1
  191. package/esm/Validation.d.ts +0 -5
  192. package/esm/Validation.js +0 -37
  193. package/esm/Validation.js.map +0 -1
  194. package/esm/array.d.ts +0 -113
  195. package/esm/array.js +0 -275
  196. package/esm/array.js.map +0 -1
  197. package/esm/color.d.ts +0 -23
  198. package/esm/color.js +0 -80
  199. package/esm/color.js.map +0 -1
  200. package/esm/console/enableConsole.d.ts +0 -2
  201. package/esm/console/enableConsole.js +0 -7
  202. package/esm/console/enableConsole.js.map +0 -1
  203. package/esm/console/index.d.ts +0 -11
  204. package/esm/console/index.js +0 -13
  205. package/esm/console/index.js.map +0 -1
  206. package/esm/console/log.d.ts +0 -15
  207. package/esm/console/log.js +0 -33
  208. package/esm/console/log.js.map +0 -1
  209. package/esm/device/browser.d.ts +0 -5
  210. package/esm/device/browser.js +0 -30
  211. package/esm/device/browser.js.map +0 -1
  212. package/esm/device/camera.d.ts +0 -7
  213. package/esm/device/camera.js +0 -168
  214. package/esm/device/camera.js.map +0 -1
  215. package/esm/device/index.d.ts +0 -5
  216. package/esm/device/index.js +0 -217
  217. package/esm/device/index.js.map +0 -1
  218. package/esm/device/os.d.ts +0 -11
  219. package/esm/device/os.js +0 -28
  220. package/esm/device/os.js.map +0 -1
  221. package/esm/file/createDir.d.ts +0 -5
  222. package/esm/file/createDir.js +0 -13
  223. package/esm/file/createDir.js.map +0 -1
  224. package/esm/file/fileMove.d.ts +0 -4
  225. package/esm/file/fileMove.js +0 -29
  226. package/esm/file/fileMove.js.map +0 -1
  227. package/esm/file/findFilesByExt.d.ts +0 -13
  228. package/esm/file/findFilesByExt.js +0 -46
  229. package/esm/file/findFilesByExt.js.map +0 -1
  230. package/esm/file/index.d.ts +0 -9
  231. package/esm/file/index.js +0 -6
  232. package/esm/file/index.js.map +0 -1
  233. package/esm/images/index.d.ts +0 -2
  234. package/esm/images/index.js +0 -4
  235. package/esm/images/index.js.map +0 -1
  236. package/esm/images/resize.d.ts +0 -2
  237. package/esm/images/resize.js +0 -31
  238. package/esm/images/resize.js.map +0 -1
  239. package/esm/images/upload.d.ts +0 -10
  240. package/esm/images/upload.js +0 -20
  241. package/esm/images/upload.js.map +0 -1
  242. package/esm/index.d.ts +0 -37
  243. package/esm/index.js +0 -38
  244. package/esm/index.js.map +0 -1
  245. package/esm/json.d.ts +0 -8
  246. package/esm/json.js +0 -28
  247. package/esm/json.js.map +0 -1
  248. package/esm/math/diffDate.d.ts +0 -5
  249. package/esm/math/diffDate.js +0 -10
  250. package/esm/math/diffDate.js.map +0 -1
  251. package/esm/math/index.d.ts +0 -30
  252. package/esm/math/index.js +0 -78
  253. package/esm/math/index.js.map +0 -1
  254. package/esm/math/positiveNumber.d.ts +0 -2
  255. package/esm/math/positiveNumber.js +0 -13
  256. package/esm/math/positiveNumber.js.map +0 -1
  257. package/esm/name/en.d.ts +0 -5
  258. package/esm/name/en.js +0 -22
  259. package/esm/name/en.js.map +0 -1
  260. package/esm/name/index.d.ts +0 -12
  261. package/esm/name/index.js +0 -6
  262. package/esm/name/index.js.map +0 -1
  263. package/esm/name/vi.d.ts +0 -5
  264. package/esm/name/vi.js +0 -24
  265. package/esm/name/vi.js.map +0 -1
  266. package/esm/object.d.ts +0 -59
  267. package/esm/object.js +0 -70
  268. package/esm/object.js.map +0 -1
  269. package/esm/permission/index.d.ts +0 -8
  270. package/esm/permission/index.js +0 -5
  271. package/esm/permission/index.js.map +0 -1
  272. package/esm/permission/requestCamera.d.ts +0 -5
  273. package/esm/permission/requestCamera.js +0 -39
  274. package/esm/permission/requestCamera.js.map +0 -1
  275. package/esm/permission/requestDeviceOrientationControl.d.ts +0 -2
  276. package/esm/permission/requestDeviceOrientationControl.js +0 -35
  277. package/esm/permission/requestDeviceOrientationControl.js.map +0 -1
  278. package/esm/response/index.d.ts +0 -49
  279. package/esm/response/index.js +0 -46
  280. package/esm/response/index.js.map +0 -1
  281. package/esm/string/formatNumber.d.ts +0 -6
  282. package/esm/string/formatNumber.js +0 -11
  283. package/esm/string/formatNumber.js.map +0 -1
  284. package/esm/string/generatePassword.d.ts +0 -9
  285. package/esm/string/generatePassword.js +0 -20
  286. package/esm/string/generatePassword.js.map +0 -1
  287. package/esm/string/generateUUID.d.ts +0 -2
  288. package/esm/string/generateUUID.js +0 -33
  289. package/esm/string/generateUUID.js.map +0 -1
  290. package/esm/string/index.d.ts +0 -65
  291. package/esm/string/index.js +0 -150
  292. package/esm/string/index.js.map +0 -1
  293. package/esm/string/makeDaySlug.d.ts +0 -31
  294. package/esm/string/makeDaySlug.js +0 -16
  295. package/esm/string/makeDaySlug.js.map +0 -1
  296. package/esm/string/random.d.ts +0 -14
  297. package/esm/string/random.js +0 -20
  298. package/esm/string/random.js.map +0 -1
  299. package/esm/string/trimNull.d.ts +0 -2
  300. package/esm/string/trimNull.js +0 -14
  301. package/esm/string/trimNull.js.map +0 -1
  302. package/esm/string/url.d.ts +0 -36
  303. package/esm/string/url.js +0 -98
  304. package/esm/string/url.js.map +0 -1
@@ -1,45 +1,45 @@
1
- import _ from "lodash";
2
- import { logRes } from "../console/log";
3
-
4
- export const getResponse = () => {
5
- return { status: 0, messages: [], data: {} };
6
- };
7
-
8
- export const getSuccessResponse = (data: any, message?: string) => {
9
- return { status: 1, messages: message ? [message] : [], data: data };
10
- };
11
-
12
- export const getFailedResponse = (...messages: any[]) => {
13
- if (!messages) messages = ["What's do you want?"];
14
- return { status: 0, error: true, messages: [...messages], data: {} };
15
- };
16
-
17
- export const Response = {
18
- send: (res: any, data: any = {}) => {
19
- if (res.locals.logEnabled) logRes(res, data);
20
- if (data.error) return Response.failed(res, data.error);
21
- return Response.succeed(res, data);
22
- },
23
- succeed: (res: any, data: any = {}) => {
24
- if (res.locals.logEnabled) logRes(res, data);
25
- return res.status(200).json(getSuccessResponse(data));
26
- },
27
- failed: (res: any, ...messages: string[]) => {
28
- if (res.locals.logEnabled) logRes(res, ...messages);
29
- return res.status(200).json(getFailedResponse(...messages));
30
- },
31
- rejected: (res: any, message?: string) => {
32
- const msg = message ? message : "Permissions denied.";
33
- if (res.locals.logEnabled) logRes(res, { message: msg });
34
- return res.status(403).json(getFailedResponse(msg));
35
- },
36
- ignore: (res: any, message?: string) => {
37
- const msg = message ? message : "What do you want?";
38
- if (res.locals.logEnabled) logRes(res, { statusCode: 404, message: msg });
39
- return res.status(200).json(getFailedResponse(msg));
40
- },
41
- };
42
-
43
- const response = { getResponse, getSuccessResponse, getFailedResponse, Response };
44
-
45
- export default response;
1
+ import _ from "lodash";
2
+ import { logRes } from "../console/log";
3
+
4
+ export const getResponse = () => {
5
+ return { status: 0, messages: [], data: {} };
6
+ };
7
+
8
+ export const getSuccessResponse = (data: any, message?: string) => {
9
+ return { status: 1, messages: message ? [message] : [], data: data };
10
+ };
11
+
12
+ export const getFailedResponse = (...messages: any[]) => {
13
+ if (!messages) messages = ["What's do you want?"];
14
+ return { status: 0, error: true, messages: [...messages], data: {} };
15
+ };
16
+
17
+ export const Response = {
18
+ send: (res: any, data: any = {}) => {
19
+ if (res.locals.logEnabled) logRes(res, data);
20
+ if (data.error) return Response.failed(res, data.error);
21
+ return Response.succeed(res, data);
22
+ },
23
+ succeed: (res: any, data: any = {}) => {
24
+ if (res.locals.logEnabled) logRes(res, data);
25
+ return res.status(200).json(getSuccessResponse(data));
26
+ },
27
+ failed: (res: any, ...messages: string[]) => {
28
+ if (res.locals.logEnabled) logRes(res, ...messages);
29
+ return res.status(200).json(getFailedResponse(...messages));
30
+ },
31
+ rejected: (res: any, message?: string) => {
32
+ const msg = message ? message : "Permissions denied.";
33
+ if (res.locals.logEnabled) logRes(res, { message: msg });
34
+ return res.status(403).json(getFailedResponse(msg));
35
+ },
36
+ ignore: (res: any, message?: string) => {
37
+ const msg = message ? message : "What do you want?";
38
+ if (res.locals.logEnabled) logRes(res, { statusCode: 404, message: msg });
39
+ return res.status(200).json(getFailedResponse(msg));
40
+ },
41
+ };
42
+
43
+ const response = { getResponse, getSuccessResponse, getFailedResponse, Response };
44
+
45
+ export default response;
@@ -1,12 +1,12 @@
1
- import { toInt } from "../object";
2
-
3
- /**
4
- * Format the input number with commas
5
- * @example 1000000 -> 1,000,000
6
- */
7
- export function formatNumber(num: number, prefix = "$") {
8
- const numRound = Math.round((toInt(num) + Number.EPSILON) * 100) / 100;
9
- return Number.isNaN(numRound) ? "0" : "" + numRound.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, prefix + "1,");
10
- }
11
-
12
- export default formatNumber;
1
+ import { toInt } from "../object";
2
+
3
+ /**
4
+ * Format the input number with commas
5
+ * @example 1000000 -> 1,000,000
6
+ */
7
+ export function formatNumber(num: number, prefix = "$") {
8
+ const numRound = Math.round((toInt(num) + Number.EPSILON) * 100) / 100;
9
+ return Number.isNaN(numRound) ? "0" : "" + numRound.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, prefix + "1,");
10
+ }
11
+
12
+ export default formatNumber;
@@ -1,18 +1,18 @@
1
- import { numeric, punctuation, randomStringByLength, textLowCase } from "./random";
2
-
3
- /**
4
- * random password
5
- * - if hard = true -> random punctuation inside
6
- * @param {*} length
7
- * @param {Boolean} hard
8
- * @returns
9
- */
10
- export function generatePassword(length = 6, hard = true) {
11
- if (!Number.isFinite(length)) length = 6;
12
- if (length <= 0) length = 6;
13
- let pass = randomStringByLength(length, textLowCase + textLowCase.toUpperCase() + numeric);
14
- if (hard) pass = pass.replace(pass[Math.floor(pass.length / 2)], randomStringByLength(1, punctuation));
15
- return pass;
16
- }
17
-
18
- export default generatePassword;
1
+ import { numeric, punctuation, randomStringByLength, textLowCase } from "./random";
2
+
3
+ /**
4
+ * random password
5
+ * - if hard = true -> random punctuation inside
6
+ * @param {*} length
7
+ * @param {Boolean} hard
8
+ * @returns
9
+ */
10
+ export function generatePassword(length = 6, hard = true) {
11
+ if (!Number.isFinite(length)) length = 6;
12
+ if (length <= 0) length = 6;
13
+ let pass = randomStringByLength(length, textLowCase + textLowCase.toUpperCase() + numeric);
14
+ if (hard) pass = pass.replace(pass[Math.floor(pass.length / 2)], randomStringByLength(1, punctuation));
15
+ return pass;
16
+ }
17
+
18
+ export default generatePassword;
@@ -1,37 +1,37 @@
1
- //prettier-ignore
2
- const _lut = [ '00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '0a', '0b', '0c', '0d', '0e', '0f', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '1a', '1b', '1c', '1d', '1e', '1f', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '2a', '2b', '2c', '2d', '2e', '2f', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '3a', '3b', '3c', '3d', '3e', '3f', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '4a', '4b', '4c', '4d', '4e', '4f', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '5a', '5b', '5c', '5d', '5e', '5f', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '6a', '6b', '6c', '6d', '6e', '6f', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '7a', '7b', '7c', '7d', '7e', '7f', '80', '81', '82', '83', '84', '85', '86', '87', '88', '89', '8a', '8b', '8c', '8d', '8e', '8f', '90', '91', '92', '93', '94', '95', '96', '97', '98', '99', '9a', '9b', '9c', '9d', '9e', '9f', 'a0', 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9', 'aa', 'ab', 'ac', 'ad', 'ae', 'af', 'b0', 'b1', 'b2', 'b3', 'b4', 'b5', 'b6', 'b7', 'b8', 'b9', 'ba', 'bb', 'bc', 'bd', 'be', 'bf', 'c0', 'c1', 'c2', 'c3', 'c4', 'c5', 'c6', 'c7', 'c8', 'c9', 'ca', 'cb', 'cc', 'cd', 'ce', 'cf', 'd0', 'd1', 'd2', 'd3', 'd4', 'd5', 'd6', 'd7', 'd8', 'd9', 'da', 'db', 'dc', 'dd', 'de', 'df', 'e0', 'e1', 'e2', 'e3', 'e4', 'e5', 'e6', 'e7', 'e8', 'e9', 'ea', 'eb', 'ec', 'ed', 'ee', 'ef', 'f0', 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'fa', 'fb', 'fc', 'fd', 'fe', 'ff' ];
3
-
4
- export function generateUUID() {
5
- // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
6
-
7
- const d0 = (Math.random() * 0xffffffff) | 0;
8
- const d1 = (Math.random() * 0xffffffff) | 0;
9
- const d2 = (Math.random() * 0xffffffff) | 0;
10
- const d3 = (Math.random() * 0xffffffff) | 0;
11
- const uuid =
12
- _lut[d0 & 0xff] +
13
- _lut[(d0 >> 8) & 0xff] +
14
- _lut[(d0 >> 16) & 0xff] +
15
- _lut[(d0 >> 24) & 0xff] +
16
- "-" +
17
- _lut[d1 & 0xff] +
18
- _lut[(d1 >> 8) & 0xff] +
19
- "-" +
20
- _lut[((d1 >> 16) & 0x0f) | 0x40] +
21
- _lut[(d1 >> 24) & 0xff] +
22
- "-" +
23
- _lut[(d2 & 0x3f) | 0x80] +
24
- _lut[(d2 >> 8) & 0xff] +
25
- "-" +
26
- _lut[(d2 >> 16) & 0xff] +
27
- _lut[(d2 >> 24) & 0xff] +
28
- _lut[d3 & 0xff] +
29
- _lut[(d3 >> 8) & 0xff] +
30
- _lut[(d3 >> 16) & 0xff] +
31
- _lut[(d3 >> 24) & 0xff];
32
-
33
- // .toLowerCase() here flattens concatenated strings to save heap memory space.
34
- return uuid.toLowerCase();
35
- }
36
-
37
- export default generateUUID;
1
+ //prettier-ignore
2
+ const _lut = [ '00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '0a', '0b', '0c', '0d', '0e', '0f', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '1a', '1b', '1c', '1d', '1e', '1f', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '2a', '2b', '2c', '2d', '2e', '2f', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '3a', '3b', '3c', '3d', '3e', '3f', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '4a', '4b', '4c', '4d', '4e', '4f', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '5a', '5b', '5c', '5d', '5e', '5f', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '6a', '6b', '6c', '6d', '6e', '6f', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '7a', '7b', '7c', '7d', '7e', '7f', '80', '81', '82', '83', '84', '85', '86', '87', '88', '89', '8a', '8b', '8c', '8d', '8e', '8f', '90', '91', '92', '93', '94', '95', '96', '97', '98', '99', '9a', '9b', '9c', '9d', '9e', '9f', 'a0', 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9', 'aa', 'ab', 'ac', 'ad', 'ae', 'af', 'b0', 'b1', 'b2', 'b3', 'b4', 'b5', 'b6', 'b7', 'b8', 'b9', 'ba', 'bb', 'bc', 'bd', 'be', 'bf', 'c0', 'c1', 'c2', 'c3', 'c4', 'c5', 'c6', 'c7', 'c8', 'c9', 'ca', 'cb', 'cc', 'cd', 'ce', 'cf', 'd0', 'd1', 'd2', 'd3', 'd4', 'd5', 'd6', 'd7', 'd8', 'd9', 'da', 'db', 'dc', 'dd', 'de', 'df', 'e0', 'e1', 'e2', 'e3', 'e4', 'e5', 'e6', 'e7', 'e8', 'e9', 'ea', 'eb', 'ec', 'ed', 'ee', 'ef', 'f0', 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'fa', 'fb', 'fc', 'fd', 'fe', 'ff' ];
3
+
4
+ export function generateUUID() {
5
+ // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
6
+
7
+ const d0 = (Math.random() * 0xffffffff) | 0;
8
+ const d1 = (Math.random() * 0xffffffff) | 0;
9
+ const d2 = (Math.random() * 0xffffffff) | 0;
10
+ const d3 = (Math.random() * 0xffffffff) | 0;
11
+ const uuid =
12
+ _lut[d0 & 0xff] +
13
+ _lut[(d0 >> 8) & 0xff] +
14
+ _lut[(d0 >> 16) & 0xff] +
15
+ _lut[(d0 >> 24) & 0xff] +
16
+ "-" +
17
+ _lut[d1 & 0xff] +
18
+ _lut[(d1 >> 8) & 0xff] +
19
+ "-" +
20
+ _lut[((d1 >> 16) & 0x0f) | 0x40] +
21
+ _lut[(d1 >> 24) & 0xff] +
22
+ "-" +
23
+ _lut[(d2 & 0x3f) | 0x80] +
24
+ _lut[(d2 >> 8) & 0xff] +
25
+ "-" +
26
+ _lut[(d2 >> 16) & 0xff] +
27
+ _lut[(d2 >> 24) & 0xff] +
28
+ _lut[d3 & 0xff] +
29
+ _lut[(d3 >> 8) & 0xff] +
30
+ _lut[(d3 >> 16) & 0xff] +
31
+ _lut[(d3 >> 24) & 0xff];
32
+
33
+ // .toLowerCase() here flattens concatenated strings to save heap memory space.
34
+ return uuid.toLowerCase();
35
+ }
36
+
37
+ export default generateUUID;
@@ -1,180 +1,180 @@
1
- // import { log } from "../../helper/log";
2
- // import { startCase, toLower } from "lodash";
3
- declare var XRegExp: any;
4
-
5
- import { isNull } from "../object";
6
-
7
- //prettier-ignore
8
- const char_map: { [key: string]: any } = { À: "A", Á: "A", Â: "A", Ã: "A", Ä: "A", Å: "A", Æ: "AE", Ç: "C", È: "E", É: "E", Ê: "E", Ë: "E", Ì: "I", Í: "I", Î: "I", Ï: "I", Ð: "D", Ñ: "N", Ò: "O", Ó: "O", Ô: "O", Õ: "O", Ö: "O", Ő: "O", Ø: "O", Ù: "U", Ú: "U", Û: "U", Ű: "U", Ý: "Y", Þ: "TH", ß: "ss", à: "a", á: "a", â: "a", ã: "a", ä: "a", å: "a", æ: "ae", è: "e", é: "e", ê: "e", ë: "e", ì: "i", í: "i", î: "i", ï: "i", ð: "d", ñ: "n", ò: "o", ó: "o", ô: "o", õ: "o", ö: "o", ő: "o", ø: "o", ù: "u", ú: "u", û: "u", ű: "u", ý: "y", þ: "th", ÿ: "y", "©": "(c)", Γ: "G", Δ: "D", Θ: "8", Λ: "L", Ξ: "3", Π: "P", Σ: "S", Φ: "F", Ψ: "PS", Ω: "W", Ά: "A", Έ: "E", Ί: "I", Ό: "O", Ύ: "Y", Ή: "H", Ώ: "W", Ϊ: "I", Ϋ: "Y", β: "b", "γ": "y", δ: "d", ε: "e", ζ: "z", η: "h", θ: "8", ι: "i", κ: "k", λ: "l", μ: "m", ν: "n", ξ: "3", ο: "o", π: "p", ρ: "r", σ: "s", τ: "t", υ: "y", φ: "f", χ: "x", ψ: "ps", ω: "w", ά: "a", έ: "e", ί: "i", ό: "o", ύ: "y", ή: "h", ώ: "w", ς: "s", ϊ: "i", ΰ: "y", ϋ: "y", ΐ: "i", Ş: "S", İ: "I", Ü: "U", Ğ: "G", ş: "s", ı: "i", ç: "c", ü: "u", ğ: "g", А: "A", Б: "B", В: "V", Г: "G", Д: "D", Е: "E", Ё: "Yo", Ж: "Zh", З: "Z", И: "I", Й: "J", К: "K", Л: "L", М: "M", Н: "N", О: "O", П: "P", Р: "R", С: "S", Т: "T", У: "U", Ф: "F", Х: "H", Ц: "C", Ч: "Ch", Ш: "Sh", Щ: "Sh", Ъ: "", Ы: "Y", Ь: "", Э: "E", Ю: "Yu", Я: "Ya", а: "a", б: "b", в: "v", г: "g", д: "d", е: "e", ё: "yo", ж: "zh", з: "z", и: "i", й: "j", к: "k", л: "l", м: "m", н: "n", о: "o", п: "p", р: "r", с: "s", т: "t", у: "u", ф: "f", х: "h", ц: "c", ч: "ch", ш: "sh", щ: "sh", ъ: "", ы: "y", ь: "", э: "e", ю: "yu", я: "ya", Є: "Ye", І: "I", Ї: "Yi", Ґ: "G", є: "ye", і: "i", ї: "yi", ґ: "g", Č: "C", Ď: "D", Ě: "E", Ň: "N", Ř: "R", Š: "S", Ť: "T", Ů: "U", Ž: "Z", č: "c", ď: "d", ě: "e", ň: "n", ř: "r", š: "s", ť: "t", ů: "u", ž: "z", Ą: "A", Ć: "C", Ę: "e", Ł: "L", Ń: "N", Ś: "S", Ź: "Z", Ż: "Z", ą: "a", ć: "c", ę: "e", ł: "l", ń: "n", ś: "s", ź: "z", ż: "z", Ā: "A", Ē: "E", Ģ: "G", Ī: "i", Ķ: "k", Ļ: "L", Ņ: "N", Ū: "u", ā: "a", ē: "e", ģ: "g", ī: "i", ķ: "k", ļ: "l", ņ: "n", ū: "u" };
9
-
10
- /**
11
- * Get string between str1 and str2 from text
12
- */
13
- export const getBetween = (text: string, str1: string, str2 = "") => {
14
- if (!text) return "";
15
- if (text.indexOf(str1) <= -1) return "";
16
-
17
- const firstIndex = text.indexOf(str1) + str1.length;
18
- const secondIndex = str2 ? text.indexOf(str2, firstIndex) : text.length;
19
- return text.substring(firstIndex, secondIndex);
20
- };
21
-
22
- /**
23
- * Convert object to string
24
- */
25
- export const makeString = (object: any = "") => {
26
- /// Ensure some object is a coerced to a string
27
- if (isNull(object)) return "";
28
-
29
- return "" + object;
30
- };
31
-
32
- /**
33
- * toUpperCase
34
- */
35
- export const toUpperCase = (str = "") => {
36
- return makeString(str).toUpperCase();
37
- };
38
-
39
- /**
40
- * toLowerCase
41
- */
42
- export const toLowerCase = (str = "") => {
43
- return makeString(str).toLowerCase();
44
- };
45
-
46
- /**
47
- * toLowerCase
48
- * @param {*} str
49
- * @return {string}
50
- */
51
- export const titleize = (str = "") => {
52
- const regString = new RegExp(/(?:^|\s|-)\S/g);
53
- return toLowerCase(str).replace(regString, function (c) {
54
- return c.toUpperCase();
55
- });
56
- };
57
-
58
- /**
59
- * Convert only first charater to UpperCase
60
- */
61
- export const capitalize = (str: string | any, lowercaseRest = 1) => {
62
- str = makeString(str);
63
- const remainingChars = !lowercaseRest ? str.slice(1) : str.slice(1).toLowerCase();
64
-
65
- return str.charAt(0).toUpperCase() + remainingChars;
66
- };
67
-
68
- /**
69
- * Convert first character from every single words to UpperCase
70
- */
71
- export const capitalizeName = (str: string) => {
72
- str = makeString(str);
73
-
74
- str = str.trim();
75
- str = str.replace(/^\s+|\s+$/gm, "");
76
-
77
- str = str.toLowerCase();
78
-
79
- const arr = str.split(" ");
80
-
81
- str = arr
82
- .map((item) => {
83
- return capitalize(item);
84
- })
85
- .filter((x) => x)
86
- .join(" ");
87
-
88
- return str;
89
- };
90
-
91
- export const clearUnicodeCharacters = (s: string, opt: { [key: string]: any } = {}) => {
92
- s = makeString(s);
93
-
94
- var defaults: { [key: string]: any } = {
95
- delimiter: " ",
96
- lowercase: true,
97
- replacements: {},
98
- transliterate: typeof XRegExp === "undefined" ? true : false,
99
- };
100
-
101
- // Merge options
102
- for (var k in defaults) {
103
- if (!opt.hasOwnProperty(k)) {
104
- opt[k] = defaults[k];
105
- }
106
- }
107
-
108
- // Vietnamese
109
- s = s.replace(/á|à|ả|ạ|ã|ă|ắ|ằ|ẳ|ẵ|ặ|â|ấ|ầ|ẩ|ẫ|ậ/gi, "a");
110
- s = s.replace(/é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ/gi, "e");
111
- s = s.replace(/i|í|ì|ỉ|ĩ|ị/gi, "i");
112
- s = s.replace(/ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ/gi, "o");
113
- s = s.replace(/ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự/gi, "u");
114
- s = s.replace(/ý|ỳ|ỷ|ỹ|ỵ/gi, "y");
115
- s = s.replace(/đ/gi, "d");
116
- s = "@" + s + "@";
117
- s = s.replace(/\@\-|\-\@|\@/gi, "");
118
-
119
- // Make custom replacements
120
- for (var k in opt.replacements) {
121
- s = s.replace(RegExp(k, "g"), opt.replacements[k]);
122
- }
123
-
124
- // Transliterate characters to ASCII
125
- if (opt.transliterate) {
126
- for (var k in char_map) {
127
- s = s.replace(RegExp(k, "g"), char_map[k]);
128
- }
129
- }
130
-
131
- // Replace non-alphanumeric characters with our delimiter
132
- var alnum = typeof XRegExp === "undefined" ? RegExp("[^a-z0-9]+", "ig") : XRegExp("[^\\p{L}\\p{N}]+", "ig");
133
- s = s.replace(alnum, opt.delimiter);
134
-
135
- // Remove duplicate delimiters
136
- s = s.replace(RegExp("[" + opt.delimiter + "]{2,}", "g"), opt.delimiter);
137
-
138
- // Truncate slug to max. characters
139
- s = s.substring(0, opt.limit);
140
-
141
- // Remove delimiter from ends
142
- s = s.replace(RegExp("(^" + opt.delimiter + "|" + opt.delimiter + "$)", "g"), "");
143
-
144
- return opt.lowercase ? s.toLowerCase() : s;
145
- };
146
-
147
- import { makeDaySlug } from "./makeDaySlug";
148
- import { generateUUID } from "./generateUUID";
149
- import { randAllCharacterByLength, randomStringByLength } from "./random";
150
- import { formatNumber } from "./formatNumber";
151
- import { generatePassword } from "./generatePassword";
152
- import { trimNull } from "./trimNull";
153
- import { addQueryParam, getUrlParams, isLink, getFileNameWithoutExtension, getFileNameWithExtension, getFileExtension, isImage } from "./url";
154
-
155
- const xstring = {
156
- getBetween,
157
- makeString,
158
- makeDaySlug,
159
- toUpperCase,
160
- toLowerCase,
161
- titleize,
162
- capitalize,
163
- capitalizeName,
164
- clearUnicodeCharacters,
165
- generateUUID,
166
- randAllCharacterByLength,
167
- randomStringByLength,
168
- formatNumber,
169
- generatePassword,
170
- trimNull,
171
- addQueryParam,
172
- getUrlParams,
173
- isLink,
174
- getFileNameWithoutExtension,
175
- getFileNameWithExtension,
176
- getFileExtension,
177
- isImage,
178
- };
179
-
180
- export default xstring;
1
+ // import { log } from "../../helper/log";
2
+ // import { startCase, toLower } from "lodash";
3
+ declare var XRegExp: any;
4
+
5
+ import { isNull } from "../object";
6
+
7
+ //prettier-ignore
8
+ const char_map: { [key: string]: any } = { À: "A", Á: "A", Â: "A", Ã: "A", Ä: "A", Å: "A", Æ: "AE", Ç: "C", È: "E", É: "E", Ê: "E", Ë: "E", Ì: "I", Í: "I", Î: "I", Ï: "I", Ð: "D", Ñ: "N", Ò: "O", Ó: "O", Ô: "O", Õ: "O", Ö: "O", Ő: "O", Ø: "O", Ù: "U", Ú: "U", Û: "U", Ű: "U", Ý: "Y", Þ: "TH", ß: "ss", à: "a", á: "a", â: "a", ã: "a", ä: "a", å: "a", æ: "ae", è: "e", é: "e", ê: "e", ë: "e", ì: "i", í: "i", î: "i", ï: "i", ð: "d", ñ: "n", ò: "o", ó: "o", ô: "o", õ: "o", ö: "o", ő: "o", ø: "o", ù: "u", ú: "u", û: "u", ű: "u", ý: "y", þ: "th", ÿ: "y", "©": "(c)", Γ: "G", Δ: "D", Θ: "8", Λ: "L", Ξ: "3", Π: "P", Σ: "S", Φ: "F", Ψ: "PS", Ω: "W", Ά: "A", Έ: "E", Ί: "I", Ό: "O", Ύ: "Y", Ή: "H", Ώ: "W", Ϊ: "I", Ϋ: "Y", β: "b", "γ": "y", δ: "d", ε: "e", ζ: "z", η: "h", θ: "8", ι: "i", κ: "k", λ: "l", μ: "m", ν: "n", ξ: "3", ο: "o", π: "p", ρ: "r", σ: "s", τ: "t", υ: "y", φ: "f", χ: "x", ψ: "ps", ω: "w", ά: "a", έ: "e", ί: "i", ό: "o", ύ: "y", ή: "h", ώ: "w", ς: "s", ϊ: "i", ΰ: "y", ϋ: "y", ΐ: "i", Ş: "S", İ: "I", Ü: "U", Ğ: "G", ş: "s", ı: "i", ç: "c", ü: "u", ğ: "g", А: "A", Б: "B", В: "V", Г: "G", Д: "D", Е: "E", Ё: "Yo", Ж: "Zh", З: "Z", И: "I", Й: "J", К: "K", Л: "L", М: "M", Н: "N", О: "O", П: "P", Р: "R", С: "S", Т: "T", У: "U", Ф: "F", Х: "H", Ц: "C", Ч: "Ch", Ш: "Sh", Щ: "Sh", Ъ: "", Ы: "Y", Ь: "", Э: "E", Ю: "Yu", Я: "Ya", а: "a", б: "b", в: "v", г: "g", д: "d", е: "e", ё: "yo", ж: "zh", з: "z", и: "i", й: "j", к: "k", л: "l", м: "m", н: "n", о: "o", п: "p", р: "r", с: "s", т: "t", у: "u", ф: "f", х: "h", ц: "c", ч: "ch", ш: "sh", щ: "sh", ъ: "", ы: "y", ь: "", э: "e", ю: "yu", я: "ya", Є: "Ye", І: "I", Ї: "Yi", Ґ: "G", є: "ye", і: "i", ї: "yi", ґ: "g", Č: "C", Ď: "D", Ě: "E", Ň: "N", Ř: "R", Š: "S", Ť: "T", Ů: "U", Ž: "Z", č: "c", ď: "d", ě: "e", ň: "n", ř: "r", š: "s", ť: "t", ů: "u", ž: "z", Ą: "A", Ć: "C", Ę: "e", Ł: "L", Ń: "N", Ś: "S", Ź: "Z", Ż: "Z", ą: "a", ć: "c", ę: "e", ł: "l", ń: "n", ś: "s", ź: "z", ż: "z", Ā: "A", Ē: "E", Ģ: "G", Ī: "i", Ķ: "k", Ļ: "L", Ņ: "N", Ū: "u", ā: "a", ē: "e", ģ: "g", ī: "i", ķ: "k", ļ: "l", ņ: "n", ū: "u" };
9
+
10
+ /**
11
+ * Get string between str1 and str2 from text
12
+ */
13
+ export const getBetween = (text: string, str1: string, str2 = "") => {
14
+ if (!text) return "";
15
+ if (text.indexOf(str1) <= -1) return "";
16
+
17
+ const firstIndex = text.indexOf(str1) + str1.length;
18
+ const secondIndex = str2 ? text.indexOf(str2, firstIndex) : text.length;
19
+ return text.substring(firstIndex, secondIndex);
20
+ };
21
+
22
+ /**
23
+ * Convert object to string
24
+ */
25
+ export const makeString = (object: any = "") => {
26
+ /// Ensure some object is a coerced to a string
27
+ if (isNull(object)) return "";
28
+
29
+ return "" + object;
30
+ };
31
+
32
+ /**
33
+ * toUpperCase
34
+ */
35
+ export const toUpperCase = (str = "") => {
36
+ return makeString(str).toUpperCase();
37
+ };
38
+
39
+ /**
40
+ * toLowerCase
41
+ */
42
+ export const toLowerCase = (str = "") => {
43
+ return makeString(str).toLowerCase();
44
+ };
45
+
46
+ /**
47
+ * toLowerCase
48
+ * @param {*} str
49
+ * @return {string}
50
+ */
51
+ export const titleize = (str = "") => {
52
+ const regString = new RegExp(/(?:^|\s|-)\S/g);
53
+ return toLowerCase(str).replace(regString, function (c) {
54
+ return c.toUpperCase();
55
+ });
56
+ };
57
+
58
+ /**
59
+ * Convert only first charater to UpperCase
60
+ */
61
+ export const capitalize = (str: string | any, lowercaseRest = 1) => {
62
+ str = makeString(str);
63
+ const remainingChars = !lowercaseRest ? str.slice(1) : str.slice(1).toLowerCase();
64
+
65
+ return str.charAt(0).toUpperCase() + remainingChars;
66
+ };
67
+
68
+ /**
69
+ * Convert first character from every single words to UpperCase
70
+ */
71
+ export const capitalizeName = (str: string) => {
72
+ str = makeString(str);
73
+
74
+ str = str.trim();
75
+ str = str.replace(/^\s+|\s+$/gm, "");
76
+
77
+ str = str.toLowerCase();
78
+
79
+ const arr = str.split(" ");
80
+
81
+ str = arr
82
+ .map((item) => {
83
+ return capitalize(item);
84
+ })
85
+ .filter((x) => x)
86
+ .join(" ");
87
+
88
+ return str;
89
+ };
90
+
91
+ export const clearUnicodeCharacters = (s: string, opt: { [key: string]: any } = {}) => {
92
+ s = makeString(s);
93
+
94
+ var defaults: { [key: string]: any } = {
95
+ delimiter: " ",
96
+ lowercase: true,
97
+ replacements: {},
98
+ transliterate: typeof XRegExp === "undefined" ? true : false,
99
+ };
100
+
101
+ // Merge options
102
+ for (var k in defaults) {
103
+ if (!opt.hasOwnProperty(k)) {
104
+ opt[k] = defaults[k];
105
+ }
106
+ }
107
+
108
+ // Vietnamese
109
+ s = s.replace(/á|à|ả|ạ|ã|ă|ắ|ằ|ẳ|ẵ|ặ|â|ấ|ầ|ẩ|ẫ|ậ/gi, "a");
110
+ s = s.replace(/é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ/gi, "e");
111
+ s = s.replace(/i|í|ì|ỉ|ĩ|ị/gi, "i");
112
+ s = s.replace(/ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ/gi, "o");
113
+ s = s.replace(/ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự/gi, "u");
114
+ s = s.replace(/ý|ỳ|ỷ|ỹ|ỵ/gi, "y");
115
+ s = s.replace(/đ/gi, "d");
116
+ s = "@" + s + "@";
117
+ s = s.replace(/\@\-|\-\@|\@/gi, "");
118
+
119
+ // Make custom replacements
120
+ for (var k in opt.replacements) {
121
+ s = s.replace(RegExp(k, "g"), opt.replacements[k]);
122
+ }
123
+
124
+ // Transliterate characters to ASCII
125
+ if (opt.transliterate) {
126
+ for (var k in char_map) {
127
+ s = s.replace(RegExp(k, "g"), char_map[k]);
128
+ }
129
+ }
130
+
131
+ // Replace non-alphanumeric characters with our delimiter
132
+ var alnum = typeof XRegExp === "undefined" ? RegExp("[^a-z0-9]+", "ig") : XRegExp("[^\\p{L}\\p{N}]+", "ig");
133
+ s = s.replace(alnum, opt.delimiter);
134
+
135
+ // Remove duplicate delimiters
136
+ s = s.replace(RegExp("[" + opt.delimiter + "]{2,}", "g"), opt.delimiter);
137
+
138
+ // Truncate slug to max. characters
139
+ s = s.substring(0, opt.limit);
140
+
141
+ // Remove delimiter from ends
142
+ s = s.replace(RegExp("(^" + opt.delimiter + "|" + opt.delimiter + "$)", "g"), "");
143
+
144
+ return opt.lowercase ? s.toLowerCase() : s;
145
+ };
146
+
147
+ import { makeDaySlug } from "./makeDaySlug";
148
+ import { generateUUID } from "./generateUUID";
149
+ import { randAllCharacterByLength, randomStringByLength } from "./random";
150
+ import { formatNumber } from "./formatNumber";
151
+ import { generatePassword } from "./generatePassword";
152
+ import { trimNull } from "./trimNull";
153
+ import { addQueryParam, getUrlParams, isLink, getFileNameWithoutExtension, getFileNameWithExtension, getFileExtension, isImage } from "./url";
154
+
155
+ const xstring = {
156
+ getBetween,
157
+ makeString,
158
+ makeDaySlug,
159
+ toUpperCase,
160
+ toLowerCase,
161
+ titleize,
162
+ capitalize,
163
+ capitalizeName,
164
+ clearUnicodeCharacters,
165
+ generateUUID,
166
+ randAllCharacterByLength,
167
+ randomStringByLength,
168
+ formatNumber,
169
+ generatePassword,
170
+ trimNull,
171
+ addQueryParam,
172
+ getUrlParams,
173
+ isLink,
174
+ getFileNameWithoutExtension,
175
+ getFileNameWithExtension,
176
+ getFileExtension,
177
+ isImage,
178
+ };
179
+
180
+ export default xstring;