A \href{https://ponyfill.com}{\texttt{ ponyfill}} for {\ttfamily Buffer.\+from}, uses native implementation if available.\hypertarget{md_sfcode_node_modules_buffer_from_readme_autotoc_md4668}{}\doxysection{Installation}\label{md_sfcode_node_modules_buffer_from_readme_autotoc_md4668}

\begin{DoxyCode}{0}
\DoxyCodeLine{npm install -\/-\/save buffer-\/from }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_buffer_from_readme_autotoc_md4669}{}\doxysection{Usage}\label{md_sfcode_node_modules_buffer_from_readme_autotoc_md4669}

\begin{DoxyCode}{0}
\DoxyCodeLine{const bufferFrom = require('buffer-\/from')}
\DoxyCodeLine{}
\DoxyCodeLine{console.log(bufferFrom([1, 2, 3, 4]))}
\DoxyCodeLine{//=> <Buffer 01 02 03 04>}
\DoxyCodeLine{}
\DoxyCodeLine{const arr = new Uint8Array([1, 2, 3, 4])}
\DoxyCodeLine{console.log(bufferFrom(arr.buffer, 1, 2))}
\DoxyCodeLine{//=> <Buffer 02 03>}
\DoxyCodeLine{}
\DoxyCodeLine{console.log(bufferFrom('test', 'utf8'))}
\DoxyCodeLine{//=> <Buffer 74 65 73 74>}
\DoxyCodeLine{}
\DoxyCodeLine{const buf = bufferFrom('test')}
\DoxyCodeLine{console.log(bufferFrom(buf))}
\DoxyCodeLine{//=> <Buffer 74 65 73 74> }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_buffer_from_readme_autotoc_md4670}{}\doxysection{API}\label{md_sfcode_node_modules_buffer_from_readme_autotoc_md4670}
\hypertarget{md_sfcode_node_modules_buffer_from_readme_autotoc_md4671}{}\doxysubsection{buffer\+From(array)}\label{md_sfcode_node_modules_buffer_from_readme_autotoc_md4671}

\begin{DoxyItemize}
\item {\ttfamily array} $<$Array$>$
\end{DoxyItemize}

Allocates a new {\ttfamily Buffer} using an {\ttfamily array} of octets.\hypertarget{md_sfcode_node_modules_buffer_from_readme_autotoc_md4672}{}\doxysubsection{buffer\+From(array\+Buffer\mbox{[}, byte\+Offset\mbox{[}, length\mbox{]}\mbox{]})}\label{md_sfcode_node_modules_buffer_from_readme_autotoc_md4672}

\begin{DoxyItemize}
\item {\ttfamily array\+Buffer} $<$Array\+Buffer$>$ The {\ttfamily .buffer} property of a Typed\+Array or Array\+Buffer
\item {\ttfamily byte\+Offset} $<$Integer$>$ Where to start copying from {\ttfamily array\+Buffer}. {\bfseries{Default\+:}} {\ttfamily 0}
\item {\ttfamily length} $<$Integer$>$ How many bytes to copy from {\ttfamily array\+Buffer}. {\bfseries{Default\+:}} {\ttfamily array\+Buffer.\+length -\/ byte\+Offset}
\end{DoxyItemize}

When passed a reference to the {\ttfamily .buffer} property of a Typed\+Array instance, the newly created {\ttfamily Buffer} will share the same allocated memory as the Typed\+Array.

The optional {\ttfamily byte\+Offset} and {\ttfamily length} arguments specify a memory range within the {\ttfamily array\+Buffer} that will be shared by the {\ttfamily Buffer}.\hypertarget{md_sfcode_node_modules_buffer_from_readme_autotoc_md4673}{}\doxysubsection{buffer\+From(buffer)}\label{md_sfcode_node_modules_buffer_from_readme_autotoc_md4673}

\begin{DoxyItemize}
\item {\ttfamily buffer} $<$Buffer$>$ An existing {\ttfamily Buffer} to copy data from
\end{DoxyItemize}

Copies the passed {\ttfamily buffer} data onto a new {\ttfamily Buffer} instance.\hypertarget{md_sfcode_node_modules_buffer_from_readme_autotoc_md4674}{}\doxysubsection{buffer\+From(string\mbox{[}, encoding\mbox{]})}\label{md_sfcode_node_modules_buffer_from_readme_autotoc_md4674}

\begin{DoxyItemize}
\item {\ttfamily string} $<$String$>$ A string to encode.
\item {\ttfamily encoding} $<$String$>$ The encoding of {\ttfamily string}. {\bfseries{Default\+:}} `\textquotesingle{}utf8'\`{}
\end{DoxyItemize}

Creates a new {\ttfamily Buffer} containing the given Java\+Script string {\ttfamily string}. If provided, the {\ttfamily encoding} parameter identifies the character encoding of {\ttfamily string}.\hypertarget{md_sfcode_node_modules_buffer_from_readme_autotoc_md4675}{}\doxysection{See also}\label{md_sfcode_node_modules_buffer_from_readme_autotoc_md4675}

\begin{DoxyItemize}
\item \href{https://github.com/LinusU/buffer-alloc}{\texttt{ buffer-\/alloc}} A ponyfill for {\ttfamily Buffer.\+alloc}
\item \href{https://github.com/LinusU/buffer-alloc-unsafe}{\texttt{ buffer-\/alloc-\/unsafe}} A ponyfill for {\ttfamily Buffer.\+alloc\+Unsafe} 
\end{DoxyItemize}