minor cleanup

This commit is contained in:
rolux 2012-06-21 13:47:52 +02:00
parent d8cd59e90f
commit 93a9805da7

View file

@ -10,6 +10,7 @@ Ox.cache <f> Memoize a function
> Ox.test.fn(10) == Ox.test.fn.clear()(10);
false
@*/
// TODO: add async test
Ox.cache = function(fn, options) {
options = Ox.extend({
async: false,
@ -17,9 +18,7 @@ Ox.cache = function(fn, options) {
}, options || {})
var cache = {},
ret = function() {
var args = Ox.toArray(arguments),
callback,
key = options.key(args);
var args = Ox.toArray(arguments), key = options.key(args);
function callback() {
// cache all arguments passed to callback
cache[key] = Ox.toArray(arguments);
@ -50,7 +49,7 @@ Ox.cache = function(fn, options) {
});
}
return ret;
}
};
return ret;
};