diginext-utils 2.0.33 → 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 (184) hide show
  1. package/package.json +1 -1
  2. package/src/console/index.ts +2 -2
  3. package/src/string/url.ts +2 -2
  4. package/dist/Checker.d.ts +0 -9
  5. package/dist/Checker.js +0 -52
  6. package/dist/Checker.mjs +0 -29
  7. package/dist/EventDispatcher.d.ts +0 -13
  8. package/dist/EventDispatcher.js +0 -77
  9. package/dist/EventDispatcher.mjs +0 -54
  10. package/dist/FileUpload.d.ts +0 -12
  11. package/dist/FileUpload.js +0 -85
  12. package/dist/FileUpload.mjs +0 -62
  13. package/dist/Slug.d.ts +0 -10
  14. package/dist/Slug.js +0 -354
  15. package/dist/Slug.mjs +0 -331
  16. package/dist/Timer-7b0c4e7c.d.ts +0 -11
  17. package/dist/Timer.d.ts +0 -1
  18. package/dist/Timer.js +0 -33
  19. package/dist/Timer.mjs +0 -7
  20. package/dist/Validation.d.ts +0 -6
  21. package/dist/Validation.js +0 -56
  22. package/dist/Validation.mjs +0 -35
  23. package/dist/array-dc599632.d.ts +0 -158
  24. package/dist/array.d.ts +0 -1
  25. package/dist/array.js +0 -277
  26. package/dist/array.mjs +0 -49
  27. package/dist/browser-8d042ffe.d.ts +0 -22
  28. package/dist/camera-1a859d72.d.ts +0 -15
  29. package/dist/chunk-5NTK5JAI.mjs +0 -57
  30. package/dist/chunk-5UEMANWE.mjs +0 -91
  31. package/dist/chunk-5ZOWNKSD.mjs +0 -166
  32. package/dist/chunk-6GNGTFNC.mjs +0 -118
  33. package/dist/chunk-7MK72U4O.mjs +0 -19
  34. package/dist/chunk-7XKT3AQX.mjs +0 -17
  35. package/dist/chunk-7ZCEZM7K.mjs +0 -41
  36. package/dist/chunk-AMBWJGSW.mjs +0 -151
  37. package/dist/chunk-C7S43KGB.mjs +0 -15
  38. package/dist/chunk-CJM7T7ON.mjs +0 -24
  39. package/dist/chunk-CKILLYAP.mjs +0 -16
  40. package/dist/chunk-DX7MUT3M.mjs +0 -51
  41. package/dist/chunk-EGUJQ5VF.mjs +0 -32
  42. package/dist/chunk-ETEIHDWU.mjs +0 -25
  43. package/dist/chunk-FJXSVGL7.mjs +0 -22
  44. package/dist/chunk-GJCAEOND.mjs +0 -20
  45. package/dist/chunk-GNJDIUYM.mjs +0 -40
  46. package/dist/chunk-IA7GINWD.mjs +0 -39
  47. package/dist/chunk-JEI7BOXY.mjs +0 -21
  48. package/dist/chunk-K4KENOE6.mjs +0 -20
  49. package/dist/chunk-KMERW6KS.mjs +0 -34
  50. package/dist/chunk-KPO3RH5G.mjs +0 -27
  51. package/dist/chunk-KWG5LYNK.mjs +0 -100
  52. package/dist/chunk-NUTQDHLQ.mjs +0 -40
  53. package/dist/chunk-O64XUDAH.mjs +0 -35
  54. package/dist/chunk-OYRPWQUA.mjs +0 -257
  55. package/dist/chunk-PNZ4KGXL.mjs +0 -56
  56. package/dist/chunk-QZYX26HT.mjs +0 -24
  57. package/dist/chunk-RDGP2CKM.mjs +0 -195
  58. package/dist/chunk-VFG5VU6S.mjs +0 -12
  59. package/dist/chunk-X3IMFCZG.mjs +0 -23
  60. package/dist/chunk-ZHNGZMRD.mjs +0 -17
  61. package/dist/color.d.ts +0 -24
  62. package/dist/color.js +0 -106
  63. package/dist/color.mjs +0 -78
  64. package/dist/console/enableConsole.d.ts +0 -1
  65. package/dist/console/enableConsole.js +0 -42
  66. package/dist/console/enableConsole.mjs +0 -9
  67. package/dist/console/index.d.ts +0 -2
  68. package/dist/console/index.js +0 -61
  69. package/dist/console/index.mjs +0 -14
  70. package/dist/console/log.d.ts +0 -16
  71. package/dist/console/log.js +0 -75
  72. package/dist/console/log.mjs +0 -19
  73. package/dist/createDir-220e0081.d.ts +0 -13
  74. package/dist/device/browser.d.ts +0 -1
  75. package/dist/device/browser.js +0 -66
  76. package/dist/device/browser.mjs +0 -15
  77. package/dist/device/camera.d.ts +0 -1
  78. package/dist/device/camera.js +0 -190
  79. package/dist/device/camera.mjs +0 -8
  80. package/dist/device/index.d.ts +0 -1
  81. package/dist/device/index.js +0 -210
  82. package/dist/device/index.mjs +0 -15
  83. package/dist/device/os.d.ts +0 -12
  84. package/dist/device/os.js +0 -65
  85. package/dist/device/os.mjs +0 -33
  86. package/dist/enableConsole-ddc24282.d.ts +0 -11
  87. package/dist/file/createDir.d.ts +0 -1
  88. package/dist/file/createDir.js +0 -37
  89. package/dist/file/createDir.mjs +0 -7
  90. package/dist/file/fileMove.d.ts +0 -1
  91. package/dist/file/fileMove.js +0 -53
  92. package/dist/file/fileMove.mjs +0 -7
  93. package/dist/file/findFilesByExt.d.ts +0 -1
  94. package/dist/file/findFilesByExt.js +0 -69
  95. package/dist/file/findFilesByExt.mjs +0 -11
  96. package/dist/file/index.d.ts +0 -11
  97. package/dist/file/index.js +0 -106
  98. package/dist/file/index.mjs +0 -17
  99. package/dist/fileMove-3a09e429.d.ts +0 -13
  100. package/dist/findFilesByExt-753e91d7.d.ts +0 -24
  101. package/dist/images/index.d.ts +0 -2
  102. package/dist/images/index.js +0 -132
  103. package/dist/images/index.mjs +0 -15
  104. package/dist/images/loadImage.d.ts +0 -3
  105. package/dist/images/loadImage.js +0 -42
  106. package/dist/images/loadImage.mjs +0 -21
  107. package/dist/images/resize.d.ts +0 -3
  108. package/dist/images/resize.js +0 -64
  109. package/dist/images/resize.mjs +0 -9
  110. package/dist/images/upload.d.ts +0 -11
  111. package/dist/images/upload.js +0 -132
  112. package/dist/images/upload.mjs +0 -14
  113. package/dist/index-1f738e52.d.ts +0 -22
  114. package/dist/index-22309f0c.d.ts +0 -23
  115. package/dist/index-6ae3c86b.d.ts +0 -63
  116. package/dist/index-c8fffc86.d.ts +0 -90
  117. package/dist/index-d652ed2c.d.ts +0 -26
  118. package/dist/index.d.ts +0 -48
  119. package/dist/index.js +0 -1353
  120. package/dist/index.mjs +0 -87
  121. package/dist/json.d.ts +0 -9
  122. package/dist/json.js +0 -52
  123. package/dist/json.mjs +0 -29
  124. package/dist/math/diffDate.d.ts +0 -6
  125. package/dist/math/diffDate.js +0 -36
  126. package/dist/math/diffDate.mjs +0 -9
  127. package/dist/math/index.d.ts +0 -3
  128. package/dist/math/index.js +0 -160
  129. package/dist/math/index.mjs +0 -34
  130. package/dist/math/positiveNumber.d.ts +0 -3
  131. package/dist/math/positiveNumber.js +0 -56
  132. package/dist/math/positiveNumber.mjs +0 -10
  133. package/dist/name/en.d.ts +0 -6
  134. package/dist/name/en.js +0 -44
  135. package/dist/name/en.mjs +0 -9
  136. package/dist/name/index.d.ts +0 -3
  137. package/dist/name/index.js +0 -88
  138. package/dist/name/index.mjs +0 -20
  139. package/dist/name/vi.d.ts +0 -6
  140. package/dist/name/vi.js +0 -66
  141. package/dist/name/vi.mjs +0 -14
  142. package/dist/object-43aaaf92.d.ts +0 -80
  143. package/dist/object.d.ts +0 -1
  144. package/dist/object.js +0 -105
  145. package/dist/object.mjs +0 -21
  146. package/dist/permission/index.d.ts +0 -9
  147. package/dist/permission/index.js +0 -231
  148. package/dist/permission/index.mjs +0 -15
  149. package/dist/permission/requestCamera.d.ts +0 -1
  150. package/dist/permission/requestCamera.js +0 -54
  151. package/dist/permission/requestCamera.mjs +0 -9
  152. package/dist/permission/requestDeviceOrientationControl.d.ts +0 -1
  153. package/dist/permission/requestDeviceOrientationControl.js +0 -206
  154. package/dist/permission/requestDeviceOrientationControl.mjs +0 -10
  155. package/dist/requestCamera-32b7dfc7.d.ts +0 -14
  156. package/dist/requestDeviceOrientationControl-b6458660.d.ts +0 -11
  157. package/dist/response/index.d.ts +0 -50
  158. package/dist/response/index.js +0 -97
  159. package/dist/response/index.mjs +0 -16
  160. package/dist/string/formatNumber.d.ts +0 -7
  161. package/dist/string/formatNumber.js +0 -56
  162. package/dist/string/formatNumber.mjs +0 -10
  163. package/dist/string/generatePassword.d.ts +0 -10
  164. package/dist/string/generatePassword.js +0 -55
  165. package/dist/string/generatePassword.mjs +0 -10
  166. package/dist/string/generateUUID.d.ts +0 -3
  167. package/dist/string/generateUUID.js +0 -40
  168. package/dist/string/generateUUID.mjs +0 -9
  169. package/dist/string/index.d.ts +0 -6
  170. package/dist/string/index.js +0 -316
  171. package/dist/string/index.mjs +0 -31
  172. package/dist/string/makeDaySlug.d.ts +0 -32
  173. package/dist/string/makeDaySlug.js +0 -47
  174. package/dist/string/makeDaySlug.mjs +0 -9
  175. package/dist/string/random.d.ts +0 -15
  176. package/dist/string/random.js +0 -56
  177. package/dist/string/random.mjs +0 -19
  178. package/dist/string/trimNull.d.ts +0 -3
  179. package/dist/string/trimNull.js +0 -49
  180. package/dist/string/trimNull.mjs +0 -9
  181. package/dist/string/url.d.ts +0 -1
  182. package/dist/string/url.js +0 -126
  183. package/dist/string/url.mjs +0 -22
  184. package/dist/url-60657387.d.ts +0 -57
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginext-utils",
3
- "version": "2.0.33",
3
+ "version": "2.0.35",
4
4
  "sideEffects": false,
