saferec

0.0.2 • Public • Published

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));

LICENSE

The Unlicense

/saferec/

    Package Sidebar

    Install

    npm i saferec

    Weekly Downloads

    0

    Version

    0.0.2

    License

    Unlicense

    Unpacked Size

    49.1 kB

    Total Files

    7

    Last publish

    Collaborators

    • micheleriva