Checks if a Uint8Array begins with a given byte prefix, used for file type detection or data validation.
function startsWith(bytes: Uint8Array, prefix: readonly number[]): boolean {
return (
bytes.length >= prefix.length &&
prefix.every((value, index) => bytes[index] === value)
);
}
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key