Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface for appending a file.

Hierarchy

  • AppendFile

Callable

  • Asynchronously appends data to a file.

    Parameters

    • path: string | Buffer | number

      file path or file descriptor

    • data: string | Buffer

      data to append

    • options: Options | string

      options (if a string, the value is the encoding)

    • clbk: Callback

      callback to invoke after appending data to a file

    Returns void

    Example

    function onAppend( err ) {
        if ( err ) {
            console.log( err.message );
        }
    }
    
    var opts = { 'flag': 'r' };
    appendFile( './beep/boop.txt', 'beep boop\n', opts, onAppend );
  • Asynchronously appends data to a file.

    Parameters

    • path: string | Buffer | number

      file path or file descriptor

    • data: string | Buffer

      data to append

    • clbk: Callback

      callback to invoke after appending data to a file

    Returns void

    Example

    function onAppend( err ) {
        if ( err ) {
            console.log( err.message );
        }
    }
    
    appendFile( './beep/boop.txt', 'beep boop\n', onAppend );

Index

Methods

Methods

sync

  • sync(path: string | Buffer | number, data: string | Buffer, options?: Options | string): Error | null
  • Synchronously appends data to a file.

    Parameters

    • path: string | Buffer | number

      file path or file descriptor

    • data: string | Buffer

      data to append

    • Optional options: Options | string

      options (if a string, the value is the encoding)

    Returns Error | null

    error object or null

    Example

    var err = appendFileSync( './beep/boop.txt', 'data to append\n' );
    if ( err instanceof Error ) {
        throw err;
    }