ts-data-forge
    Preparing search index...
    • Casts an array to BoundedLengthTuple<Min, Max, E> after checking that its length is within the inclusive range [min, max].

      This is the structural counterpart of asBoundedLengthArray; see asFixedLengthTuple for when to prefer which.

      Type Parameters

      • Min extends ArgArr

        The minimum number of elements (inclusive).

      • Max extends ArgArr

        The maximum number of elements (inclusive).

      • Xs extends readonly unknown[]

        The input array type (tuple types are preserved).

      Parameters

      • min: Min

        The minimum number of elements (inclusive).

      • max: Max

        The maximum number of elements (inclusive).

      • xs: Xs

        The array to cast.

      Returns BoundedLengthTuple<Min, Max, Xs[number]> & Xs

      xs typed as BoundedLengthTuple<Min, Max, Xs[number]> & Xs.

      const selection = Arr.asBoundedLengthTuple(1, 5, [1, 2, 3]);

      // curried version
      const asSelection = Arr.asBoundedLengthTuple(1, 5);

      // Arr.asBoundedLengthTuple(1, 2, [1, 2, 3]); // throws TypeError

      If xs.length is outside [min, max].

    • Casts an array to BoundedLengthTuple<Min, Max, E> after checking that its length is within the inclusive range [min, max].

      This is the structural counterpart of asBoundedLengthArray; see asFixedLengthTuple for when to prefer which.

      Type Parameters

      • Min extends ArgArr

        The minimum number of elements (inclusive).

      • Max extends ArgArr

        The maximum number of elements (inclusive).

      Parameters

      • min: Min

        The minimum number of elements (inclusive).

      • max: Max

        The maximum number of elements (inclusive).

      Returns <Xs extends readonly unknown[]>(
          xs: Xs,
      ) => BoundedLengthTuple<Min, Max, Xs[number]> & Xs

      xs typed as BoundedLengthTuple<Min, Max, Xs[number]> & Xs.

      const selection = Arr.asBoundedLengthTuple(1, 5, [1, 2, 3]);

      // curried version
      const asSelection = Arr.asBoundedLengthTuple(1, 5);

      // Arr.asBoundedLengthTuple(1, 2, [1, 2, 3]); // throws TypeError

      If xs.length is outside [min, max].