Open this example in the interactive library
Source code
import { Buffer } from "node:buffer";
const signature = Buffer.from("89504e470d0a1a0a", "hex");
console.log(
Buffer.compare(signature.subarray(0, 4), Buffer.from([137, 80, 78, 71])) ===
0,
);
Sample output
true
