ts-tco
v1.1.1
Published
Utility for flattening tail recursion in TypeScript
Downloads
7
Maintainers
Readme
ts-tco
Utility for flattening tail recursion in TypeScript
Usage
import { Tco, tco } from "ts-tco";
const countUp = (n: number, total = 0): Tco<number> => tco(() => {
if (n === 0)
return total;
return countUp(n - 1, total + 1);
})
console.log(countUp(2000000).execute()); // 2000000