A throttle function that restricts it's external calls with the ability to pass arguments even if calls don't allow this! I tried to pass arguments as closures with other libraries like underscore or Ben Alman's similar function but with no success. See my test page at the end.
Moreover, we can pass the context that this
refers to inside the function!
In place of a function name like myFunction
pass g3.throttle(myFunction, {delay: <time>[, context: <context>, fireFirst: <true|false|null>, fireLast: <true|false|null>}[, arg1, ...]])
where context
is a reference pointed out by this
and that's it!
Now, your function won't be called more than every time ms
and arguments arg1, arg2, ...
have been passed already!
At least {delay: <time>}
should be given or, your function is returned immediately.
None.
A test on Ben Alman's and Underscore's throttle functions compared with this one.
See: g3throttle
Have fun!