sindresorhus / p-memoize

Memoize promise-returning & async functions
MIT License
397 stars 30 forks source link

Document difference between this module and `mem` #18

Closed dtinth closed 3 years ago

dtinth commented 3 years ago

The package mem and p-memoize looks so similar, so I wonder what is the difference (i.e. why two packages? why I shouldn't we just use mem?) so I looked into the implementation. This PR documents the difference.

sindresorhus commented 3 years ago

Bump

dtinth commented 3 years ago

@sindresorhus Thank you for the bump. I updated the PR with updated text.

We should probably also mention that mem has more options.

I might miss something here, but p-memoize’s options is extended from mem’s options. So technically p-memoize accepts more options than mem.

So mem is good for normal functions and p-memoize is meant for async operations.

I was thinking about adding “Do not use p-memoize to memoize non-async functions; use mem instead.” but maybe that makes it too verbose?