【发布时间】:2015-04-08 01:06:28
【问题描述】:
我正在使用through2 试验 Node.js 流。我有一个流是 index.html 文件,我正在尝试逐行修改 index.html 内容,并在每一行添加一个-------。我有:
indexHTML
.pipe(through2.obj(function(obj, enc, next) {
blah = obj.contents.toString().split('\n');
blah.forEach(function(element) {
this.push("-------");
this.push(element):
});
next();
})).pipe(process.stdout);
我目前遇到的问题this.push() 在blah.forEach() 数组方法中不可用。关于如何实现修改 index.html 流的任何建议?
【问题讨论】:
标签: node.js stream node.js-stream