Replaces occurrences of a search buffer with a replacement buffer within a target buffer.
The type of the target buffer, extending ByteArray.
The byte pattern to search for.
The byte pattern to replace with.
The buffer to search within.
Whether to replace all occurrences or just the first. Defaults to false.
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]) Copy
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])
Replaces occurrences of a search buffer with a replacement buffer within a target buffer.