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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
