Function write

  • Write buffer to the file specified by fd. If buffer is a normal object, it must have an own toString function property.

    offset determines the part of the buffer to be written, and length is an integer specifying the number of bytes to write.

    position refers to the offset from the beginning of the file where this data should be written. If typeof position !== 'number', the data will be written at the current position. See pwrite(2).

    The callback will be given three arguments (err, bytesWritten, buffer) wherebytesWritten specifies how many bytes were written from buffer.

    If this method is invoked as its util.promisify() ed version, it returns a promise for an Object with bytesWritten and buffer properties.

    It is unsafe to use fs.write() multiple times on the same file without waiting for the callback.

    On Linux, positional writes don't work when the file is opened in append mode. The kernel ignores the position argument and always appends the data to the end of the file.

    Since

    v0.0.67

    Type Parameters

    • TBuffer extends ArrayBufferView

    Parameters

    • fd: number
    • buffer: TBuffer
    • offset: number
    • length: number
    • position: number
    • callback: ((err: SystemError, written: number, buffer: TBuffer) => void)
        • (err: SystemError, written: number, buffer: TBuffer): void
        • Parameters

          Returns void

    Returns void

  • Asynchronously writes buffer to the file referenced by the supplied file descriptor.

    Type Parameters

    • TBuffer extends ArrayBufferView

    Parameters

    • fd: number

      A file descriptor.

    • buffer: TBuffer
    • offset: number

      The part of the buffer to be written. If not supplied, defaults to 0.

    • length: number

      The number of bytes to write. If not supplied, defaults to buffer.length - offset.

    • callback: ((err: SystemError, written: number, buffer: TBuffer) => void)
        • (err: SystemError, written: number, buffer: TBuffer): void
        • Parameters

          Returns void

    Returns void

  • Asynchronously writes buffer to the file referenced by the supplied file descriptor.

    Type Parameters

    • TBuffer extends ArrayBufferView

    Parameters

    • fd: number

      A file descriptor.

    • buffer: TBuffer
    • offset: number

      The part of the buffer to be written. If not supplied, defaults to 0.

    • callback: ((err: SystemError, written: number, buffer: TBuffer) => void)
        • (err: SystemError, written: number, buffer: TBuffer): void
        • Parameters

          Returns void

    Returns void

  • Asynchronously writes buffer to the file referenced by the supplied file descriptor.

    Type Parameters

    • TBuffer extends ArrayBufferView

    Parameters

    • fd: number

      A file descriptor.

    • buffer: TBuffer
    • callback: ((err: SystemError, written: number, buffer: TBuffer) => void)
        • (err: SystemError, written: number, buffer: TBuffer): void
        • Parameters

          Returns void

    Returns void

  • Asynchronously writes string to the file referenced by the supplied file descriptor.

    Parameters

    • fd: number

      A file descriptor.

    • string: string

      A string to write.

    • position: number

      The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.

    • encoding: BufferEncoding

      The expected string encoding.

    • callback: ((err: SystemError, written: number, str: string) => void)
        • (err: SystemError, written: number, str: string): void
        • Parameters

          Returns void

    Returns void

  • Asynchronously writes string to the file referenced by the supplied file descriptor.

    Parameters

    • fd: number

      A file descriptor.

    • string: string

      A string to write.

    • position: number

      The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.

    • callback: ((err: SystemError, written: number, str: string) => void)
        • (err: SystemError, written: number, str: string): void
        • Parameters

          Returns void

    Returns void

  • Asynchronously writes string to the file referenced by the supplied file descriptor.

    Parameters

    • fd: number

      A file descriptor.

    • string: string

      A string to write.

    • callback: ((err: SystemError, written: number, str: string) => void)
        • (err: SystemError, written: number, str: string): void
        • Parameters

          Returns void

    Returns void

  • Write buffer to the file specified by fd. If buffer is a normal object, it must have an own toString function property.

    offset determines the part of the buffer to be written, and length is an integer specifying the number of bytes to write.

    position refers to the offset from the beginning of the file where this data should be written. If typeof position !== 'number', the data will be written at the current position. See pwrite(2).

    The callback will be given three arguments (err, bytesWritten, buffer) wherebytesWritten specifies how many bytes were written from buffer.

    If this method is invoked as its util.promisify() ed version, it returns a promise for an Object with bytesWritten and buffer properties.

    It is unsafe to use fs.write() multiple times on the same file without waiting for the callback.

    On Linux, positional writes don't work when the file is opened in append mode. The kernel ignores the position argument and always appends the data to the end of the file.

    Since

    v0.0.67

    Type Parameters

    • TBuffer extends ArrayBufferView

    Parameters

    • fd: number
    • buffer: TBuffer
    • offset: number
    • length: number
    • position: number
    • callback: ((err: SystemError, written: number, buffer: TBuffer) => void)
        • (err: SystemError, written: number, buffer: TBuffer): void
        • Parameters

          Returns void

    Returns void

  • Asynchronously writes buffer to the file referenced by the supplied file descriptor.

    Type Parameters

    • TBuffer extends ArrayBufferView

    Parameters

    • fd: number

      A file descriptor.

    • buffer: TBuffer
    • offset: number

      The part of the buffer to be written. If not supplied, defaults to 0.

    • length: number

      The number of bytes to write. If not supplied, defaults to buffer.length - offset.

    • callback: ((err: SystemError, written: number, buffer: TBuffer) => void)
        • (err: SystemError, written: number, buffer: TBuffer): void
        • Parameters

          Returns void

    Returns void

  • Asynchronously writes buffer to the file referenced by the supplied file descriptor.

    Type Parameters

    • TBuffer extends ArrayBufferView

    Parameters

    • fd: number

      A file descriptor.

    • buffer: TBuffer
    • offset: number

      The part of the buffer to be written. If not supplied, defaults to 0.

    • callback: ((err: SystemError, written: number, buffer: TBuffer) => void)
        • (err: SystemError, written: number, buffer: TBuffer): void
        • Parameters

          Returns void

    Returns void

  • Asynchronously writes buffer to the file referenced by the supplied file descriptor.

    Type Parameters

    • TBuffer extends ArrayBufferView

    Parameters

    • fd: number

      A file descriptor.

    • buffer: TBuffer
    • callback: ((err: SystemError, written: number, buffer: TBuffer) => void)
        • (err: SystemError, written: number, buffer: TBuffer): void
        • Parameters

          Returns void

    Returns void

  • Asynchronously writes string to the file referenced by the supplied file descriptor.

    Parameters

    • fd: number

      A file descriptor.

    • string: string

      A string to write.

    • position: number

      The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.

    • encoding: BufferEncoding

      The expected string encoding.

    • callback: ((err: SystemError, written: number, str: string) => void)
        • (err: SystemError, written: number, str: string): void
        • Parameters

          Returns void

    Returns void

  • Asynchronously writes string to the file referenced by the supplied file descriptor.

    Parameters

    • fd: number

      A file descriptor.

    • string: string

      A string to write.

    • position: number

      The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.

    • callback: ((err: SystemError, written: number, str: string) => void)
        • (err: SystemError, written: number, str: string): void
        • Parameters

          Returns void

    Returns void

  • Asynchronously writes string to the file referenced by the supplied file descriptor.

    Parameters

    • fd: number

      A file descriptor.

    • string: string

      A string to write.

    • callback: ((err: SystemError, written: number, str: string) => void)
        • (err: SystemError, written: number, str: string): void
        • Parameters

          Returns void

    Returns void

Generated using TypeDoc