@jmshal/back-off
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

@jmshal/back-off

A simple backoff approach utility.

Example usage

import { backOff } from '@jmshal/back-off';

function signJwt(digest) {
  const retry = backOff(1, 2, 4, 8, 16);
  while (true) {
    try {
      return await await keyVaultClient.sign(endpoint, kid, 'RS256', digest);
    } catch (err) {
      if (err.code === 'VaultOperationLimitReached') {
        // Azure Key Vault will throttle requests if there are considerable amount within a short
        // period of time. It may be worth notifying an error reporting system if this happens.
        await retry.wait();
      } else {
        throw err;
      }
    }
  }
}

License

MIT ❤️

Readme

Keywords

none

Package Sidebar

Install

npm i @jmshal/back-off

Weekly Downloads

108

Version

0.1.1

License

MIT

Unpacked Size

3.6 kB

Total Files

5

Last publish

Collaborators

  • jacobmarshall