example export class Limit { public callQueue = [ ] ; public lastCall ; public interval : NodeJS . Timer ; param fn param wait throttleAndQueue ( fn , wait ) { let isCalled = false ; const self = this ; const caller = function ( ) { if ( self . callQueue . length && ! isCalled ) { isCalled = true ; self . callQueue . shift ( ) . call ( ) ; setTimeout ( function ( ) { isCalled = false ; caller ( ) ; } , wait ) ; } } ; return function ( ... args ) { self . callQueue . push ( fn . bind ( this , ... args ) ) ; caller ( ) ; } ; } param fn param wait throttledUpdate ( fn , wait ) { const self = this ; function caller ( ) { if ( ! self . interval ) { self . lastCall . call ( ) ; self . lastCall = null ; self . interval = setInterval ( ( ) => { if ( self . lastCall ) { self . lastCall . call ( ) ; self . lastCall = null ; } else { clearInterval ( self . interval ) ; self . interval = null ; } } , wait ) ; } } return function ( ... args ) { self . lastCall = fn . bind ( this , ... args ) ; caller ( ) ; } ; } } param fn param wait example export function throttle ( fn , wait ) { let isCalled = false ; return function ( ... args ) { if ( ! isCalled ) { fn ( ... args ) ; isCalled = true ; setTimeout ( function ( ) { isCalled = false ; } , wait ) ; } } ; }