yyq-read
v1.0.0
Published
```js 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,"u
Downloads
2
Readme
#面向对象封装读取
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"
})