diginext-utils 1.0.1 → 1.0.5

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 (68) hide show
  1. package/dist/README.md +3 -0
  2. package/dist/babel.config.json +21 -0
  3. package/dist/index.js +148 -0
  4. package/dist/package.json +34 -0
  5. package/dist/src/Camera.js +420 -0
  6. package/dist/src/Checker.js +34 -0
  7. package/dist/src/Color.js +102 -0
  8. package/dist/src/Device.js +67 -0
  9. package/dist/src/EventDispatcher.js +62 -0
  10. package/dist/src/FileUpload.js +73 -0
  11. package/dist/src/FileUtils.js +47 -0
  12. package/dist/src/Slug.js +384 -0
  13. package/dist/src/Timer.js +16 -0
  14. package/dist/src/UserLS.js +127 -0
  15. package/dist/src/Validation.js +46 -0
  16. package/dist/src/array/index.js +377 -0
  17. package/dist/src/backend/file/createDir.js +24 -0
  18. package/dist/src/backend/file/fileMove.js +42 -0
  19. package/dist/src/backend/file/findFilesByExt.js +55 -0
  20. package/dist/src/backend/zip/extractZip.js +55 -0
  21. package/dist/src/console/enableConsole.js +16 -0
  22. package/dist/src/console/index.js +20 -0
  23. package/dist/src/device/browser.js +52 -0
  24. package/dist/src/device/camera.js +238 -0
  25. package/dist/src/device/index.js +304 -0
  26. package/{src → dist/src}/math/index.js +57 -59
  27. package/dist/src/object/index.js +65 -0
  28. package/dist/src/permission/requestCamera.js +55 -0
  29. package/dist/src/permission/requestDeviceOrientationControl.js +36 -0
  30. package/dist/src/string/index.js +531 -0
  31. package/dist/src/string/url.js +128 -0
  32. package/package.json +17 -13
  33. package/.eslintrc.json +0 -21
  34. package/dist/main.js +0 -1611
  35. package/dist/main.js.map +0 -1
  36. package/dist/module.js +0 -1584
  37. package/dist/module.js.map +0 -1
  38. package/index.js +0 -13
  39. package/src/Browser.js +0 -297
  40. package/src/Camera.js +0 -412
  41. package/src/Checker.js +0 -24
  42. package/src/Color.js +0 -81
  43. package/src/Device.js +0 -56
  44. package/src/EventDispatcher.js +0 -58
  45. package/src/FileUpload.js +0 -59
  46. package/src/FileUtils.js +0 -30
  47. package/src/ReactUtils.js +0 -25
  48. package/src/ScrollPos.js +0 -31
  49. package/src/Slug.js +0 -383
  50. package/src/Timer.js +0 -7
  51. package/src/UserLS.js +0 -104
  52. package/src/Validation.js +0 -35
  53. package/src/array/index.js +0 -301
  54. package/src/backend/file/createDir.js +0 -13
  55. package/src/backend/file/fileMove.js +0 -35
  56. package/src/backend/file/findFilesByExt.js +0 -42
  57. package/src/backend/zip/extractZip.js +0 -58
  58. package/src/console/enableConsole.js +0 -6
  59. package/src/console/index.js +0 -10
  60. package/src/device/browser.js +0 -29
  61. package/src/device/camera.js +0 -228
  62. package/src/device/index.js +0 -233
  63. package/src/isMobileOrTablet.js +0 -28
  64. package/src/object/index.js +0 -41
  65. package/src/permission/requestCamera.js +0 -43
  66. package/src/permission/requestDeviceOrientationControl.js +0 -32
  67. package/src/string/index.js +0 -228
  68. package/src/string/url.js +0 -93
@@ -1,38 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.randRound = exports.randInt = exports.randHalt = exports.randFloat = exports.rand = exports.radToDeg = exports.degToRad = void 0;
1
7
  const DEG2RAD = Math.PI / 180;
2
8
  const RAD2DEG = 180 / Math.PI;
3
-
4
9
  /**
5
10
  *
6
11
  * @param {Number} number
7
12
  * @return {Number}
8
13
  */
9
- export const randRound = (number) => {
10
- return Math.round(Math.random() * number);
11
- };
12
14
 
15
+ const randRound = number => {
16
+ return Math.round(Math.random() * number);
17
+ };
13
18
  /**
14
19
  *
15
20
  * @param {Number} number
16
21
  * @return {Number}
17
22
  */
