filehandle.read(buffer, offset, length, position)


  • buffer <Buffer> | <TypedArray> | <DataView> 一个将被填充读取的文件数据的缓冲区。
  • offset <integer> 开始填充的缓冲区位置。 默认值: 0
  • length <integer> 要读取的字节数。默认值: buffer.byteLength - offset
  • position <integer> | <bigint> | <null> 从文件开始读取数据的位置。如果为 null-1,数据将从当前文件位置读取,并且文件位置会被更新。如果 position 是非负整数,当前文件位置将保持不变。默认值: null
  • 返回:<Promise> 成功时返回一个包含两个属性的对象:

从文件中读取数据,并将其存储在给定的缓冲区中。

【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.】