time-to-botec/js/node_modules/@stdlib/fs/read-json/docs/repl.txt
NunoSempere b6addc7f05 feat: add the node modules
Necessary in order to clearly see the squiggle hotwiring.
2022-12-03 12:44:49 +00:00

73 lines
1.8 KiB
Plaintext

{{alias}}( file[, options], clbk )
Asynchronously reads a file as JSON.
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. If the encoding option is set to `utf8` and the file has a
UTF-8 byte order mark (BOM), the byte order mark is *removed* before
attempting to parse as JSON. Default: null.
options.flag: string (optional)
Flag. Default: 'r'.
options.reviver: Function (optional)
JSON transformation function.
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.json', onRead );
{{alias}}.sync( file[, options] )
Synchronously reads a file as JSON.
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. If the encoding option is set to `utf8` and the file has a
UTF-8 byte order mark (BOM), the byte order mark is *removed* before
attempting to parse as JSON. Default: null.
options.flag: string (optional)
Flag. Default: 'r'.
options.reviver: Function (optional)
JSON transformation function.
Returns
-------
out: Error|JSON
File contents.
Examples
--------
> var out = {{alias}}.sync( './beep/boop.json' );
See Also
--------