diginext-utils 2.0.6 → 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 (155) hide show
  1. package/dist/Checker.d.ts +5 -0
  2. package/dist/Checker.js +30 -0
  3. package/dist/Checker.js.map +1 -0
  4. package/dist/EventDispatcher.d.ts +11 -0
  5. package/dist/EventDispatcher.js +51 -0
  6. package/dist/EventDispatcher.js.map +1 -0
  7. package/dist/FileUpload.d.ts +11 -0
  8. package/dist/FileUpload.js +64 -0
  9. package/dist/FileUpload.js.map +1 -0
  10. package/dist/Slug.d.ts +4 -0
  11. package/dist/Slug.js +332 -0
  12. package/dist/Slug.js.map +1 -0
  13. package/dist/Timer.d.ts +3 -0
  14. package/dist/Timer.js +9 -0
  15. package/dist/Timer.js.map +1 -0
  16. package/dist/Validation.d.ts +4 -0
  17. package/dist/Validation.js +39 -0
  18. package/dist/Validation.js.map +1 -0
  19. package/dist/array.d.ts +91 -0
  20. package/dist/array.js +275 -0
  21. package/dist/array.js.map +1 -0
  22. package/dist/color.d.ts +10 -0
  23. package/dist/color.js +86 -0
  24. package/dist/color.js.map +1 -0
  25. package/dist/console/enableConsole.d.ts +1 -3
  26. package/dist/console/enableConsole.js +10 -14
  27. package/dist/console/enableConsole.js.map +1 -0
  28. package/dist/console/index.d.ts +3 -5
  29. package/dist/console/index.js +12 -16
  30. package/dist/console/index.js.map +1 -0
  31. package/dist/device/browser.d.ts +5 -7
  32. package/dist/device/browser.js +32 -34
  33. package/dist/device/browser.js.map +1 -0
  34. package/dist/device/camera.d.ts +7 -16
  35. package/dist/device/camera.js +166 -157
  36. package/dist/device/camera.js.map +1 -0
  37. package/dist/device.d.ts +4 -0
  38. package/dist/device.js +217 -0
  39. package/dist/device.js.map +1 -0
  40. package/dist/file/createDir.d.ts +1 -2
  41. package/dist/file/createDir.js +13 -20
  42. package/dist/file/createDir.js.map +1 -0
  43. package/dist/file/fileMove.d.ts +1 -3
  44. package/dist/file/fileMove.js +29 -35
  45. package/dist/file/fileMove.js.map +1 -0
  46. package/dist/file/findFilesByExt.d.ts +0 -1
  47. package/dist/file/findFilesByExt.js +41 -46
  48. package/dist/file/findFilesByExt.js.map +1 -0
  49. package/dist/index.d.ts +16 -0
  50. package/dist/index.js +33 -0
  51. package/dist/index.js.map +1 -0
  52. package/dist/math/diffDate.d.ts +1 -3
  53. package/dist/math/diffDate.js +10 -9
  54. package/dist/math/diffDate.js.map +1 -0
  55. package/dist/math/index.d.ts +8 -10
  56. package/dist/math/index.js +92 -48
  57. package/dist/math/index.js.map +1 -0
  58. package/dist/math/positiveNumber.d.ts +1 -3
  59. package/dist/math/positiveNumber.js +13 -27
  60. package/dist/math/positiveNumber.js.map +1 -0
  61. package/dist/name/en.d.ts +1 -3
  62. package/dist/name/en.js +17 -12
  63. package/dist/name/en.js.map +1 -0
  64. package/dist/name/vi.d.ts +1 -3
  65. package/dist/name/vi.js +23 -34
  66. package/dist/name/vi.js.map +1 -0
  67. package/dist/object.d.ts +23 -0
  68. package/dist/object.js +57 -0
  69. package/dist/object.js.map +1 -0
  70. package/dist/permission/requestCamera.d.ts +2 -3
  71. package/dist/permission/requestCamera.js +37 -25
  72. package/dist/permission/requestCamera.js.map +1 -0
  73. package/dist/permission/requestDeviceOrientationControl.d.ts +0 -1
  74. package/dist/permission/requestDeviceOrientationControl.js +35 -174
  75. package/dist/permission/requestDeviceOrientationControl.js.map +1 -0
  76. package/dist/string/formatNumber.d.ts +1 -3
  77. package/dist/string/formatNumber.js +11 -27
  78. package/dist/string/formatNumber.js.map +1 -0
  79. package/dist/string/generatePassword.d.ts +1 -3
  80. package/dist/string/generatePassword.js +20 -26
  81. package/dist/string/generatePassword.js.map +1 -0
  82. package/dist/string/generateUUID.d.ts +1 -3
  83. package/dist/string/generateUUID.js +33 -13
  84. package/dist/string/generateUUID.js.map +1 -0
  85. package/dist/string/index.d.ts +8 -10
  86. package/dist/string/index.js +118 -96
  87. package/dist/string/index.js.map +1 -0
  88. package/dist/string/random.d.ts +6 -8
  89. package/dist/string/random.js +20 -23
  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 -19
  93. package/dist/string/trimNull.js.map +1 -0
  94. package/dist/string/url.d.ts +7 -14
  95. package/dist/string/url.js +92 -77
  96. package/dist/string/url.js.map +1 -0
  97. package/package.json +6 -8
  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/esm/chunk-5HIQS7HE.js +0 -40
  131. package/dist/esm/chunk-EZUCZHGV.js +0 -9
  132. package/dist/esm/chunk-HDM7KM5F.js +0 -20
  133. package/dist/esm/chunk-LNLCKCWC.js +0 -17
  134. package/dist/esm/chunk-X3K4KC75.js +0 -26
  135. package/dist/esm/console/enableConsole.js +0 -9
  136. package/dist/esm/console/index.js +0 -15
  137. package/dist/esm/device/browser.js +0 -34
  138. package/dist/esm/device/camera.js +0 -137
  139. package/dist/esm/file/createDir.js +0 -13
  140. package/dist/esm/file/fileMove.js +0 -29
  141. package/dist/esm/file/findFilesByExt.js +0 -39
  142. package/dist/esm/math/diffDate.js +0 -10
  143. package/dist/esm/math/index.js +0 -2
  144. package/dist/esm/math/positiveNumber.js +0 -16
  145. package/dist/esm/name/en.js +0 -17
  146. package/dist/esm/name/vi.js +0 -31
  147. package/dist/esm/permission/requestCamera.js +0 -2
  148. package/dist/esm/permission/requestDeviceOrientationControl.js +0 -175
  149. package/dist/esm/string/formatNumber.js +0 -10
  150. package/dist/esm/string/generatePassword.js +0 -16
  151. package/dist/esm/string/generateUUID.js +0 -14
  152. package/dist/esm/string/index.js +0 -86
  153. package/dist/esm/string/random.js +0 -2
  154. package/dist/esm/string/trimNull.js +0 -14
  155. package/dist/esm/string/url.js +0 -69
