Issue #306 : Switch implementation for memoizer

This commit is contained in:
jdescottes
2015-09-14 22:04:25 +02:00
parent cbb97c60d0
commit e6950e5c1a
6 changed files with 25 additions and 23 deletions

View File

@@ -0,0 +1,16 @@
(function () {
var ns = $.namespace('pskl.utils');
ns.FunctionUtils = {
memo : function (fn, cache, scope) {
var memoized = function () {
var key = Array.prototype.join.call(arguments, '-');
if (!cache[key]) {
cache[key] = fn.apply(scope, arguments);
}
return cache[key];
};
return memoized;
}
};
})();