Skip to content

fix(types): introduce the MapLike-type instead of using Map #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
type MapLike<K, V> = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋🏾 from Web Systems - bumping this comment #25 (comment)

set(key: K, value: V): void
get(key: K): V | undefined
has(key: K): boolean
delete(key: K): void
}

export interface MemoizeOptions<A extends unknown[], R, H = unknown> {
/**
* Provides a single value to use as the Key for the memoization.
Expand All @@ -9,7 +16,7 @@ export interface MemoizeOptions<A extends unknown[], R, H = unknown> {
* The Cache implementation to provide. Must be a Map or Map-alike.
* Defaults to a Map. Useful for replacing the cache with an LRU cache or similar.
*/
cache?: Map<H, R>
cache?: MapLike<H, R>
}

export type MemoizableFunction<A extends unknown[], R extends unknown, T extends unknown> = (this: T, ...args: A) => R
Expand Down