Conversation
- peek() retrieves value without moving item in LRU order - peek() does not perform TTL checks or delete expired items - All core operations remain O(1) - Updated tests, documentation, and AGENTS.md
- Added 68 new tests covering forEach, getMany, hasAll, hasAny, cleanup, toJSON, stats, onEvict, sizeByTTL, keysByTTL, and valuesByTTL methods - Refactored values() to directly iterate linked list instead of using keys() - Refactored forEach() for direct linked list traversal - Updated API documentation in docs/API.md - Updated README.md method table - Updated AGENTS.md API reference - All tests passing (145/145)
- Added test for items with expiry=0 when ttl>0 (manual expiry set) - Covers uncovered lines 534-535 and 563-564 in sizeByTTL and keysByTTL - 100% line coverage achieved
- Compress badges to first 8 lines after title - Add new badges: GitHub stars, Codecov - Organize content with clear sections - Add modern usage patterns (LLM caching, session auth) - Improve 'Why Tiny LRU?' comparison table - Add detailed API reference with all methods - Include TypeScript examples - Add security best practices - Remove duplicate TypeScript section - Standardize method descriptions - Add comprehensive code examples Fixes: branch name references (master vs main)
- Update bundle sizes to actual measured values (gzipped) - Fix quick-lru TTL support (it does support maxAge) - Replace inaccurate 'Comprehensive API' column with 'Pure LRU'
- Methods now sorted A-Z: cleanup() to valuesByTTL() - Expanded table of contents with 1-3 level headers - All method anchors now directly link to section headers
- Removed redundant TECHNICAL_DOCUMENTATION link in Security section - Added Documentation section with links to all three docs files
- Corrected resetTtl doc to say 'via set()' instead of 'via get()' - Removed 'readonly' from class properties (implementation doesn't use readonly)
🤖 Augment PR SummarySummary: Expands tiny-lru’s public API with new utility/introspection methods, modernizes distribution outputs, and refreshes documentation/tests. Changes:
Technical Notes: Type definitions were updated to include the new APIs and to type 🤖 Was this summary useful? React with 👍 or 👎 |
- When evicting items, ensure both prev and next pointers are cleared - This prevents keeping the rest of the list reachable when consumers hold references to evicted nodes
- Items with expiry === 0 represent noTTL items, not expired items - Changed cleanup() to only remove items where expiry !== 0 && expiry <= now - This matches the semantics in sizeByTTL()/keysByTTL()
Owner
Author
|
augment review |
- Properly unlink expired nodes during cleanup() deletion - Clear prev/next pointers to allow garbage collection - Fix iteration to save next pointer before unlinking
…ined> This correctly reflects that items[key] returns undefined for missing keys,
Prevents runtime error if onEvict() is called with undefined or non-function value. The evict() method already checked #onEvict !== null, but that allows non-functions.
Owner
Author
|
augment review |
clear() now iterates through linked list to nullify prev/next pointers, allowing proper garbage collection of nodes.
The sets counter increments in both set() and setWithEvicted() methods. Updated documentation to reflect actual behavior.
The delete count includes both explicit delete() calls AND internal removal of expired items by get(). Update the documentation to reflect this behavior accurately.
Remove the redundant nodei.co npm badge which duplicated npm version and downloads information already shown in the badges above.
- Properties: first, last, max, resetTtl, size, ttl - Methods: clear, cleanup, delete, entries, evict, forEach, get, getMany, has, hasAll, hasAny, keys, keysByTTL, onEvict, peek, set, setWithEvicted, sizeByTTL, stats, toJSON, values, valuesByTTL, expiresAt
Updated Methods table to be alphabetically sorted: - cleanup, clear, delete, entries, evict, expiresAt, forEach, get, getMany, has, hasAll, hasAny, keys, keysByTTL, onEvict, peek, set, setWithEvicted, sizeByTTL, stats, toJSON, values, valuesByTTL
Owner
Author
|
augment review |
- Added test count to README.md Tests section - Added test count to AGENTS.md Testing section
- cleanup() returns number, not (documented in Method Chaining section) - setWithEvicted() TTL reset behavior on updates with resetTtl=true - values() example comment: 'respects LRU order' -> 'order matches input array' - onEvict() parameter validation throws TypeError - forEach() thisArg type: Object -> * - entries() return type: Array<[string, *]> -> Array<(string|*)[]>
- dist/tiny-lru.min.js is available in repo but not packaged for npm - Only dist/tiny-lru.js, dist/tiny-lru.cjs, and types/lru.d.ts are shipped
- getMany() calls get() for each key - Updates LRU order (items move to MRU position) - Removes expired items (affects stats: hits, misses, deletes) - Clarify this is not a read-only operation
Owner
Author
|
augment review |
Correctly state that noTTL contains items where expiry === 0, regardless of cache ttl setting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces comprehensive documentation improvements, removes obsolete UMD builds, adds test coverage for utility methods, and introduces new utility methods (
peek(),cleanup(),getMany(),hasAll(),hasAny(),expiresAt(),sizeByTTL(),keysByTTL(),valuesByTTL(),onEvict()) to the tiny-lru cache library.Key Changes
Documentation Overhaul
Build System
dist/tiny-lru.umd.js,dist/tiny-lru.umd.min.js, anddist/tiny-lru.umd.min.js.maprollup.config.jsto support only ESM and CommonJS formatsBreaking changes
resetTtlparameter/property toresetTTLNew Methods
peek(key): Retrieve a value without updating LRU order or performing TTL checkscleanup(): Remove expired items without affecting LRU ordergetMany(keys): Batch retrieve multiple itemshasAll(keys): Batch existence check - returns true if ALL keys existhasAny(keys): Batch existence check - returns true if ANY key existsexpiresAt(key): Get expiration timestamp for a keysizeByTTL(): Get counts of items by TTL statuskeysByTTL(): Get keys filtered by TTL statusvaluesByTTL(): Get values filtered by TTL statusonEvict(callback): Register callback for evicted itemsTest Coverage
noTTLitems insizeByTTL()/keysByTTL()Minor Fixes
resetTtldocumentation (was "via get()", now "via set()")readonlyfrom type definitions (matches actual implementation)Files Changed
peek(),cleanup(),getMany(),hasAll(),hasAny(),expiresAt(),sizeByTTL(),keysByTTL(),valuesByTTL(),onEvict()