Function write

  • Write buffer to the file specified by fd.

    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. For this scenario, createWriteStream is recommended.

    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.

    Type Parameters

    Parameters

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

          Returns void

    Returns void

    Since

    v0.0.2

    See

  • Write buffer to the file specified by fd.

    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. For this scenario, createWriteStream is recommended.

    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.

    Type Parameters

    Parameters

    • fd: number
    • buffer: TBuffer
    • offset: undefined | null | number
    • length: undefined | null | number
    • callback: ((err, written, buffer) => void)
        • (err, written, buffer): void
        • Parameters

          Returns void

    Returns void

    Since

    v0.0.2

    See

  • Write buffer to the file specified by fd.

    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. For this scenario, createWriteStream is recommended.

    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.

    Type Parameters

    Parameters

    • fd: number
    • buffer: TBuffer
    • offset: undefined | null | number
    • callback: ((err, written, buffer) => void)
        • (err, written, buffer): void
        • Parameters

          Returns void

    Returns void

    Since

    v0.0.2

    See

  • Write buffer to the file specified by fd.

    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. For this scenario, createWriteStream is recommended.

    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.

    Type Parameters

    Parameters

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

          Returns void

    Returns void

    Since

    v0.0.2

    See

  • Write buffer to the file specified by fd.

    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. For this scenario, createWriteStream is recommended.

    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.

    Parameters

    • fd: number
    • string: string
    • position: undefined | null | number
    • encoding: undefined | null | BufferEncoding
    • callback: ((err, written, str) => void)
        • (err, written, str): void
        • Parameters

          Returns void

    Returns void

    Since

    v0.0.2

    See

  • Write buffer to the file specified by fd.

    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. For this scenario, createWriteStream is recommended.

    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.

    Parameters

    • fd: number
    • string: string
    • position: undefined | null | number
    • callback: ((err, written, str) => void)
        • (err, written, str): void
        • Parameters

          Returns void

    Returns void

    Since

    v0.0.2

    See

  • Write buffer to the file specified by fd.

    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. For this scenario, createWriteStream is recommended.

    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.

    Parameters

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

          Returns void

    Returns void

    Since

    v0.0.2

    See

  • Write buffer to the file specified by fd.

    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. For this scenario, createWriteStream is recommended.

    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.

    Type Parameters

    Parameters

    • fd: number
    • Optional buffer: TBuffer
    • Optional offset: number
    • Optional length: number
    • Optional position: null | number

    Returns Promise<{
        buffer: TBuffer;
        bytesWritten: number;
    }>

    Since

    v0.0.2

    See

  • Write buffer to the file specified by fd.

    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. For this scenario, createWriteStream is recommended.

    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.

    Parameters

    • fd: number
    • string: string
    • Optional position: null | number
    • Optional encoding: null | BufferEncoding

    Returns Promise<{
        buffer: string;
        bytesWritten: number;
    }>

    Since

    v0.0.2

    See

Methods

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

    Type Parameters

    Parameters

    • fd: number

      A file descriptor.

    • Optional buffer: TBuffer
    • Optional offset: number

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

    • Optional length: number

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

    • Optional position: null | number

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

    Returns Promise<{
        buffer: TBuffer;
        bytesWritten: number;
    }>

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

    Parameters

    • fd: number

      A file descriptor.

    • string: string

      A string to write.

    • Optional position: null | number

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

    • Optional encoding: null | BufferEncoding

      The expected string encoding.

    Returns Promise<{
        buffer: string;
        bytesWritten: number;
    }>

Generated using TypeDoc