readFileSync method

JSAny readFileSync(
  1. JSAny path,
  2. JSAny options
)

path string | Buffer | URL | integer filename or file descriptor options Object | string encoding string | null Default: null flag string See support of file system flags. Default: 'r'. Returns: string | Buffer

Returns the contents of the path.

If the encoding option is specified then this function returns a string. Otherwise it returns a buffer.

Ex to read a file as a string: fs.readFileSync('/Users/joe/test.txt', 'utf8');

Implementation

external JSAny readFileSync(JSAny path, JSAny options);