Skip to content

Commit 23ea316

Browse files
committed
Improve cancelable: consistent-return
1 parent 240d9db commit 23ea316

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

JavaScript/9-cancelable.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
'use strict';
22

3-
const cancelable = (f) => {
4-
const wrapper = (...args) => {
5-
if (f) return f(...args);
6-
};
7-
wrapper.cancel = () => f = null;
3+
const cancelable = (fn) => {
4+
const wrapper = (...args) => (fn ? fn(...args) : null);
5+
wrapper.cancel = () => fn = null;
86
return wrapper;
97
};
108

0 commit comments

Comments
 (0)