From c91723e1653d18b9d07c4096cf77f7c3c624f82d Mon Sep 17 00:00:00 2001 From: Tommy Bergeron Date: Mon, 24 Jul 2017 18:59:14 -0400 Subject: [PATCH] Update methods.js --- lib/methods.js | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/methods.js b/lib/methods.js index e0d3363..7e03f3b 100644 --- a/lib/methods.js +++ b/lib/methods.js @@ -94,7 +94,32 @@ module.exports = function (FQ) { this.execQueue(); }; + + /** + * Asynchronously append data to file + * https://nodejs.org/docs/v0.10.15/api/fs.html#fs_fs_appendfile_filename_data_options_callback + */ + FQ.prototype.appendFile = function(filename, data, options, callback) { + + if(!callback) { + callback = options; + options = null; + } + + this.addToQueue(function(fs, cb) { + if(options) { + fs.appendFile(filename, data, options, cb); + return; + } + + fs.appendFile(filename, data, cb); + + }, callback); + + this.execQueue(); + }; + /** * Asynchronous stat * http://nodejs.org/docs/v0.10.15/api/fs.html#fs_fs_stat_path_callback @@ -213,4 +238,4 @@ module.exports = function (FQ) { return writeStream; }; -}; \ No newline at end of file +};