add Ox.once, fix docs
This commit is contained in:
parent
5a615730e9
commit
2077ea718a
1 changed files with 18 additions and 3 deletions
|
@ -59,8 +59,8 @@ Ox.cache = function(fn, options) {
|
|||
};
|
||||
|
||||
/*@
|
||||
Ox.debounce <f> Runs a function once it stops being called for a given time frame
|
||||
(fn[, ms][, immediate]) -> <f> Throttled function
|
||||
Ox.debounce <f> Runs a function once it stops being called for a given interval
|
||||
(fn[, ms][, immediate]) -> <f> Debounced function
|
||||
fn <f> Function to debounce
|
||||
ms <n|250> Interval in milliseconds
|
||||
immediate <b|false> If true, function is called once immediately
|
||||
|
@ -113,6 +113,21 @@ Ox.noop = function() {
|
|||
Ox.isFunction(callback) && callback();
|
||||
};
|
||||
|
||||
/*@
|
||||
Ox.once <f> Runs a function once, and then never again
|
||||
(fn[, ms]) -> <f> Function that will run only once
|
||||
fn <f> Function to run once
|
||||
@*/
|
||||
Ox.once = function(fn) {
|
||||
var once = false;
|
||||
return function() {
|
||||
if (!once) {
|
||||
once = true;
|
||||
fn.apply(null, args);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/*@
|
||||
Ox.queue <f> Queue of asynchronous function calls with cached results
|
||||
The results are cached based on all arguments to `fn`, except the last one,
|
||||
|
@ -179,7 +194,7 @@ Ox.queue = function(fn, maxThreads) {
|
|||
};
|
||||
|
||||
/*@
|
||||
Ox.throttle <f> Runs a function at most once per given time frame
|
||||
Ox.throttle <f> Runs a function at most once per given interval
|
||||
(fn[, ms]) -> <f> Throttled function
|
||||
fn <f> Function to throttle
|
||||
ms <n|250> Interval in milliseconds
|
||||
|
|
Loading…
Reference in a new issue