(func: Function, wait: number = 1000)
| 1 | function throttle(func: Function, wait: number = 1000) { |
| 2 | var context, args; |
| 3 | var previous = 0; |
| 4 | return function () { |
| 5 | var now = +new Date(); |
| 6 | context = this; |
| 7 | args = arguments; |
| 8 | if (now - previous > wait) { |
| 9 | func.apply(context, args); |
| 10 | previous = now; |
| 11 | } |
| 12 | } |
| 13 | } |
| 14 | |
| 15 | const utils = { |
| 16 | throttle |
nothing calls this directly
no outgoing calls
no test coverage detected