1 Star 6 Fork 0

编码猿 / VueClassApiTsx

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
test.js 1.45 KB
一键复制 编辑 原始数据 按行查看 历史
liubing 提交于 2023-12-01 16:24 . 文件生成,ast重写
const fs = require('fs')
class readFileLine {
configPath = "./src/core/config/configure.config.ts";
lineLength = 0;
textArr = [];
lineBuffer = new Buffer(4096);
getFileList() {
this.text = fs.createReadStream(this.configPath)
return new Promise((s, e) => {
this.textArr = [];
let status = false
this.text.on('data', (data) => {
for (var i = 0; i < data.length; i++) {
if (data[i] == 10 || data[i] == 13) {
if (data[i] == 10) {
try {
var line = this.lineBuffer.slice(0, this.lineLength);
if (line.length != 0) {
let str = line.toString('utf8')
.replace(/^\s+|\s+$/g, '')
.replace(/\'/g, "")
.replace(/,/g, "")
if (str.includes("start -")) {
status = true
continue;
}
if (str.includes("end -")) {
status = false
break;
}
if (status) {
this.textArr.push(str);
}
}
} finally {
this.lineLength = 0;
}
}
} else {
this.lineBuffer[this.lineLength] = data[i];
this.lineLength++;
}
}
s(this.textArr)
})
})
}
}
module.exports = new readFileLine();
TypeScript
1
https://gitee.com/bmycode/vue-class-api-tsx.git
git@gitee.com:bmycode/vue-class-api-tsx.git
bmycode
vue-class-api-tsx
VueClassApiTsx
master

搜索帮助