ts-tco
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

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

Package Sidebar

Install

npm i ts-tco

Weekly Downloads

0

Version

1.1.1

License

ISC

Unpacked Size

4.38 kB

Total Files

6

Last publish

Collaborators

  • tjjfvi