diginext-utils 1.2.3 → 1.2.4

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.
package/dist/device.js CHANGED
@@ -4,44 +4,34 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.isMobile = exports.isIos = exports.isAndroid = exports.checkOS = void 0;
7
-
8
7
  require("core-js/modules/es.regexp.exec.js");
9
-
10
8
  require("core-js/modules/es.string.match.js");
11
-
12
9
  require("core-js/modules/es.parse-float.js");
13
-
14
10
  require("core-js/modules/es.parse-int.js");
15
-
16
11
  require("core-js/modules/es.regexp.test.js");
17
-
18
12
  const isIos = () => {
19
13
  const deviceInfo = checkOS();
20
14
  if (deviceInfo) return deviceInfo.os.toLowerCase() == "ios";
21
15
  console.log("Can't check OS");
22
16
  return null;
23
17
  };
24
-
25
18
  exports.isIos = isIos;
26
-
27
19
  const isAndroid = () => {
28
20
  const deviceInfo = checkOS();
29
21
  if (deviceInfo) return deviceInfo.os.toLowerCase() == "android";
30
22
  console.log("Can't check OS");
31
23
  return null;
32
24
  };
33
-
34
25
  exports.isAndroid = isAndroid;
35
-
36
26
  const isMobile = () => {
37
27
  if (typeof navigator == "undefined") return null;
38
-
39
28
  if (navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i)) {
40
29
  return true;
41
30
  } else {
42
31
  return false;
43
32
  }
44
33
  };
34
+
45
35
  /**
46
36
  *
47
37
  * @returns {{
@@ -56,107 +46,104 @@ const isMobile = () => {
56
46
  * flashVersion,
57
47
  * }}
58
48
  */
59
-
60
-
61
49
  exports.isMobile = isMobile;
62
-
63
50
  const checkOS = () => {
64
51
  var _window;
65
-
66
52
  if (typeof window == "undefined") return {};
67
-
68
53
  if (typeof ((_window = window) === null || _window === void 0 ? void 0 : _window.deviceInfo) == "undefined") {
69
- var unknown = "-"; // screen
54
+ var unknown = "-";
70
55
 
56
+ // screen
71
57
  var screenSize = "";
72
-
73
58
  if (screen.width) {
74
59
  var width = screen.width ? screen.width : "";
75
60
  var height = screen.height ? screen.height : "";
76
61
  screenSize += "" + width + " x " + height;
77
- } // browser
78
-
62
+ }
79
63
 
64
+ // browser
80
65
  var nVer = navigator.appVersion;
81
66
  var nAgt = navigator.userAgent;
82
67
  var browser = navigator.appName;
83
68
  var version = "" + parseFloat(navigator.appVersion);
84
69
  var majorVersion = parseInt(navigator.appVersion, 10);
85
- var nameOffset, verOffset, ix; // Opera
70
+ var nameOffset, verOffset, ix;
86
71
 
72
+ // Opera
87
73
  if ((verOffset = nAgt.indexOf("Opera")) != -1) {
88
74
  browser = "Opera";
89
75
  version = nAgt.substring(verOffset + 6);
90
-
91
76
  if ((verOffset = nAgt.indexOf("Version")) != -1) {
92
77
  version = nAgt.substring(verOffset + 8);
93
78
  }
94
- } // Opera Next
95
-
96
-
79
+ }
80
+ // Opera Next
97
81
  if ((verOffset = nAgt.indexOf("OPR")) != -1) {
98
82
  browser = "Opera";
99
83
  version = nAgt.substring(verOffset + 4);
100
- } // Edge
84
+ }
85
+ // Edge
101
86
  else if ((verOffset = nAgt.indexOf("Edge")) != -1) {
102
87
  browser = "Microsoft Edge";
103
88
  version = nAgt.substring(verOffset + 5);
104
- } // MSIE
89
+ }
90
+ // MSIE
105
91
  else if ((verOffset = nAgt.indexOf("MSIE")) != -1) {
106
92
  browser = "Microsoft Internet Explorer";
107
93
  version = nAgt.substring(verOffset + 5);
108
- } // Chrome
94
+ }
95
+ // Chrome
109
96
  else if ((verOffset = nAgt.indexOf("Chrome")) != -1) {
110
97
  browser = "Chrome";
111
98
  version = nAgt.substring(verOffset + 7);
112
- } // Safari
99
+ }
100
+ // Safari
113
101
  else if ((verOffset = nAgt.indexOf("Safari")) != -1) {
114
102
  browser = "Safari";
115
103
  version = nAgt.substring(verOffset + 7);
116
-
117
104
  if ((verOffset = nAgt.indexOf("Version")) != -1) {
118
105
  version = nAgt.substring(verOffset + 8);
119
106
  }
120
- } // Firefox
107
+ }
108
+ // Firefox
121
109
  else if ((verOffset = nAgt.indexOf("Firefox")) != -1) {
122
110
  browser = "Firefox";
123
111
  version = nAgt.substring(verOffset + 8);
124
- } // MSIE 11+
112
+ }
113
+ // MSIE 11+
125
114
  else if (nAgt.indexOf("Trident/") != -1) {
126
115
  browser = "Microsoft Internet Explorer";
127
116
  version = nAgt.substring(nAgt.indexOf("rv:") + 3);
128
- } // Other browsers
117
+ }
118
+ // Other browsers
129
119
  else if ((nameOffset = nAgt.lastIndexOf(" ") + 1) < (verOffset = nAgt.lastIndexOf("/"))) {
130
120
  browser = nAgt.substring(nameOffset, verOffset);
131
121
  version = nAgt.substring(verOffset + 1);
132
-
133
122
  if (browser.toLowerCase() == browser.toUpperCase()) {
134
123
  browser = navigator.appName;
135
124
  }
136
- } // trim the version string
137
-
138
-
125
+ }
126
+ // trim the version string
139
127
  if ((ix = version.indexOf(";")) != -1) version = version.substring(0, ix);
