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