Given a function fn and a time in milliseconds t, return a throttled version of that function.
A throttled function is first called without delay and then, for a time interval of t milliseconds, can't be executed but should store the latest function arguments provided to call fn with them after the end of the delay.
For instance, t = 50ms, and the function was called at 30ms, 40ms, and 60ms:
• At 30ms: function executes immediately without delay
• At 40ms: function is blocked, arguments stored
• At 60ms: arguments overwrite the stored ones from 40ms
• At 80ms (30ms + 50ms): function executes with the latest arguments from 60ms
The throttled function should create another delay period after each execution.
Input & Output
Constraints
- 0 ≤ t ≤ 1000
- 1 ≤ calls.length ≤ 10
- 0 ≤ calls[i].t ≤ 1000
- 0 ≤ calls[i].inputs.length ≤ 10