BinaryStream Class
a BinaryStream can be use to perform sequential read or write inside a buffer. The BinaryStream maintains a cursor up to date as the caller operates on the stream using the various read/write methods. It uses the Little Endian convention.
data can either be:
- a Buffer , in this case the BinaryStream operates on this Buffer
 - null , in this case a BinaryStream with 1024 bytes is created
 - any data , in this case the object is converted into a binary buffer.
 
example:
var stream = new BinaryStream(32)
Constructor
BinaryStream
        
                - 
                                
data 
Parameters:
- 
                                
dataNull | Buffer | Number 
Item Index
Methods
- BinaryStream.rewind
 - calculateByteLength calculate the size in bytes of a utf8 string
 - decodeArray
 - encodeArray
 - getRandomInt
 - getRandomInt
 - readArrayBuffer
 - readByte
 - readByteStream
 - readDouble
 - readFloat
 - readInt16
 - readInteger
 - readUInt16
 - readUInt32
 - readUInt8
 - writeArrayBuffer
 - writeByteStream
 - writeDouble
 - writeFloat
 - writeInt16
 - writeInt8
 - writeInteger
 - writeUInt16
 - writeUInt32
 - writeUInt8
 
Methods
BinaryStream.rewind
                    
                            ()
                    
                            
                                
                            
                    
                    
                    
                    
                    
                    
                    
                        
                    
                        set the cursor to the begining of the stream
Returns:
null
calculateByteLength
                    calculate the size in bytes of a utf8 string
                    
                            - 
                                            
str 
Parameters:
- 
                                            
strString 
decodeArray
                    
                            - 
                                            
stream - 
                                            
decode_element_func 
Parameters:
- 
                                            
streamBinaryStreamthe stream.
 - 
                                            
decode_element_funcFunctionThe function to decode a single array element. This function returns the element decoded from the stream
- 
                                                        
streamBinaryStreamthe stream.
 
 - 
                                                        
 
Returns:
encodeArray
                    
                            - 
                                            
arr - 
                                            
stream - 
                                            
encode_element_func 
Parameters:
- 
                                            
arrArraythe array to encode.
 - 
                                            
streamBinaryStreamthe stream.
 - 
                                            
encode_element_funcFunctionThe function to encode a single array element.
- 
                                                        
elementObject - 
                                                        
streamBinaryStreamthe stream.
 
 - 
                                                        
 
getRandomInt
                    
                            - 
                                            
min - 
                                            
max 
return a random integer value in the range of min inclusive and max exclusive
Parameters:
- 
                                            
minObject - 
                                            
maxObject 
Returns:
getRandomInt
                    
                            - 
                                            
min - 
                                            
max 
return a random float value in the range of min inclusive and max exclusive
Parameters:
- 
                                            
minObject - 
                                            
maxObject 
Returns:
readArrayBuffer
                    
                            - 
                                            
length 
Parameters:
- 
                                            
lengthObject 
Returns:
readByte
                    
                            ()
                    
                            
                                Number
                            
                    
                    
                    
                    
                    
                    
                    
                        
                    
                        read a single signed byte (8 bits) from the stream.
Returns:
readByteStream
                    
                            ()
                    
                            
                                Buffer
                            
                    
                    
                    
                    
                    
                    
                    
                        
                    
                        read a byte stream to the stream. The method reads the length of the byte array from the stream as a 32 bits integer before reading the byte stream.
Returns:
readDouble
                    
                            ()
                    
                            
                                
                            
                    
                    
                    
                    
                    
                    
                    
                        
                    
                        read a single 64-bit floating point number from the stream.
Returns:
the value read from the stream
readFloat
                    
                            ()
                    
                            
                                
                            
                    
                    
                    
                    
                    
                    
                    
                        
                    
                        read a single 32-bit floating point number from the stream.
Returns:
the value read from the stream
readInt16
                    
                            ()
                    
                            
                                Number
                            
                    
                    
                    
                    
                    
                    
                    
                        
                    
                        read a single signed 16-bit integer from the stream.
Returns:
readInteger
                    
                            ()
                    
                            
                                Number
                            
                    
                    
                    
                    
                    
                    
                    
                        
                    
                        read a single signed 32-bit integer from the stream.
Returns:
readUInt16
                    
                            ()
                    
                            
                                Number
                            
                    
                    
                    
                    
                    
                    
                    
                        
                    
                        read a single unsigned 16-bit integer from the stream.
Returns:
q
readUInt32
                    
                            ()
                    
                            
                                Number
                            
                    
                    
                    
                    
                    
                    
                    
                        
                    
                        read a single unsigned 32-bit integer from the stream.
Returns:
the value read from the stream
readUInt8
                    
                            ()
                    
                            
                                Number
                            
                    
                    
                    
                    
                    
                    
                    
                        
                    
                        read a single unsigned byte (8 bits) from the stream.
Returns:
writeArrayBuffer
                    
                            - 
                                            
arrayBuf - 
                                            
offset - 
                                            
length 
Parameters:
- 
                                            
arrayBufArrayBuffer - 
                                            
offsetNumber - 
                                            
lengthNumber 
writeByteStream
                    
                            - 
                                            
buf 
write a byte stream to the stream. The method writes the length of the byte array into the stream as a 32 bits integer before the byte stream.
Parameters:
- 
                                            
bufBufferthe buffer to write. the buffer buf.length the buffer to write
 
writeDouble
                    
                            - 
                                            
value 
write a single 64 bit floating number to the stream.
Parameters:
- 
                                            
valueObject 
writeFloat
                    
                            - 
                                            
value 
write a single 32 bit floating number to the stream.
Parameters:
- 
                                            
valueObject 
writeInt16
                    
                            - 
                                            
value 
write a single 16 bit signed integer to the stream.
Parameters:
- 
                                            
valueObject 
writeInt8
                    
                            - 
                                            
value 
write a single signed byte (8 bits) to the stream. value must be in the range of [-127,128]
Parameters:
- 
                                            
valueObject 
writeInteger
                    
                            - 
                                            
value 
write a single 32 bit signed integer to the stream.
Parameters:
- 
                                            
valueObject 
writeUInt16
                    
                            - 
                                            
value 
write a single 16 bit unsigned integer to the stream.
Parameters:
- 
                                            
valueObject 
writeUInt32
                    
                            - 
                                            
value 
write a single 32 bit unsigned integer to the stream.
Parameters:
- 
                                            
valueObject 
writeUInt8
                    
                            - 
                                            
value 
write a single unsigned byte (8 bits) to the stream.
Parameters:
- 
                                            
valueObject 
            The NodeOPCUA API