Kit
Functions

containsBytes

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
dataUint8Array<ArrayBufferLike> | ReadonlyUint8ArrayThe byte sequence to search for.
bytesUint8Array<ArrayBufferLike> | ReadonlyUint8ArrayThe byte array in which to search for data.
offsetnumberThe position in bytes where the search begins.

Returns

boolean

Example

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

On this page