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 as the last argument whereas in case of synchronous, it only consists of the file descriptor. A fsync() function does not return any value but helps to get the file descriptor in a synchronous way. A fsyncSync() method is just the synchronized form of fsync(). It helps to synchronize the disc cache.
fd refers to the File Descriptor and its return value is undefined.
Parameter: File Descriptor.
Return Type: Undefined.
File descriptor is a number that uniquely identifies an open file in a computer. It provides an entry to the global file table that provides us with the location of that entry. Example : if the file descriptor is 3, it means that in the global file table it is saved as a read/write operation with offset : 12.
At first, we need to install ‘fs’ and ‘express’ module in our NodeJS project.
npm install fs express --save
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.