From ba4086bc55b12577d3b38eaf73e3159ce8c271a8 Mon Sep 17 00:00:00 2001 From: rolux Date: Sun, 27 May 2012 18:43:12 +0200 Subject: [PATCH] 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 --- source/Ox/js/Function.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/source/Ox/js/Function.js b/source/Ox/js/Function.js index 96e9bf55..6986951b 100644 --- a/source/Ox/js/Function.js +++ b/source/Ox/js/Function.js @@ -58,14 +58,16 @@ Ox.cache = function(fn, options) { Ox.identity 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 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(); -}; \ No newline at end of file +};