pdf-lite - v1.0.1
    Preparing search index...

    Function replaceInBuffer

    • Replaces occurrences of a search buffer with a replacement buffer within a target buffer.

      Type Parameters

      • T extends ByteArray

        The type of the target buffer, extending ByteArray.

      Parameters

      • searchBuffer: ByteArray

        The byte pattern to search for.

      • replaceBuffer: ByteArray

        The byte pattern to replace with.

      • targetBuffer: T

        The buffer to search within.

      • multiple: boolean = false

        Whether to replace all occurrences or just the first. Defaults to false.

      Returns ByteArray

      A new byte array with the replacements made.

      Error if the search buffer is not found in the target buffer.

      const result = replaceInBuffer(
      new Uint8Array([1, 2]),
      new Uint8Array([3, 4, 5]),
      new Uint8Array([0, 1, 2, 6])
      ) // Returns Uint8Array([0, 3, 4, 5, 6])