"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function withPromiseCache(target, propertyName, propertyDesciptor) {
    var promiseCache = {};
    var method = propertyDesciptor.value;
    propertyDesciptor.value = function () {
        var args = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            args[_i] = arguments[_i];
        }
        var cacheKey = JSON.stringify(args);
        if (Object.prototype.hasOwnProperty.call(promiseCache, cacheKey)) {
            return promiseCache[cacheKey];
        }
        promiseCache[cacheKey] = method
            .apply(this, args)
            .then(function (response) {
            delete promiseCache[cacheKey];
            return response;
        })
            .catch(function (err) {
            delete promiseCache[cacheKey];
            throw err;
        });
        return promiseCache[cacheKey];
    };
    return propertyDesciptor;
}
exports.default = withPromiseCache;
//# sourceMappingURL=cached-promise.js.map