JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 13
  • Score
    100M100P100Q34522F
  • License MIT

An abstraction over continuation-passing and trampolining to write recursive functions that don't exceed the maximum call stack size.

Package Exports

  • decurse

Readme

Decurse

An abstraction over continuation-passing and trampolining to write recursive functions that don't exceed the maximum call stack size.

Example

import { makeDecurse } from "decurse"

const decurse = makeDecurse()

const factorial = (/** @type {bigint} */ n) => decurse(() => n
    ? factorial(n - 1n).then(result => result * n)
    : 1n
)

factorial.then(value => console.log(value))