diff --git a/README.md b/README.md index 925a53e..a0f003f 100644 --- a/README.md +++ b/README.md @@ -914,7 +914,22 @@ fs.open('/myfile.txt', function(err, fd) { #### fs.fsync(fd, callback) -NOTE: Not yet implemented, see https://github.com/filerjs/filer/issues/87 +Synchronize the data and metadata for the file referred to by `fd` to disk. +Asynchronous [fsync(2)](http://man7.org/linux/man-pages/man2/fsync.2.html). +The callback gets `(error)`. + +```js +fs.open('/myfile', 'r', function(error, fd) { + if(err) throw err; + + // Use fd, then sync + + fs.fsync(fd, function(error) { + if(err) throw err; + fs.close(fd, done); + }); +}); +``` #### fs.write(fd, buffer, offset, length, position, callback) diff --git a/tests/spec/fs.fsync.spec.js b/tests/spec/fs.fsync.spec.js index fcedaab..6c21877 100644 --- a/tests/spec/fs.fsync.spec.js +++ b/tests/spec/fs.fsync.spec.js @@ -38,8 +38,8 @@ describe('fs.fsync', function() { if(error) throw error; fs.fsync(fd, function(error) { - expect(error).to.not.exist; - fs.close(done); + expect(error).not.to.exist; + fs.close(fd, done); }); }); });