Sanity Library Reference Docs
    Preparing search index...

    Function truncate

    • Creates a truncate operation that will remove all items after startIndex until the end of the array or the provided endIndex.

      Parameters

      • startIndex: number

        The start index for the truncate operation.

      • OptionalendIndex: number

        The end index for the truncate operation.

      Returns TruncateOp

      A truncate operation.

      const clearArray = truncate(0)
      const removeItems = truncate(3, 5) // Removes items at index 3, 4, and 5
      const truncate200 = truncate(200) // Removes all items after index 200