Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: isaacs/node-lru-cache
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v7.9.1
Choose a base ref
...
head repository: isaacs/node-lru-cache
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v7.10.0
Choose a head ref
  • 6 commits
  • 33 files changed
  • 1 contributor

Commits on May 11, 2022

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    3ad0061 View commit details
  2. handle failures from fetchMethod

    Remove the failed fetch key from the cache, rather than raising an
    unhandled rejection error when the promise was not returned.
    
    At present, there is no way to suppress this behavior, but it is
    still preferable to raising an unhandled exception in these cases.
    
    Fix: #233
    isaacs committed May 11, 2022
    Copy the full SHA
    8069477 View commit details
  3. 7.9.1

    isaacs committed May 11, 2022
    Copy the full SHA
    32e7912 View commit details
  4. feat: add noDeleteOnFetchRejection

    This suppresses the default behavior of deleting the key from the cache
    in the case of fetchMethod rejections, opting instead to leave the stale
    value in the cache.
    
    Semver-minor feature addition.
    
    Re: #233
    isaacs committed May 11, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    05942bc View commit details
  5. Build types locally, run tests in ts

    The lib itself is still JS so it can be hand-tuned, but the tests
    cover the whole lib, and are in TS, so any errors in the types should
    be apparent.
    isaacs committed May 11, 2022
    Copy the full SHA
    efbb661 View commit details
  6. 7.10.0

    isaacs committed May 11, 2022
    Copy the full SHA
    c551cbf View commit details
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
tap-snapshots
coverage
.nyc_output
bench-lru
.github
scripts
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
# cringe lorg

## 7.10.0

* Add `noDeleteOnFetchRejection` option, to suppress behavior
where a failed `fetch` will delete a previous stale value.
* Ship types along with the package, rather than relying on
out of date types coming from DefinitelyTyped.

## 7.9.0

* Better AbortController polyfill, supporting
`signal.addEventListener('abort')` and `signal.onabort`.
* (7.9.1) Drop item from cache instead of crashing with an
`unhandledRejection` when the `fetchMethod` throws an error or
returns a rejected Promise.

## 7.8.0

17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -164,6 +164,23 @@ value is resolved. For example, a DNS cache may update the TTL
based on the value returned from a remote DNS server by changing
`options.ttl` in the `fetchMethod`.

### `noDeleteOnFetchRejection`

If a `fetchMethod` throws an error or returns a rejected promise,
then by default, any existing stale value will be removed from
the cache.

If `noDeleteOnFetchRejection` is set to `true`, then this
behavior is suppressed, and the stale value remains in the cache
in the case of a rejected `fetchMethod`.

This is important in cases where a `fetchMethod` is _only_ called
as a background update while the stale value is returned, when
`allowStale` is used.

This may be set in calls to `fetch()`, or defaulted on the
constructor.

### `dispose`

Function that is called on items when they are dropped from the
Loading