Node.js stats.isFIFO() Method
Last Updated :
07 Oct, 2021
The stats.isFIFO() method is an inbuilt application programming interface of the fs.Stats class which is used to check whether fs.Stats object describes a first-in-first-out (FIFO) pipe or not.
Syntax:
stats.isFIFO();
Parameters: This method does not accept any parameter.
Return Value: This method returns a boolean value, which is true if fs.Stats object describes a first-in-first-out (FIFO) pipe, false otherwise.
Below examples illustrate the use of stats.isFIFO() method in Node.js:
Example 1:
const fs = require( 'fs' );
fs.lstat( './filename.txt' , (err, stats) => {
if (err) throw err;
console.log(stats.isFIFO());
if (stats.isFIFO()) {
console.log( "fs.Stats describes a "
+ "first-in-first-out (FIFO) pipe." );
} else {
console.log( "fs.Stats does not describe a"
+ " first-in-first-out (FIFO) pipe." );
}
});
fs.stat( './' , (err, stats) => {
if (err) throw err;
console.log(stats.isFIFO());
if (stats.isFIFO()) {
console.log( "fs.Stats describes a "
+ "first-in-first-out (FIFO) pipe." );
} else {
console.log( "fs.Stats does not describe a "
+ "first-in-first-out (FIFO) pipe." );
}
});
|
Output:
false
fs.Stats does not describe a a first-in-first-out (FIFO) pipe.
false
fs.Stats does not describe a a first-in-first-out (FIFO) pipe.
Example 2:
const fs = require( 'fs' ).promises;
(async () => {
const stat = await fs.lstat( './' );
console.log(stat.isFIFO());
})(). catch (console.error)
|
Output:
false
Note: The above program will compile and run by using the node filename.js
command and use the file_path correctly.
Reference: https://nodejs.org/api/fs.html#fs_stats_isfifo
Share your thoughts in the comments
Please Login to comment...