Skip to content

A throttle function that restricts it's external calls with the ability to pass arguments even if calls don't allow this!

License

Notifications You must be signed in to change notification settings

centurianii/g3throttle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

g3throttle

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!

Usage

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.

Dependencies

None.

Evaluator test page

A test on Ben Alman's and Underscore's throttle functions compared with this one.

See: g3throttle

Have fun!

About

A throttle function that restricts it's external calls with the ability to pass arguments even if calls don't allow this!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published