140
128
  if ((ix = version.indexOf(" ")) != -1) version = version.substring(0, ix);
141
129
  if ((ix = version.indexOf(")")) != -1) version = version.substring(0, ix);
142
130
  majorVersion = parseInt("" + version, 10);
143
-
144
131
  if (isNaN(majorVersion)) {
145
132
  version = "" + parseFloat(navigator.appVersion);
146
133
  majorVersion = parseInt(navigator.appVersion, 10);
147
- } // mobile version
148
-
134
+ }
149
135
 
150
- var mobile = /Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(nVer); // cookie
136
+ // mobile version
137
+ var mobile = /Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(nVer);
151
138
 
139
+ // cookie
152
140
  var cookieEnabled = navigator.cookieEnabled ? true : false;
153
-
154
141
  if (typeof navigator.cookieEnabled == "undefined" && !cookieEnabled) {
155
142
  document.cookie = "testcookie";
156
143
  cookieEnabled = document.cookie.indexOf("testcookie") != -1 ? true : false;
157
- } // system
158
-
144
+ }
159
145
 
146
+ // system
160
147
  var os = unknown;
161
148
  var clientStrings = [{
162
149
  s: "Windows 10",
@@ -237,53 +224,42 @@ const checkOS = () => {
237
224
  s: "Search Bot",
238
225
  r: /(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver)/
239
226
  }];
240
-
241
227
  for (var id in clientStrings) {
242
228
  var cs = clientStrings[id];
243
-
244
229
  if (cs.r.test(nAgt)) {
245
230
  os = cs.s;
246
231
  break;
247
232
  }
248
233
  }
249
-
250
234
  var osVersion = unknown;
251
-
252
235
  if (/Windows/.test(os)) {
253
236
  osVersion = /Windows (.*)/.exec(os)[1];
254
237
  os = "Windows";
255
238
  }
256
-
257
239
  switch (os) {
258
240
  case "Mac OS X":
259
241
  osVersion = /Mac OS X (10[\.\_\d]+)/.exec(nAgt)[1];
260
242
  break;
261
-
262
243
  case "Android":
263
244
  osVersion = /Android ([\.\_\d]+)/.exec(nAgt)[1];
264
245
  break;
265
-
266
246
  case "iOS":
267
247
  osVersion = /OS (\d+)_(\d+)_?(\d+)?/.exec(nVer);
268
248
  osVersion = osVersion[1] + "." + osVersion[2] + "." + (osVersion[3] | 0);
269
249
  break;
270
- } // flash (you'll need to include swfobject)
250
+ }
271
251
 
