util-helpers 4.19.0 → 4.19.1

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.
@@ -129,6 +129,44 @@
129
129
  return typeof value === 'symbol' || (isObjectLike(value) && isType(value, 'Symbol'));
130
130
  }
131
131
 
132
+ var reIsBinary = /^0b[01]+$/i;
133
+ var reIsOctal = /^0o[0-7]+$/i;
134
+ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
135
+ function toNumber(value) {
136
+ if (typeof value === 'number') {
137
+ return value;
138
+ }
139
+ if (isSymbol(value)) {
140
+ return NaN;
141
+ }
142
+ if (isObject(value)) {
143
+ value = Number(value);
144
+ }
145
+ if (typeof value !== 'string') {
146
+ return value === 0 ? value : +value;
147
+ }
148
+ value = value.trim();
149
+ var isBinary = reIsBinary.test(value);
150
+ return isBinary || reIsOctal.test(value)
151
+ ? parseInt(value.slice(2), isBinary ? 2 : 8)
152
+ : reIsBadHex.test(value)
153
+ ? NaN
154
+ : +value;
155
+ }
156
+
157
+ function toInteger(value) {
158
+ var result = toNumber(value);
159
+ if (!result || result === Infinity || result === -Infinity) {
160
+ return result === result ? result : 0;
161
+ }
162
+ var remainder = result % 1;
163
+ return remainder ? result - remainder : result;
164
+ }
165
+
166
+ var argType = 'Arguments';
167
+ isType((function () { return arguments; })(), argType);
168
+ var numberIsFinite = Number.isFinite;
169
+
132
170
  /******************************************************************************
133
171
  Copyright (c) Microsoft Corporation.
134
172
 
@@ -246,6 +284,10 @@
246
284
  return to.concat(ar || Array.prototype.slice.call(from));
247
285
  }
248
286
 
287
+ function isFinite$1(value) {
288
+ return numberIsFinite ? numberIsFinite(value) : typeof value === 'number' && root.isFinite(value);
289
+ }
290
+
249
291
  function baseToString(value) {
250
292
  if (typeof value === 'string') {
251
293
  return value;
@@ -263,6 +305,24 @@
263
305
  return value == null ? '' : baseToString(value);
264
306
  }
265
307
 
308
+ function decimalAdjust(type, value, precision) {
309
+ if (precision === void 0) { precision = 0; }
310
+ var func = Math[type];
311
+ value = toNumber(value);
312
+ precision = Math.min(toInteger(precision), 292);
313
+ if (precision === 0 || !isFinite$1(value)) {
314
+ return func(value);
315
+ }
316
+ var pair = toString(value).split('e');
317
+ value = func(+(pair[0] + 'e' + (pair[1] ? +pair[1] + precision : precision)));
318
+ pair = toString(value).split('e');
319
+ return +(pair[0] + 'e' + (pair[1] ? +pair[1] - precision : -precision));
320
+ }
321
+
322
+ function round(number, precision) {
323
+ return decimalAdjust('round', number, precision);
324
+ }
325
+
266
326
  function isBlob(value) {
267
327
  return (blobExisted && value instanceof Blob) || isType(value, ['Blob', 'File']);
268
328
  }
@@ -1245,14 +1305,9 @@
1245
1305
  return times(num1Changed / num2Changed, strip(Math.pow(10, digitLength(num2) - digitLength(num1))));
1246
1306
  }
1247
1307
 
1248
- function round(num, precision) {
1308
+ function _round(num, precision) {
1249
1309
  if (precision === void 0) { precision = 0; }
1250
- num = transformEffectiveNumber(num);
1251
- if (isNaN$1(num)) {
1252
- return Number.NaN;
1253
- }
1254
- var base = Math.pow(10, precision);
1255
- return divide(Math.round(times(num, base)), base);
1310
+ return round(num, precision);
1256
1311
  }
1257
1312
 
1258
1313
  function ajax(url, options) {
@@ -1748,9 +1803,9 @@
1748
1803
  return internalFindTreeSelect(tree, predicate, childrenField);
1749
1804
  }
1750
1805
 
1751
- var VERSION = "4.19.0";
1806
+ var VERSION = "4.19.1";
1752
1807
 
1753
- var version = "4.19.0";
1808
+ var version = "4.19.1";
1754
1809
 
1755
1810
  exports.VERSION = VERSION;
1756
1811
  exports.ajax = ajax;
@@ -1800,7 +1855,7 @@
1800
1855
  exports.plus = plus;
1801
1856
  exports.randomString = randomString;
1802
1857
  exports.replaceChar = replaceChar;
1803
- exports.round = round;
1858
+ exports.round = _round;
1804
1859
  exports.safeDate = safeDate;
1805
1860
  exports.setDataURLPrefix = setDataURLPrefix;
1806
1861
  exports.setDisableWarning = setDisableWarning;