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

Documentation for .set is wrong. #45

Closed
mstade opened this issue Aug 27, 2023 · 1 comment
Closed

Documentation for .set is wrong. #45

mstade opened this issue Aug 27, 2023 · 1 comment

Comments

@mstade
Copy link

mstade commented Aug 27, 2023

Hi! Lovely library, thank you for sharing it with the world!

The documentation for .set states:

.set(key, value, options?)

Set an item. Returns the instance.

(Emphasis mine.) This seems to be wrong – .set doesn't actually return anything. It would be rather handy if it returned the value though, it'd allow for things like:

const thing = lru.get(key) ?? lru.set(key, getThing())

Returning the instance would work too I suppose, it'd be a bit awkward but still:

const thing = lru.get(key) ?? lru.set(key, getThing()).get(key)

Either way, .set doesn't actually return anything so the docs seem to be wrong.

@sindresorhus
Copy link
Owner

Fixed.

I'm open to adding a getOrSet() method.

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

No branches or pull requests

2 participants