Node.js stats.isFIFO() Method
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:
// Node.js program to demonstrate the // stats.isFIFO() Method // Accessing fs module const fs = require( 'fs' ); // Calling isFIFO() method from // fs.Stats class fs.lstat( './filename.txt' , (err, stats) => { if (err) throw err; // console.log(`stats: ${JSON.stringify(stats)}`); 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: ${JSON.stringify(stats)}`); 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:
// Node.js program to demonstrate the // stats.isFIFO() Method // Accessing fs module const fs = require( 'fs' ).promises; // Calling isFIFO() method from // fs.Stats class (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