sindresorhus

quick-lru

Simple “Least Recently Used” (LRU) cache

by sindresorhus

JavaScript

JavaScript98.5%
TypeScript1.5%

Commit activity

Last 12 weeks · 1 commit

Full graph →

Community health

4 of 6 standards met

Community profile →
85
✓README✓License✓Contributing✓Code of Conduct○Issue Template○PR Template

Recent PRs & issues

Active · 1 discussion · Last activity 1mo ago
See all on GitHub →
simpleciki

Pull requests on this repo are limited to collaborators, so I'm offering this as an issue instead. After a rotation, writing a key again leaves a live copy in and a stale copy in . The existing tests don't exercise that state, so a change to the guard logic that handles it can go unnoticed. I have 24 tests for that state (, frozen, then set again with a longer ): Every read path uses the live copy: , , , , , , , , , and iteration. Every enumeration sees the key once, and counts it once, including when is not full (, one old key deleted). It is one commit that adds them to and does not touch : https://github.com/sindresorhus/quick-lru/compare/main...simpleciki:quick-lru:test/key-in-both-caches There is no bug in quick-lru. I checked the tests by making small changes to one at a time. For example, dropping the check from the loop in the getter makes report 3 instead of 2 when is not full: all 115 existing tests still pass, and one of the new tests fails. passes (139 tests). Every test only freezes inside a synchronous test and restores it before returning. The tests were written with IBM Bob, an AI coding assistant, during a hackathon, and I adapted them to (names, lint). If you'd like them, I'm happy to open a pull request, or you can take the commit as it is, trimmed down if you prefer fewer. If not, feel free to close this.

simpleciki · 3w ago
clicktodev

Replace and the hand-written with a single typed that is compiled to . Runtime behavior is unchanged; the JSDoc from now lives on the members it documents, so the emitted declarations keep the same docs. Iterator-returning members are typed , since is no longer assignable to the signatures they override. The constructor destructures via so the still fires on while stays required in the public signature. deliberately keeps so a falls back to . Tests move to unchanged apart from type annotations and on the cases that intentionally pass invalid input. ava runs them through , so no compile step is needed to test on Node 18. Swap for , which supports ESM — the reason coverage upload was commented out in CI — and bump ava, xo, and tsd. Add Node 22 to the CI matrix.

clicktodev · 2mo ago
light885168-star

Summary The test (added in #24) actually asserts the opposite of its name: it checks that is called when shrinks the cache (). Renamed it to to match what it verifies. No behavioral or assertion changes. Test plan [x] Read through test.js to confirm the assertions match the new name [ ] CI (xo && nyc ava && tsd) passes on this PR

light885168-star · 3mo ago
hiSandog

Summary add for newest-first key iteration add for newest-first value iteration update TypeScript declarations and README add tests for ordering and duplicate-key behavior Why The API already exposes , but consumers currently need to map over entries just to get newest-first keys or values. Adding these iterators makes the API more symmetric and convenient while keeping the implementation small. Notes implementation delegates to to preserve ordering semantics verified the new iterators locally with direct runtime checks I was not able to complete the full run in this environment because stalled before devDependencies finished installing

hiSandog · 6mo ago
Structured data for AI agents

Repository: sindresorhus/quick-lru. Description: Simple “Least Recently Used” (LRU) cache Stars: 770, Forks: 64. Primary language: JavaScript. Languages: JavaScript (98.5%), TypeScript (1.5%). License: MIT. Latest release: v7.3.0 (1y ago). Open PRs: 0, open issues: 1. Last activity: 1mo ago. Community health: 85%. Top contributors: sindresorhus, BendingBender, skeggse, javi11, silverwind, adityapatadia, achingbrain, coreyfarrell, fabiospampinato, lukechilds and others.