Function read

  • Read data from the file specified by fd.

    The callback is given the three arguments, (err, bytesRead, buffer).

    If the file is not modified concurrently, the end-of-file is reached when the number of bytes read is zero.

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

    Since

    v0.0.67

    Type Parameters

    • TBuffer extends ArrayBufferView

    Parameters

    • fd: number
    • buffer: TBuffer

      The buffer that the data will be written to.

    • offset: number

      The position in buffer to write the data to.

    • length: number

      The number of bytes to read.

    • position: "fs".ReadPosition

      Specifies where to begin reading from in the file. If position is null or -1 , data will be read from the current file position, and the file position will be updated. If position is an integer, the file position will be unchanged.

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

          Returns void

    Returns void

  • Similar to the above fs.read function, this version takes an optional options object. If not otherwise specified in an options object, buffer defaults to Buffer.alloc(16384), offset defaults to 0, length defaults to buffer.byteLength, - offset as of Node 17.6.0 position defaults to null

    Since

    v0.0.67

    Type Parameters

    • TBuffer extends ArrayBufferView

    Parameters

    Returns void

  • Parameters

    • fd: number
    • callback: ((err: SystemError, bytesRead: number, buffer: ArrayBufferView) => void)
        • (err: SystemError, bytesRead: number, buffer: ArrayBufferView): void
        • Parameters

          • err: SystemError
          • bytesRead: number
          • buffer: ArrayBufferView

          Returns void

    Returns void

  • Read data from the file specified by fd.

    The callback is given the three arguments, (err, bytesRead, buffer).

    If the file is not modified concurrently, the end-of-file is reached when the number of bytes read is zero.

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

    Since

    v0.0.67

    Type Parameters

    • TBuffer extends ArrayBufferView

    Parameters

    • fd: number
    • buffer: TBuffer

      The buffer that the data will be written to.

    • offset: number

      The position in buffer to write the data to.

    • length: number

      The number of bytes to read.

    • position: "fs".ReadPosition

      Specifies where to begin reading from in the file. If position is null or -1 , data will be read from the current file position, and the file position will be updated. If position is an integer, the file position will be unchanged.

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

          Returns void

    Returns void

  • Similar to the above fs.read function, this version takes an optional options object. If not otherwise specified in an options object, buffer defaults to Buffer.alloc(16384), offset defaults to 0, length defaults to buffer.byteLength, - offset as of Node 17.6.0 position defaults to null

    Since

    v0.0.67

    Type Parameters

    • TBuffer extends ArrayBufferView

    Parameters

    Returns void

  • Parameters

    • fd: number
    • callback: ((err: SystemError, bytesRead: number, buffer: ArrayBufferView) => void)
        • (err: SystemError, bytesRead: number, buffer: ArrayBufferView): void
        • Parameters

          • err: SystemError
          • bytesRead: number
          • buffer: ArrayBufferView

          Returns void

    Returns void

Generated using TypeDoc