File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -7,11 +7,12 @@ const wrap = (func) => {
77 let fn = func ;
88
99 const wrapper = ( ...args ) => {
10+ //console.dir({ limit, counter, fn, args });
1011 if ( ! fn ) return ;
1112 if ( limit && counter === limit ) {
1213 limit = 0 ;
1314 counter = 0 ;
14- this . cancel ( ) ;
15+ wrapper . cancel ( ) ;
1516 return ;
1617 }
1718 const res = fn ( ...args ) ;
@@ -25,13 +26,7 @@ const wrap = (func) => {
2526 return this ;
2627 } ,
2728 resume ( ) {
28- if ( ! fn ) {
29- fn = func ;
30- if ( limit ) {
31- limit = 0 ;
32- counter = 0 ;
33- }
34- }
29+ if ( ! fn ) fn = func ;
3530 return this ;
3631 } ,
3732 timeout ( msec ) {
@@ -40,7 +35,7 @@ const wrap = (func) => {
4035 return this ;
4136 } ,
4237 limit ( count ) {
43- limit = count ;
38+ limit = count || 0 ;
4439 counter = 0 ;
4540 return this ;
4641 }
@@ -68,7 +63,11 @@ setTimeout(() => {
6863 setTimeout ( ( ) => {
6964 f ( '5th' ) ;
7065 setTimeout ( ( ) => {
66+ f . limit ( 1 ) ;
7167 f ( '6th' ) ;
68+ f ( '7th' ) ;
69+ f . resume ( ) ;
70+ f ( '8th' ) ;
7271 } , 150 ) ;
7372 } , 150 ) ;
7473} , 150 ) ;
You can’t perform that action at this time.
0 commit comments