鍍金池/ 問答/HTML/ Nodejs isexe模塊中代碼看不懂

Nodejs isexe模塊中代碼看不懂

isexe 中的代碼看不懂,求大神指導(dǎo)。

module.exports=isexe;//這句:是暴露自己的函數(shù),可以讓別人使用嗎
isexe.sync=sync;//這句不太明白,和下面的sync函數(shù)有關(guān)嗎

var fs=require('fs);

function isexe(path,options,cb){
    fs.stat(path,function(er,stat){
        cb(er,er?false:checkStat(stat,options));
    });
}

function sync(path,options){
    return checkStat(fs.statSync(path),options);
}
function checkStat(){...}
function checkMode(){...}
回答
編輯回答
安若晴

這是Node中關(guān)于模塊的基礎(chǔ)知識(shí)。

如何定義模塊,如何暴露模塊,如何引入模塊,都是Node中的模塊機(jī)制在起作用。
Node中,模塊實(shí)現(xiàn)遵循CommonJS規(guī)范。

可以參考這篇文章,系統(tǒng)學(xué)習(xí)下:http://www.infoq.com/cn/artic...

2017年12月24日 19:32