Skip to content
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

Constructor parameters: ordered or options bag? #10

Open
js-choi opened this issue Aug 17, 2022 · 2 comments
Open

Constructor parameters: ordered or options bag? #10

js-choi opened this issue Aug 17, 2022 · 2 comments
Labels
question Further information is requested

Comments

@js-choi
Copy link
Collaborator

js-choi commented Aug 17, 2022

Let’s assume that we make new classes rather than using Map and Set (see #8 and #5).
Given that, we now have two or three possible parameters:

There are several API choices that I can think of:

new CacheMap('lru', [ 256, 'purgeable' ], entries)
new CacheMap('lru', { maxSize: 256, purgeable: true }, entries)
new CacheMap('lru', entries, { maxSize: 256, purgeable: true })
new CacheMap('lru', { maxSize: 256, purgeable: true, entries })
new CacheMap({ policy: 'lru', maxSize: 256, purgeable: true, entries })
@js-choi js-choi added the question Further information is requested label Aug 17, 2022
@js-choi js-choi changed the title Parameter order Constructor parameters: ordered or options bag? Aug 17, 2022
@ljharb
Copy link
Member

ljharb commented Aug 17, 2022

Why separate classes rather than a constructor options bag parameter to the existing Map and Set?

@js-choi
Copy link
Collaborator Author

js-choi commented Aug 17, 2022

Reusing Map and Set and extending them with option bags is another API option. I’ve tweaked this issue’s original post to say that this issue assumes that we’re going with separate classes as per #8 or #5.

I’m inclined to agree with #1 (comment), but we probably should talk about that more in #1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants