smart-\/buffer is a Buffer wrapper that adds automatic read \& write offset tracking, string operations, data insertions, and more.



{\bfseries{Key Features}}\+:
\begin{DoxyItemize}
\item Proxies all of the Buffer write and read functions
\item Keeps track of read and write offsets automatically
\item Grows the internal Buffer as needed
\item Useful string operations. (Null terminating strings)
\item Allows for inserting values at specific points in the Buffer
\item Built in Type\+Script
\item Type Definitions Provided
\item Browser Support (using Webpack/\+Browserify)
\item Full test coverage
\end{DoxyItemize}

{\bfseries{Requirements}}\+:
\begin{DoxyItemize}
\item Node v4.\+0+ is supported at this time. (Versions prior to 2.\+0 will work on node 0.\+10)
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27096}{}\doxysection{Breaking Changes in v4.\+0}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27096}

\begin{DoxyItemize}
\item Old constructor patterns have been completely removed. It\textquotesingle{}s now required to use the Smart\+Buffer.\+from\+XXX() factory constructors.
\item rewind(), skip(), move\+To() have been removed. (see \href{\#offsets}{\texttt{ offsets}})
\item Internal private properties are now prefixed with underscores (\+\_\+)
\item {\bfseries{All}} write\+XXX() methods that are given an offset will now {\bfseries{overwrite data}} instead of insert. (see \href{\#write-vs-insert}{\texttt{ write vs insert}})
\item insert\+XXX() methods have been added for when you want to insert data at a specific offset (this replaces the old behavior of write\+XXX() when an offset was provided)
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27097}{}\doxysection{Looking for v3 docs?}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27097}
Legacy documentation for version 3 and prior can be found \href{https://github.com/JoshGlazebrook/smart-buffer/blob/master/docs/README_v3.md}{\texttt{ here}}.\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27098}{}\doxysection{Installing\+:}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27098}
{\ttfamily yarn add smart-\/buffer}

or

{\ttfamily npm install smart-\/buffer}

Note\+: The published NPM package includes the built javascript library. If you cloned this repo and wish to build the library manually use\+:

{\ttfamily npm run build}\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27099}{}\doxysection{Using smart-\/buffer}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27099}

\begin{DoxyCode}{0}
\DoxyCodeLine{// Javascript}
\DoxyCodeLine{const SmartBuffer = require('smart-\/buffer').SmartBuffer;}
\DoxyCodeLine{}
\DoxyCodeLine{// Typescript}
\DoxyCodeLine{import \{ SmartBuffer, SmartBufferOptions\} from 'smart-\/buffer'; }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27100}{}\doxysubsection{Simple Example}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27100}
Building a packet that uses the following protocol specification\+:

{\ttfamily \mbox{[}Packet\+Type\+:2\mbox{]}\mbox{[}Packet\+Length\+:2\mbox{]}\mbox{[}Data\+:XX\mbox{]}}

To build this packet using the vanilla Buffer class, you would have to count up the length of the data payload beforehand. You would also need to keep track of the current \char`\"{}cursor\char`\"{} position in your Buffer so you write everything in the right places. With smart-\/buffer you don\textquotesingle{}t have to do either of those things.


\begin{DoxyCode}{0}
\DoxyCodeLine{function createLoginPacket(username, password, age, country) \{}
\DoxyCodeLine{    const packet = new SmartBuffer();}
\DoxyCodeLine{    packet.writeUInt16LE(0x0060); // Some packet type}
\DoxyCodeLine{    packet.writeStringNT(username);}
\DoxyCodeLine{    packet.writeStringNT(password);}
\DoxyCodeLine{    packet.writeUInt8(age);}
\DoxyCodeLine{    packet.writeStringNT(country);}
\DoxyCodeLine{    packet.insertUInt16LE(packet.length -\/ 2, 2);}
\DoxyCodeLine{}
\DoxyCodeLine{    return packet.toBuffer();}
\DoxyCodeLine{\} }

\end{DoxyCode}
 With the above function, you now can do this\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{const login = createLoginPacket("{}Josh"{}, "{}secret123"{}, 22, "{}United States"{});}
\DoxyCodeLine{}
\DoxyCodeLine{// <Buffer 60 00 1e 00 4a 6f 73 68 00 73 65 63 72 65 74 31 32 33 00 16 55 6e 69 74 65 64 20 53 74 61 74 65 73 00> }

\end{DoxyCode}
 Notice that the {\ttfamily \mbox{[}Packet\+Length\+:2\mbox{]}} value (1e 00) was inserted at position 2.

Reading back the packet we created above is just as easy\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{const reader = SmartBuffer.fromBuffer(login);}
\DoxyCodeLine{}
\DoxyCodeLine{const logininfo = \{}
\DoxyCodeLine{    packetType: reader.readUInt16LE(),}
\DoxyCodeLine{    packetLength: reader.readUInt16LE(),}
\DoxyCodeLine{    username: reader.readStringNT(),}
\DoxyCodeLine{    password: reader.readStringNT(),}
\DoxyCodeLine{    age: reader.readUInt8(),}
\DoxyCodeLine{    country: reader.readStringNT()}
\DoxyCodeLine{\};}
\DoxyCodeLine{}
\DoxyCodeLine{/*}
\DoxyCodeLine{\{}
\DoxyCodeLine{    packetType: 96, (0x0060)}
\DoxyCodeLine{    packetLength: 30,}
\DoxyCodeLine{    username: 'Josh',}
\DoxyCodeLine{    password: 'secret123',}
\DoxyCodeLine{    age: 22,}
\DoxyCodeLine{    country: 'United States'}
\DoxyCodeLine{\}}
\DoxyCodeLine{*/ }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27101}{}\doxysection{Write vs Insert}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27101}
In prior versions of Smart\+Buffer, .write\+XXX(value, offset) calls would insert data when an offset was provided. In version 4, this will now overwrite the data at the offset position. To insert data there are now corresponding .insert\+XXX(value, offset) methods.

{\bfseries{Smart\+Buffer v3}}\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{const buff = SmartBuffer.fromBuffer(new Buffer([1,2,3,4,5,6]));}
\DoxyCodeLine{buff.writeInt8(7, 2);}
\DoxyCodeLine{console.log(buff.toBuffer())}
\DoxyCodeLine{}
\DoxyCodeLine{// <Buffer 01 02 07 03 04 05 06> }

\end{DoxyCode}


{\bfseries{Smart\+Buffer v4}}\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{const buff = SmartBuffer.fromBuffer(new Buffer([1,2,3,4,5,6]));}
\DoxyCodeLine{buff.writeInt8(7, 2);}
\DoxyCodeLine{console.log(buff.toBuffer());}
\DoxyCodeLine{}
\DoxyCodeLine{// <Buffer 01 02 07 04 05 06> }

\end{DoxyCode}


To insert you instead should use\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{const buff = SmartBuffer.fromBuffer(new Buffer([1,2,3,4,5,6]));}
\DoxyCodeLine{buff.insertInt8(7, 2);}
\DoxyCodeLine{console.log(buff.toBuffer());}
\DoxyCodeLine{}
\DoxyCodeLine{// <Buffer 01 02 07 03 04 05 06> }

\end{DoxyCode}


{\bfseries{Note\+:}} Insert/\+Writing to a position beyond the currently tracked internal Buffer will zero pad to your offset.\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27102}{}\doxysection{Constructing a smart-\/buffer}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27102}
There are a few different ways to construct a Smart\+Buffer instance.


\begin{DoxyCode}{0}
\DoxyCodeLine{// Creating SmartBuffer from existing Buffer}
\DoxyCodeLine{const buff = SmartBuffer.fromBuffer(buffer); // Creates instance from buffer. (Uses default utf8 encoding)}
\DoxyCodeLine{const buff = SmartBuffer.fromBuffer(buffer, 'ascii'); // Creates instance from buffer with ascii encoding for strings.}
\DoxyCodeLine{}
\DoxyCodeLine{// Creating SmartBuffer with specified internal Buffer size. (Note: this is not a hard cap, the internal buffer will grow as needed).}
\DoxyCodeLine{const buff = SmartBuffer.fromSize(1024); // Creates instance with internal Buffer size of 1024.}
\DoxyCodeLine{const buff = SmartBuffer.fromSize(1024, 'utf8'); // Creates instance with internal Buffer size of 1024, and utf8 encoding for strings.}
\DoxyCodeLine{}
\DoxyCodeLine{// Creating SmartBuffer with options object. This one specifies size and encoding.}
\DoxyCodeLine{const buff = SmartBuffer.fromOptions(\{}
\DoxyCodeLine{    size: 1024,}
\DoxyCodeLine{    encoding: 'ascii'}
\DoxyCodeLine{\});}
\DoxyCodeLine{}
\DoxyCodeLine{// Creating SmartBuffer with options object. This one specified an existing Buffer.}
\DoxyCodeLine{const buff = SmartBuffer.fromOptions(\{}
\DoxyCodeLine{    buff: buffer}
\DoxyCodeLine{\});}
\DoxyCodeLine{}
\DoxyCodeLine{// Creating SmartBuffer from a string.}
\DoxyCodeLine{const buff = SmartBuffer.fromBuffer(Buffer.from('some string', 'utf8'));}
\DoxyCodeLine{}
\DoxyCodeLine{// Just want a regular SmartBuffer with all default options?}
\DoxyCodeLine{const buff = new SmartBuffer(); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27103}{}\doxysection{Api Reference\+:}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27103}
{\bfseries{Note\+:}} Smart\+Buffer is fully documented with Typescript definitions as well as jsdocs so your favorite editor/\+IDE will have intellisense.

{\bfseries{Table of Contents}}


\begin{DoxyEnumerate}
\item \href{\#constructing}{\texttt{ Constructing}}
\item {\bfseries{Numbers}}
\begin{DoxyEnumerate}
\item \href{\#integers}{\texttt{ Integers}}
\item \href{\#floating-point-numbers}{\texttt{ Floating Points}}
\end{DoxyEnumerate}
\item {\bfseries{Strings}}
\begin{DoxyEnumerate}
\item \href{\#strings}{\texttt{ Strings}}
\item \href{\#null-terminated-strings}{\texttt{ Null Terminated Strings}}
\end{DoxyEnumerate}
\item \href{\#buffers}{\texttt{ Buffers}}
\item \href{\#offsets}{\texttt{ Offsets}}
\item \href{\#other}{\texttt{ Other}}
\end{DoxyEnumerate}\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27104}{}\doxysubsection{Constructing}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27104}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27105}{}\doxysubsubsection{constructor()}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27105}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27106}{}\doxysubsubsection{constructor(\mbox{[}options\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27106}

\begin{DoxyItemize}
\item {\ttfamily options} $\ast$\{Smart\+Buffer\+Options\}$\ast$ An optional options object to construct a Smart\+Buffer with.
\end{DoxyItemize}

Examples\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{const buff = new SmartBuffer();}
\DoxyCodeLine{const buff = new SmartBuffer(\{}
\DoxyCodeLine{    size: 1024,}
\DoxyCodeLine{    encoding: 'ascii'}
\DoxyCodeLine{\}); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27107}{}\doxysubsubsection{Class Method\+: from\+Buffer(buffer\mbox{[}, encoding\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27107}

\begin{DoxyItemize}
\item {\ttfamily buffer} $\ast$\{Buffer\}$\ast$ The Buffer instance to wrap.
\item {\ttfamily encoding} $\ast$\{string\}$\ast$ The string encoding to use. {\ttfamily Default\+: \textquotesingle{}utf8\textquotesingle{}}
\end{DoxyItemize}

Examples\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{const someBuffer = Buffer.from('some string');}
\DoxyCodeLine{const buff = SmartBuffer.fromBuffer(someBuffer); // Defaults to utf8}
\DoxyCodeLine{const buff = SmartBuffer.fromBuffer(someBuffer, 'ascii'); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27108}{}\doxysubsubsection{Class Method\+: from\+Size(size\mbox{[}, encoding\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27108}

\begin{DoxyItemize}
\item {\ttfamily size} $\ast$\{number\}$\ast$ The size to initialize the internal Buffer.
\item {\ttfamily encoding} $\ast$\{string\}$\ast$ The string encoding to use. {\ttfamily Default\+: \textquotesingle{}utf8\textquotesingle{}}
\end{DoxyItemize}

Examples\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{const buff = SmartBuffer.fromSize(1024); // Defaults to utf8}
\DoxyCodeLine{const buff = SmartBuffer.fromSize(1024, 'ascii'); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27109}{}\doxysubsubsection{Class Method\+: from\+Options(options)}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27109}

\begin{DoxyItemize}
\item {\ttfamily options} $\ast$\{Smart\+Buffer\+Options\}$\ast$ The Buffer instance to wrap.
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{interface SmartBufferOptions \{}
\DoxyCodeLine{    encoding?: BufferEncoding; // Defaults to utf8}
\DoxyCodeLine{    size?: number; // Defaults to 4096}
\DoxyCodeLine{    buff?: Buffer;}
\DoxyCodeLine{\} }

\end{DoxyCode}


Examples\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{const buff = SmartBuffer.fromOptions(\{}
\DoxyCodeLine{    size: 1024}
\DoxyCodeLine{\};}
\DoxyCodeLine{const buff = SmartBuffer.fromOptions(\{}
\DoxyCodeLine{    size: 1024,}
\DoxyCodeLine{    encoding: 'utf8'}
\DoxyCodeLine{\});}
\DoxyCodeLine{const buff = SmartBuffer.fromOptions(\{}
\DoxyCodeLine{    encoding: 'utf8'}
\DoxyCodeLine{\});}
\DoxyCodeLine{}
\DoxyCodeLine{const someBuff = Buffer.from('some string', 'utf8');}
\DoxyCodeLine{const buff = SmartBuffer.fromOptions(\{}
\DoxyCodeLine{    buffer: someBuff,}
\DoxyCodeLine{    encoding: 'utf8'}
\DoxyCodeLine{\}); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27110}{}\doxysubsection{Integers}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27110}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27111}{}\doxysubsubsection{read\+Int8(\mbox{[}offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27111}

\begin{DoxyItemize}
\item {\ttfamily offset} $\ast$\{number\}$\ast$ Optional position to start reading data from. {\bfseries{Default}}\+: {\ttfamily Auto managed offset}
\item Returns $\ast$\{number\}$\ast$
\end{DoxyItemize}

Read a Int8 value.\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27112}{}\doxysubsubsection{buff.\+read\+Int16\+BE(\mbox{[}offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27112}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27113}{}\doxysubsubsection{buff.\+read\+Int16\+LE(\mbox{[}offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27113}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27114}{}\doxysubsubsection{buff.\+read\+UInt16\+BE(\mbox{[}offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27114}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27115}{}\doxysubsubsection{buff.\+read\+UInt16\+LE(\mbox{[}offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27115}

\begin{DoxyItemize}
\item {\ttfamily offset} $\ast$\{number\}$\ast$ Optional position to start reading data from. {\bfseries{Default}}\+: {\ttfamily Auto managed offset}
\item Returns $\ast$\{number\}$\ast$
\end{DoxyItemize}

Read a 16 bit integer value.\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27116}{}\doxysubsubsection{buff.\+read\+Int32\+BE(\mbox{[}offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27116}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27117}{}\doxysubsubsection{buff.\+read\+Int32\+LE(\mbox{[}offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27117}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27118}{}\doxysubsubsection{buff.\+read\+UInt32\+BE(\mbox{[}offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27118}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27119}{}\doxysubsubsection{buff.\+read\+UInt32\+LE(\mbox{[}offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27119}

\begin{DoxyItemize}
\item {\ttfamily offset} $\ast$\{number\}$\ast$ Optional position to start reading data from. {\bfseries{Default}}\+: {\ttfamily Auto managed offset}
\item Returns $\ast$\{number\}$\ast$
\end{DoxyItemize}

Read a 32 bit integer value.\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27120}{}\doxysubsubsection{buff.\+write\+Int8(value\mbox{[}, offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27120}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27121}{}\doxysubsubsection{buff.\+write\+UInt8(value\mbox{[}, offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27121}

\begin{DoxyItemize}
\item {\ttfamily value} $\ast$\{number\}$\ast$ The value to write.
\item {\ttfamily offset} $\ast$\{number\}$\ast$ An optional offset to write this value to. {\bfseries{Default\+:}} {\ttfamily Auto managed offset}
\item Returns $\ast$\{this\}$\ast$
\end{DoxyItemize}

Write a Int8 value.\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27122}{}\doxysubsubsection{buff.\+insert\+Int8(value, offset)}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27122}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27123}{}\doxysubsubsection{buff.\+insert\+UInt8(value, offset)}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27123}

\begin{DoxyItemize}
\item {\ttfamily value} $\ast$\{number\}$\ast$ The value to insert.
\item {\ttfamily offset} $\ast$\{number\}$\ast$ The offset to insert this data at.
\item Returns $\ast$\{this\}$\ast$
\end{DoxyItemize}

Insert a Int8 value.\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27124}{}\doxysubsubsection{buff.\+write\+Int16\+BE(value\mbox{[}, offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27124}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27125}{}\doxysubsubsection{buff.\+write\+Int16\+LE(value\mbox{[}, offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27125}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27126}{}\doxysubsubsection{buff.\+write\+UInt16\+BE(value\mbox{[}, offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27126}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27127}{}\doxysubsubsection{buff.\+write\+UInt16\+LE(value\mbox{[}, offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27127}

\begin{DoxyItemize}
\item {\ttfamily value} $\ast$\{number\}$\ast$ The value to write.
\item {\ttfamily offset} $\ast$\{number\}$\ast$ An optional offset to write this value to. {\bfseries{Default\+:}} {\ttfamily Auto managed offset}
\item Returns $\ast$\{this\}$\ast$
\end{DoxyItemize}

Write a 16 bit integer value.\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27128}{}\doxysubsubsection{buff.\+insert\+Int16\+BE(value, offset)}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27128}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27129}{}\doxysubsubsection{buff.\+insert\+Int16\+LE(value, offset)}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27129}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27130}{}\doxysubsubsection{buff.\+insert\+UInt16\+BE(value, offset)}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27130}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27131}{}\doxysubsubsection{buff.\+insert\+UInt16\+LE(value, offset)}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27131}

\begin{DoxyItemize}
\item {\ttfamily value} $\ast$\{number\}$\ast$ The value to insert.
\item {\ttfamily offset} $\ast$\{number\}$\ast$ The offset to insert this data at.
\item Returns $\ast$\{this\}$\ast$
\end{DoxyItemize}

Insert a 16 bit integer value.\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27132}{}\doxysubsubsection{buff.\+write\+Int32\+BE(value\mbox{[}, offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27132}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27133}{}\doxysubsubsection{buff.\+write\+Int32\+LE(value\mbox{[}, offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27133}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27134}{}\doxysubsubsection{buff.\+write\+UInt32\+BE(value\mbox{[}, offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27134}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27135}{}\doxysubsubsection{buff.\+write\+UInt32\+LE(value\mbox{[}, offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27135}

\begin{DoxyItemize}
\item {\ttfamily value} $\ast$\{number\}$\ast$ The value to write.
\item {\ttfamily offset} $\ast$\{number\}$\ast$ An optional offset to write this value to. {\bfseries{Default\+:}} {\ttfamily Auto managed offset}
\item Returns $\ast$\{this\}$\ast$
\end{DoxyItemize}

Write a 32 bit integer value.\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27136}{}\doxysubsubsection{buff.\+insert\+Int32\+BE(value, offset)}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27136}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27137}{}\doxysubsubsection{buff.\+insert\+Int32\+LE(value, offset)}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27137}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27138}{}\doxysubsubsection{buff.\+insert\+UInt32\+BE(value, offset)}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27138}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27139}{}\doxysubsubsection{buff.\+nsert\+UInt32\+LE(value, offset)}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27139}

\begin{DoxyItemize}
\item {\ttfamily value} $\ast$\{number\}$\ast$ The value to insert.
\item {\ttfamily offset} $\ast$\{number\}$\ast$ The offset to insert this data at.
\item Returns $\ast$\{this\}$\ast$
\end{DoxyItemize}

Insert a 32 bit integer value.\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27140}{}\doxysubsection{Floating Point Numbers}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27140}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27141}{}\doxysubsubsection{buff.\+read\+Float\+BE(\mbox{[}offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27141}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27142}{}\doxysubsubsection{buff.\+read\+Float\+LE(\mbox{[}offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27142}

\begin{DoxyItemize}
\item {\ttfamily offset} $\ast$\{number\}$\ast$ Optional position to start reading data from. {\bfseries{Default}}\+: {\ttfamily Auto managed offset}
\item Returns $\ast$\{number\}$\ast$
\end{DoxyItemize}

Read a Float value.\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27143}{}\doxysubsubsection{buff.\+ead\+Double\+BE(\mbox{[}offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27143}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27144}{}\doxysubsubsection{buff.\+read\+Double\+LE(\mbox{[}offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27144}

\begin{DoxyItemize}
\item {\ttfamily offset} $\ast$\{number\}$\ast$ Optional position to start reading data from. {\bfseries{Default}}\+: {\ttfamily Auto managed offset}
\item Returns $\ast$\{number\}$\ast$
\end{DoxyItemize}

Read a Double value.\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27145}{}\doxysubsubsection{buff.\+write\+Float\+BE(value\mbox{[}, offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27145}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27146}{}\doxysubsubsection{buff.\+write\+Float\+LE(value\mbox{[}, offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27146}

\begin{DoxyItemize}
\item {\ttfamily value} $\ast$\{number\}$\ast$ The value to write.
\item {\ttfamily offset} $\ast$\{number\}$\ast$ An optional offset to write this value to. {\bfseries{Default\+:}} {\ttfamily Auto managed offset}
\item Returns $\ast$\{this\}$\ast$
\end{DoxyItemize}

Write a Float value.\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27147}{}\doxysubsubsection{buff.\+insert\+Float\+BE(value, offset)}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27147}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27148}{}\doxysubsubsection{buff.\+insert\+Float\+LE(value, offset)}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27148}

\begin{DoxyItemize}
\item {\ttfamily value} $\ast$\{number\}$\ast$ The value to insert.
\item {\ttfamily offset} $\ast$\{number\}$\ast$ The offset to insert this data at.
\item Returns $\ast$\{this\}$\ast$
\end{DoxyItemize}

Insert a Float value.\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27149}{}\doxysubsubsection{buff.\+write\+Double\+BE(value\mbox{[}, offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27149}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27150}{}\doxysubsubsection{buff.\+write\+Double\+LE(value\mbox{[}, offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27150}

\begin{DoxyItemize}
\item {\ttfamily value} $\ast$\{number\}$\ast$ The value to write.
\item {\ttfamily offset} $\ast$\{number\}$\ast$ An optional offset to write this value to. {\bfseries{Default\+:}} {\ttfamily Auto managed offset}
\item Returns $\ast$\{this\}$\ast$
\end{DoxyItemize}

Write a Double value.\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27151}{}\doxysubsubsection{buff.\+insert\+Double\+BE(value, offset)}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27151}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27152}{}\doxysubsubsection{buff.\+insert\+Double\+LE(value, offset)}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27152}

\begin{DoxyItemize}
\item {\ttfamily value} $\ast$\{number\}$\ast$ The value to insert.
\item {\ttfamily offset} $\ast$\{number\}$\ast$ The offset to insert this data at.
\item Returns $\ast$\{this\}$\ast$
\end{DoxyItemize}

Insert a Double value.\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27153}{}\doxysubsection{Strings}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27153}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27154}{}\doxysubsubsection{buff.\+read\+String()}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27154}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27155}{}\doxysubsubsection{buff.\+read\+String(size\mbox{[}, encoding\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27155}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27156}{}\doxysubsubsection{buff.\+read\+String(encoding)}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27156}

\begin{DoxyItemize}
\item {\ttfamily size} $\ast$\{number\}$\ast$ The number of bytes to read. {\bfseries{Default\+:}} {\ttfamily Reads to the end of the Buffer.}
\item {\ttfamily encoding} $\ast$\{string\}$\ast$ The string encoding to use. {\bfseries{Default\+:}} {\ttfamily utf8}.
\end{DoxyItemize}

Read a string value.

Examples\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{const buff = SmartBuffer.fromBuffer(Buffer.from('hello there', 'utf8'));}
\DoxyCodeLine{buff.readString(); // 'hello there'}
\DoxyCodeLine{buff.readString(2); // 'he'}
\DoxyCodeLine{buff.readString(2, 'utf8'); // 'he'}
\DoxyCodeLine{buff.readString('utf8'); // 'hello there' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27157}{}\doxysubsubsection{buff.\+write\+String(value)}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27157}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27158}{}\doxysubsubsection{buff.\+write\+String(value\mbox{[}, offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27158}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27159}{}\doxysubsubsection{buff.\+write\+String(value\mbox{[}, encoding\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27159}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27160}{}\doxysubsubsection{buff.\+write\+String(value\mbox{[}, offset\mbox{[}, encoding\mbox{]}\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27160}

\begin{DoxyItemize}
\item {\ttfamily value} $\ast$\{string\}$\ast$ The string value to write.
\item {\ttfamily offset} $\ast$\{number\}$\ast$ The offset to write this value to. {\bfseries{Default\+:}} {\ttfamily Auto managed offset}
\item {\ttfamily encoding} $\ast$\{string\}$\ast$ An optional string encoding to use. {\bfseries{Default\+:}} {\ttfamily utf8}
\end{DoxyItemize}

Write a string value.

Examples\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{buff.writeString('hello'); // Auto managed offset}
\DoxyCodeLine{buff.writeString('hello', 2);}
\DoxyCodeLine{buff.writeString('hello', 'utf8') // Auto managed offset}
\DoxyCodeLine{buff.writeString('hello', 2, 'utf8'); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27161}{}\doxysubsubsection{buff.\+insert\+String(value, offset\mbox{[}, encoding\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27161}

\begin{DoxyItemize}
\item {\ttfamily value} $\ast$\{string\}$\ast$ The string value to write.
\item {\ttfamily offset} $\ast$\{number\}$\ast$ The offset to write this value to.
\item {\ttfamily encoding} $\ast$\{string\}$\ast$ An optional string encoding to use. {\bfseries{Default\+:}} {\ttfamily utf8}
\end{DoxyItemize}

Insert a string value.

Examples\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{buff.insertString('hello', 2);}
\DoxyCodeLine{buff.insertString('hello', 2, 'utf8'); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27162}{}\doxysubsection{Null Terminated Strings}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27162}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27163}{}\doxysubsubsection{buff.\+read\+String\+NT()}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27163}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27164}{}\doxysubsubsection{buff.\+read\+String\+NT(encoding)}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27164}

\begin{DoxyItemize}
\item {\ttfamily encoding} $\ast$\{string\}$\ast$ The string encoding to use. {\bfseries{Default\+:}} {\ttfamily utf8}.
\end{DoxyItemize}

Read a null terminated string value. (If a null is not found, it will read to the end of the Buffer).

Examples\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{const buff = SmartBuffer.fromBuffer(Buffer.from('hello\(\backslash\)0 there', 'utf8'));}
\DoxyCodeLine{buff.readStringNT(); // 'hello'}
\DoxyCodeLine{}
\DoxyCodeLine{// If we called this again:}
\DoxyCodeLine{buff.readStringNT(); // ' there' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27165}{}\doxysubsubsection{buff.\+write\+String\+NT(value)}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27165}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27166}{}\doxysubsubsection{buff.\+write\+String\+NT(value\mbox{[}, offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27166}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27167}{}\doxysubsubsection{buff.\+write\+String\+NT(value\mbox{[}, encoding\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27167}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27168}{}\doxysubsubsection{buff.\+write\+String\+NT(value\mbox{[}, offset\mbox{[}, encoding\mbox{]}\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27168}

\begin{DoxyItemize}
\item {\ttfamily value} $\ast$\{string\}$\ast$ The string value to write.
\item {\ttfamily offset} $\ast$\{number\}$\ast$ The offset to write this value to. {\bfseries{Default\+:}} {\ttfamily Auto managed offset}
\item {\ttfamily encoding} $\ast$\{string\}$\ast$ An optional string encoding to use. {\bfseries{Default\+:}} {\ttfamily utf8}
\end{DoxyItemize}

Write a null terminated string value.

Examples\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{buff.writeStringNT('hello'); // Auto managed offset   <Buffer 68 65 6c 6c 6f 00>}
\DoxyCodeLine{buff.writeStringNT('hello', 2); // <Buffer 00 00 68 65 6c 6c 6f 00>}
\DoxyCodeLine{buff.writeStringNT('hello', 'utf8') // Auto managed offset}
\DoxyCodeLine{buff.writeStringNT('hello', 2, 'utf8'); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27169}{}\doxysubsubsection{buff.\+insert\+String\+NT(value, offset\mbox{[}, encoding\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27169}

\begin{DoxyItemize}
\item {\ttfamily value} $\ast$\{string\}$\ast$ The string value to write.
\item {\ttfamily offset} $\ast$\{number\}$\ast$ The offset to write this value to.
\item {\ttfamily encoding} $\ast$\{string\}$\ast$ An optional string encoding to use. {\bfseries{Default\+:}} {\ttfamily utf8}
\end{DoxyItemize}

Insert a null terminated string value.

Examples\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{buff.insertStringNT('hello', 2);}
\DoxyCodeLine{buff.insertStringNT('hello', 2, 'utf8'); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27170}{}\doxysubsection{Buffers}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27170}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27171}{}\doxysubsubsection{buff.\+read\+Buffer(\mbox{[}length\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27171}

\begin{DoxyItemize}
\item {\ttfamily length} $\ast$\{number\}$\ast$ The number of bytes to read into a Buffer. {\bfseries{Default\+:}} {\ttfamily Reads to the end of the Buffer}
\end{DoxyItemize}

Read a Buffer of a specified size.\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27172}{}\doxysubsubsection{buff.\+write\+Buffer(value\mbox{[}, offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27172}

\begin{DoxyItemize}
\item {\ttfamily value} $\ast$\{Buffer\}$\ast$ The buffer value to write.
\item {\ttfamily offset} $\ast$\{number\}$\ast$ An optional offset to write the value to. {\bfseries{Default\+:}} {\ttfamily Auto managed offset}
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27173}{}\doxysubsubsection{buff.\+insert\+Buffer(value, offset)}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27173}

\begin{DoxyItemize}
\item {\ttfamily value} $\ast$\{Buffer\}$\ast$ The buffer value to write.
\item {\ttfamily offset} $\ast$\{number\}$\ast$ The offset to write the value to.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27174}{}\doxysubsubsection{buff.\+read\+Buffer\+NT()}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27174}
Read a null terminated Buffer.\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27175}{}\doxysubsubsection{buff.\+write\+Buffer\+NT(value\mbox{[}, offset\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27175}

\begin{DoxyItemize}
\item {\ttfamily value} $\ast$\{Buffer\}$\ast$ The buffer value to write.
\item {\ttfamily offset} $\ast$\{number\}$\ast$ An optional offset to write the value to. {\bfseries{Default\+:}} {\ttfamily Auto managed offset}
\end{DoxyItemize}

Write a null terminated Buffer.\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27176}{}\doxysubsubsection{buff.\+insert\+Buffer\+NT(value, offset)}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27176}

\begin{DoxyItemize}
\item {\ttfamily value} $\ast$\{Buffer\}$\ast$ The buffer value to write.
\item {\ttfamily offset} $\ast$\{number\}$\ast$ The offset to write the value to.
\end{DoxyItemize}

Insert a null terminated Buffer.\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27177}{}\doxysubsection{Offsets}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27177}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27178}{}\doxysubsubsection{buff.\+read\+Offset}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27178}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27179}{}\doxysubsubsection{buff.\+read\+Offset(offset)}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27179}

\begin{DoxyItemize}
\item {\ttfamily offset} $\ast$\{number\}$\ast$ The new read offset value to set.
\item Returns\+: {\ttfamily The current read offset}
\end{DoxyItemize}

Gets or sets the current read offset.

Examples\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{const currentOffset = buff.readOffset; // 5}
\DoxyCodeLine{}
\DoxyCodeLine{buff.readOffset = 10;}
\DoxyCodeLine{}
\DoxyCodeLine{console.log(buff.readOffset) // 10 }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27180}{}\doxysubsubsection{buff.\+write\+Offset}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27180}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27181}{}\doxysubsubsection{buff.\+write\+Offset(offset)}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27181}

\begin{DoxyItemize}
\item {\ttfamily offset} $\ast$\{number\}$\ast$ The new write offset value to set.
\item Returns\+: {\ttfamily The current write offset}
\end{DoxyItemize}

Gets or sets the current write offset.

Examples\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{const currentOffset = buff.writeOffset; // 5}
\DoxyCodeLine{}
\DoxyCodeLine{buff.writeOffset = 10;}
\DoxyCodeLine{}
\DoxyCodeLine{console.log(buff.writeOffset) // 10 }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27182}{}\doxysubsubsection{buff.\+encoding}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27182}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27183}{}\doxysubsubsection{buff.\+encoding(encoding)}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27183}

\begin{DoxyItemize}
\item {\ttfamily encoding} $\ast$\{string\}$\ast$ The new string encoding to set.
\item Returns\+: {\ttfamily The current string encoding}
\end{DoxyItemize}

Gets or sets the current string encoding.

Examples\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{const currentEncoding = buff.encoding; // 'utf8'}
\DoxyCodeLine{}
\DoxyCodeLine{buff.encoding = 'ascii';}
\DoxyCodeLine{}
\DoxyCodeLine{console.log(buff.encoding) // 'ascii' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27184}{}\doxysubsection{Other}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27184}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27185}{}\doxysubsubsection{buff.\+clear()}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27185}
Clear and resets the Smart\+Buffer instance.\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27186}{}\doxysubsubsection{buff.\+remaining()}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27186}

\begin{DoxyItemize}
\item Returns {\ttfamily Remaining data left to be read}
\end{DoxyItemize}

Gets the number of remaining bytes to be read.\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27187}{}\doxysubsubsection{buff.\+internal\+Buffer}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27187}

\begin{DoxyItemize}
\item Returns\+: $\ast$\{Buffer\}$\ast$
\end{DoxyItemize}

Gets the internally managed Buffer (Includes unmanaged data).

Examples\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{const buff = SmartBuffer.fromSize(16);}
\DoxyCodeLine{buff.writeString('hello');}
\DoxyCodeLine{console.log(buff.InternalBuffer); // <Buffer 68 65 6c 6c 6f 00 00 00 00 00 00 00 00 00 00 00> }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27188}{}\doxysubsubsection{buff.\+to\+Buffer()}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27188}

\begin{DoxyItemize}
\item Returns\+: $\ast$\{Buffer\}$\ast$
\end{DoxyItemize}

Gets a sliced Buffer instance of the internally managed Buffer. (Only includes managed data)

Examples\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{const buff = SmartBuffer.fromSize(16);}
\DoxyCodeLine{buff.writeString('hello');}
\DoxyCodeLine{console.log(buff.toBuffer()); // <Buffer 68 65 6c 6c 6f> }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27189}{}\doxysubsubsection{buff.\+to\+String(\mbox{[}encoding\mbox{]})}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27189}

\begin{DoxyItemize}
\item {\ttfamily encoding} $\ast$\{string\}$\ast$ The string encoding to use when converting to a string. {\bfseries{Default\+:}} {\ttfamily utf8}
\item Returns $\ast$\{string\}$\ast$
\end{DoxyItemize}

Gets a string representation of all data in the Smart\+Buffer.\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27190}{}\doxysubsubsection{buff.\+destroy()}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27190}
Destroys the Smart\+Buffer instance.\hypertarget{md_sfcode_node_modules_smart_buffer_README_autotoc_md27191}{}\doxysubsection{License}\label{md_sfcode_node_modules_smart_buffer_README_autotoc_md27191}
This work is licensed under the \href{http://en.wikipedia.org/wiki/MIT_License}{\texttt{ MIT license}}. 