Buffer
Buffer.readUInt16BE()
Reads an unsigned two-byte integer in big-endian order. Tested on Node.js 22.16.0. The offset must leave two available bytes; use the byte order required by the protocol.
Formal Syntax & Structure
nodejs syntaxnodejs
buf.readUInt16BE([offset])Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| offset | integer | First byte position, default 0. |
Return Value
number
Integer from 0 to 65535.
Working Example
Example Snippetnodejs
import { Buffer } from 'node:buffer';const b=Buffer.from([1,2]);console.log(b.readUInt16BE(), b.readUInt16LE());