firefly-limiter - v1.0.1
    Preparing search index...

    Function fallback

    • Answers with something rather than failing, once everything else has been tried: stale data, an empty list, a degraded result.

      It belongs outermost, where the failure it sees is the one the caller would otherwise have caught. It is a TypedPolicy rather than a Policy because it produces a result, and a result has a type, so it wraps a stack rather than sitting in one:

      const rates = await fallback(() => cached)(policy(readRates))();
      

      The handler receives the failure, so "fall back only for this" is a decision you make with the error in hand rather than one this package makes for you.

      Type Parameters

      • T

      Parameters

      Returns TypedPolicy<T>