Ox.noop: call the last (not the first) argument in case it is a function - this way it can be used as an async iterator

This commit is contained in:
rolux 2012-05-27 18:43:12 +02:00
parent a811f29837
commit ba4086bc55

View file

@ -58,14 +58,16 @@ Ox.cache = function(fn, options) {
Ox.identity <f> Returns its first argument
This can be used as a default iterator
@*/
Ox.identity = function(val) {
return val;
Ox.identity = function(value) {
return value;
};
/*@
Ox.noop <f> Returns undefined and calls optional callback without arguments
This can be used to combine a synchronous and an asynchronous code path.
This can be used as a default iterator in an asynchronous loop, or to
combine a synchronous and an asynchronous code path.
@*/
Ox.noop = function(callback) {
Ox.noop = function() {
var callback = Ox.last(arguments);
Ox.isFunction(callback) && callback();
};
};