Skip to content

Commit 3be822e

Browse files
committed
initial commit
0 parents  commit 3be822e

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
.idea
3+
workspace.xml
4+
npm-debug.log

index.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"use strict";
2+
3+
function trampoline(boundFunc) {
4+
while (boundFunc && boundFunc instanceof Function) {
5+
boundFunc = boundFunc();
6+
}
7+
return boundFunc;
8+
}
9+
10+
var loopCount = 100000;
11+
12+
13+
function loopit(i) {
14+
function looper(i) {
15+
if (i < loopCount) {
16+
console.log(`${i + 1}/${loopCount}`);
17+
return looper.bind(null, i+1);
18+
}
19+
}
20+
return trampoline(looper.bind(null, i));
21+
}
22+
23+
loopit(0);
24+

package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "callstack-recursion",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"author": "",
10+
"license": "ISC"
11+
}

0 commit comments

Comments
 (0)