ts-data-forge
    Preparing search index...
    • Slices an array with automatically clamped start and end indices.

      Type Parameters

      • const Ar extends readonly unknown[]

      Parameters

      • array: Ar
      • start: ArgArrayIndexWithNegative<Ar>
      • end: ArgArrayIndexWithNegative<Ar>

      Returns readonly Ar[number][]

      const letters = ['a', 'b', 'c', 'd', 'e'];

      const lastThree = Arr.sliceClamped(letters, -3, 10);
      const middleTwo = Arr.sliceClamped(1, 3)(letters);

      assert.deepStrictEqual(lastThree, ['a', 'b', 'c', 'd', 'e']);
      assert.deepStrictEqual(middleTwo, ['b', 'c']);
    • Slices an array with automatically clamped start and end indices.

      Parameters

      • start: ArgArrWithNegative
      • end: ArgArrWithNegative

      Returns <E>(array: readonly E[]) => readonly E[]

      const letters = ['a', 'b', 'c', 'd', 'e'];

      const lastThree = Arr.sliceClamped(letters, -3, 10);
      const middleTwo = Arr.sliceClamped(1, 3)(letters);

      assert.deepStrictEqual(lastThree, ['a', 'b', 'c', 'd', 'e']);
      assert.deepStrictEqual(middleTwo, ['b', 'c']);