UNPKG

retryable-operation

Version:

a simple package that allow executing retryable operation and providing retry options

28 lines 1.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RetryableOperation = exports.retryable = exports.wrap = exports.operation = void 0; const retryable_operation_1 = require("./retryable-operation"); Object.defineProperty(exports, "RetryableOperation", { enumerable: true, get: function () { return retryable_operation_1.RetryableOperation; } }); function operation(options) { return new retryable_operation_1.RetryableOperation(options); } exports.operation = operation; function wrap(fn, options) { const op = operation(Object.assign(Object.assign({}, options), { fn })); if ("autoAttempt" in options) return op.attempt(); return op; } exports.wrap = wrap; function retryable(options) { return function (_, _1, descriptor) { const originalMethod = descriptor.value; descriptor.value = function (...args) { const op = operation(Object.assign(Object.assign({ fn: originalMethod }, (options !== null && options !== void 0 ? options : {})), { args })); return op.attempt(); }; return descriptor; }; } exports.retryable = retryable; //# sourceMappingURL=retry.js.map