252
+ // flash (you'll need to include swfobject)
272
253
  /* script src="//ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js" */
273
-
274
-
275
254
  var flashVersion = "no check";
276
-
277
255
  if (typeof swfobject != "undefined") {
278
256
  var fv = swfobject.getFlashPlayerVersion();
279
-
280
257
  if (fv.major > 0) {
281
258
  flashVersion = fv.major + "." + fv.minor + " r" + fv.release;
282
259
  } else {
283
260
  flashVersion = unknown;
284
261
  }
285
262
  }
286
-
287
263
  const deviceInfo = {
288
264
  screen: screenSize,
289
265
  browser: browser,
@@ -297,8 +273,6 @@ const checkOS = () => {
297
273
  };
298
274
  window.deviceInfo = deviceInfo;
299
275
  }
300
-
301
276
  return window.deviceInfo;
302
277
  };
303
-
304
278
  exports.checkOS = checkOS;
package/dist/index.js CHANGED
@@ -33,9 +33,7 @@ Object.defineProperty(exports, "requestDeviceOrientationControl", {
33
33
  return _requestDeviceOrientationControl.default;
34
34
  }
35
35
  });
36
-
37
36
  var _array = require("./array");
38
-
39
37
  Object.keys(_array).forEach(function (key) {
40
38
  if (key === "default" || key === "__esModule") return;
41
39
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -47,9 +45,7 @@ Object.keys(_array).forEach(function (key) {
47
45
  }
48
46
  });
49
47
  });
50
-
51
48
  var _device = require("./device");
52
-
53
49
  Object.keys(_device).forEach(function (key) {
54
50
  if (key === "default" || key === "__esModule") return;
55
51
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -61,9 +57,7 @@ Object.keys(_device).forEach(function (key) {
61
57
  }
62
58
  });
63
59
  });
64
-
65
60
  var _console = require("./console");
66
-
67
61
  Object.keys(_console).forEach(function (key) {
68
62
  if (key === "default" || key === "__esModule") return;
69
63
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -75,9 +69,7 @@ Object.keys(_console).forEach(function (key) {
75
69
  }
76
70
  });
77
71
  });
78
-
79
72
  var _browser = require("./device/browser");
80
-
81
73
  Object.keys(_browser).forEach(function (key) {
82
74
  if (key === "default" || key === "__esModule") return;
83
75
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -89,9 +81,7 @@ Object.keys(_browser).forEach(function (key) {
89
81
  }
90
82
  });
91
83
  });
92
-
93
84
  var _camera = require("./device/camera");
94
-
95
85
  Object.keys(_camera).forEach(function (key) {
96
86
  if (key === "default" || key === "__esModule") return;
97
87
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -103,9 +93,7 @@ Object.keys(_camera).forEach(function (key) {
103
93
  }
104
94
  });
105
95
  });
106
-
107
96
  var _math = require("./math");
108
-
109
97
  Object.keys(_math).forEach(function (key) {
110
98
  if (key === "default" || key === "__esModule") return;
111
99
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -117,9 +105,7 @@ Object.keys(_math).forEach(function (key) {
117
105
  }
118
106
  });
119
107
  });
120
-
121
108
  var _object = require("./object");
122
-
123
109
  Object.keys(_object).forEach(function (key) {
124
110
  if (key === "default" || key === "__esModule") return;
125
111
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -131,9 +117,7 @@ Object.keys(_object).forEach(function (key) {
131
117
  }
132
118
  });
133
119
  });
134
-
135
120
  var _string = require("./string");
136
-
137
121
  Object.keys(_string).forEach(function (key) {
138
122
  if (key === "default" || key === "__esModule") return;
139
123
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -145,9 +129,7 @@ Object.keys(_string).forEach(function (key) {
145
129
  }
146
130
  });
147
131
  });
148
-
149
132
  var _url = require("./string/url");
