time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

repl.txt (1862B)


      1 
      2 {{alias}}( file[, options], clbk )
      3     Asynchronously reads a file as JSON.
      4 
      5     Parameters
      6     ----------
      7     file: string|Buffer|integer
      8         Filename or file descriptor.
      9 
     10     options: Object|string (optional)
     11         Options. If a string, the value is the encoding.
     12 
     13     options.encoding: string|null (optional)
     14         Encoding. If the encoding option is set to `utf8` and the file has a
     15         UTF-8 byte order mark (BOM), the byte order mark is *removed* before
     16         attempting to parse as JSON. Default: null.
     17 
     18     options.flag: string (optional)
     19         Flag. Default: 'r'.
     20 
     21     options.reviver: Function (optional)
     22         JSON transformation function.
     23 
     24     clbk: Function
     25         Callback to invoke upon reading file contents.
     26 
     27     Examples
     28     --------
     29     > function onRead( error, data ) {
     30     ...     if ( error ) {
     31     ...         console.error( error.message );
     32     ...     } else {
     33     ...         console.log( data );
     34     ...     }
     35     ... };
     36     > {{alias}}( './beep/boop.json', onRead );
     37 
     38 
     39 {{alias}}.sync( file[, options] )
     40     Synchronously reads a file as JSON.
     41 
     42     Parameters
     43     ----------
     44     file: string|Buffer|integer
     45         Filename or file descriptor.
     46 
     47     options: Object|string (optional)
     48         Options. If a string, the value is the encoding.
     49 
     50     options.encoding: string|null (optional)
     51         Encoding. If the encoding option is set to `utf8` and the file has a
     52         UTF-8 byte order mark (BOM), the byte order mark is *removed* before
     53         attempting to parse as JSON. Default: null.
     54 
     55     options.flag: string (optional)
     56         Flag. Default: 'r'.
     57 
     58     options.reviver: Function (optional)
     59         JSON transformation function.
     60 
     61     Returns
     62     -------
     63     out: Error|JSON
     64         File contents.
     65 
     66     Examples
     67     --------
     68     > var out = {{alias}}.sync( './beep/boop.json' );
     69 
     70     See Also
     71     --------
     72