@zakodium/utils
    Preparing search index...

    Function assertIn

    • Asserts that the given value is in the given array. If the call does not throw, the value is narrowed to the type of the array elements.

      Type Parameters

      • Value
      • InConstraint

      Parameters

      • value: Value

        The value to check.

      • values: readonly InConstraint[]

        The constraint values.

      Returns asserts value is InConstraint

      type Unit = "ppm" | "hz" | "pt" | "s";
      type Mode = "fid" | "ft";
      const fidUnits = ["pt", "s"] as const;
      const ftUnits = ["pt", "ppm", "hz"] as const;

      function setUnit(unit: Unit, mode: Mode) {
      match(mode)
      .with('fid', (mode) => {
      assertIn(unit, fidUnits);
      // unit is narrowed to "pt" | "s"
      return dispatch({
      type: 'SET_AXIS_UNIT_1D_HORIZONTAL',
      payload: { nucleus, mode, unit },
      });
      })
      .with('ft', (mode) => {
      assertIn(unit, ftUnits);
      // unit is narrowed to "pt" | "ppm" | "hz"
      return dispatch({
      type: 'SET_AXIS_UNIT_1D_HORIZONTAL',
      payload: { nucleus, mode, unit },
      });
      })
      .exhaustive();
      }