150
-
151
133
  Object.keys(_url).forEach(function (key) {
152
134
  if (key === "default" || key === "__esModule") return;
153
135
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -159,13 +141,8 @@ Object.keys(_url).forEach(function (key) {
159
141
  }
160
142
  });
161
143
  });
162
-
163
144
  var _Timer = _interopRequireDefault(require("./Timer"));
164
-
165
145
  var _requestCamera = _interopRequireDefault(require("./permission/requestCamera"));
166
-
167
146
  var _requestDeviceOrientationControl = _interopRequireDefault(require("./permission/requestDeviceOrientationControl"));
168
-
169
147
  var _enableConsole = _interopRequireDefault(require("./console/enableConsole"));
170
-
171
148
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = diffDate;
7
-
8
7
  /**
9
8
  *
10
9
  * @param {string} date1
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = positiveNumber;
7
-
8
7
  var _object = require("../object");
9
-
10
8
  function positiveNumber(number) {
11
9
  if ((0, _object.isNull)(number)) return 0;
12
10
  if (!Number.isFinite(Number(number))) return 0;
package/dist/math.js CHANGED
@@ -6,46 +6,40 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.randRound = exports.randInt = exports.randHalt = exports.randFloat = exports.rand = exports.radToDeg = exports.degToRad = exports.angleBetweenPoints = void 0;
7
7
  const DEG2RAD = Math.PI / 180;
8
8
  const RAD2DEG = 180 / Math.PI;
9
+
9
10
  /**
10
11
  *
11
12
  * @param {Number} number
12
13
  * @return {Number}
13
14
  */
14
-
15
15
  const randRound = number => {
16
16
  return Math.round(Math.random() * number);
17
17
  };
18
+
18
19
  /**
19
20
  *
20
21
  * @param {Number} number
21
22
  * @return {Number}
22
23
  */
23
-
24
-
25
24
  exports.randRound = randRound;
26
-
27
25
  const rand = number => {
28
26
  return (Math.random() - Math.random()) * number;
29
27
  };
28
+
30
29
  /**
31
30
  *
32
31
  * @param {Number} number
33
32
  * @return {Number}
34
33
  */
35
-
36
-
37
34
  exports.rand = rand;
38
-
39
35
  const randHalt = number => {
40
36
  var rand = Math.random() - Math.random();
41
37
  var res;
42
-
43
38
  if (rand > 0) {
44
39
  res = rand * (number / 2) + number / 2;
45
40
  } else {
46
41
  res = rand * (number / 2) - number / 2;
47
42
  }
48
-
49
43
  return Math.abs(res);
50
44
  };
51
45
  /**
@@ -54,23 +48,18 @@ const randHalt = number => {
54
48
  * @param {Number} high
55
49
  * @return {Number}
56
50
  */
57
-
58
-
59
51
  exports.randHalt = randHalt;
60
-
61
52
  const randInt = (low, high) => {
62
53
  return low + Math.floor(Math.random() * (high - low + 1));
63
54
  };
55
+
64
56
  /**
65
57
  *
66
58
  * @param {Number} low
67
59
  * @param {Number} high
68
60
  * @return {Number}
69
61
  */
70
-
71
-
72
62
  exports.randInt = randInt;
73
-
74
63
  const randFloat = (low, high) => {
75
64
  return low + Math.random() * (high - low);
76
65
  };
@@ -79,25 +68,21 @@ const randFloat = (low, high) => {
79
68
  * @param {Number} degrees
80
69
  * @return {Number}
81
70
  */
82
-
83
-
84
71
  exports.randFloat = randFloat;
85
-
86
72
  const degToRad = degrees => {
87
73
  return degrees * DEG2RAD;
88
74
  };
75
+
89
76
  /**
90
77
  *
91
78
  * @param {Number} degrees
92
79
  * @return {Number}
93
80
  */
94
-
95
-
96
81
  exports.degToRad = degToRad;
97
-
98
82
  const radToDeg = radians => {
99
83
  return radians * RAD2DEG;
100
84
  };
85
+
101
86
  /**
102
87
  *
103
88
  * @param {Number} cx
@@ -106,27 +91,26 @@ const radToDeg = radians => {
106
91
  * @param {Number} ey
107
92
  * @returns {Number}
108
93
  */
109
-
110
-
111
94
  exports.radToDeg = radToDeg;
112
-
113
95
  const angleBetweenPoints = (cx, cy, ex, ey) => {
114
96
  var dy = ey - cy;
115
97
  var dx = ex - cx;
116
98
  var theta = Math.atan2(dy, dx); // range (-PI, PI]
117
-
118
99
  theta *= 180 / Math.PI; // rads to degs, range (-180, 180]
119
-
120
100
  return theta;
121
- }; // const MathExtra = {
101
+ };
102
+
103
+ // const MathExtra = {
122
104
  // isRotateLeft(a, b, c) {
