util-helpers 4.23.2 → 4.23.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.
@@ -200,11 +200,6 @@
200
200
  return isNil(value) ? '' : baseToString(value);
201
201
  }
202
202
 
203
- var defaultTo = function (value, defaultValue) {
204
- return value == null || value !== value ? defaultValue : value;
205
- };
206
- var defaultTo$1 = defaultTo;
207
-
208
203
  var blobExisted = typeof Blob !== stringUndefined;
209
204
  function isBlob(value) {
210
205
  if (blobExisted && value instanceof Blob) {
@@ -283,6 +278,7 @@
283
278
 
284
279
  var idCounter = 0;
285
280
  function uniqueId(prefix) {
281
+ if (prefix === void 0) { prefix = ''; }
286
282
  var id = ++idCounter;
287
283
  return toString(prefix) + id;
288
284
  }
@@ -2006,6 +2002,17 @@
2006
2002
  return AsyncMemo;
2007
2003
  }());
2008
2004
 
2005
+ var wm = new WeakMap();
2006
+ var getCacheKey = function (obj) {
2007
+ if (typeof obj === 'string' || !obj) {
2008
+ return obj;
2009
+ }
2010
+ if (!wm.has(obj)) {
2011
+ wm.set(obj, uniqueId('__uh_cache_key__'));
2012
+ }
2013
+ return wm.get(obj);
2014
+ };
2015
+
2009
2016
  var asyncMemo$2 = new AsyncMemo({ max: 1, maxStrategy: 'replaced' });
2010
2017
  asyncMemo$2.cache.on('del', function (k, v) {
2011
2018
  try {
@@ -2022,8 +2029,9 @@
2022
2029
  var _cacheOptions = {
2023
2030
  useCache: cacheOptionsIsObject ? cacheOptions.useCache !== false : cacheOptions !== false,
2024
2031
  autoRevokeOnDel: cacheOptionsIsObject ? cacheOptions.autoRevokeOnDel !== false : !!cacheOptions,
2025
- cacheKey: defaultTo$1(cacheOptionsIsObject ? cacheOptions.cacheKey : undefined, typeof img === 'string' ? img : undefined)
2032
+ cacheKey: cacheOptionsIsObject ? cacheOptions.cacheKey : undefined
2026
2033
  };
2034
+ var cacheKey = _cacheOptions.useCache ? getCacheKey(_cacheOptions.cacheKey || img) : undefined;
2027
2035
  return asyncMemo$2
2028
2036
  .run(function () {
2029
2037
  return new Promise(function (resolve, reject) {
@@ -2047,7 +2055,7 @@
2047
2055
  })
2048
2056
  .catch(reject);
2049
2057
  });
2050
- }, _cacheOptions.useCache && _cacheOptions.cacheKey ? _cacheOptions.cacheKey : undefined)
2058
+ }, cacheKey)
2051
2059
  .then(function (res) { return res.data; });
2052
2060
  }
2053
2061
 
@@ -2219,8 +2227,9 @@
2219
2227
  var _cacheOptions = {
2220
2228
  useCache: cacheOptionsIsObject ? cacheOptions.useCache !== false : cacheOptions !== false,
2221
2229
  autoRevokeOnDel: cacheOptionsIsObject ? cacheOptions.autoRevokeOnDel !== false : !!cacheOptions,
2222
- cacheKey: defaultTo$1(cacheOptionsIsObject ? cacheOptions.cacheKey : undefined, typeof img === 'string' ? img : undefined)
2230
+ cacheKey: cacheOptionsIsObject ? cacheOptions.cacheKey : undefined
2223
2231
  };
2232
+ var cacheKey = _cacheOptions.useCache ? getCacheKey(_cacheOptions.cacheKey || img) : undefined;
2224
2233
  return asyncMemo$1
2225
2234
  .run(function () {
2226
2235
  return loadImageWithBlob(img, false, ajaxOptions).then(function (_a) {
@@ -2241,7 +2250,7 @@
2241
2250
  r: _cacheOptions.autoRevokeOnDel
2242
2251
  };
2243
2252
  });
2244
- }, _cacheOptions.useCache && _cacheOptions.cacheKey ? _cacheOptions.cacheKey : undefined)
2253
+ }, cacheKey)
2245
2254
  .then(function (res) { return res.data; });
2246
2255
  }
2247
2256
 
@@ -2261,8 +2270,9 @@
2261
2270
  var _cacheOptions = {
2262
2271
  useCache: cacheOptionsIsObject ? cacheOptions.useCache !== false : cacheOptions !== false,
2263
2272
  autoRevokeOnDel: cacheOptionsIsObject ? cacheOptions.autoRevokeOnDel !== false : !!cacheOptions,
2264
- cacheKey: defaultTo$1(cacheOptionsIsObject ? cacheOptions.cacheKey : undefined, typeof img === 'string' ? img : undefined)
2273
+ cacheKey: cacheOptionsIsObject ? cacheOptions.cacheKey : undefined
2265
2274
  };
2275
+ var cacheKey = _cacheOptions.useCache ? getCacheKey(_cacheOptions.cacheKey || img) : undefined;
2266
2276
  return asyncMemo
2267
2277
  .run(function () {
2268
2278
  return new Promise(function (resolve, reject) {
@@ -2287,7 +2297,7 @@
2287
2297
  };
2288
2298
  image.src = url;
2289
2299
  });
2290
- }, _cacheOptions.useCache && _cacheOptions.cacheKey ? _cacheOptions.cacheKey : undefined)
2300
+ }, cacheKey)
2291
2301
  .then(function (res) { return res.data; });
2292
2302
  }
2293
2303
 
@@ -2640,9 +2650,9 @@
2640
2650
  return internalFindTreeSelect(tree, predicate, childrenField);
2641
2651
  }
2642
2652
 
2643
- var VERSION = "4.23.2";
2653
+ var VERSION = "4.23.3";
2644
2654
 
2645
- var version = "4.23.2";
2655
+ var version = "4.23.3";
2646
2656
 
2647
2657
  exports.AsyncMemo = AsyncMemo;
2648
2658
  exports.VERSION = VERSION;