Sha256: 8680d409d2fe0865c61d6b66f5ce5445ef71447d4f89725a7690b52043267b79

Contents?: true

Size: 711 Bytes

Versions: 7

Compression:

Stored size: 711 Bytes

Contents

this.gts = this.gts || {};

this.gts.cache = function (fn) {
    var cache = [];

    function equal(arr1, arr2) {
        if (arr1.length !== arr2.length) { return false; }
        for (var i = 0, l = arr1.length; i < l; ++i) {
            if (arr1[i] !== arr2[i]) { return false; }
        }
        return true;
    }

    return function () {
        var args = [].slice.call(arguments);
        var i, l, j, k, result;
        for (i = 0, l = cache.length; i < l; ++i) {
            if (equal(cache[i].args, args)) {
                return cache[i].result;
            }
        }

        result = fn.apply(self, args);
        cache.push({ args: args, result: result });
        return result;
    };
};

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
dolt-0.29.0 vendor/ui/js/src/cache.js
dolt-0.28.1 vendor/ui/js/src/cache.js
dolt-0.28.0 vendor/ui/js/src/cache.js
dolt-0.27.0 vendor/ui/js/src/cache.js
dolt-0.26.0 vendor/ui/js/src/cache.js
dolt-0.25.0 vendor/ui/js/src/cache.js
dolt-0.24.0 vendor/ui/js/src/cache.js