@@ -1,177 +1,38 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- // src/device.ts
6
- var isAndroid = () => {
7
- const deviceInfo2 = checkOS();
8
- if (deviceInfo2)
9
- return deviceInfo2.os.toLowerCase() == "android";
10
- console.log("Can't check OS");
11
- return null;
12
- };
13
- var deviceInfo;
14
- var checkOS = () => {
15
- if (typeof window == "undefined")
16
- return {};
17
- if (typeof deviceInfo == "undefined") {
18
- var unknown = "-";
19
- var screenSize = "";
20
- if (screen.width) {
21
- var width = screen.width ? screen.width : "";
22
- var height = screen.height ? screen.height : "";
23
- screenSize += "" + width + " x " + height;
24
- }
25
- var nVer = navigator.appVersion;
26
- var nAgt = navigator.userAgent;
27
- var browser = navigator.appName;
28
- var version = "" + parseFloat(navigator.appVersion);
29
- var majorVersion = parseInt(navigator.appVersion, 10);
30
- var nameOffset, verOffset, ix;
31
- if ((verOffset = nAgt.indexOf("Opera")) != -1) {
32
- browser = "Opera";
33
- version = nAgt.substring(verOffset + 6);
34
- if ((verOffset = nAgt.indexOf("Version")) != -1) {
35
- version = nAgt.substring(verOffset + 8);
36
- }
37
- }
38
- if ((verOffset = nAgt.indexOf("OPR")) != -1) {
39
- browser = "Opera";
40
- version = nAgt.substring(verOffset + 4);
41
- } else if ((verOffset = nAgt.indexOf("Edge")) != -1) {
42
- browser = "Microsoft Edge";
43
- version = nAgt.substring(verOffset + 5);
44
- } else if ((verOffset = nAgt.indexOf("MSIE")) != -1) {
45
- browser = "Microsoft Internet Explorer";
46
- version = nAgt.substring(verOffset + 5);
47
- } else if ((verOffset = nAgt.indexOf("Chrome")) != -1) {
48
- browser = "Chrome";
49
- version = nAgt.substring(verOffset + 7);
50
- } else if ((verOffset = nAgt.indexOf("Safari")) != -1) {
51
- browser = "Safari";
52
- version = nAgt.substring(verOffset + 7);
53
- if ((verOffset = nAgt.indexOf("Version")) != -1) {
54
- version = nAgt.substring(verOffset + 8);
55
- }
56
- } else if ((verOffset = nAgt.indexOf("Firefox")) != -1) {
57
- browser = "Firefox";
58
- version = nAgt.substring(verOffset + 8);
59
- } else if (nAgt.indexOf("Trident/") != -1) {
60
- browser = "Microsoft Internet Explorer";
61
- version = nAgt.substring(nAgt.indexOf("rv:") + 3);
62
- } else if ((nameOffset = nAgt.lastIndexOf(" ") + 1) < (verOffset = nAgt.lastIndexOf("/"))) {
63
- browser = nAgt.substring(nameOffset, verOffset);
64
- version = nAgt.substring(verOffset + 1);
65
- if (browser.toLowerCase() == browser.toUpperCase()) {
66
- browser = navigator.appName;
67
- }
68
- }
69
- if ((ix = version.indexOf(";")) != -1)
70
- version = version.substring(0, ix);
71
- if ((ix = version.indexOf(" ")) != -1)
72
- version = version.substring(0, ix);
73
- if ((ix = version.indexOf(")")) != -1)
74
- version = version.substring(0, ix);
75
- majorVersion = parseInt("" + version, 10);
76
- if (isNaN(majorVersion)) {
77
- version = "" + parseFloat(navigator.appVersion);
78
- majorVersion = parseInt(navigator.appVersion, 10);
79
- }
80
- var mobile = /Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(nVer);
81
- var cookieEnabled = navigator.cookieEnabled ? true : false;
82
- if (typeof navigator.cookieEnabled == "undefined" && !cookieEnabled) {
83
- document.cookie = "testcookie";
84
- cookieEnabled = document.cookie.indexOf("testcookie") != -1 ? true : false;
85
- }
86
- var os = unknown;
87
- var clientStrings = [
88
- { s: "Windows 10", r: /(Windows 10.0|Windows NT 10.0)/ },
89
- { s: "Windows 8.1", r: /(Windows 8.1|Windows NT 6.3)/ },
90
- { s: "Windows 8", r: /(Windows 8|Windows NT 6.2)/ },
91
- { s: "Windows 7", r: /(Windows 7|Windows NT 6.1)/ },
92
- { s: "Windows Vista", r: /Windows NT 6.0/ },
93
- { s: "Windows Server 2003", r: /Windows NT 5.2/ },
94
- { s: "Windows XP", r: /(Windows NT 5.1|Windows XP)/ },
95
- { s: "Windows 2000", r: /(Windows NT 5.0|Windows 2000)/ },
96
- { s: "Windows ME", r: /(Win 9x 4.90|Windows ME)/ },
97
- { s: "Windows 98", r: /(Windows 98|Win98)/ },
98
- { s: "Windows 95", r: /(Windows 95|Win95|Windows_95)/ },
99
- { s: "Windows NT 4.0", r: /(Windows NT 4.0|WinNT4.0|WinNT|Windows NT)/ },
100
- { s: "Windows CE", r: /Windows CE/ },
101
- { s: "Windows 3.11", r: /Win16/ },
102
- { s: "Android", r: /Android/ },
103
- { s: "Open BSD", r: /OpenBSD/ },
104
- { s: "Sun OS", r: /SunOS/ },
105
- { s: "Linux", r: /(Linux|X11)/ },
106
- { s: "iOS", r: /(iPhone|iPad|iPod)/ },
107
- { s: "Mac OS X", r: /Mac OS X/ },
108
- { s: "Mac OS", r: /(MacPPC|MacIntel|Mac_PowerPC|Macintosh)/ },
109
- { s: "QNX", r: /QNX/ },
110
- { s: "UNIX", r: /UNIX/ },
111
- { s: "BeOS", r: /BeOS/ },
112
- { s: "OS/2", r: /OS\/2/ },
113
- { s: "Search Bot", r: /(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver)/ }
114
- ];
115
- for (var id in clientStrings) {
116
- var cs = clientStrings[id];
117
- if (cs.r.test(nAgt)) {
118
- os = cs.s;
119
- break;
120
- }
121
- }
122
- var osVersion = unknown;
123
- if (/Windows/.test(os)) {
124
- osVersion = /Windows (.*)/.exec(os)[1];
125
- os = "Windows";
126
- }
127
- switch (os) {
128
- case "Mac OS X":
129
- osVersion = /Mac OS X (10[\.\_\d]+)/.exec(nAgt)[1];
130
- break;
131
- case "Android":
132
- osVersion = /Android ([\.\_\d]+)/.exec(nAgt)[1];
133
- break;
134
- case "iOS":
135
- const _osVersion = /OS (\d+)_(\d+)_?(\d+)?/.exec(nVer);
136
- osVersion = _osVersion[1] + "." + _osVersion[2] + "." + (_osVersion[3] || 0);
137
- break;
138
- }
139
- const _deviceInfo = {
140
- screen: screenSize,
141
- browser,
142
- browserVersion: version,
143
- browserMajorVersion: majorVersion,
144
- mobile,
145
- os,
146
- osVersion,
147
- cookies: cookieEnabled
148
- };
149
- deviceInfo = _deviceInfo;
150
- }
151
- return deviceInfo;
152
- };
153
-
154
- // src/permission/requestDeviceOrientationControl.ts
155
- var requestDeviceOrientationControl = () => {
156
- if (typeof window == "undefined")
157
- return false;
158
- return new Promise((resolve, reject) => {
159
- if (isAndroid())
160
- resolve(true);
161
- if (typeof DeviceMotionEvent != "undefined" && DeviceMotionEvent.requestPermission) {
162
- DeviceMotionEvent.requestPermission().then((response) => {
163
- if (response == "granted") {
164
- resolve(true);
165
- } else {
166
- resolve(false);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.requestDeviceOrientationControl = void 0;
4
+ const device_1 = require("../device");
5
+ const requestDeviceOrientationControl = () => {
6
+ if (typeof window == "undefined")
7
+ return false;
8
+ return new Promise((resolve, reject) => {
9
+ if ((0, device_1.isAndroid)())
10
+ resolve(true);
11
+ if (typeof DeviceMotionEvent != "undefined" && DeviceMotionEvent.requestPermission) {
12
+ // (optional) Do something before API request prompt.
13
+ DeviceMotionEvent
14
+ .requestPermission()
15
+ .then((response) => {
16
+ // (optional) Do something after API prompt dismissed.
17
+ if (response == "granted") {
18
+ resolve(true);
19
+ // resolve({ status: true })
20
+ }
21
+ else {
22
+ resolve(false);
23
+ // resolve({ status: false, reason: "DeviceMotionEvent is not support" })
24
+ }
25
+ })
26
+ .catch((response) => {
27
+ resolve(false);
28
+ // resolve({ status: false, reason: response })
29
+ });
30
+ }
31
+ else {
32
+ resolve(false);
33
+ // resolve({ status: false, reason: "DeviceMotionEvent is not defined" })
167
34
  }
168
- }).catch((response) => {
169
- resolve(false);
170
- });
171
- } else {
172
- resolve(false);
173
- }
174
- });
35
+ });
175
36
  };
176
-
177
37
  exports.requestDeviceOrientationControl = requestDeviceOrientationControl;
38
+ //# sourceMappingURL=requestDeviceOrientationControl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requestDeviceOrientationControl.js","sourceRoot":"","sources":["../../src/permission/requestDeviceOrientationControl.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AAEtC,MAAM,+BAA+B,GAAG,GAAG,EAAE;IAC5C,IAAI,OAAO,MAAM,IAAI,WAAW;QAAE,OAAO,KAAK,CAAC;IAC/C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtC,IAAI,IAAA,kBAAS,GAAE;YAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QAE/B,IAAI,OAAO,iBAAiB,IAAI,WAAW,IAAK,iBAAyB,CAAC,iBAAiB,EAAE;YAC5F,qDAAqD;YACpD,iBAAyB;iBACxB,iBAAiB,EAAE;iBACnB,IAAI,CAAC,CAAC,QAAa,EAAE,EAAE;gBACvB,sDAAsD;gBACtD,IAAI,QAAQ,IAAI,SAAS,EAAE;oBAC1B,OAAO,CAAC,IAAI,CAAC,CAAC;oBACd,4BAA4B;iBAC5B;qBAAM;oBACN,OAAO,CAAC,KAAK,CAAC,CAAC;oBACf,yEAAyE;iBACzE;YACF,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,QAAa,EAAE,EAAE;gBACxB,OAAO,CAAC,KAAK,CAAC,CAAC;gBACf,+CAA+C;YAChD,CAAC,CAAC,CAAC;SACJ;aAAM;YACN,OAAO,CAAC,KAAK,CAAC,CAAC;YACf,yEAAyE;SACzE;IACF,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC;AAEO,0EAA+B"}
@@ -2,6 +2,4 @@
2
2
  * Format the input number with commas
3
3
  * @example 1000000 -> 1,000,000
4
4
  */
5
- declare function formatNumber(num: number, prefix?: string): string;
6
-
7
- export { formatNumber };
5
+ export declare function formatNumber(num: number, prefix?: string): string;
@@ -1,30 +1,14 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- // src/object.ts
6
- var isNull = (object) => {
7
- if (typeof object == "undefined")
8
- return true;
9
- if (object == "")
10
- return true;
11
- if (Array.isArray(object))
12
- return object.length == 0;
13
- if (JSON.stringify(object) == "{}")
14
- return true;
15
- return object == null;
16
- };
17
- var toInt = (object) => {
18
- if (isNull(object))
19
- return 0;
20
- object = object.toString();
21
- return parseInt(object, 10);
22
- };
23
-
24
- // src/string/formatNumber.ts
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatNumber = void 0;
4
+ const object_1 = require("../object");
5
+ /**
6
+ * Format the input number with commas
7
+ * @example 1000000 -> 1,000,000
8
+ */
25
9
  function formatNumber(num, prefix = "$") {
26
- const numRound = Math.round((toInt(num) + Number.EPSILON) * 100) / 100;
27
- return Number.isNaN(numRound) ? "0" : "" + numRound.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, prefix + "1,");
10
+ const numRound = Math.round(((0, object_1.toInt)(num) + Number.EPSILON) * 100) / 100;
11
+ return Number.isNaN(numRound) ? "0" : "" + numRound.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, prefix + "1,");
28
12
  }
