stats.isFIFO()方法是fs.Stats类的内置应用程序编程接口,用于检查fs.Stats对象是否描述了先进先出(FIFO)管道。
用法:
stats.isFIFO();
参数:此方法不接受任何参数。
返回值:此方法返回一个布尔值,如果fs.Stats对象描述了先进先出(FIFO)管道,则为true,否则为false。
以下示例说明了Node.js中stats.isFIFO()方法的用法:
范例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."); 
    } 
}); 
输出:
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.
范例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)输出:
false
注意:上面的程序将通过使用以下命令进行编译和运行node filename.js命令并正确使用file_path。
参考: https://nodejs.org/api/fs.html#fs_stats_isfifo
相关用法
- Node.js console.timeLog()用法及代码示例
 - Node.js GM drawLine()用法及代码示例
 - Node.js GM drawArc()用法及代码示例
 - Node.js GM channel()用法及代码示例
 - Node.js GM chop()用法及代码示例
 - Node.js GM border()用法及代码示例
 - Node.js GM minify()用法及代码示例
 - Node.js GM magnify()用法及代码示例
 - Node.js GM drawRectangle()用法及代码示例
 - Node.js GM operator()用法及代码示例
 - Node.js GM whiteThreshold()用法及代码示例
 - Node.js GM write()用法及代码示例
 
注:本文由纯净天空筛选整理自gekcho大神的英文原创作品 Node.js | stats.isFIFO() Method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
