util-helpers 5.0.1 → 5.0.3

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.
@@ -71,11 +71,7 @@
71
71
  }
72
72
  value = value.trim();
73
73
  var isBinary = reIsBinary.test(value);
74
- return isBinary || reIsOctal.test(value)
75
- ? parseInt(value.slice(2), isBinary ? 2 : 8)
76
- : reIsBadHex.test(value)
77
- ? NaN
78
- : +value;
74
+ return isBinary || reIsOctal.test(value) ? parseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NaN : +value;
79
75
  }
80
76
 
81
77
  function toInteger(value) {
@@ -172,7 +168,6 @@
172
168
  }
173
169
 
174
170
  var forEach = createForEach(1);
175
- var forEach$1 = forEach;
176
171
 
177
172
  function isNumber(value) {
178
173
  return typeof value === 'number' || getTag(value) === numberTag;
@@ -225,14 +220,13 @@
225
220
  var freeGlobal = globalExisted && global.Object === Object && global;
226
221
  var freeSelf = selfExisted && self.Object === Object && self;
227
222
  var root = freeGlobalThis || freeGlobal || freeSelf || Function('return this')();
228
- var root$1 = root;
229
223
 
230
224
  function isFinite$1(value) {
231
- return numberIsFinite ? numberIsFinite(value) : typeof value === 'number' && root$1.isFinite(value);
225
+ return numberIsFinite ? numberIsFinite(value) : typeof value === 'number' && root.isFinite(value);
232
226
  }
233
227
 
234
228
  function isNaN(value) {
235
- return isNumber(value) && root$1.isNaN(value);
229
+ return isNumber(value) && root.isNaN(value);
236
230
  }
237
231
 
238
232
  function isPromiseLike(value) {
@@ -270,9 +264,9 @@
270
264
  function noop() { }
271
265
 
272
266
  var idCounter = 0;
267
+ '_' + Math.random().toString(36).substring(2, 4);
273
268
  function uniqueId(prefix) {
274
- var id = ++idCounter;
275
- return toString(prefix) + id;
269
+ return '' + prefix + ++idCounter;
276
270
  }
277
271
 
278
272
  var reg$b = /^1[3456789]\d{9}$/;
@@ -765,18 +759,6 @@
765
759
  }
766
760
  }
767
761
 
