Open this example in the interactive library
Source code
import { Buffer } from "node:buffer";
const signature = Buffer.from("89504e470d0a1a0a", "hex");
console.log(
signature.subarray(1, 4).toString("ascii") === "PNG" && signature[0] === 0x89,
);
Sample output
true
