@@ -31,7 +31,7 @@ function decorate(decorator: (fn: Function, key: string) => Function): Function
3131function _memoize ( fn : Function , key : string ) : Function {
3232 const memoizeKey = `$memoize$${ key } ` ;
3333
34- return function ( ...args : any [ ] ) {
34+ return function ( this : any , ...args : any [ ] ) {
3535 if ( ! this . hasOwnProperty ( memoizeKey ) ) {
3636 Object . defineProperty ( this , memoizeKey , {
3737 configurable : false ,
@@ -51,7 +51,7 @@ function _throttle<T>(fn: Function, key: string): Function {
5151 const currentKey = `$throttle$current$${ key } ` ;
5252 const nextKey = `$throttle$next$${ key } ` ;
5353
54- const trigger = function ( ...args : any [ ] ) {
54+ const trigger = function ( this : any , ...args : any [ ] ) {
5555 if ( this [ nextKey ] ) {
5656 return this [ nextKey ] ;
5757 }
@@ -81,7 +81,7 @@ export const throttle = decorate(_throttle);
8181function _sequentialize < T > ( fn : Function , key : string ) : Function {
8282 const currentKey = `__$sequence$${ key } ` ;
8383
84- return function ( ...args : any [ ] ) {
84+ return function ( this : any , ...args : any [ ] ) {
8585 const currentPromise = this [ currentKey ] as Promise < any > || Promise . resolve ( null ) ;
8686 const run = async ( ) => await fn . apply ( this , args ) ;
8787 this [ currentKey ] = currentPromise . then ( run , run ) ;
@@ -95,7 +95,7 @@ export function debounce(delay: number): Function {
9595 return decorate ( ( fn , key ) => {
9696 const timerKey = `$debounce$${ key } ` ;
9797
98- return function ( ...args : any [ ] ) {
98+ return function ( this : any , ...args : any [ ] ) {
9999 clearTimeout ( this [ timerKey ] ) ;
100100 this [ timerKey ] = setTimeout ( ( ) => fn . apply ( this , args ) , delay ) ;
101101 } ;
0 commit comments