Meet npm Pro: unlimited public & private packages + package-based permissions.Learn more »

lru-cache-ext

1.1.10 • Public • Published

lru-cache-ext

Build Status Test Coverage Dependabot Status Dependencies NPM Downloads Semantic-Release Gardener

Thin wrapper around lru-cache with extended functionality.

Install

Install with npm:

$ npm install --save lru-cache-ext

Usage

Please refer to lru-cache.

Additions

Some additional, non-invasive functionality is added.

memoize(key: String, valueFn: function)

Only when the key is not present in cache (or has expired), valueFn is called and placed into cache.

The cached value is returned when it becomes available (important in the case where valueFn is async).

The cache is left empty if an error is thrown at any point in valueFn (even asynchronous).

Useful when multiple async operation need to access the same async information.

memoizeSync(key: String, valueFn: function)

Similar to "memoize", when key is not present (or has expired), valueFn is called and placed into the cache.

Cached value is returned from the function.

valueFn can be a synchronous or asynchronous function.

If valueFn is an asynchronous function and an error is thrown asynchronously, the cache is not invalidated.

Install

npm i lru-cache-ext

DownloadsWeekly Downloads

500

Version

1.1.10

License

MIT

Unpacked Size

8.82 kB

Total Files

4

Last publish

Collaborators

  • avatar