File tree Expand file tree Collapse file tree 3 files changed +11
-4
lines changed Expand file tree Collapse file tree 3 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ const cancelable = (fn) => {
66 } ;
77 wrapper . cancel = ( ) => {
88 fn = null ;
9+ return wrapper ;
910 } ;
1011 return wrapper ;
1112} ;
Original file line number Diff line number Diff line change @@ -5,8 +5,12 @@ const wrap = (fn) => {
55 let counter = 0 ;
66
77 const wrapper = ( ...args ) => {
8- if ( limit && counter ++ === limit ) wrapper . cancel ( ) ;
9- if ( fn ) return fn ( ...args ) ;
8+ if ( limit && counter === limit ) wrapper . cancel ( ) ;
9+ if ( fn ) {
10+ const res = fn ( ...args ) ;
11+ counter ++ ;
12+ return res ;
13+ }
1014 } ;
1115
1216 wrapper . cancel = ( ) => {
Original file line number Diff line number Diff line change @@ -8,13 +8,15 @@ const wrap = (func) => {
88
99 const wrapper = ( ...args ) => {
1010 if ( ! fn ) return ;
11- if ( limit && counter ++ === limit ) {
11+ if ( limit && counter === limit ) {
1212 limit = 0 ;
1313 counter = 0 ;
1414 this . cancel ( ) ;
1515 return ;
1616 }
17- return fn ( ...args ) ;
17+ const res = fn ( ...args ) ;
18+ counter ++
19+ return res ;
1820 } ;
1921
2022 const methods = {
You can’t perform that action at this time.
0 commit comments