What is the Buffer.readUInt8() method in Node.js?
The readUInt8()
method reads an unsigned 8-bit integer from the buffer object at the specified offset and returns an integer.
An unsigned 8-bit integer is an unsigned whole or natural number ranging from 0 to +255.
Table of Contents
Syntax
buffer.readUInt8( offset )
Parameters
offset
: Number of bytes to skip before starting to read. Offset must be in the range0 <= offset <= buf.length - 1
. The default value of the offset is0
.
Code
Example 1
In the following example:
- In line
1
, we construct the buffer object from[1,255]
. - In line
4
, we print an unsigned 8-bit integer of1
. - In line
7
, we print an unsigned 8-bit integer of255
.
Read more here: Source link