new fs.Utf8Stream([options])
-
options
<Object>-
append
:<boolean> 将写入内容附加到目标文件,而不是截断它。默认值:true
。¥
append
: <boolean> Appends writes to dest file instead of truncating it. Default:true
. -
contentMode
:<string> 你可以向写入函数发送哪种类型的数据,支持的值是'utf8'
或'buffer'
。默认值:'utf8'
。¥
contentMode
: <string> Which type of data you can send to the write function, supported values are'utf8'
or'buffer'
. Default:'utf8'
. -
dest
:<string> 要写入的文件路径(模式由 append 选项控制)。¥
dest
: <string> A path to a file to be written to (mode controlled by the append option). -
fd
:<number> 文件描述符,由fs.open()
或fs.openSync()
返回。¥
fd
: <number> A file descriptor, something that is returned byfs.open()
orfs.openSync()
. -
fs
:<Object> 一个与fs
模块具有相同 API 的对象,可用于模拟、测试或自定义流的行为。¥
fs
: <Object> An object that has the same API as thefs
module, useful for mocking, testing, or customizing the behavior of the stream. -
fsync
:<boolean> 每次写入完成后执行fs.fsyncSync()
。¥
fsync
: <boolean> Perform afs.fsyncSync()
every time a write is completed. -
maxLength
:<number> 内部缓冲区的最大长度。如果写入操作导致缓冲区超过maxLength
,则写入的数据将被丢弃,并触发 drop 事件,其中包含丢弃的数据。¥
maxLength
: <number> The maximum length of the internal buffer. If a write operation would cause the buffer to exceedmaxLength
, the data written is dropped and a drop event is emitted with the dropped data -
maxWrite
:<number> 可写入的最大字节数;默认值:16384
¥
maxWrite
: <number> The maximum number of bytes that can be written; Default:16384
-
minLength
:<number> 刷新前需要填满的内部缓冲区的最小长度。¥
minLength
: <number> The minimum length of the internal buffer that is required to be full before flushing. -
mkdir
:<boolean> 当为 true 时,确保dest
文件的目录存在。默认值:false
。¥
mkdir
: <boolean> Ensure directory fordest
file exists when true. Default:false
. -
mode
:<number> | <string> 指定创建文件模式(请参阅fs.open()
)。¥
mode
: <number> | <string> Specify the creating file mode (seefs.open()
). -
periodicFlush
:<number> 每periodicFlush
毫秒调用一次 flush 函数。¥
periodicFlush
: <number> Calls flush everyperiodicFlush
milliseconds. -
retryEAGAIN
<Function> 当write()
、writeSync()
或flushSync()
遇到EAGAIN
或EBUSY
错误时将调用的函数。如果返回值为true
,则操作将重试,否则将使错误冒泡。err
是导致此函数被调用的错误,writeBufferLen
是已写入缓冲区的长度,remainingBufferLen
是流未尝试写入的剩余缓冲区的长度。¥
retryEAGAIN
<Function> A function that will be called whenwrite()
,writeSync()
, orflushSync()
encounters anEAGAIN
orEBUSY
error. If the return value istrue
the operation will be retried, otherwise it will bubble the error. Theerr
is the error that caused this function to be called,writeBufferLen
is the length of the buffer that was written, andremainingBufferLen
is the length of the remaining buffer that the stream did not try to write. -
sync
:<boolean> 同步执行写入操作。¥
sync
: <boolean> Perform writes synchronously.
-