29
-
30
13
  exports.formatNumber = formatNumber;
14
+ //# sourceMappingURL=formatNumber.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatNumber.js","sourceRoot":"","sources":["../../src/string/formatNumber.ts"],"names":[],"mappings":";;;AAAA,sCAAkC;AAElC;;;GAGG;AACH,SAAgB,YAAY,CAAC,GAAW,EAAE,MAAM,GAAG,GAAG;IACrD,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,IAAA,cAAK,EAAC,GAAG,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;IACvE,OAAO,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,yBAAyB,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;AAClH,CAAC;AAHD,oCAGC"}
@@ -5,6 +5,4 @@
5
5
  * @param {Boolean} hard
6
6
  * @returns
7
7
  */
8
- declare function generatePassword(length?: number, hard?: boolean): string;
9
-
10
- export { generatePassword };
8
+ export declare function generatePassword(length?: number, hard?: boolean): string;
@@ -1,29 +1,23 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- // src/string/random.ts
6
- var textLowCase = "abcdefghijklmnopqrstuvwxyz";
7
- var numeric = "0123456789";
8
- var punctuation = "!@#$%^&*()_+~|}{[];?><,./-=";
9
- var randomStringByLength = (length, str = textLowCase) => {
10
- let result = "";
11
- for (let i = 0; i < length; i++) {
12
- result += str.charAt(Math.floor(Math.random() * str.length));
13
- }
14
- return result;
15
- };
16
-
17
- // src/string/generatePassword.ts
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generatePassword = void 0;
4
+ const random_1 = require("./random");
5
+ /**
6
+ * random password
7
+ * - if hard = true -> random punctuation inside
8
+ * @param {*} length
9
+ * @param {Boolean} hard
10
+ * @returns
11
+ */
18
12
  function generatePassword(length = 6, hard = true) {
19
- if (!Number.isFinite(length))
20
- length = 6;
21
- if (length <= 0)
22
- length = 6;
23
- let pass = randomStringByLength(length, textLowCase + textLowCase.toUpperCase() + numeric);
24
- if (hard)
25
- pass = pass.replace(pass[Math.floor(pass.length / 2)], randomStringByLength(1, punctuation));
26
- return pass;
13
+ if (!Number.isFinite(length))
14
+ length = 6;
15
+ if (length <= 0)
16
+ length = 6;
17
+ let pass = (0, random_1.randomStringByLength)(length, random_1.textLowCase + random_1.textLowCase.toUpperCase() + random_1.numeric);
18
+ if (hard)
19
+ pass = pass.replace(pass[Math.floor(pass.length / 2)], (0, random_1.randomStringByLength)(1, random_1.punctuation));
20
+ return pass;
27
21
  }
