yyq-read

1.0.0 • Public • Published

#面向对象封装读取

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"
})

Readme

Keywords

none

Package Sidebar

Install

npm i yyq-read

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

1.58 kB

Total Files

4

Last publish

Collaborators

  • yuyaqian