ChemPal Documentation - v1.6.0
    Preparing search index...

    Function fulfillableShippingRanges

    • The shipping-type options the given suppliers can fulfill: every scope at or below the broadest selected supplier's scope (per the shippingCovers hierarchy). Used to decide which shipping options stay selectable — an option no selected supplier can fulfill is disabled. Empty in ⇒ empty out (no supplier constraint).

      Parameters

      • meta: SupplierMetaMap

        Supplier shipping/country metadata.

      • suppliers: readonly string[]

        The currently selected supplier class names.

      Returns Set<ShippingRange>

      The set of shipping scopes at least one selected supplier can fulfill.

      fulfillableShippingRanges(
      { A: { country: 'US', shipping: 'domestic' } },
      ['A'],
      ); // => Set { 'local', 'domestic' }
      export function fulfillableShippingRanges(
      meta: SupplierMetaMap,
      suppliers: readonly string[],
      ): Set<ShippingRange> {
      const fulfillable = new Set<ShippingRange>();
      for (const option of SHIPPING_OPTIONS) {
      const reachable = suppliers.some((key) => {
      const entry = meta[key];
      return entry !== undefined && shippingCovers(entry.shipping, option);
      });
      if (reachable) fulfillable.add(option);
      }
      return fulfillable;
      }