Method description:
This method functions similar to fs.appendFile(). The only difference is that the method uses synchronous operations, while fs.appendFile uses asynchronous.
grammar:
The code copy is as follows:
fs.appendFileSync(filename, data, [options])
Since this method belongs to the fs module, it is necessary to introduce the fs module before use (var fs = require("fs") )
Receive parameters:
1. filename {String}
2. data {String | Buffer}
3. options {Object}
encoding {String | Null} default = 'utf8'
mode {Number} default = 438 (aka 0666 in October)
flag {String} default = 'a'
Source code:
The code copy is as follows:
fs.appendFileSync = function(path, data, options) {
if (!options) {
options = { encoding: 'utf8', mode: 438 /*=0666*/, flag: 'a' };
} else if (util.isString(options)) {
options = { encoding: options, mode: 438, flag: 'a' };
} else if (!util.isObject(options)) {
throw new TypeError('Bad arguments');
}
if (!options.flag)
options = util._extend({ flag: 'a' }, options);
fs.writeFileSync(path, data, options);
};