π First Stable Release
Features
β Automatic Tail Call Optimization
- Converts tail-recursive functions to efficient loops at compile time
- Prevents stack overflow errors
- Zero runtime overhead
- Production-ready quality
β Comprehensive Support
- Function declarations and expressions
- Arrow functions (block and expression forms)
- Conditional tail calls (ternary operators, if/else statements)
- Logical expression tail calls (&&, ||)
- Nested conditions and complex patterns
β Developer Experience
- Full TypeScript support with type definitions
- Source maps for debugging
- Configurable optimization via annotations
- Clean, readable generated code
- Detailed error messages
Performance
π Benchmark Results:
- Handles 100,000+ iterations without stack overflow
- Performance near hand-written loops
- 0-2ms for complex recursive operations
| Test | Input | Unoptimized | Optimized | Result |
|---|---|---|---|---|
| Factorial | 10,000 | β Stack overflow | β 0ms | Crash prevention |
| Sum | 100,000 | β Stack overflow | β 1ms | Crash prevention |
| Fibonacci | 10,000 | β Stack overflow | β 2ms | Crash prevention |
See PERFORMANCE.md for full benchmark results.
Quality Assurance
β
100% Test Coverage - 40 comprehensive tests
β
CI/CD - Automated testing on Node.js 18/20/22
β
Code Quality - Codecov integration
β
Type Safety - Full TypeScript definitions
Documentation
- π README - Complete usage guide with examples
- π Examples - Real-world code samples (Fibonacci, arrays, strings)
- π Performance Report - Detailed benchmark results
- π€ Contributing Guide - How to contribute
- π Changelog - Version history
Installation
npm install --save-dev js-tail-recursion-opt-pluginQuick Start
.babelrc
{
"plugins": ["js-tail-recursion-opt-plugin"]
}Example:
// Before optimization - causes stack overflow at ~10,000
function factorial(n, acc = 1) {
if (n <= 1) return acc;
return factorial(n - 1, n * acc);
}
// After optimization - works for any depth!
factorial(100000); // β
No stack overflow!What's New in 1.0.0
π¨ Code Generation Improvements
- Optimized single-parameter assignments (no temp variables)
- Cleaner multi-parameter handling with indexed temps
- More readable generated code
πΊοΈ Source Map Support
- Full debugging support
- Navigate to original source in stack traces
π Complete Documentation
- 3 real-world example files
- Comprehensive README
- Contributing guidelines
- Performance benchmarks
π§ CI/CD Pipeline
- Automated testing on multiple Node versions
- Code coverage reporting
- Automated npm publishing on release
Browser Compatibility
Optimized code works in:
- β Node.js 18+
- β Modern browsers (ES2020+)
- β
Any environment that supports
whileloops
Credits
Built with β€οΈ using:
- Babel for AST transformation
- TypeScript for type safety
- Jest for testing
- GitHub Actions for CI/CD
Links
- π Homepage
- π Documentation
- π Issues
- π¬ Discussions
Thank You!
Thank you for trying js-tail-recursion-opt-plugin! If you find it useful, please β star the repo and share with others!