filehandle.read([options])
-
options
<Object>-
buffer
<Buffer> | <TypedArray> | <DataView> 将填充读取的文件数据的缓冲区。默认值:Buffer.alloc(16384)
¥
buffer
<Buffer> | <TypedArray> | <DataView> A buffer that will be filled with the file data read. Default:Buffer.alloc(16384)
-
offset
<integer> 缓冲区中开始填充的位置。默认值:0
¥
offset
<integer> The location in the buffer at which to start filling. Default:0
-
length
<integer> 读取的字节数。默认值:buffer.byteLength - offset
¥
length
<integer> The number of bytes to read. Default:buffer.byteLength - offset
-
position
<integer> | <null> 从文件开始读取数据的位置。如果为null
,则将从当前文件位置读取数据,并将更新该位置。如果position
是整数,则当前文件位置将保持不变。Default::null
¥
position
<integer> | <null> The location where to begin reading data from the file. Ifnull
, data will be read from the current file position, and the position will be updated. Ifposition
is an integer, the current file position will remain unchanged. Default::null
-
-
返回:<Promise> 成功时将使用具有以下两个属性的对象履行:
¥Returns: <Promise> Fulfills upon success with an object with two properties:
-
bytesRead
<integer> 读取的字节数¥
bytesRead
<integer> The number of bytes read -
buffer
<Buffer> | <TypedArray> | <DataView> 对传入的buffer
参数的引用。¥
buffer
<Buffer> | <TypedArray> | <DataView> A reference to the passed inbuffer
argument.
-
从文件中读取数据,并将其存储在给定的缓冲区中。
¥Reads data from the file and stores that in the given buffer.
如果未同时修改文件,当读取的字节数为零时,则到达文件末尾。
¥If the file is not modified concurrently, the end-of-file is reached when the number of bytes read is zero.