saferec
v0.0.2
Published
Easy and lightweight trampoline for your recursive functions.
Downloads
2
Readme
SafeRec is a simple but powerful trampoline which converts your recursive function into a fast and safe while
loop.
You can read more about why you should adopt memory safe recursion here
Installation
Yarn
yarn add saferec
NPM
npm install saferec --save-dev
Usage
import rec from "saferec"
function factorial(num) {
return num === 0
? 1
: (num * factorial(num - 1));
}
const result = rec(factorial(1000));