-
-
Notifications
You must be signed in to change notification settings - Fork 54
Open
Description
Neither CacheItem, nor CacheLike are exported.
So, in order to define a custom cache, I have to manually copy the types:
// https://github.com/sindresorhus/memoize/blob/4c2b35fad5841cea20274b461fe2528fa40a692d/index.ts#L12-L15
type CacheItem<ValueType> = {
data: ValueType;
maxAge: number;
};
const cacheMap = new Map<Key, CacheItem<Value>>();or, a bit nicer:
// https://github.com/sindresorhus/memoize/blob/4c2b35fad5841cea20274b461fe2528fa40a692d/index.ts#L12C1-L23C3
type CacheItem<ValueType> = {
data: ValueType;
maxAge: number;
};
type CacheLike<KeyType, ValueType> = {
has: (key: KeyType) => boolean;
get: (key: KeyType) => CacheItem<ValueType> | undefined;
set: (key: KeyType, value: CacheItem<ValueType>) => void;
delete: (key: KeyType) => void;
clear?: () => void;
};
const cacheMap: CacheLike<Key, Value> = new Map();Could we have some exported types?
Copilot
Metadata
Metadata
Assignees
Labels
No labels