5
5
  "readme": "README.md",
6
6
  "homepage": "https://wearetopgroup.com",
@@ -1,4 +1,4 @@
1
- export const disableConsole = (params: any) => {
1
+ export const disableConsole = () => {
2
2
  for (var key in console) {
3
3
  (console as any)[key] = function () {};
4
4
  }
@@ -6,7 +6,7 @@ export const disableConsole = (params: any) => {
6
6
 
7
7
  export const removeConsole = disableConsole;
8
8
 
9
- export const showCredit = (params: any) => {
9
+ export const showCredit = () => {
10
10
  console.log("Developed by Digitop | https://www.wearetopgroup.com/?utm_src=console");
11
11
  };
12
12
 
package/src/string/url.ts CHANGED
@@ -102,10 +102,10 @@ export const getFileExtension = (url: string) => {
102
102
  export const isImage = (url: string) => {
103
103
  if (!url) return false;
104
104
 
105
- const arr = ["png", "jpg", "jpeg", "jpe", "jif", "jfif", "gif", "svg"];
105
+ const arr = [".png", ".jpg", ".jpeg", ".jpe", ".jif", ".jfif", ".gif", ".svg"];
106
106
 
107
107
  const index = arr.findIndex((item) => {
108
- return getFileExtension(url)?.toLowerCase() == item;
108
+ return url.indexOf(item) >= 0;
109
109
  });
110
110
 
111
111
  return index >= 0;
package/dist/Checker.d.ts DELETED
@@ -1,9 +0,0 @@
1
- /**
2
- * Check if the object or string is in JSON format
3
- */
4
- declare const isJSON: (content: object | string) => boolean;
5
- declare const Checker: {
6
- isJSON: (content: object | string) => boolean;
7
- };
8
-
9
- export { Checker as default, isJSON };
package/dist/Checker.js DELETED
@@ -1,52 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/Checker.ts
21
- var Checker_exports = {};
22
- __export(Checker_exports, {
23
- default: () => Checker_default,
24
- isJSON: () => isJSON
25
- });
26
- module.exports = __toCommonJS(Checker_exports);
27
- var isJSON = (content) => {
28
- if (typeof content == "object") {
29
- try {
30
- content = JSON.stringify(content);
31
- } catch (err) {
32
- return false;
33
- }
34
- }
35
- if (typeof content == "string") {
36
- try {
37
- content = JSON.parse(content);
38
- } catch (err) {
39
- return false;
40
- }
41
- }
42
- if (typeof content != "object") {
43
- return false;
44
- }
45
- return true;
46
- };
47
- var Checker = { isJSON };
48
- var Checker_default = Checker;
49
- // Annotate the CommonJS export names for ESM import in node:
50
- 0 && (module.exports = {
51
- isJSON
52
- });
package/dist/Checker.mjs DELETED
@@ -1,29 +0,0 @@
1
- import "./chunk-ZHNGZMRD.mjs";
2
-
3
- // src/Checker.ts
4
- var isJSON = (content) => {
5
- if (typeof content == "object") {
6
- try {
7
- content = JSON.stringify(content);
8
- } catch (err) {
9
- return false;
10
- }
11
- }
12
- if (typeof content == "string") {
13
- try {
14
- content = JSON.parse(content);
15
- } catch (err) {
16
- return false;
17
- }
18
- }
19
- if (typeof content != "object") {
20
- return false;
21
- }
22
- return true;
23
- };
24
- var Checker = { isJSON };
25
- var Checker_default = Checker;
26
- export {
27
- Checker_default as default,
28
- isJSON
29
- };
@@ -1,13 +0,0 @@
1
- declare class EventDispatcher {
2
- constructor();
3
- _listeners: any;
4
- addEventListener(type: string, listener: any): void;
5
- hasEventListener(type: string, listener: any): boolean;
6
- removeEventListener(type: string, listener: any): void;
7
- dispatchEvent(event: {
8
- type: string;
9
- target: any;
10
- }): void;
11
- }
12
-
13
- export { EventDispatcher, EventDispatcher as default };
@@ -1,77 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/EventDispatcher.ts
21
- var EventDispatcher_exports = {};
22
- __export(EventDispatcher_exports, {
23
- EventDispatcher: () => EventDispatcher,
24
- default: () => EventDispatcher_default
25
- });
26
- module.exports = __toCommonJS(EventDispatcher_exports);
27
- var EventDispatcher = class {
28
- constructor() {
29
- }
30
- addEventListener(type, listener) {
31
- if (this._listeners === void 0)
32
- this._listeners = {};
33
- const listeners = this._listeners;
34
- if (listeners[type] === void 0) {
35
- listeners[type] = [];
36
- }
37
- if (listeners[type].indexOf(listener) === -1) {
38
- listeners[type].push(listener);
39
- }
40
- }
41
- hasEventListener(type, listener) {
42
- if (this._listeners === void 0)
43
- return false;
44
- const listeners = this._listeners;
45
- return listeners[type] !== void 0 && listeners[type].indexOf(listener) !== -1;
46
- }
47
- removeEventListener(type, listener) {
48
- if (this._listeners === void 0)
49
- return;
50
- const listeners = this._listeners;
51
- const listenerArray = listeners[type];
52
- if (listenerArray !== void 0) {
53
- const index = listenerArray.indexOf(listener);
54
- if (index !== -1) {
55
- listenerArray.splice(index, 1);
56
- }
57
- }
58
- }
59
- dispatchEvent(event) {
60
- if (this._listeners === void 0)
61
- return;
62
- const listeners = this._listeners;
63
- const listenerArray = listeners[event.type];
64
- if (listenerArray !== void 0) {
65
- event.target = this;
66
- const array = listenerArray.slice(0);
67
- for (let i = 0, l = array.length; i < l; i++) {
68
- array[i].call(this, event);
69
- }
70
- }
71
- }
72
- };
73
- var EventDispatcher_default = EventDispatcher;
74
- // Annotate the CommonJS export names for ESM import in node:
75
- 0 && (module.exports = {
76
- EventDispatcher
77
- });
@@ -1,54 +0,0 @@
1
- import "./chunk-ZHNGZMRD.mjs";
2
-
3
- // src/EventDispatcher.ts
4
- var EventDispatcher = class {
5
- constructor() {
6
- }
7
- addEventListener(type, listener) {
8
- if (this._listeners === void 0)
9
- this._listeners = {};
10
- const listeners = this._listeners;
11
- if (listeners[type] === void 0) {
12
- listeners[type] = [];
13
- }
14
- if (listeners[type].indexOf(listener) === -1) {
15
- listeners[type].push(listener);
16
- }
17
- }
18
- hasEventListener(type, listener) {
19
- if (this._listeners === void 0)
20
- return false;
21
- const listeners = this._listeners;
22
- return listeners[type] !== void 0 && listeners[type].indexOf(listener) !== -1;
23
- }
24
- removeEventListener(type, listener) {
25
- if (this._listeners === void 0)
26
- return;
27
- const listeners = this._listeners;
28
- const listenerArray = listeners[type];
29
- if (listenerArray !== void 0) {
30
- const index = listenerArray.indexOf(listener);
31
- if (index !== -1) {
32
- listenerArray.splice(index, 1);
33
- }
34
- }
35
- }
36
- dispatchEvent(event) {
37
- if (this._listeners === void 0)
38
- return;
39
- const listeners = this._listeners;
40
- const listenerArray = listeners[event.type];
41
- if (listenerArray !== void 0) {
42
- event.target = this;
43
- const array = listenerArray.slice(0);
44
- for (let i = 0, l = array.length; i < l; i++) {
45
- array[i].call(this, event);
46
- }
47
- }
48
- }
49
- };
50
- var EventDispatcher_default = EventDispatcher;
51
- export {
52
- EventDispatcher,
53
- EventDispatcher_default as default
54
- };
@@ -1,12 +0,0 @@
1
- type UploadParams = {
2
- blob: Blob;
3
- url: string;
4
- params: any;
5
- onComplete: any;
6
- onError: any;
7
- };
8
- declare const FileUpload: {
9
- uploadBlob(props: UploadParams): void;
10
- };
11
-
12
- export { FileUpload, FileUpload as default };
@@ -1,85 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/FileUpload.ts
21
- var FileUpload_exports = {};
22
- __export(FileUpload_exports, {
23
- FileUpload: () => FileUpload,
24
- default: () => FileUpload_default
25
- });
26
- module.exports = __toCommonJS(FileUpload_exports);
27
- var logFile = "[FileUpload.js] ";
28
- var FileUpload = {
29
- uploadBlob(props) {
30
- const { blob, url, params, onComplete, onError } = props;
31
- var formData = new FormData();
32
- formData.append("upload", blob, "img_" + +new Date() + ".jpg");
33
- if (params) {
34
- Object.keys(params).forEach((key) => {
35
- var val = params[key];
36
- formData.append(key, val);
37
- });
38
- }
39
- var request = new XMLHttpRequest();
40
- request.open("POST", url);
41
- request.send(formData);
42
- request.onreadystatechange = function() {
43
- if (this.readyState == 4) {
44
- if (this.status == 200) {
45
- var response = {};
46
- try {
47
- response = JSON.parse(request.response) || "";
48
- } catch (error) {
49
- console.error(logFile, "Can't part JSON of the response");
50
- }
51
- var statusOfSafety = response.status || 0;
52
- if (statusOfSafety == 1) {
53
- console.log(logFile, "request: ", request);
54
- var data = response.data || {};
55
- console.log(logFile, data);
56
- var _url = data["url"];
57
- if (onComplete)
58
- onComplete(_url);
59
- } else {
60
- var errMsg = "\u1EA2nh c\xF3 n\u1ED9i dung kh\xF4ng ph\xF9 h\u1EE3p.";
61
- console.error(logFile, errMsg);
62
- if (onError)
63
- onError(errMsg);
64
- }
65
- } else {
66
- var errMsg = "Upload \u1EA3nh kh\xF4ng th\xE0nh c\xF4ng!";
67
- console.error(logFile, errMsg);
68
- if (onError)
69
- onError(errMsg);
70
- }
71
- }
72
- };
73
- request.onerror = function(res) {
74
- var errMsg = "Upload \u1EA3nh kh\xF4ng th\xE0nh c\xF4ng!";
75
- console.error(logFile, errMsg, "=>", res);
76
- if (onError)
77
- onError(errMsg);
78
- };
79
- }
80
- };
81
- var FileUpload_default = FileUpload;
82
- // Annotate the CommonJS export names for ESM import in node:
83
- 0 && (module.exports = {
84
- FileUpload
85
- });
@@ -1,62 +0,0 @@
1
- import "./chunk-ZHNGZMRD.mjs";
2
-
3
- // src/FileUpload.ts
4
- var logFile = "[FileUpload.js] ";
5
- var FileUpload = {
6
- uploadBlob(props) {
7
- const { blob, url, params, onComplete, onError } = props;
8
- var formData = new FormData();
9
- formData.append("upload", blob, "img_" + +new Date() + ".jpg");
10
- if (params) {
11
- Object.keys(params).forEach((key) => {
12
- var val = params[key];
13
- formData.append(key, val);
14
- });
15
- }
16
- var request = new XMLHttpRequest();
17
- request.open("POST", url);
18
- request.send(formData);
19
- request.onreadystatechange = function() {
20
- if (this.readyState == 4) {
21
- if (this.status == 200) {
22
- var response = {};
23
- try {
24
- response = JSON.parse(request.response) || "";
25
- } catch (error) {
26
- console.error(logFile, "Can't part JSON of the response");
27
- }
28
- var statusOfSafety = response.status || 0;
29
- if (statusOfSafety == 1) {
30
- console.log(logFile, "request: ", request);
31
- var data = response.data || {};
32
- console.log(logFile, data);
33
- var _url = data["url"];
34
- if (onComplete)
35
- onComplete(_url);
36
- } else {
37
- var errMsg = "\u1EA2nh c\xF3 n\u1ED9i dung kh\xF4ng ph\xF9 h\u1EE3p.";
38
- console.error(logFile, errMsg);
39
- if (onError)
40
- onError(errMsg);
41
- }
42
- } else {
43
- var errMsg = "Upload \u1EA3nh kh\xF4ng th\xE0nh c\xF4ng!";
44
- console.error(logFile, errMsg);
45
- if (onError)
46
- onError(errMsg);
47
- }
48
- }
49
- };
50
- request.onerror = function(res) {
51
- var errMsg = "Upload \u1EA3nh kh\xF4ng th\xE0nh c\xF4ng!";
52
- console.error(logFile, errMsg, "=>", res);
53
- if (onError)
54
- onError(errMsg);
55
- };
56
- }
57
- };
58
- var FileUpload_default = FileUpload;
59
- export {
60
- FileUpload,
61
- FileUpload_default as default
62
- };
package/dist/Slug.d.ts DELETED
@@ -1,10 +0,0 @@
1
- declare const makeSlug: (s: string, opt?: {
2
- [key: string]: any;
3
- }) => string;
4
- declare const slug: {
5
- makeSlug: (s: string, opt?: {
6
- [key: string]: any;
7
- }) => string;
8
- };
9
-
10
- export { slug as default, makeSlug };