Skip to content

Commit 591f848

Browse files
committed
Fix consistent return
1 parent 8c68345 commit 591f848

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

JavaScript/5-timeout.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const timeout = (msec, f) => {
88
timer = null;
99
}, msec);
1010
return (...args) => {
11-
if (!timer) return;
11+
if (!timer) return null;
1212
clearTimeout(timer);
1313
timer = null;
1414
return f(...args);

JavaScript/6-timeout-async.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ const timeout = (msec, f) => {
88
timer = null;
99
}, msec);
1010
return (...args) => {
11-
if (timer) {
12-
clearTimeout(timer);
13-
timer = null;
14-
return f(...args);
15-
}
11+
if (!timer) return null;
12+
clearTimeout(timer);
13+
timer = null;
14+
return f(...args);
1615
};
1716
};
1817

0 commit comments

Comments
 (0)