123
105
  // return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x) > 0;
124
106
  // },
107
+
125
108
  // deg_between_points_360(cx, cy, ex, ey) {
126
109
  // var theta = this.angleLine(cx, cy, ex, ey); // range (-180, 180]
127
110
  // if (theta < 0) theta = 360 + theta; // range [0, 360)
128
111
  // return theta;
129
112
  // },
113
+
130
114
  // deg_between_points(cx, cy, ex, ey) {
131
115
  // var dy = ey - cy;
132
116
  // var dx = ex - cx;
@@ -134,6 +118,7 @@ const angleBetweenPoints = (cx, cy, ex, ey) => {
134
118
  // theta *= 180 / Math.PI; // rads to degs, range (-180, 180]
135
119
  // return theta;
136
120
  // },
121
+
137
122
  // angle_between_points(cx, cy, ex, ey) {
138
123
  // var dy = ey - cy;
139
124
  // var dx = ex - cx;
@@ -141,44 +126,63 @@ const angleBetweenPoints = (cx, cy, ex, ey) => {
141
126
  // // theta *= 180 / Math.PI; // rads to degs, range (-180, 180]
142
127
  // return theta;
143
128
  // },
129
+
144
130
  // distance2Point(x1, y1, x2, y2) {
145
131
  // var dist = Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
146
132
  // return dist;
147
133
  // },
134
+
148
135
  // clamp(value, min, max) {
149
136
  // return Math.max(min, Math.min(max, value));
150
137
  // },
138
+
151
139
  // // compute euclidian modulo of m % n
152
140
  // // https://en.wikipedia.org/wiki/Modulo_operation
141
+
153
142
  // euclideanModulo(n, m) {
154
143
  // return ((n % m) + m) % m;
155
144
  // },
145
+
156
146
  // // Linear mapping from range <a1, a2> to range <b1, b2>
147
+
157
148
  // mapLinear(x, a1, a2, b1, b2) {
158
149
  // return b1 + ((x - a1) * (b2 - b1)) / (a2 - a1);
159
150
  // },
151
+
160
152
  // // https://en.wikipedia.org/wiki/Linear_interpolation
153
+
161
154
  // lerp(x, y, t) {
162
155
  // return (1 - t) * x + t * y;
163
156
  // },
157
+
164
158
  // // http://en.wikipedia.org/wiki/Smoothstep
159
+
165
160
  // smoothstep(x, min, max) {
166
161
  // if (x <= min) return 0;
167
162
  // if (x >= max) return 1;
163
+
168
164
  // x = (x - min) / (max - min);
165
+
169
166
  // return x * x * (3 - 2 * x);
170
167
  // },
168
+
171
169
  // smootherstep(x, min, max) {
172
170
  // if (x <= min) return 0;
173
171
  // if (x >= max) return 1;
172
+
174
173
  // x = (x - min) / (max - min);
174
+
175
175
  // return x * x * x * (x * (x * 6 - 15) + 10);
176
176
  // },
177
+
177
178
  // // Random integer from <low, high> interval
179
+
178
180
  // // Random float from <-range/2, range/2> interval
181
+
179
182
  // randFloatSpread(range) {
180
183
  // return range * (0.5 - Math.random());
181
184
  // },
185
+
182
186
  // rotationDegToRad(rotation) {
183
187
  // return {
184
188
  // x: this.degToRad(rotation.x),
@@ -186,15 +190,19 @@ const angleBetweenPoints = (cx, cy, ex, ey) => {
186
190
  // z: this.degToRad(rotation.z),
187
191
  // };
188
192
  // },
193
+
189
194
  // radToDeg(radians) {
190
195
  // return radians * RAD2DEG;
191
196
  // },
197
+
192
198
  // isPowerOfTwo(value) {
193
199
  // return (value & (value - 1)) === 0 && value !== 0;
194
200
  // },
201
+
195
202
  // nearestPowerOfTwo(value) {
196
203
  // return Math.pow(2, Math.round(Math.log(value) / Math.LN2));
197
204
  // },
205
+
198
206
  // nextPowerOfTwo(value) {
199
207
  // value--;
200
208
  // value |= value >> 1;
@@ -203,14 +211,18 @@ const angleBetweenPoints = (cx, cy, ex, ey) => {
203
211
  // value |= value >> 8;
204
212
  // value |= value >> 16;
205
213
  // value++;
214
+
206
215
  // return value;
207
216
  // },
217
+
208
218
  // circleByPercentRadius(percent, radius) {
209
219
  // const theta = ((percent * 360 - 90) * Math.PI) / 180;
220
+
210
221
  // const x = radius * Math.cos(theta);
211
222
  // const y = -radius * Math.sin(theta);
212
223
  // return { x, y };
213
224
  // },
225
+
214
226
  // /**
215
227
  // *
216
228
  // * @param {Array} array
@@ -224,7 +236,6 @@ const angleBetweenPoints = (cx, cy, ex, ey) => {
224
236
  // return result;
225
237
  // },
226
238
  // };
227
- // export default MathExtra;
228
-
229
239
 
240
+ // export default MathExtra;
230
241
  exports.angleBetweenPoints = angleBetweenPoints;
package/dist/object.js CHANGED
@@ -1,20 +1,14 @@
1
1
  "use strict";
2
2
 
3
3
  require("core-js/modules/es.promise.js");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.toInt = exports.toFloat = exports.toBool = exports.toArray = exports.objectToArray = exports.isNull = void 0;
9
-
10
8
  require("core-js/modules/es.json.stringify.js");
11
-
12
9
  require("core-js/modules/es.regexp.to-string.js");
13
-
14
10
  require("core-js/modules/es.parse-int.js");
15
-
16
11
  require("core-js/modules/es.parse-float.js");
17
-
18
12
  const isNull = object => {
19
13
  if (typeof object == "undefined") return true;
20
14
  if (object == "") return true;
@@ -22,59 +16,44 @@ const isNull = object => {
22
16
  if (JSON.stringify(object) == "{}") return true;
23
17
  return object == null;
24
18
  };
25
-
26
19
  exports.isNull = isNull;
27
-
28
20
  const toBool = object => {
29
21
  if (isNull(object)) return false;
30
22
  object = object.toString();
31
23
  return object === "true" || object == "1";
32
24
  };
33
-
34
25
  exports.toBool = toBool;
35
-
36
26
  const toInt = object => {
37
27
  if (isNull(object)) return 0;
38
28
  object = object.toString();
39
29
  return parseInt(object, 10);
40
30
  };
41
-
42
31
  exports.toInt = toInt;
43
-
44
32
  const toFloat = object => {
45
33
  if (isNull(object)) return 0;
46
34
  object = object.toString();
47
35
  return parseFloat(object);
48
36
  };
49
-
50
37
  exports.toFloat = toFloat;
51
-
52
38
  const toArray = obj => {
53
39
  if (isNull(obj)) return [];
54
-
55
40
  if (!Array.isArray(obj)) {
56
41
  obj = [obj];
57
42
  }
58
-
59
43
  return obj;
60
44
  };
45
+
61
46
  /**
62
47
  * Convert value in object to array
63
48
  * @param {object} obj
64
49
  * @returns {Array}
65
50
  */
66
-
67
-
68
51
  exports.toArray = toArray;
69
-
70
52
  const objectToArray = obj => {
71
53
  const array = [];
72
-
73
54
  for (const key in obj) {
74
55
  array.push(obj[key]);
75
56
  }
76
-
77
57
  return array;
78
58
  };
79
-
80
59
  exports.objectToArray = objectToArray;