28
-
29
22
  exports.generatePassword = generatePassword;
23
+ //# sourceMappingURL=generatePassword.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generatePassword.js","sourceRoot":"","sources":["../../src/string/generatePassword.ts"],"names":[],"mappings":";;;AAAA,qCAAmF;AAEnF;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,IAAI,GAAG,IAAI;IACvD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,MAAM,GAAG,CAAC,CAAC;IACzC,IAAI,MAAM,IAAI,CAAC;QAAE,MAAM,GAAG,CAAC,CAAC;IAC5B,IAAI,IAAI,GAAG,IAAA,6BAAoB,EAAC,MAAM,EAAE,oBAAW,GAAG,oBAAW,CAAC,WAAW,EAAE,GAAG,gBAAO,CAAC,CAAC;IAC3F,IAAI,IAAI;QAAE,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,IAAA,6BAAoB,EAAC,CAAC,EAAE,oBAAW,CAAC,CAAC,CAAC;IACvG,OAAO,IAAI,CAAC;AACb,CAAC;AAND,4CAMC"}
@@ -1,3 +1 @@
1
- declare function generateUUID(): string;
2
-
3
- export { generateUUID };
1
+ export declare function generateUUID(): string;
@@ -1,16 +1,36 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- // src/string/generateUUID.ts
6
- var _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"];
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateUUID = void 0;
4
+ //prettier-ignore
5
+ 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'];
7
6
  function generateUUID() {
8
- const d0 = Math.random() * 4294967295 | 0;
9
- const d1 = Math.random() * 4294967295 | 0;
10
- const d2 = Math.random() * 4294967295 | 0;
11
- const d3 = Math.random() * 4294967295 | 0;
12
- const uuid = _lut[d0 & 255] + _lut[d0 >> 8 & 255] + _lut[d0 >> 16 & 255] + _lut[d0 >> 24 & 255] + "-" + _lut[d1 & 255] + _lut[d1 >> 8 & 255] + "-" + _lut[d1 >> 16 & 15 | 64] + _lut[d1 >> 24 & 255] + "-" + _lut[d2 & 63 | 128] + _lut[d2 >> 8 & 255] + "-" + _lut[d2 >> 16 & 255] + _lut[d2 >> 24 & 255] + _lut[d3 & 255] + _lut[d3 >> 8 & 255] + _lut[d3 >> 16 & 255] + _lut[d3 >> 24 & 255];
13
- return uuid.toLowerCase();
7
+ // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
8
+ const d0 = (Math.random() * 0xffffffff) | 0;
9
+ const d1 = (Math.random() * 0xffffffff) | 0;
10
+ const d2 = (Math.random() * 0xffffffff) | 0;
11
+ const d3 = (Math.random() * 0xffffffff) | 0;
12
+ const uuid = _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
+ // .toLowerCase() here flattens concatenated strings to save heap memory space.
33
+ return uuid.toLowerCase();
14
34
  }
