util-helpers 4.23.2 → 4.23.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/util-helpers.js +23 -13
- package/dist/util-helpers.js.map +1 -1
- package/dist/util-helpers.min.js +1 -1
- package/dist/util-helpers.min.js.map +1 -1
- package/esm/VERSION.js +1 -1
- package/esm/getImageInfo.js +5 -3
- package/esm/index.js +1 -1
- package/esm/loadImage.js +5 -3
- package/esm/loadImageWithBlob.js +4 -3
- package/esm/utils/getCacheKey.js +15 -0
- package/lib/VERSION.js +1 -1
- package/lib/getImageInfo.js +4 -2
- package/lib/index.js +1 -1
- package/lib/loadImage.js +4 -2
- package/lib/loadImageWithBlob.js +4 -3
- package/lib/utils/getCacheKey.js +17 -0
- package/package.json +1 -1
- package/types/transformObjectValue.d.ts +4 -5
- package/types/utils/getCacheKey.d.ts +2 -0
- package/types/utils/Cache.d.ts +0 -14
package/dist/util-helpers.js
CHANGED
|
@@ -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:
|
|
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
|
-
},
|
|
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:
|
|
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
|
-
},
|
|
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:
|
|
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
|
-
},
|
|
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.
|
|
2653
|
+
var VERSION = "4.23.4";
|
|
2644
2654
|
|
|
2645
|
-
var version = "4.23.
|
|
2655
|
+
var version = "4.23.4";
|
|
2646
2656
|
|
|
2647
2657
|
exports.AsyncMemo = AsyncMemo;
|
|
2648
2658
|
exports.VERSION = VERSION;
|