@andrew_l/toolkit 0.2.7 → 0.2.8
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/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -822,14 +822,14 @@ function createWithCache({
|
|
|
822
822
|
getPointer,
|
|
823
823
|
argToKeyOptions
|
|
824
824
|
};
|
|
825
|
-
const wrapFn = (...args)
|
|
825
|
+
const wrapFn = function(...args) {
|
|
826
826
|
const storage = getBucket(getPointer());
|
|
827
827
|
const cacheKey = args.map((v) => argToKey(v, argToKeyOptions)).join("_");
|
|
828
828
|
if (storage.has(cacheKey)) {
|
|
829
829
|
const value = storage.get(cacheKey);
|
|
830
830
|
return isAsync ? Promise.resolve(value) : value;
|
|
831
831
|
}
|
|
832
|
-
const newValue = fn(
|
|
832
|
+
const newValue = fn.apply(this, args);
|
|
833
833
|
if (isPromise(newValue)) {
|
|
834
834
|
return newValue.then((value) => {
|
|
835
835
|
storage.set(cacheKey, value);
|
|
@@ -1388,13 +1388,13 @@ function withCacheBucketBatch({
|
|
|
1388
1388
|
}
|
|
1389
1389
|
return fnCache;
|
|
1390
1390
|
};
|
|
1391
|
-
const wrapFn = async (values)
|
|
1391
|
+
const wrapFn = async function(values) {
|
|
1392
1392
|
const result = /* @__PURE__ */ new Map();
|
|
1393
1393
|
let fnCache = getBucket();
|
|
1394
1394
|
const batchSet = /* @__PURE__ */ new Set();
|
|
1395
1395
|
const drainMaybe = async () => {
|
|
1396
1396
|
if (!batchSet.size) return;
|
|
1397
|
-
const items = await resolver(Array.from(batchSet));
|
|
1397
|
+
const items = await resolver.call(this, Array.from(batchSet));
|
|
1398
1398
|
for (let idx = 0; idx < items.length; idx++) {
|
|
1399
1399
|
const item = items[idx];
|
|
1400
1400
|
if (!isObject(item)) continue;
|