Skip to content

Commit

Permalink
🤷‍♂️
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante committed May 25, 2023
1 parent cddab7a commit ffe1534
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cache-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ export default class CacheItem<
Updater extends ((...args: unknown[]) => Promise<ScopedValue>) = ((...args: unknown[]) => Promise<ScopedValue>),
Arguments extends unknown[] = Parameters<Updater>,
> {
readonly maxAge: TimeDescriptor;
readonly staleWhileRevalidate: TimeDescriptor;
#cacheKey: CacheKey<Arguments>;
#updater: Updater | undefined;
#shouldRevalidate: ((cachedValue: ScopedValue) => boolean) | undefined;
readonly maxAge: TimeDescriptor;
readonly staleWhileRevalidate: TimeDescriptor;

constructor(
public name: string,
Expand Down
3 changes: 3 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ async function set<ScopedValue extends Value>(
throw new TypeError('Expected a value as the second argument');
}

// eslint-disable-next-line unicorn/no-typeof-undefined -- TODO
if (typeof value === 'undefined') {
await delete_(key);
} else {
Expand All @@ -106,6 +107,7 @@ async function deleteWithLogic(
const wholeCache = (await chromeP.storage.local.get()) as Record<string, any>;
const removableItems: string[] = [];
for (const [key, value] of Object.entries(wholeCache)) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
if (key.startsWith('cache:') && (logic?.(value) ?? true)) {
removableItems.push(key);
}
Expand Down Expand Up @@ -177,6 +179,7 @@ function function_<
return cachedItem.data;
};

// eslint-disable-next-line @typescript-eslint/promise-function-async -- TODO
function memoizePending(...args: Arguments) {
const userKey = getUserKey(name, cacheKey, args);
if (inFlightCache.has(userKey)) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@
"sinon-chrome": "^3.0.1",
"tsd": "^0.25.0",
"typescript": "^4.9.5",
"xo": "^0.53.1"
"xo": "^0.54.2"
}
}

0 comments on commit ffe1534

Please sign in to comment.