https://github.com/samualtnorman/decurse
An abstraction over continuation-passing and trampolining to write recursive functions that don't exceed the maximum call stack size.
https://github.com/samualtnorman/decurse
abstraction call-stack callstack continuation-passing continuation-passing-style recursion trampoline uncurse
Last synced: 5 months ago
JSON representation
An abstraction over continuation-passing and trampolining to write recursive functions that don't exceed the maximum call stack size.
- Host: GitHub
- URL: https://github.com/samualtnorman/decurse
- Owner: samualtnorman
- License: mit
- Created: 2025-06-20T09:45:28.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-07-04T13:35:59.000Z (6 months ago)
- Last Synced: 2025-07-04T14:08:26.819Z (6 months ago)
- Topics: abstraction, call-stack, callstack, continuation-passing, continuation-passing-style, recursion, trampoline, uncurse
- Language: JavaScript
- Homepage:
- Size: 30.3 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Decurse
An abstraction over continuation-passing and trampolining to write recursive functions that don't exceed the maximum call stack size.
## Example
```js
import { makeDecurse } from "decurse"
const decurse = makeDecurse()
const factorial = (/** @type {bigint} */ n) => decurse(() => n
? factorial(n - 1n).then(result => result * n)
: 1n
)
factorial(100_000n).then(value => console.log(value))
```