NaturalCycles/js-lib

View on GitHub
src/decorators/retry.decorator.ts

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import type { PRetryOptions } from '..'
import { pRetryFn } from '..'

// eslint-disable-next-line @typescript-eslint/naming-convention
export function _Retry(opt: PRetryOptions = {}): MethodDecorator {
  return (target, key, descriptor) => {
    const originalFn = descriptor.value
    descriptor.value = pRetryFn(originalFn as any, opt)
    return descriptor
  }
}