\href{https://nodejs.org/api/fs.html\#fs_fs_read_fd_buffer_offset_length_position_callback}{\texttt{ {\ttfamily fs.\+read()}}} \& \href{https://nodejs.org/api/fs.html\#fs_fs_write_fd_buffer_offset_length_position_callback}{\texttt{ {\ttfamily fs.\+write()}}} are different from other {\ttfamily fs} methods in that their callbacks are called with 3 arguments instead of the usual 2 arguments.

If you\textquotesingle{}re using them with callbacks, they will behave as usual. However, their promise usage is a little different. {\ttfamily fs-\/extra} promisifies these methods like \href{https://nodejs.org/api/util.html\#util_util_promisify_original}{\texttt{ {\ttfamily util.\+promisify()}}} (only availible in Node 8+) does.

Here\textquotesingle{}s the example promise usage\+:\hypertarget{md_sfcode_node_modules_fs_extra_docs_fs_read_write_autotoc_md11015}{}\doxysection{$<$tt$>$fs.\+read()$<$/tt$>$}\label{md_sfcode_node_modules_fs_extra_docs_fs_read_write_autotoc_md11015}

\begin{DoxyCode}{0}
\DoxyCodeLine{// Basic promises}
\DoxyCodeLine{fs.read(fd, buffer, offset, length, position)}
\DoxyCodeLine{  .then(results => \{}
\DoxyCodeLine{    console.log(results)}
\DoxyCodeLine{    // \{ bytesRead: 20, buffer: <Buffer 0f 34 5d ...> \}}
\DoxyCodeLine{  \})}
\DoxyCodeLine{}
\DoxyCodeLine{// Async/await usage:}
\DoxyCodeLine{async function example () \{}
\DoxyCodeLine{  const \{ bytesRead, buffer \} = await fs.read(fd, Buffer.alloc(length), offset, length, position)}
\DoxyCodeLine{\} }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_fs_extra_docs_fs_read_write_autotoc_md11016}{}\doxysection{$<$tt$>$fs.\+write()$<$/tt$>$}\label{md_sfcode_node_modules_fs_extra_docs_fs_read_write_autotoc_md11016}

\begin{DoxyCode}{0}
\DoxyCodeLine{// Basic promises}
\DoxyCodeLine{fs.write(fd, buffer, offset, length, position)}
\DoxyCodeLine{  .then(results => \{}
\DoxyCodeLine{    console.log(results)}
\DoxyCodeLine{    // \{ bytesWritten: 20, buffer: <Buffer 0f 34 5d ...> \}}
\DoxyCodeLine{  \})}
\DoxyCodeLine{}
\DoxyCodeLine{// Async/await usage:}
\DoxyCodeLine{async function example () \{}
\DoxyCodeLine{  const \{ bytesWritten, buffer \} = await fs.write(fd, Buffer.alloc(length), offset, length, position)}
\DoxyCodeLine{\} }

\end{DoxyCode}
 