Skip to content
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
b8c9355
Add CLAUDE.md and AGENTS.md, replace eslint with oxfmt/oxlint
avoidwork Mar 20, 2026
6bf7ef8
Remove .cursor directory
avoidwork Mar 20, 2026
0d34942
Update AGENTS.md with project info, remove c8 dependency
avoidwork Mar 21, 2026
b4f1e2e
Remove mocha and c8 dependencies, simplify test script
avoidwork Mar 21, 2026
b0cba3a
Update oxfmt and oxlint versions
avoidwork Mar 21, 2026
2be6af3
Use Node's native test runner
avoidwork Mar 21, 2026
c92facc
Replace new Array() with Array.from() to fix lint warnings
avoidwork Mar 21, 2026
dee4f55
Audit fixes: has() TTL check, evict() null guard, lazy default params…
avoidwork Mar 21, 2026
c4bfb3c
Rewrite README.md for new and experienced developers
avoidwork Mar 21, 2026
4b03957
Add docs/API.md with complete API reference
avoidwork Mar 21, 2026
6d0ea31
Update CODE_STYLE_GUIDE.md with actual coding conventions
avoidwork Mar 21, 2026
645897f
Update TECHNICAL_DOCUMENTATION.md to reflect actual implementation
avoidwork Mar 21, 2026
c8d04ba
Revert TECHNICAL_DOCUMENTATION.md changes
avoidwork Mar 21, 2026
d125a12
Fix TECHNICAL_DOCUMENTATION.md to accurately reflect implementation
avoidwork Mar 21, 2026
87c71f0
Fix Mathematical Foundation section in TECHNICAL_DOCUMENTATION.md
avoidwork Mar 21, 2026
281b3f0
Fix memory leak, stale data, and improve performance
avoidwork Mar 21, 2026
5eac383
Update AGENTS.md with common issues and implementation notes
avoidwork Mar 21, 2026
26a6e14
Remove dead code in moveToEnd()
avoidwork Mar 21, 2026
9d4f7c1
Update lint script to check formatting
avoidwork Mar 21, 2026
f5fa3fe
Replace fmt script with fix script
avoidwork Mar 21, 2026
e96fca9
Apply formatting fixes
avoidwork Mar 21, 2026
87d89fe
Add coverage script and rename test file
avoidwork Mar 21, 2026
96736a2
Add tests for 100% line coverage
avoidwork Mar 21, 2026
1dad65b
Add test coverage info to README
avoidwork Mar 21, 2026
e5f5109
Remove unused eslint config
avoidwork Mar 21, 2026
f235aa9
Fix Mathematical Foundation section to match implementation
avoidwork Mar 21, 2026
b40d6b4
Update TypeScript definitions to match implementation
avoidwork Mar 21, 2026
458f414
Rebuild distribution files
avoidwork Mar 21, 2026
38bd623
fix: rename cache variables in factory function example to avoid rede…
avoidwork Mar 29, 2026
81a7045
fix: correct values() example comment to reflect input key order
avoidwork Mar 29, 2026
282bd7e
feat: add oxlint.json configuration
avoidwork Mar 29, 2026
e9727f7
feat: add .oxfmtrc.json configuration
avoidwork Mar 29, 2026
341e6db
feat: update pre-commit hook to run fix, coverage, and stage all changes
avoidwork Mar 29, 2026
406a3d3
build: update dist files
avoidwork Mar 29, 2026
c988ca2
fix: clarify entries() and values() ordering in JSDoc
avoidwork Mar 29, 2026
543d6d1
build: update dist files
avoidwork Mar 29, 2026
4435b76
docs: add development principles (DRY, YAGNI, SOLID, OWASP)
avoidwork Mar 29, 2026
085e4f3
refactor: extract unlink() to eliminate linked list duplication
avoidwork Mar 29, 2026
9330ff4
build: update dist files
avoidwork Mar 29, 2026
5d9ed36
refactor: remove bypass parameter from set() to simplify API
avoidwork Mar 29, 2026
ab6843b
refactor: simplify set() and setWithEvicted() API by removing resetTt…
avoidwork Mar 29, 2026
8e85031
build: update dist files
avoidwork Mar 29, 2026
fa96113
docs: sort methods and properties alphabetically in README
avoidwork Mar 29, 2026
016ef16
docs: add badges, TypeScript example, comparison, and contributing guide
avoidwork Mar 29, 2026
748ad76
docs: update copyright year to 2026
avoidwork Mar 29, 2026
bad9e0e
docs: fix build badge URL to point to ci.yml
avoidwork Mar 29, 2026
5b47ce4
docs: restore coverage badge
avoidwork Mar 29, 2026
c99834b
docs: update package.json description to match README tagline
avoidwork Mar 29, 2026
923683d
docs: optimize package.json keywords for discoverability
avoidwork Mar 29, 2026
b5eb5c4
chore: update files array to explicitly list lru.d.ts
avoidwork Mar 29, 2026
b7eacfd
docs: add contributing guide
avoidwork Mar 29, 2026
1afa568
docs: update AGENTS.md with correct npm scripts
avoidwork Mar 29, 2026
d0f5992
docs: update AGENTS.md development workflow section
avoidwork Mar 29, 2026
2351d32
docs: rename ESLint Configuration to Lint Configuration
avoidwork Mar 29, 2026
9a9788f
types: update set() and setWithEvicted() signatures to remove unused …
avoidwork Mar 29, 2026
f69680e
docs: fix TypeScript signatures in TECHNICAL_DOCUMENTATION.md to matc…
avoidwork Mar 29, 2026
08335be
docs: fix TTL reset invariant and expiry formula in technical documen…
avoidwork Mar 29, 2026
93465ff
perf: remove bypass parameter from evict() to avoid V8 deoptimization
avoidwork Mar 29, 2026
05482df
docs: fix resetTtl description and setWithEvicted return type
avoidwork Mar 29, 2026
65a1785
build: update distribution files
avoidwork Mar 29, 2026
72a2dd2
refactor: make unlink() private and update Node.js version requirement
avoidwork Mar 29, 2026
ee7cdc2
refactor: simplify JSDoc by removing @example, @see, @since, @method,…
avoidwork Mar 29, 2026
00fea20
test: update tests to match current API and add edge case coverage
avoidwork Mar 29, 2026
7d409e8
docs: update Node.js version requirement to 14+ and fix test runner r…
avoidwork Mar 29, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions .cursor/rules/javascript.mdc

