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: v10.0.2
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: v10.0.3
Choose a head ref
  • 4 commits
  • 10 files changed
  • 1 contributor

Commits on Nov 10, 2023

  1. npm pkg fix

    isaacs committed Nov 10, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    32fb439 View commit details

Commits on Nov 11, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    6105ea7 View commit details

Commits on Nov 19, 2023

  1. remove spurious semver dep

    isaacs committed Nov 19, 2023
    Copy the full SHA
    8f2b01d View commit details
  2. 10.0.3

    isaacs committed Nov 19, 2023
    Copy the full SHA
    e8feab5 View commit details
Showing with 75 additions and 124 deletions.
  1. +1 −0 .gitignore
  2. +7 −7 .prettierignore
  3. +1 −1 CHANGELOG.md
  4. +2 −2 README.md
  5. +6 −6 package-lock.json
  6. +6 −6 package.json
  7. +0 −75 scripts/max-size-test.js
  8. +2 −2 test/avoid-memory-leak.ts
  9. +2 −2 test/move-to-tail.ts
  10. +48 −23 test/warn-missing-ac.ts
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.tap
/node_modules
/dist
/docs
14 changes: 7 additions & 7 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/node_modules
/tap-snapshots
/coverage
/.nyc_output
/benchmark
/.github
/scripts
/CHANGELOG.md
/docs
/.tap
/*.json
/example
/.github
/dist
/tap-snapshots
/benchmark
/.tshy
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
## 9.0.0

- Use named export only, no default export.
- Bring back minimal polyfill. If this polyfill ends up being
- Bring back minimal polyfill. If this polyfill ends up being
used, then a warning is printed, as it is not safe for use
outside of LRUCache.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -278,10 +278,10 @@ For example:
```ts
const cache = new LRUCache<string, any>({
ttl: 100,
fetchMethod: async (url, oldValue, { signal }) => {
fetchMethod: async (url, oldValue, { signal }) => {
const res = await fetch(url, { signal })
return await res.json()
}
},
})
cache.set('https://example.com/', { some: 'data' })
// 100ms go by...
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "lru-cache",
"description": "A cache object that deletes the least-recently-used items.",
"version": "10.0.2",
"version": "10.0.3",
"author": "Isaac Z. Schlueter <i@izs.me>",
"keywords": [
"mru",
@@ -45,7 +45,10 @@
}
}
},
"repository": "git://github.com/isaacs/node-lru-cache.git",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/node-lru-cache.git"
},
"devDependencies": {
"@tapjs/clock": "^1.1.16",
"@types/node": "^20.2.5",
@@ -111,8 +114,5 @@
}
}
},
"type": "module",
"dependencies": {
"semver": "^7.3.5"
}
"type": "module"
}
75 changes: 0 additions & 75 deletions scripts/max-size-test.js

This file was deleted.

4 changes: 2 additions & 2 deletions test/avoid-memory-leak.ts
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

// https://github.com/isaacs/node-lru-cache/issues/227

import t, {Test} from 'tap'
import t, { Test } from 'tap'
import { expose } from './fixtures/expose.js'

const maxSize = 100_000
@@ -28,7 +28,7 @@ const tryReq = (mod: string) => {
const v8 = tryReq('v8')

import { LRUCache } from '../dist/esm/index.js'
import {createRequire} from 'module'
import { createRequire } from 'module'
const expectItemCount = Math.ceil(maxSize / itemSize)
const max = expectItemCount + 1
const keyRange = expectItemCount * 2
4 changes: 2 additions & 2 deletions test/move-to-tail.ts
Original file line number Diff line number Diff line change
@@ -30,10 +30,10 @@ t.test('list integrity', { bail: true }, t => {
t.test(msg, { bail: false }, t => {
for (let i = 0; i < c.max; i++) {
if (i !== exp.head) {
t.equal(exp.next[(exp.prev[i] as number)], i, 'n[p[i]] === i')
t.equal(exp.next[exp.prev[i] as number], i, 'n[p[i]] === i')
}
if (i !== exp.tail) {
t.equal(exp.prev[(exp.next[i] as number)], i, 'p[n[i]] === i')
t.equal(exp.prev[exp.next[i] as number], i, 'p[n[i]] === i')
}
}
t.end()
71 changes: 48 additions & 23 deletions test/warn-missing-ac.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {fileURLToPath} from 'url'
import { createRequire } from 'module'
import { fileURLToPath } from 'url'

export {}
const __filename = fileURLToPath(import.meta.url)
const main = async () => {
const { default: t } = await import('tap')
@@ -9,32 +9,46 @@ const main = async () => {
// need to run both tests in parallel so we don't miss the close event
t.jobs = 3

const warn = spawn(process.execPath, [
...process.execArgv,
__filename,
'child',
])
const argv = process.execArgv.filter(
a => !a.startsWith('--no-warnings')
)
const warn = spawn(
process.execPath,
[...argv, __filename, 'child'],
{
env: {
...process.env,
NODE_OPTIONS: '',
},
}
)
const warnErr: Buffer[] = []
warn.stderr.on('data', c => warnErr.push(c))

const noWarn = spawn(
process.execPath,
[...process.execArgv, __filename, 'child'],
[...argv, __filename, 'child'],
{
env: {
...process.env,
LRU_CACHE_IGNORE_AC_WARNING: '1',
NODE_OPTIONS: '',
},
}
)
const noWarnErr: Buffer[] = []
noWarn.stderr.on('data', c => noWarnErr.push(c))

const noFetch = spawn(process.execPath, [
...process.execArgv,
__filename,
'child-no-fetch',
])
const noFetch = spawn(
process.execPath,
[...argv, __filename, 'child-no-fetch'],
{
env: {
...process.env,
NODE_OPTIONS: '',
},
}
)
const noFetchErr: Buffer[] = []
noFetch.stderr.on('data', c => noFetchErr.push(c))

@@ -46,7 +60,10 @@ const main = async () => {
r()
})
)
t.equal(Buffer.concat(noWarnErr).toString().trim(), '')
t.notMatch(
Buffer.concat(noWarnErr).toString().trim(),
'NO_ABORT_CONTROLLER'
)
})

t.test('no warning (because no fetch)', async t => {
@@ -57,7 +74,10 @@ const main = async () => {
r()
})
)
t.equal(Buffer.concat(noFetchErr).toString().trim(), '')
t.notMatch(
Buffer.concat(noWarnErr).toString().trim(),
'NO_ABORT_CONTROLLER'
)
})

t.test('warning', async t => {
@@ -68,24 +88,29 @@ const main = async () => {
r()
})
)
t.not(Buffer.concat(warnErr).toString().trim(), '')
t.match(
Buffer.concat(warnErr).toString().trim(),
/NO_ABORT_CONTROLLER/
)
})
}

switch (process.argv[2]) {
case 'child':
//@ts-ignore
//@ts-expect-error
process.emitWarning = null
//@ts-expect-error
globalThis.AbortController = undefined
//@ts-ignore
//@ts-expect-error
globalThis.AbortSignal = undefined
import('../dist/esm/index.js').then(({ LRUCache }) => {
new LRUCache({ max: 1, fetchMethod: async () => 1 }).fetch(1)
})
const req = createRequire(import.meta.url)
const { LRUCache } = req('../dist/commonjs/index.js')
new LRUCache({ max: 1, fetchMethod: async () => 1 }).fetch(1)
break
case 'child-no-fetch':
//@ts-ignore
//@ts-expect-error
globalThis.AbortController = undefined
//@ts-ignore
//@ts-expect-error
globalThis.AbortSignal = undefined
import('../dist/esm/index.js')
break