Unnamed paste

pasted by Unknown [options]

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
    function CacheTrampoline(f) {
        return function () {
            var res = f.apply(this, arguments);

            if (res && res instanceof Array) {
                if (!skip_cache) {
                    // check cache and optionally call the thunk...
                    var ckey = "METADATA:"+res[2]+":"+res[3];
                    if (ckey in METADATA_CACHE) {
                        return METADATA_CACHE[ckey];
                    } else {
                        var r2 = _cache.get(ckey);
                        if (r2 !== null) return r2;
                    }
                }

                return res[0].apply(null, res.slice(1));
            } else {
                return res;
            }
        };
    }