18
- export const rand = (number) => {
19
- return (Math.random() - Math.random()) * number;
20
- };
21
23
 
24
+
25
+ exports.randRound = randRound;
26
+
27
+ const rand = number => {
28
+ return (Math.random() - Math.random()) * number;
29
+ };
22
30
  /**
23
31
  *
24
32
  * @param {Number} number
25
33
  * @return {Number}
26
34
  */
27
- export const randHalt = (number) => {
28
- var rand = Math.random() - Math.random();
29
- var res;
30
- if (rand > 0) {
31
- res = rand * (number / 2) + number / 2;
32
- } else {
33
- res = rand * (number / 2) - number / 2;
34
- }
35
- return Math.abs(res);
35
+
36
+
37
+ exports.rand = rand;
38
+
39
+ const randHalt = number => {
40
+ var rand = Math.random() - Math.random();
41
+ var res;
42
+
43
+ if (rand > 0) {
44
+ res = rand * (number / 2) + number / 2;
45
+ } else {
46
+ res = rand * (number / 2) - number / 2;
47
+ }
48
+
49
+ return Math.abs(res);
36
50
  };
37
51
  /**
38
52
  *
@@ -40,48 +54,58 @@ export const randHalt = (number) => {
40
54
  * @param {Number} high
41
55
  * @return {Number}
42
56
  */
43
- export const randInt = (low, high) => {
44
- return low + Math.floor(Math.random() * (high - low + 1));
45
- };
46
57
 
58
+
59
+ exports.randHalt = randHalt;
60
+
61
+ const randInt = (low, high) => {
62
+ return low + Math.floor(Math.random() * (high - low + 1));
63
+ };
47
64
  /**
48
65
  *
49
66
  * @param {Number} low
50
67
  * @param {Number} high
51
68
  * @return {Number}
52
69
  */
53
- export const randFloat = (low, high) => {
54
- return low + Math.random() * (high - low);
70
+
71
+
72
+ exports.randInt = randInt;
73
+
74
+ const randFloat = (low, high) => {
75
+ return low + Math.random() * (high - low);
55
76
  };
56
77
  /**
57
78
  *
58
79
  * @param {Number} degrees
59
80
  * @return {Number}
60
81
  */
61
- export const degToRad = (degrees) => {
62
- return degrees * DEG2RAD;
63
- };
64
82
 
83
+
84
+ exports.randFloat = randFloat;
85
+
86
+ const degToRad = degrees => {
87
+ return degrees * DEG2RAD;
88
+ };
65
89
  /**
66
90
  *
67
91
  * @param {Number} degrees
68
92
  * @return {Number}
69
93
  */
70
- export const radToDeg = (radians) => {
71
- return radians * RAD2DEG;
72
- };
73
94
 
74
- // const MathExtra = {
95
+
96
+ exports.degToRad = degToRad;
97
+
98
+ const radToDeg = radians => {
99
+ return radians * RAD2DEG;
100
+ }; // const MathExtra = {
75
101
  // isRotateLeft(a, b, c) {
76
102
  // return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x) > 0;
77
103
  // },
78
-
79
104
  // deg_between_points_360(cx, cy, ex, ey) {
80
105
  // var theta = this.angleLine(cx, cy, ex, ey); // range (-180, 180]
81
106
  // if (theta < 0) theta = 360 + theta; // range [0, 360)
82
107
  // return theta;
83
108
  // },
84
-
85
109
  // deg_between_points(cx, cy, ex, ey) {
86
110
  // var dy = ey - cy;
87
111
  // var dx = ex - cx;
@@ -89,7 +113,6 @@ export const radToDeg = (radians) => {
89
113
  // theta *= 180 / Math.PI; // rads to degs, range (-180, 180]
90
114
  // return theta;
91
115
  // },
92
-
93
116
  // angle_between_points(cx, cy, ex, ey) {
94
117
  // var dy = ey - cy;
95
118
  // var dx = ex - cx;
@@ -97,63 +120,44 @@ export const radToDeg = (radians) => {
97
120
  // // theta *= 180 / Math.PI; // rads to degs, range (-180, 180]
98
121
  // return theta;
99
122
  // },
100
-
101
123
  // distance2Point(x1, y1, x2, y2) {
102
124
  // var dist = Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
103
125
  // return dist;
104
126
  // },
105
-
106
127
  // clamp(value, min, max) {
107
128
  // return Math.max(min, Math.min(max, value));
108
129
  // },
109
-
110
130
  // // compute euclidian modulo of m % n
111
131
  // // https://en.wikipedia.org/wiki/Modulo_operation
112
-
113
132
  // euclideanModulo(n, m) {
114
133
  // return ((n % m) + m) % m;
115
134
  // },
116
-
117
135
  // // Linear mapping from range <a1, a2> to range <b1, b2>
118
-
119
136
  // mapLinear(x, a1, a2, b1, b2) {
120
137
  // return b1 + ((x - a1) * (b2 - b1)) / (a2 - a1);
121
138
  // },
122
-
123
139
  // // https://en.wikipedia.org/wiki/Linear_interpolation
124
-
125
140
  // lerp(x, y, t) {
126
141
  // return (1 - t) * x + t * y;
127
142
  // },
128
-
129
143
  // // http://en.wikipedia.org/wiki/Smoothstep
130
-
131
144
  // smoothstep(x, min, max) {
132
145
  // if (x <= min) return 0;
133
146
  // if (x >= max) return 1;
134
-
135
147
  // x = (x - min) / (max - min);
136
-
137
148
  // return x * x * (3 - 2 * x);
138
149
  // },
139
-
140
150
  // smootherstep(x, min, max) {
141
151
  // if (x <= min) return 0;
142
152
  // if (x >= max) return 1;
143
-
144
153
  // x = (x - min) / (max - min);
145
-
146
154
  // return x * x * x * (x * (x * 6 - 15) + 10);
147
155
  // },
148
-
149
156
  // // Random integer from <low, high> interval
150
-
151
157
  // // Random float from <-range/2, range/2> interval
152
-
153
158
  // randFloatSpread(range) {
154
159
  // return range * (0.5 - Math.random());
155
160
  // },
156
-
157
161
  // rotationDegToRad(rotation) {
158
162
  // return {
159
163
  // x: this.degToRad(rotation.x),
@@ -161,19 +165,15 @@ export const radToDeg = (radians) => {
161
165
  // z: this.degToRad(rotation.z),
162
166
  // };
163
167
  // },
164
-
165
168
  // radToDeg(radians) {
166
169
  // return radians * RAD2DEG;
167
170
  // },
168
-
169
171
  // isPowerOfTwo(value) {
170
172
  // return (value & (value - 1)) === 0 && value !== 0;
171
173
  // },
172
-
173
174
  // nearestPowerOfTwo(value) {
174
175
  // return Math.pow(2, Math.round(Math.log(value) / Math.LN2));
175
176
  // },
176
-
177
177
  // nextPowerOfTwo(value) {
178
178
  // value--;
179
179
  // value |= value >> 1;
@@ -182,18 +182,14 @@ export const radToDeg = (radians) => {
182
182
  // value |= value >> 8;
183
183
  // value |= value >> 16;
184
184
  // value++;
185
-
186
185
  // return value;
187
186
  // },
188
-
189
187
  // circleByPercentRadius(percent, radius) {
190
188
  // const theta = ((percent * 360 - 90) * Math.PI) / 180;
191
-
192
189
  // const x = radius * Math.cos(theta);
193
190
  // const y = -radius * Math.sin(theta);
194
191
  // return { x, y };
195
192
  // },
196
-
197
193
  // /**
198
194
  // *
199
195
  // * @param {Array} array
@@ -207,5 +203,7 @@ export const radToDeg = (radians) => {
207
203
  // return result;
208
204
  // },
209
205
  // };
210
-
211
206
  // export default MathExtra;
207
+
208
+
209
+ exports.radToDeg = radToDeg;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.promise.js");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.toInt = exports.toFloat = exports.toBool = exports.toArray = exports.isNull = void 0;
9
+
10
+ require("core-js/modules/es.regexp.to-string.js");
11
+
12
+ require("core-js/modules/es.parse-int.js");
13
+
14
+ require("core-js/modules/es.parse-float.js");
15
+
16
+ const isNull = object => {
17
+ if (typeof object == "undefined") return true;
18
+ if (object == "") return true;
19
+ if (Array.isArray(object)) return object.length == 0;
20
+ return object == null;
21
+ };
22
+
23
+ exports.isNull = isNull;
24
+
25
+ const toBool = object => {
26
+ if (isNull(object)) return false;
27
+ object = object.toString();
28
+ return object === "true" || object == "1";
29
+ };
30
+
31
+ exports.toBool = toBool;
32
+
33
+ const toInt = object => {
34
+ if (isNull(object)) return 0;
35
+ object = object.toString();
36
+ return parseInt(object, 10);
37
+ };
38
+
39
+ exports.toInt = toInt;
40
+
41
+ const toFloat = object => {
42
+ if (isNull(object)) return 0;
43
+ object = object.toString();
44
+ return parseFloat(object);
45
+ };
46
+ /**
47
+ * Convert value in object to array
48
+ * @param {object} obj
49
+ * @returns {Array}
50
+ */
51
+
52
+
53
+ exports.toFloat = toFloat;
54
+
55
+ const toArray = obj => {
56
+ const array = [];
57
+
58
+ for (const key in obj) {
59
+ array.push(obj[key]);
60
+ }
61
+
62
+ return array;
63
+ };
64
+
65
+ exports.toArray = toArray;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ require("core-js/modules/es.promise.js");
9
+
10
+ const requestCamera = _ref => {
11
+ let {
12
+ audio = true,
13
+ video = true
14
+ } = _ref;
15
+ if (typeof window == "undefined") return false;
16
+ return new Promise((resolve, reject) => {
17
+ // Older browsers might not implement mediaDevices at all, so we set an empty object first
18
+ if (navigator.mediaDevices === undefined) {
19
+ navigator.mediaDevices = {};
20
+ } // Some browsers partially implement mediaDevices. We can't just assign an object
21
+ // with getUserMedia as it would overwrite existing properties.
22
+ // Here, we will just add the getUserMedia property if it's missing.
23
+
24
+
25
+ if (navigator.mediaDevices.getUserMedia === undefined) {
26
+ navigator.mediaDevices.getUserMedia = function (constraints) {
27
+ // First get ahold of the legacy getUserMedia, if present
28
+ var getUserMedia = navigator.webkitGetUserMedia || navigator.mozGetUserMedia; // Some browsers just don't implement it - return a rejected promise with an error
29
+ // to keep a consistent interface
30
+
31
+ if (!getUserMedia) {
32
+ return Promise.reject(new Error("getUserMedia is not implemented in this browser"));
33
+ } // Otherwise, wrap the call to the old navigator.getUserMedia with a Promise
34
+
35
+
36
+ return new Promise(function (resolve, reject) {
37
+ getUserMedia.call(navigator, constraints, resolve, reject);
38
+ });
39
+ };
40
+ }
41
+
42
+ navigator.mediaDevices.getUserMedia({
43
+ audio,
44
+ video
45
+ }).then(function (stream) {
46
+ resolve(true);
47
+ }).catch(function (err) {
48
+ console.log(err.name + ": " + err.message);
49
+ resolve(false);
50
+ });
51
+ });
52
+ };
53
+
54
+ var _default = requestCamera;
55
+ exports.default = _default;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ require("core-js/modules/es.promise.js");
9
+
10
+ var _device = require("../device");
11
+
12
+ const requestDeviceOrientationControl = () => {
13
+ if (typeof window == "undefined") return false;
14
+ return new Promise((resolve, reject) => {
15
+ if ((0, _device.isAndroid)()) resolve(true);
16
+
17
+ if (typeof DeviceMotionEvent != "undefined" && DeviceMotionEvent.requestPermission) {
18
+ // (optional) Do something before API request prompt.
19
+ DeviceOrientationEvent.requestPermission().then(response => {
20
+ // (optional) Do something after API prompt dismissed.
21
+ if (response == "granted") {
22
+ resolve(true); // resolve({ status: true })
23
+ } else {
24
+ resolve(false); // resolve({ status: false, reason: "DeviceMotionEvent is not support" })
25
+ }
26
+ }).catch(response => {
27
+ resolve(false); // resolve({ status: false, reason: response })
28
+ });
29
+ } else {
30
+ resolve(false); // resolve({ status: false, reason: "DeviceMotionEvent is not defined" })
31
+ }
32
+ });
33
+ };
34
+
35
+ var _default = requestDeviceOrientationControl;
36
+ exports.default = _default;