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 by fs.open() or fs.openSync().

    • fs<Object> 一个与 fs 模块具有相同 API 的对象,可用于模拟、测试或自定义流的行为。

      ¥fs: <Object> An object that has the same API as the fs module, useful for mocking, testing, or customizing the behavior of the stream.

    • fsync<boolean> 每次写入完成后执行 fs.fsyncSync()

      ¥fsync: <boolean> Perform a fs.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 exceed maxLength, 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 for dest file exists when true. Default: false.

    • mode<number> | <string> 指定创建文件模式(请参阅 fs.open())。

      ¥mode: <number> | <string> Specify the creating file mode (see fs.open()).

    • periodicFlush<number>periodicFlush 毫秒调用一次 flush 函数。

      ¥periodicFlush: <number> Calls flush every periodicFlush milliseconds.

    • retryEAGAIN <Function>write()writeSync()flushSync() 遇到 EAGAINEBUSY 错误时将调用的函数。如果返回值为 true,则操作将重试,否则将使错误冒泡。err 是导致此函数被调用的错误,writeBufferLen 是已写入缓冲区的长度,remainingBufferLen 是流未尝试写入的剩余缓冲区的长度。

      ¥retryEAGAIN <Function> A function that will be called when write(), writeSync(), or flushSync() encounters an EAGAIN or EBUSY error. If the return value is true the operation will be retried, otherwise it will bubble the error. The err is the error that caused this function to be called, writeBufferLen is the length of the buffer that was written, and remainingBufferLen is the length of the remaining buffer that the stream did not try to write.

    • sync<boolean> 同步执行写入操作。

      ¥sync: <boolean> Perform writes synchronously.