Node.js fs.fsync() Method
In Node, the ‘fs’ module provides an API for interacting with the file system in a manner closely modeled around standard Portable Operating System Interface (POSIX) functions.
It has both synchronous and asynchronous forms. The asynchronous form always takes a completion callback as its last argument. The arguments passed to the completion callback depend on the method, but the first argument is always reserved for an exception. If the operation was completed successfully, then the first argument will be null or undefined. The fs.fsync() method is a kind of asynchronous form. Synchronizes a file with the one stored on the computer.
Parameters: This method accepts two parameters as mentioned above and described below:
- fd: It is a file descriptor (integer) to get in a synchronous way.
- callback: It is a callback function to check whether any error has occurred.
Return Value: This function does not return any value.
Example 1: Filename: index.js
Example 2: Filename: index.js
Run index.js file using the following command:
Server listening to port 3000 FD: 3
Please Login to comment...