1.0.0 • Published 3 months ago

yyq-read v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
3 months ago

#面向对象封装读取

const fs=require('fs');
class ReadFile{
      constructor(options){
          Object.assign(this,{},options);
          const info=fs.statSync(this.pathfile);
          if(info.isFile()){
              const a=fs.readFileSync(this.pathfile,"utf-8");
              console.log(a);
              
          }else{
              const arr=fs.readdirSync(this.pathfile);
              arr.forEach(item=>{
                  item=this.pathfile+"/"+item;
                  const b=fs.readFileSync(item,"utf-8");
                  console.log(b);  
              })
          }
      }
}
new ReadFile({
    pathfile:"1.txt"
})
1.0.0

3 months ago