The underscore library provides a debounce function that prevents multiple calls to a function within a set period of time. Their version makes use of setTimeout.
H
Worth mentioning that debounce comes built in with Angular 1.3. As you'd expect, it's implemented as a directive. You can do this:
The $scope.address attribute is not updated until 500ms after the last keystroke.
If you want more granularity, you can set different bounce times for different events:
Here for example we have a 500ms debounce for a keystroke, and no debounce for a blur.
Read the documentation here: https://docs.angularjs.org/api/ng/directive/ngModelOptions