ts-data-forge
    Preparing search index...
    • Casts an array to MinLengthTuple<MinLength, E> after checking that it has at least minLength elements.

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

      Type Parameters

      • MinLength extends ArgArr

        The minimum number of elements (inclusive).

      • Xs extends readonly unknown[]

        The input array type (tuple types are preserved).

      Parameters

      • minLength: MinLength

        The minimum number of elements (inclusive).

      • xs: Xs

        The array to cast.

      Returns readonly [MakeTupleImpl<Xs[number], `${MinLength}`, []>, Xs[number]] & Xs

      xs typed as MinLengthTuple<MinLength, Xs[number]> & Xs.

      const history = Arr.asMinLengthTuple(3, [0, 1, 2, 3]);

      const first: number = history[0]; // OK — no `undefined`

      // curried version
      const asHistory = Arr.asMinLengthTuple(3);

      // Arr.asMinLengthTuple(3, [0, 1]); // throws TypeError

      If xs.length < minLength.

    • Casts an array to MinLengthTuple<MinLength, E> after checking that it has at least minLength elements.

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

      Type Parameters

      • MinLength extends ArgArr

        The minimum number of elements (inclusive).

      Parameters

      • minLength: MinLength

        The minimum number of elements (inclusive).

      Returns <Xs extends readonly unknown[]>(
          xs: Xs,
      ) => readonly [MakeTupleImpl<Xs[number], `${MinLength}`, []>, Xs[number]] & Xs

      xs typed as MinLengthTuple<MinLength, Xs[number]> & Xs.

      const history = Arr.asMinLengthTuple(3, [0, 1, 2, 3]);

      const first: number = history[0]; // OK — no `undefined`

      // curried version
      const asHistory = Arr.asMinLengthTuple(3);

      // Arr.asMinLengthTuple(3, [0, 1]); // throws TypeError

      If xs.length < minLength.