Node.js fs.fdatasyncSync() Method Last Updated : 02 Mar, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report The fs(File System) module enables interacting with the file system in a way modeled on standard POSIX functions, which means we can perform I/O operations with our Computer's file System. Like reading data from a file, writing data to a file, etc. All the file system operations have synchronous and asynchronous forms and mostly the asynchronous form takes a completion callback as its last argument. The fs.fdatasyncSync() (Added in v0.1.96) method is the synchronous version of fs.fdatasync(). fs.fdatasync() method is an inbuilt API(Application Programming Interface) of the fs(File System) module which is similar to fs.fsync() method, fs.fsync() transfers ( or flushes) all modified data of the file to the disk memory so that all changed information can be retrieved even if the system crashes or rebooted, but fdatasync() method does not transfer or flush modified metadata unless that metadata is needed in order to allow a succeeding data write/read to be correctly handled. Both fdatasyncSync() and fdatasync() methods reduce unnecessary disk activity. Syntax: // Require fs module at the top of this .js file const fs = require('fs'); fs.fdatasyncSync(fd); Parameter: fs.fdatasyncSync() method takes only one parameter. fd<integer>: This an integer type value. Example: In the main.js file, write the following code. JavaScript // Node.js program to demonstrate the // fs.fdatasyncSync() method // Using require to access fs module const fs = require('fs'); // Data function which we'll write to data.js function data() { console.log("Hi this is data function"); } // Open the file fs.open('data.js', "a+", (err, fd) => { if (err) throw err; // Write our data fs.writeFile(fd, data, (err) => { // Checking error if (err) throw err; // Force the file to be flushed fs.fdatasyncSync(fd); //return undefined // Print after dataSync console.log("Writing 'data' in 'data.js'... ") }); }); Run the file using node main.js Output: Writing 'data' in 'data.js' Reference:https://nodejs.org/api/fs.html#fs_fs_fdatasyncsync_fd Comment More infoAdvertise with us Next Article Node.js fs.fsyncSync() Method S saideepesh000 Follow Improve Article Tags : Web Technologies Node.js Node.js-Methods Node.js-fs-module Similar Reads Node.js fs.fdatasync() Method The fs module provides an API for interacting with the file-system in a manner closely modeled around standard POSIX functions. All the file system operations have synchronous and asynchronous forms and mostly the asynchronous form takes a completion callback as its last argument. The fs.fdatasync() 2 min read Node.js fs.fsyncSync() Method In this article, we will be learning about fsyncSync() method in NodeJS. Before diving deep into the topic, let's have a brief idea about what a fsync() method is. Node.js provides us with a 'fs' module that helps us with both synchronous and asynchronous forms. An asynchronous form has a callback a 2 min read Node.js fs.fchmodSync() Method The fs.fchmodSync() method is an inbuilt application programming of fs module which is used to synchronously change the permissions of a given file descriptor. These permissions can be specified as a parameter using string constants or octal numbers that corresponding to their respective file modes. 3 min read Node.js | fs. fchownSync() Method The fs.fchownSync() method is used to synchronously change the owner and group of the given file descriptor. The function accepts a user id and group id that can be used to set the respective owner and group. It does not return anything. Syntax: fs.fchownSync( fd, uid, gid ) Parameters: This method 3 min read Node.js fs.accessSync() Method The fs.accessSync() method is used to synchronously test the permissions of a given file or directory. The permissions to be checked can be specified as a parameter using file access constants. It is also possible to check multiple file permissions by using the bitwise OR operator to create a mask w 3 min read Node.js fs.filehandle.datasync() Method The fs.filehandle.datasync() method is an inbuilt application programming interface of class fs.filehandle within File System module which is used to sync the data of the file. Syntax:Â Â const filehandle.datasync() Parameter: This method does not accept any parameter.Return value: This method return 3 min read Like