containsBytes

function containsBytes(data, bytes, offset): boolean;

Returns true if and only if the provided data byte array contains the provided bytes byte array at the specified offset.

Parameters

ParameterTypeDescription
data| ReadonlyUint8Array<ArrayBufferLike> | Uint8Array<ArrayBufferLike>The byte array in which to search for bytes.
bytes| ReadonlyUint8Array<ArrayBufferLike> | Uint8Array<ArrayBufferLike>The byte sequence to search for.
offsetnumberThe position in data where the search begins.

Returns

boolean

Example

const data = new Uint8Array([0x01, 0x02, 0x03, 0x04]);
const bytes = new Uint8Array([0x02, 0x03]);
containsBytes(data, bytes, 1); // true
containsBytes(data, bytes, 2); // false

On this page