medikoo / memoizee

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

Don't memoize undefined #103

Open earonesty opened 5 years ago

earonesty commented 5 years ago

Feature idea: tell memoizee not to memoize a result.

Right now if i never want to memoize an undefined result, i have to write a wrapper lambda that deletes it right after memoizee adds it. Which is OK. But it woudl be cool if there was an optional argument:

memoized = memoize(afn, { promise: true, except:(res)=>{res == undefined} })

I can submit a pull req if you like the idea.

medikoo commented 5 years ago

This is similar request to: https://github.com/medikoo/memoizee/issues/102

For composition reasons I would keep it out of memoizee internals, still can you describe the use case in more detail?