diff options
author | Rich Trott <rtrott@gmail.com> | 2015-05-27 06:11:38 +0300 |
---|---|---|
committer | Jeremiah Senkpiel <fishrock123@rocketmail.com> | 2015-05-27 22:53:14 +0300 |
commit | ff794498e713d5684feff44e1a7adb57ee993595 (patch) | |
tree | 643f296cfb75a13e03f609d63ef133a9f8aea348 | |
parent | 1bbf8d0720a061e281718f9e6a542da4268160b8 (diff) |
doc: `fs.*File()` also accept encoding strings
Fixes: https://github.com/nodejs/io.js/issues/1797
PR-URL: https://github.com/nodejs/io.js/pull/1806
Reviewed-By: fishrock123@rocketmail.com
-rw-r--r-- | doc/api/fs.markdown | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/doc/api/fs.markdown b/doc/api/fs.markdown index 92f34dbda90..3b85d789d52 100644 --- a/doc/api/fs.markdown +++ b/doc/api/fs.markdown @@ -455,7 +455,7 @@ Synchronous version of `fs.read`. Returns the number of `bytesRead`. ## fs.readFile(filename[, options], callback) * `filename` {String} -* `options` {Object} +* `options` {Object | String} * `encoding` {String | Null} default = `null` * `flag` {String} default = `'r'` * `callback` {Function} @@ -472,6 +472,10 @@ contents of the file. If no encoding is specified, then the raw buffer is returned. +If `options` is a string, then it specifies the encoding. Example: + + fs.readFile('/etc/passwd', 'utf8', callback); + ## fs.readFileSync(filename[, options]) @@ -485,7 +489,7 @@ string. Otherwise it returns a buffer. * `filename` {String} * `data` {String | Buffer} -* `options` {Object} +* `options` {Object | String} * `encoding` {String | Null} default = `'utf8'` * `mode` {Number} default = `0o666` * `flag` {String} default = `'w'` @@ -504,6 +508,10 @@ Example: console.log('It\'s saved!'); }); +If `options` is a string, then it specifies the encoding. Example: + + fs.writeFile('message.txt', 'Hello io.js', 'utf8', callback); + ## fs.writeFileSync(filename, data[, options]) The synchronous version of `fs.writeFile`. @@ -512,7 +520,7 @@ The synchronous version of `fs.writeFile`. * `filename` {String} * `data` {String | Buffer} -* `options` {Object} +* `options` {Object | String} * `encoding` {String | Null} default = `'utf8'` * `mode` {Number} default = `0o666` * `flag` {String} default = `'a'` @@ -528,6 +536,10 @@ Example: console.log('The "data to append" was appended to file!'); }); +If `options` is a string, then it specifies the encoding. Example: + + fs.appendFile('message.txt', 'data to append', 'utf8', callback); + ## fs.appendFileSync(filename, data[, options]) The synchronous version of `fs.appendFile`. |