15
-
16
35
  exports.generateUUID = generateUUID;
36
+ //# sourceMappingURL=generateUUID.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateUUID.js","sourceRoot":"","sources":["../../src/string/generateUUID.ts"],"names":[],"mappings":";;;AAAA,iBAAiB;AACjB,MAAM,IAAI,GAAG,CAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE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C;QACvB,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;IAEzB,+EAA+E;IAC/E,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;AAC3B,CAAC;AA/BD,oCA+BC"}
@@ -1,35 +1,33 @@
1
1
  /**
2
2
  * Get string between str1 and str2 from text
3
3
  */
4
- declare const getBetween: (text: string, str1: string, str2?: string) => string;
4
+ export declare const getBetween: (text: string, str1: string, str2?: string) => string;
5
5
  /**
6
6
  * Convert object to string
7
7
  */
8
- declare const makeString: (object?: any) => string;
8
+ export declare const makeString: (object?: any) => string;
9
9
  /**
10
10
  * toUpperCase
11
11
  */
12
- declare const toUpperCase: (str?: string) => string;
12
+ export declare const toUpperCase: (str?: string) => string;
13
13
  /**
14
14
  * toLowerCase
15
15
  */
16
- declare const toLowerCase: (str?: string) => string;
16
+ export declare const toLowerCase: (str?: string) => string;
17
17
  /**
18
18
  * toLowerCase
19
19
  * @param {*} str
20
20
  * @return {string}
21
21
  */
22
- declare const titleize: (str?: string) => string;
22
+ export declare const titleize: (str?: string) => string;
23
23
  /**
24
24
  * Convert only first charater to UpperCase
25
25
  */
26
- declare const capitalize: (str: string | any, lowercaseRest?: number) => any;
26
+ export declare const capitalize: (str: string | any, lowercaseRest?: number) => any;
27
27
  /**
28
28
  * Convert first character from every single words to UpperCase
29
29
  */
30
- declare const capitalizeName: (str: string) => string;
31
- declare const clearUnicodeCharacters: (s: string, opt?: {
30
+ export declare const capitalizeName: (str: string) => string;
31
+ export declare const clearUnicodeCharacters: (s: string, opt?: {
32
32
  [key: string]: any;
33
33
  }) => string;
34
-
35
- export { capitalize, capitalizeName, clearUnicodeCharacters, getBetween, makeString, titleize, toLowerCase, toUpperCase };