69 lines
1.6 KiB
Plaintext
69 lines
1.6 KiB
Plaintext
|
|
||
|
{{alias}}( file[, options], clbk )
|
||
|
Asynchronously reads the entire contents of a file.
|
||
|
|
||
|
If provided an encoding, the function returns a string. Otherwise, the
|
||
|
function returns a Buffer object.
|
||
|
|
||
|
Parameters
|
||
|
----------
|
||
|
file: string|Buffer|integer
|
||
|
Filename or file descriptor.
|
||
|
|
||
|
options: Object|string (optional)
|
||
|
Options. If a string, the value is the encoding.
|
||
|
|
||
|
options.encoding: string|null (optional)
|
||
|
Encoding. Default: null.
|
||
|
|
||
|
options.flag: string (optional)
|
||
|
Flag. Default: 'r'.
|
||
|
|
||
|
clbk: Function
|
||
|
Callback to invoke upon reading file contents.
|
||
|
|
||
|
Examples
|
||
|
--------
|
||
|
> function onRead( error, data ) {
|
||
|
... if ( error ) {
|
||
|
... console.error( error.message );
|
||
|
... } else {
|
||
|
... console.log( data );
|
||
|
... }
|
||
|
... };
|
||
|
> {{alias}}( './beep/boop.js', onRead );
|
||
|
|
||
|
|
||
|
{{alias}}.sync( file[, options] )
|
||
|
Synchronously reads the entire contents of a file.
|
||
|
|
||
|
If provided an encoding, the function returns a string. Otherwise, the
|
||
|
function returns a Buffer object.
|
||
|
|
||
|
Parameters
|
||
|
----------
|
||
|
file: string|Buffer|integer
|
||
|
Filename or file descriptor.
|
||
|
|
||
|
options: Object|string (optional)
|
||
|
Options. If a string, the value is the encoding.
|
||
|
|
||
|
options.encoding: string|null (optional)
|
||
|
Encoding. Default: null.
|
||
|
|
||
|
options.flag: string (optional)
|
||
|
Flag. Default: 'r'.
|
||
|
|
||
|
Returns
|
||
|
-------
|
||
|
out: Error|Buffer|string
|
||
|
File contents.
|
||
|
|
||
|
Examples
|
||
|
--------
|
||
|
> var out = {{alias}}.sync( './beep/boop.js' );
|
||
|
|
||
|
See Also
|
||
|
--------
|
||
|
|