1.0.14 • Published 2 years ago

@machiavelli/retry v1.0.14

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

A very simple failed operation retry module. Originally forked from https://github.com/tim-kos/node-retry

Installation

npm install @machiavelli/retry

constructor

new Operation(options: { retries: number; interval: number; noDelay?: boolean})

create a new OperationRetry object

  • retries: How many times to retry an opearation after it failed once.
  • interval: The interval between retries (in milliseconds)
  • noDelay: Whether to delay the first operation attempt.

Methods

attempt(operation: (currentAttempt: number))

  • operation: The callback (operation) that needs to be retried on failures
  • currentAttempt: Holds the current operation attempt.

retry()

To be called in the callback (operation) passed in the attempt() method. The operation won't be retried if this is not called. Returns true when operation will be attempted again, false if exhausted all retries

setNewConfig(options: { retries: number; interval: number; }

To be called in the callback (operation) passed in the attempt() method. Sets a new config to the OperationRetry instance. This is useful when the config needs before exhausting all the retries. Calling this method only has effect once to avoid infinite retries. Retries do not add up. Number passed is the number of times the operation will be attempted going forward.

  • options: same as options passed in the constructor.
1.0.14

2 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago