@oazmi/kitchensink - v0.9.13
    Preparing search index...

    Function spliceArray2DMajor

    • splice rows of a row-major 2D array and optionally insert new rows at the specified start index.

      Type Parameters

      • T

      Parameters

      • arr2d: Array2DRowMajor<T>

        the row-major 2D array to be spliced.

      • start: number

        the row-index at which to start changing the array.

      • Optionaldelete_count: number

        the number of rows to remove. if undefined, all rows from start to the end of the array will be removed.

      • ...insert_items: Array2DRowMajor<T>

        optionally insert row-major based 2D array items the index of start.

      Returns Array2DRowMajor<T>

      a new row-major 2D array containing the deleted rows.

      delete 1 row from arr2d (starting at row-index 1), and insert 2 new rows in its place.

      import { assertEquals } from "jsr:@std/assert"

      const arr2d: Array2DRowMajor<number> = [
      [1 , 2 , 3 , 4 , 5 ],
      [6 , 7 , 8 , 9 , 10],
      [11, 12, 13, 14, 15],
      ]
      const deleted_rows = spliceArray2DMajor(arr2d, 1, 1,
      [21, 22, 23, 24, 25],
      [31, 32, 33, 34, 35]
      )
      assertEquals(arr2d, [
      [1 , 2 , 3 , 4 , 5 ],
      [21, 22, 23, 24, 25],
      [31, 32, 33, 34, 35],
      [11, 12, 13, 14, 15],
      ])
      assertEquals(deleted_rows, [
      [6 , 7 , 8 , 9 , 10],
      ])