This file was deleted.

77 changes: 77 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# AGENTS.md

## Project Overview

`tiny-lru` is a high-performance, lightweight LRU (Least Recently Used) cache library for JavaScript with O(1) operations and optional TTL support.

## Setup Commands

```bash
npm install # Install dependencies
npm run build # Lint and build (runs lint then rollup)
npm run rollup # Build with rollup
npm run test # Run lint and tests
npm run mocha # Run tests with coverage (c8)
npm run fmt # Format code with oxfmt
npm run lint # Lint code with oxlint
```

## Development Workflow

Source code is in `src/`.

- **lint**: Check and fix linting issues with oxlint
- **fmt**: Format code with oxfmt
- **build**: Lint + rollup build
- **mocha**: Run test suite with coverage reporting

## Project Structure

```
├── src/lru.js # Main LRU cache implementation
├── tests/ # Test files
├── benchmarks/ # Performance benchmarks
├── dist/ # Built distribution files
├── types/ # TypeScript definitions
├── docs/ # Documentation
├── rollup.config.js # Build configuration
└── package.json # Project configuration
```

## Code Style

- Indentation: Tabs
- Quotes: Double quotes
- Semicolons: Required
- Array constructor: Avoid `new Array()` (oxlint will warn)

## API Reference

- `lru(max, ttl, resetTtl)` - Factory function to create cache
- `LRU` class - Direct instantiation with `new LRU(max, ttl, resetTtl)`
- Key methods: `get()`, `set()`, `delete()`, `has()`, `clear()`, `evict()`
- Array methods: `keys()`, `values()`, `entries()`
- Properties: `first`, `last`, `max`, `size`, `ttl`, `resetTtl`

## Testing

- Framework: Node.js built-in test runner (`node --test`)
- Coverage: 100% (c8)
- Test pattern: `tests/**/*.js`
- All tests must pass with 100% coverage before merging
- Run: `npm test` (lint + tests)

## Common Issues to Avoid

- **Memory leaks**: When removing items from the linked list, always clear `prev`/`next` pointers to allow garbage collection
- **LRU order pollution**: Methods like `entries()` and `values()` should access items directly rather than calling `get()`, which moves items and can delete expired items mid-iteration
- **TTL edge cases**: Direct property access (`this.items[key]`) should be used instead of `has()` when you need to inspect expired-but-not-yet-deleted items
- **Dead code**: Always verify edge case code is actually reachable before adding special handling
- **Constructor assignment**: Use `let` not `const` for variables that may be reassigned (e.g., in `setWithEvicted`)

## Implementation Notes

- The LRU uses a doubly-linked list with `first` and `last` pointers for O(1) operations
- TTL is stored per-item as an `expiry` timestamp; `0` means no expiration
- `moveToEnd()` is the core method for maintaining LRU order - item is always moved to the `last` position
- `setWithEvicted()` optimizes updates by avoiding the full `set()` path for existing keys
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@AGENTS.md
Loading
Loading