768
- function __values(o) {
769
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
770
- if (m) return m.call(o);
771
- if (o && typeof o.length === "number") return {
772
- next: function () {
773
- if (o && i >= o.length) o = void 0;
774
- return { value: o && o[i++], done: !o };
775
- }
776
- };
777
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
778
- }
779
-
780
762
  function __read(o, n) {
781
763
  var m = typeof Symbol === "function" && o[Symbol.iterator];
782
764
  if (!m) return o;
@@ -1244,7 +1226,7 @@
1244
1226
  if (deep === void 0) { deep = true; }
1245
1227
  if (isPlainObject(data)) {
1246
1228
  var result_1 = {};
1247
- forEach$1(data, function (value, key) {
1229
+ forEach(data, function (value, key) {
1248
1230
  var newValue = deep && (isPlainObject(value) || isArray(value)) ? transformObjectValue(value, fn) : fn(value, key);
1249
1231
  result_1[key] = newValue;
1250
1232
  });
@@ -1252,7 +1234,7 @@
1252
1234
  }
1253
1235
  else if (isArray(data)) {
1254
1236
  var result_2 = [];
1255
- forEach$1(data, function (value, index) {
1237
+ forEach(data, function (value, index) {
1256
1238
  var newValue = deep && (isPlainObject(value) || isArray(value)) ? transformObjectValue(value, fn) : fn(value, index);
1257
1239
  result_2.push(newValue);
1258
1240
  });
@@ -1514,23 +1496,33 @@
1514
1496
  });
1515
1497
  }
1516
1498
 
1517
- function loadImageWithBlob(img, ajaxOptions) {
1499
+ function loadImage(img) {
1518
1500
  return new Promise(function (resolve, reject) {
1519
- getFileBlob(img, ajaxOptions)
1520
- .then(function (blob) {
1521
- var url = createObjectURL(blob);
1522
- var image = new Image();
1523
- image.onload = function () {
1524
- resolve({ blob: blob, image: image });
1525
- };
1526
- image.onerror = function (err) {
1501
+ var imgIsBlob = isBlob(img);
1502
+ var url = imgIsBlob ? createObjectURL(img) : img;
1503
+ var image = new Image();
1504
+ if (!imgIsBlob) {
1505
+ image.crossOrigin = 'anonymous';
1506
+ }
1507
+ image.onload = function () {
1508
+ resolve(image);
1509
+ };
1510
+ image.onerror = function (err) {
1511
+ if (imgIsBlob) {
1527
1512
  revokeObjectURL(url);
1528
- console.error("[loadImageWithBlob] The image load failed, '".concat(img, "'."));
1529
- reject(err);
1530
- };
1531
- image.src = url;
1532
- })
1533
- .catch(reject);
1513
+ }
1514
+ console.error("[loadImage] The image load failed, '".concat(img, "'."));
1515
+ reject(err);
1516
+ };
1517
+ image.src = url;
1518
+ });
1519
+ }
1520
+
1521
+ function loadImageWithBlob(img, ajaxOptions) {
1522
+ return getFileBlob(img, ajaxOptions).then(function (blob) {
1523
+ return loadImage(blob).then(function (image) {
1524
+ return { blob: blob, image: image };
1525
+ });
1534
1526
  });
1535
1527
  }
1536
1528
 
@@ -1703,28 +1695,6 @@
1703
1695
  });
1704
1696
  }
1705
1697
 
1706
- function loadImage(img) {
1707
- return new Promise(function (resolve, reject) {
1708
- var imgIsBlob = isBlob(img);
1709
- var url = imgIsBlob ? createObjectURL(img) : img;
1710
- var image = new Image();
1711
- if (!imgIsBlob) {
1712
- image.crossOrigin = 'anonymous';
1713
- }
1714
- image.onload = function () {
1715
- resolve(image);
1716
- };
1717
- image.onerror = function (err) {
1718
- if (imgIsBlob) {
1719
- revokeObjectURL(url);
1720
- }
1721
- console.error("[loadImage] The image load failed, '".concat(img, "'."));
1722
- reject(err);
1723
- };
1724
- image.src = url;
1725
- });
1726
- }
1727
-
1728
1698
  function loadScript(src, options) {
1729
1699
  return new Promise(function (resolve, reject) {
1730
1700
  var head = document.head;
@@ -1951,16 +1921,11 @@
1951
1921
  }
1952
1922
 
1953
1923
  function findTreeNode(tree, predicate, childrenField) {
1954
- var e_1, _a;
1955
1924
  if (childrenField === void 0) { childrenField = 'children'; }
1956
1925
  var stack = [];
1957
1926
  var node;
1958
- if (!isArray(tree)) {
1959
- return node;
1960
- }
1961
- try {
1962
- for (var tree_1 = __values(tree), tree_1_1 = tree_1.next(); !tree_1_1.done; tree_1_1 = tree_1.next()) {
1963
- var item = tree_1_1.value;
1927
+ if (isArray(tree)) {
1928
+ forEach(tree, function (item) {
1964
1929
  stack.push(item);
1965
1930
  while (stack.length) {
1966
1931
  var temp = stack.pop();
@@ -1978,31 +1943,19 @@
1978
1943
  }
1979
1944
  }
1980
1945
  if (node) {
1981
- break;
1946
+ return false;
1982
1947
  }
1983
- }
1984
- }
1985
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1986
- finally {
1987
- try {
1988
- if (tree_1_1 && !tree_1_1.done && (_a = tree_1.return)) _a.call(tree_1);
1989
- }
1990
- finally { if (e_1) throw e_1.error; }
1948
+ });
1991
1949
  }
1992
1950
  return node;
1993
1951
  }
1994
1952
 
1995
1953
  function findTreeNodes(tree, predicate, childrenField) {
1996
- var e_1, _a;
1997
1954
  if (childrenField === void 0) { childrenField = 'children'; }
1998
1955
  var stack = [];
1999
1956
  var nodes = [];
2000
- if (!isArray(tree)) {
2001
- return nodes;
2002
- }
2003
- try {
2004
- for (var tree_1 = __values(tree), tree_1_1 = tree_1.next(); !tree_1_1.done; tree_1_1 = tree_1.next()) {
2005
- var item = tree_1_1.value;
1957
+ if (isArray(tree)) {
1958
+ forEach(tree, function (item) {
2006
1959
  stack.push(item);
2007
1960
  while (stack.length) {
2008
1961
  var temp = stack.pop();
@@ -2018,58 +1971,42 @@
2018
1971
  }
2019
1972
  }
2020
1973
  }
2021
- }
2022
- }
2023
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2024
- finally {
2025
- try {
2026
- if (tree_1_1 && !tree_1_1.done && (_a = tree_1.return)) _a.call(tree_1);
2027
- }
2028
- finally { if (e_1) throw e_1.error; }
1974
+ });
2029
1975
  }
2030
1976
  return nodes;
2031
1977
  }
2032
1978
 
2033
1979
  function internalFindTreeSelect(tree, predicate, childrenField, path) {
2034
- var e_1, _a;
2035
1980
  if (path === void 0) { path = []; }
2036
- if (!isArray(tree)) {
2037
- return [];
2038
- }
2039
- try {
2040
- for (var tree_1 = __values(tree), tree_1_1 = tree_1.next(); !tree_1_1.done; tree_1_1 = tree_1.next()) {
2041
- var item = tree_1_1.value;
1981
+ var result = [];
1982
+ if (isArray(tree)) {
1983
+ forEach(tree, function (item) {
2042
1984
  path.push(item);
2043
1985
  if (predicate(item)) {
2044
- return path;
1986
+ result = path;
1987
+ return false;
2045
1988
  }
2046
1989
  if (isObject(item)) {
2047
1990
  var childs = item[childrenField];
2048
1991
  if (isArray(childs) && childs.length > 0) {
2049
1992
  var findChildren = internalFindTreeSelect(childs, predicate, childrenField, path);
2050
1993
  if (findChildren.length > 0) {
2051
- return findChildren;
1994
+ result = findChildren;
1995
+ return false;
2052
1996
  }
2053
1997
  }
2054
1998
  }
2055
1999
  path.pop();
2056
- }
2057
- }
2058
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2059
- finally {
2060
- try {
2061
- if (tree_1_1 && !tree_1_1.done && (_a = tree_1.return)) _a.call(tree_1);
2062
- }
2063
- finally { if (e_1) throw e_1.error; }
2000
+ });
2064
2001
  }
2065
- return [];
2002
+ return result;
2066
2003
  }
2067
2004
  function findTreeSelect(tree, predicate, childrenField) {
2068
2005
  if (childrenField === void 0) { childrenField = 'children'; }
2069
2006
  return internalFindTreeSelect(tree, predicate, childrenField);
2070
2007
  }
2071
2008
 
2072
- var VERSION = "5.0.1";
2009
+ var VERSION = "5.0.3";
2073
2010
 
2074
2011
  var EmitterPro = /** @class */ (function () {
2075
2012
  function EmitterPro() {