UNPKG

nestjs-resilience

Version:

A module for improving the reliability and fault-tolerance of your NestJS applications

18 lines (17 loc) 576 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FibonacciBackoff = void 0; const base_backoff_1 = require("./base.backoff"); class FibonacciBackoff extends base_backoff_1.Backoff { *getGenerator(maxRetries) { let attempt = 0, previous = 0, current = 1; while (attempt < maxRetries) { const next = previous + current; previous = current; current = next; yield next * this.baseDelay; attempt += 1; } } } exports.FibonacciBackoff = FibonacciBackoff;