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


  • buffer <Buffer> | <TypedArray> | <DataView> 一个将被填充读取的文件数据的缓冲区。
  • offset <integer> 在缓冲区中开始填充的位置。
  • length <integer> 要读取的字节数。
  • position <integer> | <null> 开始从文件读取数据的位置。如果为 null,数据将从当前文件位置读取,并且位置将被更新。如果 position 是一个整数,则当前文件位置保持不变。
  • 返回:<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.