Skip to content

dataview-endianness ​

view.getUint32(offset) without the littleEndian argument.

Why: DataView reads and writes big-endian by default, while most binary formats and every common CPU are little-endian. Forgetting the argument reads 0x8BADF00D as 0x0DF0AD8B (v8.dev). Saying it explicitly costs nothing.

ts
export function magic(view: DataView): number {
  return view.getUint32(0);
}
✓ Accepted0 diagnostics
ts
export function magic(view: DataView): number {
  return view.getUint32(0, true);
}

Quick fixes: Little-endian (true) and Big-endian (false, the default). One-byte accessors (getUint8) have no byte order and are not reported.

MIT OR Apache-2.0 · Docs by Gemini 4 Neon Extra