@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.mjs
CHANGED
|
@@ -811,14 +811,14 @@ function createWithCache({
|
|
|
811
811
|
getPointer,
|
|
812
812
|
argToKeyOptions
|
|
813
813
|
};
|
|
814
|
-
const wrapFn = (...args)
|
|
814
|
+
const wrapFn = function(...args) {
|
|
815
815
|
const storage = getBucket(getPointer());
|
|
816
816
|
const cacheKey = args.map((v) => argToKey(v, argToKeyOptions)).join("_");
|
|
817
817
|
if (storage.has(cacheKey)) {
|
|
818
818
|
const value = storage.get(cacheKey);
|
|
819
819
|
return isAsync ? Promise.resolve(value) : value;
|
|
820
820
|
}
|
|
821
|
-
const newValue = fn(
|
|
821
|
+
const newValue = fn.apply(this, args);
|
|
822
822
|
if (isPromise(newValue)) {
|
|
823
823
|
return newValue.then((value) => {
|
|
824
824
|
storage.set(cacheKey, value);
|
|
@@ -1377,13 +1377,13 @@ function withCacheBucketBatch({
|
|
|
1377
1377
|
}
|
|
1378
1378
|
return fnCache;
|
|
1379
1379
|
};
|
|
1380
|
-
const wrapFn = async (values)
|
|
1380
|
+
const wrapFn = async function(values) {
|
|
1381
1381
|
const result = /* @__PURE__ */ new Map();
|
|
1382
1382
|
let fnCache = getBucket();
|
|
1383
1383
|
const batchSet = /* @__PURE__ */ new Set();
|
|
1384
1384
|
const drainMaybe = async () => {
|
|
1385
1385
|
if (!batchSet.size) return;
|
|
1386
|
-
const items = await resolver(Array.from(batchSet));
|
|
1386
|
+
const items = await resolver.call(this, Array.from(batchSet));
|
|
1387
1387
|
for (let idx = 0; idx < items.length; idx++) {
|
|
1388
1388
|
const item = items[idx];
|
|
1389
1389
|
if (!isObject(item)) continue;
|