medikoo / memoizee

Complete memoize/cache solution for JavaScript
ISC License
1.73k stars 61 forks source link

Expose `get` and `has` methods #72

Closed epayet closed 7 years ago

epayet commented 7 years ago

This has been mentioned in a few issues (https://github.com/medikoo/memoizee/issues/45, https://github.com/medikoo/memoizee/issues/33, https://github.com/medikoo/memoizee/issues/51).

The goal is to expose get and has methods so that we easily have read access to the cache, depending on the arguments. Hopefully, the tests will demonstrate really well how this works.

I tried to match your coding style, I am happy to take any feedback. This would be really useful for my use case described here: https://github.com/medikoo/memoizee/issues/33#issuecomment-278046852

I know you're planning to do a major refactor soon, but in the meantime, I think that exposing those 2 new methods are costless and will be really useful to some people, me included :)

Many thanks.

medikoo commented 7 years ago

Thanks @epayet, at first glance looks good. I'm keen to take it but would prefer to give it a more careful look. If not today, I'll take care of this on Monday.

epayet commented 7 years ago

Sure @medikoo thanks for the quick response 👍

epayet commented 7 years ago

I gave it another go according to your requested changes. Can you have a look now and give your feedback?

I left a note on async on another comment, this is an interesting case that I hope will be solved in v1. In the meantime, if you're happy with this code, it would still be very helpful.

Thanks :)

medikoo commented 7 years ago

@epayet looks great, just check my comment towards null handling :)

epayet commented 7 years ago

I added the null check for _has :) And the build is green 👍

medikoo commented 7 years ago

Thank you, published with v0.4.4

epayet commented 7 years ago

Thanks I just checked, it works 👍